/* jQuery Functions for Healthcare Regulation Worldwide */
//Input form tempory value function
var formInputDefault = function(str,input){
	var countrySearch = $('input#'+input);
	countrySearch.val(str);
	$(countrySearch).focus(function(){
		$(this).val('');
	});
	$(countrySearch).blur(function(){
		if ($(this).val()==''){
			$(this).val(str);
		};
	});
};
//Map highlight function
var map = function(){
	var highlight = $('#highlightLayer');
	var regions = ['europe','northAmerica','centralAmerica','southAmerica','caribbean','africa','middleEast','asia','oceania'];

	//Function for each region
	var showHide = function(region){
		$(highlight).hide();
		$('dd.' + region).hover(
			function(){
				$(highlight).css('background-image','url(/images/' + region + '.png)').fadeIn();
				
			},
			function(){
				$(highlight).css('background-image','none').hide();
			}
		);
	};
	
	for(i=0; i<9; i++) { 
		showHide(regions[i]);
	};	
};

//Tooltips for the Map
this.tooltip = function(type){	
		xOffset = 0;
		yOffset = 30;	
		
	$(".tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";	
		
		if (type == 'table'){
			var forTable = $("body").append("<p id='tooltip' class='table'><span>&nbsp;</span><em>"+ this.t +"<br /></em>Check for any outstanding hearings</p>");
			var useme = forMap;
		}
		else if (type == 'map'){
			var forMap = $("body").append("<p id='tooltip'><span>&nbsp;</span><em>"+ this.t +"</em></p>");
			var useme = forMap;
		}
		else if (type == 'form'){
			var forMap = $("body").append("<p id='tooltip' class='table'><span>&nbsp;</span><em>"+ this.t +"<br /></em>hold ctrl + click to select</p>");
			var useme = forMap;
		}
	
		$(useme);
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast")
			.bgiframe({ left: '-1' , top: '-1' , width: '150', opacity: true});		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$(".tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	
	
	
	//advanced search selects
	$("#c1,#c2,#c3,#c4,#c5,#c6,#c7,#c8,#c9,#c10").hide();
	$("#f_adv_continent").change( function() {
	  	var option = $(this).attr('value');
		if (option != 0){
			$("#all,#c1,#c2,#c3,#c4,#c5,#c6,#c7,#c8,#c9,#c10").hide();
			$("#c"+option).show();
			$("#selectedContinent").attr('value','cont' + option);
		}
		else
		{
			$("#selectedContinent").attr('value','contAll');
			$("#all,#c1,#c2,#c3,#c4,#c5,#c6,#c7,#c8,#c9,#c10").hide();
			$("#all").show();
		}
	});
		
};







