
//****all JQuery related scripts should be put into ready function
$(document).ready(function(e) {

	//***for global page to close colorbox and reload parent page
	$('#DivisionalHome a').click(function(e) { 
		parent.location = jQuery(this).attr("href");

		//hack for null reference error caused by setting iframe as false for IE only
		try{
			parent.$.fn.colorbox.close(); 
		}catch(err){}
	});    

	//***for global page popup menu/rotating
	//1.popup menu
	$('.GlobalPopUpSection_innerContents ul li a.a_hspopup').click(function(e) { 
		location.href = $(this).attr("href");
		return false;
	});        

	$('.GlobalPopUpSection_innerContents ul li a.a_hspopup').hover(function(e) { 
		//only modify visibility here
		var _popMenu=$(this).parent().find('ul');
		_popMenu.css({"visibility":"visible"});
		}, function() {
		//do nothing here
	});  

	//enforce url link(fix for pop menu links for ie6 )
	$('.GlobalPopUpSection_innerContents ul li ul li a').click(function(e) { 
		var link = jQuery(this);
		location.href = link.attr("href");
		return false;
	});          

	$('.GlobalPopUpSection_innerContents ul li').hover(function() {
		//do nothing here(all defined in css)		          
		}, function() {
		//only modify visibility here
		var _popMenu=$(this).find('ul');
		_popMenu.css({"visibility":"hidden"});
	});
	
	
	var hsiDomain = ((getCookie("hsi_domain")=="") ? null : getCookie("hsi_domain"));
	var hsiLocale = ((getCookie("hsi_locale")=="") ? null : getCookie("hsi_locale"));
	
	if (hsiDomain != null && hsiLocale != null)
	{

		$('a.Dental_Landing').click(function(e) { 
			e.preventDefault();
			$.fn.colorbox({href:'http://' + hsiDomain + '/' + hsiLocale + '/Dental.aspx', open:true,width:"850px", height:"500px", iframe:true, opacity:.7}); 
		});

		$('a.Medical_Landing').click(function(e) { 
			e.preventDefault();
			$.fn.colorbox({href:'http://' + hsiDomain + '/' + hsiLocale + '/Medical.aspx', open:true,width:"850px", height:"500px", iframe:true, opacity:.7}); 
		});

		$('a.Veterinary_Landing').click(function(e) { 
			e.preventDefault();
			$.fn.colorbox({href:'http://' + hsiDomain + '/' + hsiLocale + '/Veterinary.aspx', open:true,width:"850px", height:"500px", iframe:true, opacity:.7}); 
		});
	
	}
	else
	{
	
		$('a.Dental_Landing').click(function(e) { 
			e.preventDefault();
			$.fn.colorbox({href:'/us-en/Dental.aspx', open:true,width:"850px", height:"500px", iframe:true, opacity:.7}); 
		});

		$('a.Medical_Landing').click(function(e) { 
			e.preventDefault();
			$.fn.colorbox({href:'/us-en/Medical.aspx', open:true,width:"850px", height:"500px", iframe:true, opacity:.7}); 
		});

		$('a.Veterinary_Landing').click(function(e) { 
			e.preventDefault();
			$.fn.colorbox({href:'/us-en/Veterinary.aspx', open:true,width:"850px", height:"500px", iframe:true, opacity:.7}); 
		});
		
	}
	

});


