/*
	Fast Pivot Quick Shop Scripts 
	Copyright 2010
*/


jQuery(document).ready(function() {

	jQuery("td.qsTD").hover(
		function() {
			jQuery(this).find(".quickShop").show();
		}, function() {
			jQuery(this).find(".quickShop").hide();
	});
	
	jQuery(".float120").hover(
		function() {
			jQuery(this).find(".quickShop").show();
		}, function() {
			jQuery(this).find(".quickShop").hide();
	});	
	
	
	
	/* Actual Modal Code */
	
	//When you click on a link with class of poplight and the href starts with a # 
	jQuery('.quickShop img').click(function(e) {
		
		// Get Current Button's Position
		var yPos = e.pageY;
		
		var popID = jQuery(this).attr('class');
		var popWidth = 489; 

		//Fade in the Popup
		jQuery('#' + popID).fadeIn().css({ 'width': Number( popWidth ) });
		
		//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
		var popMargLeft = (jQuery('#' + popID).width() + 80) / 2;
		var popMargTop = yPos - 80;
		
		//Apply Margin to Popup
		jQuery('#' + popID).css({ 
			'margin-top' : popMargTop,
			'margin-left' : -popMargLeft
		});
		
		
		//Fade in Background
		jQuery('body').append('<div id="fade"></div>');
		jQuery('#fade').fadeIn();
		
		return false;
	});
	
	
	//Close Popups and Fade Layer
	jQuery('.qsClosebar img, #fade').live('click', function() { 
	  	jQuery('#fade , .fpqsPop').fadeOut(function() {
			jQuery('#fade, a.close').remove();  
	}); 
		
		return false;
	});


	/* Close Popups and Fade Layer on ATC ( When Floating Cart is Enabled )
	jQuery('.qaAtcCell input').click(function(){
		jQuery('#fade , .fpqsPop').fadeOut();
		jQuery('html, body').animate({scrollTop:0}, 'slow');
	});*/
	
	
	
});
