//loading popup with jQuery magic!  
function loadPopupV1(backGroundDiv, popUpDiv){
		backGroundDiv = backGroundDiv || 'backgroundPopupV1';
		popUpDiv = popUpDiv || 'tooltip-box';
				
		if (backGroundDiv != '') {			
			$("."+backGroundDiv).css({"opacity": "0.7"});  
			$("."+backGroundDiv).fadeIn("fast");
		}
		
		if (popUpDiv == 'tooltip-box') {
			$("."+popUpDiv).css("display", "inline");  
			$("."+popUpDiv+"[id!='']").css("display", "none");
		}
		else {			
			$("#"+popUpDiv).css("display", "inline");
		}
		centerPopup(backGroundDiv, popUpDiv);
}

//disabling popup with jQuery magic!  
function disablePopupV1(backGroundDiv, popUpDiv){ 
		backGroundDiv = backGroundDiv || 'backgroundPopupV1';
		popUpDiv = popUpDiv || 'tooltip-box';
		
		if (backGroundDiv != '') {
			$("."+backGroundDiv).fadeOut("fast");
		}
		
		if (popUpDiv == 'tooltip-box') {
			$("."+popUpDiv).fadeOut("fast");  
		}
		else {
			$("#"+popUpDiv).fadeOut("fast");
		}		
}  

function redisplayPopup(backGroundDiv, popUpDiv) {
		backGroundDiv = backGroundDiv || 'backgroundPopupV1';
		popUpDiv = popUpDiv || 'tooltip-box';
		centerPopup(backGroundDiv, popUpDiv);
		
		$("."+backGroundDiv).css({  
			"height": getWindowHeight() ,  
			"width": getWindowWidth()     
		});  
}

// from www.howtocreate.co.uk/tutorials/javascript/browserwindow
function getWindowWidth() {
	var myWidth = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}

function getWindowHeight() {
	var myHeight = 0;
	
	if( typeof( window.innerHeight ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
		
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
		
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

 //centering popup  
function centerPopup(backGroundDiv, popUpDiv){ 	
	backGroundDiv = backGroundDiv || 'backgroundPopupV1';
	popUpDiv = popUpDiv || 'tooltip-box';
	
	//request data for centering  
	var windowWidth = getWindowWidth();  
	var windowHeight = getWindowHeight();	
	var popupHeight = 0;
	var popupWidth = 0;

	if (popUpDiv == 'tooltip-box' || popUpDiv == 'calender-popup') {
		popupHeight = $("."+popUpDiv).height();  
		popupWidth = $("."+popUpDiv).width();  
	}
	else {
		popupHeight =$("#"+popUpDiv).height();  
		popupWidth = $("#"+popUpDiv).width();
	}
		
	var top = (windowHeight/2-popupHeight/2)
	var left = ((windowWidth/2)-(popupWidth/2));
	
	//centering
	
	if (popUpDiv == 'tooltip-box' || popUpDiv == 'calender-popup') {
		$("."+popUpDiv).css({  
			"position": "fixed", 
			"top": top,  
			"left": left 
		});
	}
	else {
		$("#"+popUpDiv).css({  
			"position": "fixed", 
			"top": top,  
			"left": left 
		}); 
	}
	
	//only need force for IE6  
	$("."+backGroundDiv).css({ "height": windowHeight });  
}

function closePopup(backGroundDiv, popUpDiv) {
	disablePopupV1(backGroundDiv,popUpDiv);
}