var timer, currentMenu;

pauselength = 1000;


function mo( imageName, imageSrc ){
				
		document[imageName].src = imageSrc;

}


function closeMenu(){
	
	obj = document.getElementById( currentMenu );
	
	if( obj ){
		obj.style.backgroundImage = "url(images/menu/menubg.gif)";
		//if there is a submenu, close it:
		sobj = document.getElementById( "sub" + currentMenu );
		if( sobj ){
			sobj.style.display = "none";
		}
	}
}

function mover( obj ){
	
	clearTimeout(timer);
	
	//if there is a menu open, close it:
	closeMenu();
	
	currentMenu = obj.id;
	obj.style.backgroundImage = "url(images/menu/menubgover.gif)";
	//if there is a submenu, show it:
	sobj = document.getElementById( "sub" + currentMenu );
	if( sobj ){
		sobj.style.display = "block";
	}


}

function mout(){

	timer = setTimeout( "closeMenu()", pauselength );


}


function sover( obj ){
	
	obj.style.backgroundImage = "url(images/menu/menubgover.gif)";
	clearTimeout(timer);


}

function sout( obj ){

	obj.style.backgroundImage = "url(images/menu/menubg.gif)";
	timer = setTimeout( "closeMenu()", pauselength );
	

}

function showAnswer( str ){
	
	
	  obj = document.getElementById( str );
	  if ($(obj).is(":hidden")) {													  
		$(obj).slideDown();
	  }else{
		$(obj).slideUp();
	  }
	  
	  
}

function open_new_window(theURL,winName,features) {
  window.open(theURL,winName,features);
  
}

function confirmExit( msg, url ){
	 
	if( msg == "hcp" ){
	 	confirm_msg = "The information you are about to view is intended only for U.S. healthcare professionals.";
	}
	
	if( msg == "link" ){
	 	confirm_msg = "You are now leaving this site.";
	}
	
	if( confirm( confirm_msg ) == false){
		//event.returnValue=false;
		return false;
		
		
	}
	else{
		return true;
	}

}

var modalLink;

function logModalLink( url ){
	modalLink = url;
}

function openModalLink(){
	if( modalLink ){
		window.open( modalLink );
	}
}

function defineBioId(){
	



	URL =  document.getElementsByTagName('base')[0].href + 'AboutDivigel/Bioidentical.php';
	open_new_window(URL,'','status=no,scrollbars=no,toolbar=no,menubar=no,location=no,resizable=no,width=400,height=200')
	
}

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});


function createCookie(name,value,days,path) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=" + path;
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

