
// Quick View Function
function loadQuickView(data)
{
   $('#quickViewContainer').html('');
   $("#quickViewContainer").html(data);
   $.blockUI.defaults.applyPlatformOpacityRules = false;
   $.blockUI({ message: $('#quickViewContainer'),
      centerX: true,
      centerY: false,
      css: {
            top: '5%',
            /*left: '225px',*/ //Center quickview
            width: '580px',
            height: 'auto',
            cursor: 'default',
            border: 'none',
            textalign: 'center',
            backgroundColor: 'auto', 
      }, 
            overlayCSS:  { 
                        opacity: 0.4 ,
                        cursor: 'default',
            } 
       });
}

// On Doc Ready
jQuery(function ($) { 

// Sizechart PopOver
$("#OP_Sizechart_Anchor").click(function(){
  if ($("#OP_Sizechart_Popover").is(":hidden")) { 
    var AnchorPos = $(this).offset();
    var ChartWidth = $("#OP_Sizechart_Popover").width();
    var ChartHeight = $("#OP_Sizechart_Popover").height();
    $("#OP_Sizechart_Popover").css( { "right":  "-30px", "top": (1 - ChartHeight - 30) + "px" } );
    $("#OP_Sizechart_Popover").show('slow');
  } else {
    $("#OP_Sizechart_Popover").hide();
  }
  return false;
 });

 $(".SizingTableContainer").click(function(){
    $("#OP_Sizechart_Popover").hide();
 });
 
 $(".PopoverCloseX").click(function(){
    $('#OP_Sizechart_Popover').hide();
 });
 

// Image Rollover - Swap
$('img.imgRollover, input.imgRollover').hover(function() {
   $(this).attr('src', $(this).data('rollover'));
  }, function() {
   $(this).attr("src", $(this).data('rolloff'));
});
// Image Rollover PreLoad
$('img.imgRollover, input.imgRollover').each(function(index) {
	$this = $(this);
	var rolloff = $this.attr('src');
	var rollext = rolloff.substr( (rolloff.lastIndexOf('.')) ); 
	var rollover = rolloff.replace(rollext, '-rollover'+rollext);
	$this.data('rolloff', rolloff);
	$this.data('rollover', rollover);
	var i = $('<img />').attr('src', $this.data('rollover')); 
	$('.br').append( i );
});
  
//  Image Swap - Depreciated
$("img.imgswap, input.imgswap").hover(function() {
   $this = $(this); 
   $this.attr("src", $this.attr("src").replace("-off", "-over"));
  }, function() {
   $this = $(this); 
   $this.attr("src", $this.attr("src").replace("-over", "-off"));
});

// PopOver - onReady - remove default link
 $(".PopoverAnchor").attr("href", "#");
 
// PopOver - onClick anchor
$("#AnchorLNPopoverFreeShipping").click(function(){	
  $this = $(this);
  $('.Popover').fadeOut();
  var anchorPos = $this.offset();
  var anchorWidth = $this.width();
  popoverLeft = (anchorPos.left + anchorWidth);
  popoverTop = (anchorPos.top + ($this.height() / 2) - ($("#PopoverFreeShipping").height() / 2) );
  popoverTop = Math.max(10, popoverTop);
  $("#PopoverFreeShipping").css( { "left": popoverLeft + "px", "top": popoverTop + "px" } );  
  if ($('#PopoverFreeShipping').is(':hidden')) { $('#PopoverFreeShipping').fadeIn('slow'); } 
});
 
// PopOver - onClick Popover
$("#PopoverFreeShipping").click(function(){
  $(".Popover").hide();
});

// PopOver  
	$("#holidayFAQ").click(function(){	 
		$popover = $('#holidayFAQPopover');
		$('.Popover').fadeOut();
		if ($popover.is(':hidden')) { $popover.fadeIn('slow'); } 
	});

	$("#holidayFAQPopover").click(function(){
  		$(".Popover").hide();
	});


// LN Brand PopOver - Init
$("#AnchorBrandPO").attr("href", "#"); 
// LN Brand PopOver - Click
$("#AnchorBrandPO").click(function(){
    var pos = $(this).offset();
	var $BrandPO = $("#BrandPO");
    $($BrandPO).css( { "left": (pos.left + 150) + "px", "top":(pos.top - $($BrandPO).height() + 50) + "px" } );
    $($BrandPO).show();
});
// LN Brand PopOver - Close
$("#BrandPOClose").click(function(){
  $("#BrandPO").hide();
});

// IE Ajax issue 
if ( !$.browser.msie ) {
// Top search suggestions
$('.SEARCHinput').keyup(function(){
		$("#top_suggestion_form").children('input').val($(this).val());
		$("#top_suggestion_form").submit();
		return false;
});
$('.SEARCHinput').blur(function(){
		$("#topSuggestionsYahoo").delay(200).fadeOut(0);
});
$('.SEARCHinput').focus(function(){
		$("#topSuggestionsYahoo").toggle(true);
});
$('#top_suggestion_form').bind('submit', function() {
		$(this).ajaxSubmit({ target: '#topSuggestionsYahoo' }); 
		return false;
});
};

// Top search 
$('.SEARCHinput').focus(function(){
				if($(this).val() == "search keyword or item #") {$(this).val(""); }
});
$('.SEARCHinput').blur(function(){
				if($(this).val() == "") { $(this).val("search keyword or item #"); }
});
$('#TNsearch').click(function(){
  if($(this).val() == "search keyword or item #") { $(this).val(""); }
});
$('#TNsearch').submit(function(){
				if($('.SEARCHinput').val() == "search keyword or item #") { $('.SEARCHinput').val(""); }
});

// document.domain = 'vickerey.com';

// Quick View Local
$(".productImageQuickView").mouseover(function() {
	$(this).children('a.quickViewIcon').css('display', 'block');
	$(this).children('a.quickViewIcon').children('img').css('display', 'block');
}).mouseleave(function() {
	$(this).children('a.quickViewIcon').css('display', 'none');
	$(this).children('a.quickViewIcon').children('img').css('display', 'none');
});
$(".quickViewIconImage").mouseover(function() {
	$(this).attr('src', "http://media.vickerey.com/images/search/quick-view-icon-on.png");
}).mouseleave(function() {
	$(this).attr('src', "http://media.vickerey.com/images/search/quick-view-icon-off.png");
});				

//Look Book Quickview Events
$(".lookBookImageQuickView").mouseover(function() {
        $(this).children('a.quickViewIcon').css('display', 'block');
        $(this).children('a.quickViewIcon').children('img').css('display', 'block');
}).mouseleave(function() {
        $(this).children('a.quickViewIcon').css('display', 'none');
        $(this).children('a.quickViewIcon').children('img').css('display', 'none');
});
$(".lookBookQuickViewIconImage").mouseover(function() {
        $(this).attr('src', "http://media.vickerey.com/images/search/lookbook-quickview-rollover.png");
}).mouseleave(function() {
        $(this).attr('src', "http://media.vickerey.com/images/search/lookbook-quickview.png");
});    


// Quick View Frame
$(".quickViewLink").click(function(a){
	a.preventDefault();
	$("#quickViewLink").attr('href', $(this).attr('href'));
	$("#iframeHolder").html("<iframe style='display:none;' src='http://store.vickerey.com/quickview_iframe/' width='0' height='0'></iframe>");
});

$('.blockOverlay').live('click',function(){
	$('#quickViewContainer').toggle(false);
	$('#quickViewContainer').html('');
	$.unblockUI();
});


$("#addToBasket").mouseover(function() {
	$(this).children('img').attr('src', 'http://media.vickerey.com/images/quickview/add_to_basket_active.png');
}).mouseleave(function() {
	$(this).children('img').attr('src', 'http://media.vickerey.com/images/quickview/add_to_basket_inactive.png');
});
$("#addToBasket").click(function(){
	$("form[name='basketForm']").submit();
});
$(".quickViewThumbnail a").live('click', function(a){
	a.preventDefault();
	$("#quickViewImage").attr('src', $(this).attr('href'));
});
$("#quickViewClose").mouseover(function() {
	$(this).children('img').attr('src', 'http://media.vickerey.com/images/quickview/close_on.png');
}).mouseleave(function() {
	$(this).children('img').attr('src', 'http://media.vickerey.com/images/quickview/close_off.png');
});
$("#quickViewClose").live('click', function(a){
	a.preventDefault();
	$('#quickViewContainer').toggle(false);
	$('#quickViewContainer').html('');
	$.unblockUI();
});

$("#quickViewSwatchWrapper a").live('click', function(a){
	a.preventDefault();
	$("#quickViewLeftSide").block({ message: '<span class="loadingSwatchStatus">loading...</span>',
		centerX: true,
		centerY: false,
		css: {
				width: '258px',
				cursor: 'null',
				border: 'none',
				backgroundColor: 'auto', 
		}, 
		overlayCSS:  { 
				opacity: 0.2,
				cursor: 'null',
		} 
	});			
	$("#quickViewLeftSideContainer").load($(this).attr('href'));
});

 
// Close On Doc Ready 
});

