(function($) {
    $(document).ready(function(){

	$.fn.selectedmenu = function() 
	{
		$(this).attr("src","images/circle_arrow.gif");
		var hcontent = "<div style='text-align:center;width:95%;height:100%'><img src='images/loading.gif' border=0 align=absmiddle></div>";
		 $("#main_container").html(hcontent);
	}

	$.fn.normalmenu = function() 
	{
		$(this).attr("src","images/circle_arrow2.gif");
	}


	$("#prom_overview a").click(function () {
		$('td [id^=prom_]').each(
			function(intIndex ){
				$("#"+this.id+" img").normalmenu();				
			}		
		);
		$("#prom_overview img").selectedmenu();
		$.get("view_professional.php", { tabid: "view_professional",'proid':$("#proid").val()}, function(data){
		  $("#main_container").html(data);
			tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
			imgLoader = new Image();// preload image
			imgLoader.src = tb_pathToImage;
		});
	return false;	
	});

	$("#prom_bio_credits a").click(function () {
		$('td [id^=prom_]').each(
			function(intIndex ){
				$("#"+this.id+" img").normalmenu();				
			}		
		);
		$("#prom_bio_credits img").selectedmenu();
		$.get("professional_bio_credits.php", { tabid: "bio_credits",'proid':$("#proid").val()}, function(data){
		  $("#main_container").html(data);
		});
	return false;	
	});

	$("#prom_submit_professional a").click(function () {
		$('td [id^=prom_]').each(
			function(intIndex ){
				$("#"+this.id+" img").normalmenu();				
			}		
		);
		$("#prom_submit_professional img").selectedmenu();
		$.get("submit_professional.php", { tabid: "submit_pro",'proid':$("#proid").val()}, function(data){
		  $("#main_container").html(data);
		});
	return false;	
	});

	$("#submission_msg").keyup(function(){
		var textid = 'submission_msg';
		var limit= 140;
		var infodiv = 'deatil_ques';
		var text = $('#'+textid).val();
		var textlength = text.length;
		if(textlength > limit)
		{
			$('#' + infodiv).html('You cannot write more then '+limit+' characters!');

			$('#'+textid).val(text.substr(0,limit));

			return false;
		}
		else
		{

			$('#' + infodiv).html(''+ (limit - textlength) +' Characters Remaining');
			return true;
		 }

	})
	$("#submission_contact").keyup(function(){
		var textid = 'submission_contact';
		var limit= 240;
		var infodiv = 'contact_msg';
		var text = $('#'+textid).val();
		var textlength = text.length;
		if(textlength > limit)
		{
			$('#' + infodiv).html('You cannot write more then '+limit+' characters!');

			$('#'+textid).val(text.substr(0,limit));

			return false;
		}
		else
		{

			$('#' + infodiv).html(''+ (limit - textlength) +' Characters Remaining');
			return true;
		 }

	})

	$("#submission_title").keyup(function(){
		var textid = 'submission_title';
		var limit= 80;
		var infodiv = 'title_msg';
		var text = $('#'+textid).val();
		var textlength = text.length;
		if(textlength > limit)
		{
			$('#' + infodiv).html('You cannot write more then '+limit+' characters!');

			$('#'+textid).val(text.substr(0,limit));

			return false;
		}
		else
		{

			$('#' + infodiv).html(''+ (limit - textlength) +' Characters Remaining');
			return true;
		 }

	})

    });
})(jQuery);
