//Function to update the positin of the pop up window
		function updatePopupPosition(e)
			{
				var windowSize = getWindowSize();
				var popupSize = getPopupSize();
				var settings = jQuery.extend({
				cursorTopOffset: 15,
				cursorLeftOffset: 15
				});
			if (windowSize.width + windowSize.scrollLeft < e.pageX + popupSize.width + settings.cursorLeftOffset){
				$('#popupDetails').css("left", e.pageX - popupSize.width - settings.cursorLeftOffset);				
				$('#popupDetails').find('em').css({left:"230px", backgroundPosition: "0 100%"});
			} else {
				$('#popupDetails').css("left", e.pageX + settings.cursorLeftOffset);				
				$('#popupDetails').find('em').css("left","-13px");
			}
			if (windowSize.height + windowSize.scrollTop < e.pageY + popupSize.height + settings.cursorTopOffset){
				$('#popupDetails').css("top", e.pageY - popupSize.height - settings.cursorTopOffset);				
			} else {
				$('#popupDetails').css("top", e.pageY + settings.cursorTopOffset);				
				}
			}
		

		//Function that returns the window size 
		function getWindowSize() {
			return {
				scrollLeft: $(window).scrollLeft(),
				scrollTop: $(window).scrollTop(),
				width: $(window).width(),
				height: $(window).height()
				};
			}
						


		//Function that returns the size of the pop up window
		function getPopupSize() {
			return {
				width: $('#popupDetails').width(),
				height: $('#popupDetails').height()
			};
		}

this.imagePreview=function(){	
	xOffset = 10;
	yOffset = 30;
	var readyType = document.getElementById('readyType').value;

	if($('#colorlable').length)
	{
	var colorlabel = document.getElementById('colorlable').value;
	}
	if($('#pricelable').length)
	{
	var pricelabel = document.getElementById('pricelable').value;
	}
	if($('#descriptionlable').length)
	{
	var descriptionlabel = document.getElementById('descriptionlable').value;
	}
	
	$("a.rollOver").hover(function(e){
		var imgSrc = $(this).find('.popUpCnt img').attr('src');			
		var prodTitle = $(this).find('.popUpCnt p.prodTitle').text();
		var prodPrice = $(this).find(".popUpCnt p.prodPrice").html();
		var prodDesc = $(this).find(".popUpCnt p.prodDescription").text();
		if($.browser.msie && $.browser.version=="6.0"){
			$('select').hide();
		}			
		if(readyType=='duo'){
			$('body').append("<p id='popupDetails' class='popupDetailsduo'><span><strong_inline><b>"+colorlabel+":</b>"+prodTitle+"<br/><b>"+descriptionlabel+":</b> "+"(L to R)"+"<br/>"+prodDesc+"</strong_inline></span><img height='84' width='179'  src='"+ imgSrc +"' alt='Image preview' /><span><b>"+pricelabel+":</b> "+ prodPrice +"</span></p>");	
		}
		else if(readyType=='quad'){
			$('body').append("<p id='popupDetails' class='popupDetailsquad'><span><strong_inline><b>"+colorlabel+":</b>"+prodTitle+"<br/><b>"+descriptionlabel+":</b> "+"(L to R Top to Bottom)"+"<br/>"+prodDesc+"</strong_inline></span><img src='"+ imgSrc +"' alt='Image preview' /><span><b>"+pricelabel+":</b> "+ prodPrice +"</span></p>");	
		}
		else{
		$('body').append("<p id='popupDetails'><span><strong_inline><b>"+colorlabel+":</b> "+prodTitle+"<br/><b>"+descriptionlabel+":</b> "+prodDesc+"</strong_inline></span><img src='"+ imgSrc +"' alt='Image preview' /><span><b>"+pricelabel+":</b> "+ prodPrice +"</span></p>");	
		}
		setTimeout(function(){
			$("#popupDetails")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
			updatePopupPosition(e);
			}, 500);
		  },function(){
			$("#popupDetails").remove();
			if($.browser.msie && $.browser.version=="6.0"){
				$('select').show();
				}
		    });	
		};

		function removeHover(){
			$("#popupDetails").remove();
			}
		

function productSkinShadeSelector(){
	$(".popup_urlindiv").divLayer({layer: ".show_urlindiv", modal: false, vertPosition: "middle", positionedHeight: 558});
	$(".popup_productECdiv").divLayer({layer: ".show_urlindiv", modal: false, vertPosition: "middle", positionedHeight: 558});
	$(".popup_urlindivWL").divLayer({layer: ".show_urlindiv", modal: false, vertPosition: "middle", positionedHeight: 558});
	$(".public_profile").divLayer({
		layer: ".popup_public_profile",
		vertPosition: "top",
		modal: false
		});
	rating_hover_init();
	$(".select_video a.close_div").live("click", function() {
		$(".select_video").empty();
		$(".pop_curtain").remove();
		$("#popupDetails").remove();
		});
	jQuery(".addToBagInlineMsgDiv").click(function() {
		if(document.getElementById('tempInlineMsgLinkId')!=null){											
		var btnid=document.getElementById('tempInlineMsgLinkId').value;		
		var inlinedivID = "#" + btnid;
		var itemAddedToShoppingBagLabel = document.getElementById('itemAddedToShoppingBagLabel').value;
		var friendAddressAvailableLabel = document.getElementById('friendAddressAvailableLabel').value;
		var friendAddressNotAvailableLabel = document.getElementById('friendAddressNotAvailableLabel').value;
		if($(inlinedivID).hasClass("addToBagOwnerLink")){				
		document.getElementById('di'+btnid).innerHTML=itemAddedToShoppingBagLabel;
		}else if($(inlinedivID).hasClass("addToBagInlineMasgLink")){	
		document.getElementById('di'+btnid).innerHTML=friendAddressAvailableLabel;
		}else if($(inlinedivID).hasClass("addToBagInlineMasgLinkNoAddress")){
		document.getElementById('di'+btnid).innerHTML=friendAddressNotAvailableLabel;
		}	
		}		
		});
	}


function closeDiv()
{
$(".pop_curtain").remove();
$(".select_variance").hide();
$("#popupDetails").remove();
}



function pop_up(){
	$(".popup_content").divLayer({layer: ".show_content", modal: false, vertPosition: "middle", positionedHeight: 558});
	$('.show_content').css('z-index', '300');
}
function popupProduct(){
	$(".popup_product").divLayer({
		layer: ".select_product",
		modal: false,
		vertPosition: "middle",
		positionedHeight: 558
	});
}

function productCardOfflineReady(){
	$('.select_variance').removeClass('popup_xl').addClass('popup_small');
	$(".select_variance .popup_close").live("click", function() {
		$('.select_variance').removeClass('popup_small').addClass('popup_xl');
	});
	$(".pop_curtain").live("click", function() {
		$('.select_variance').removeClass('popup_small').addClass('popup_xl');
	});
	$(".select_video a.close_div").live("click", function() {
		$(".select_video").empty();
		$(".pop_curtain").remove();
	})
}
