$(document).ready(function()
{
	
	$("#whatsThis").click(function(e)
			{
				cvvPopup(e.pageX, e.pageY);
			});
	$("#cvvClose").click(function()
			{
				cvvClose();
			});
	
	$("#selectYourDevice").click(function(e)
			{
				devicePopup(e.pageX, e.pageY);
			});
	$("#closeDevices").click(function()
			{
				deviceClose();
			});

	$("#myAccountLink").mouseover(function(e)
			{
				popup(e.pageX, e.pageY);
			});
	$("#close").click(function()
			{
				close();
			});
	
	
	
});

function cvvPopup(x, y)
{
	y = y - 10;
	
	
	var windowWidth = document.documentElement.clientWidth;  
	var windowHeight = document.documentElement.clientHeight;  
	var popupHeight = $("#cvvPopup").height();  
	var popupWidth = $("#cvvPopup").width();  
	 
	 $("#cvvPopup").css({  
	 "position": "absolute",  
	 "top": windowHeight - (popupHeight/2),  
     "left": windowWidth/2-popupWidth/2  
	   });  
	
	
	 
	$("#cvvPopup").fadeIn("slow");
}

function cvvClose()
{
	$("#cvvPopup").fadeOut("slow");
	
	
}


function devicePopup(x, y)
{
	y = y - 10;
	
	
	var windowWidth = document.documentElement.clientWidth;  
	var windowHeight = document.documentElement.clientHeight;  
	var popupHeight = $("#devicePopup").height();  
	var popupWidth = $("#devicePopup").width();  
	 
	 $("#devicePopup").css({  
	 "position": "absolute",  
	 "top": y,  
     "left": windowWidth/2-popupWidth/2  
	   });  
	
	$("#devicePopup").fadeIn("slow");
}

function close()
{
	$("#popup").fadeOut("slow");
	
	
}



function popup(x, y)
{
	y = y - 10;
	
	
	var windowWidth = document.documentElement.clientWidth;  
	var windowHeight = document.documentElement.clientHeight;  
	var popupHeight = $("#popup").height();  
	var popupWidth = $("#popup").width();  
	 
	 $("#popup").css({  
	 "position": "absolute",  
	 "top": y,  
     "left": windowWidth/2-popupWidth/2  
	   });  
		
	$("#popup").fadeIn("slow");
	$("#myPreferencesPop").load("includes/myPicksPop.jsp");
}

function deviceClose()
{
	$("#devicePopup #deviceContainer #willItWork").show();	
	$("#devicePopup").fadeOut("slow");
	
}