$(window).load(function() {
	/*
    $('#slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        animSpeed:500, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
    });
    */
    
});

$(window).resize(function() {
  	var container = $('#container');
 	var position = container.position();
 	var top = position.top + 65;
 	var top2 = position.top + 175;
 	var top3 = position.top + 245;
 	$('#logo.no-index').css({
 		'position': 'fixed',
 		'left': + position.left,
 		'top': + top
 	});
 	$('#backtoshelf').css({
 		'position': 'fixed',
 		'left': + position.left,
 		'top': + top2
 	});
 	$('.secondary-menu').css({
 		'position': 'fixed',
 		'left': + position.left,
 		'top': + top3
 	});
});

$(document).ready(function(){

 	var container = $('#container');
 	var position = container.position();
 	var top = position.top + 65;
 	var top2 = position.top + 175;
 	var top3 = position.top + 245;
 	$('#logo.no-index').css({
 		'position': 'fixed',
 		'left': + position.left,
 		'top': + top
 	});
 	$('#backtoshelf').css({
 		'position': 'fixed',
 		'left': + position.left,
 		'top': + top2
 	});
 	$('.secondary-menu').css({
 		'position': 'fixed',
 		'left': + position.left,
 		'top': + top3
 	});
 	
 	$('#customform-subscribe #Field1').val('E-Mail Address');
	$('#customform-subscribe #Field1').focus(function() {
		if($('#customform-subscribe #Field1').val()=='E-Mail Address'){
			$('#customform-subscribe #Field1').val('');
		};
	});
	$('#customform-subscribe #Field1').blur(function() {
		if($('#customform-subscribe #Field1').val()== ''){
			$('#customform-subscribe #Field1').val('E-Mail Address');
		};
	});
 	
	$(".item .imgholder.on").hover(
		function(){
			$(this).children(".bottle-roll").show();
			$(this).children(".bottle-head").hide();
			$(this).next(".label").children(".label-roll").show();
			$(this).next(".label").children(".label-head").hide();
		},function(){
			$(this).children(".bottle-head").show();
			$(this).children(".bottle-roll").hide();
			$(this).next(".label").children(".label-head").show();
			$(this).next(".label").children(".label-roll").hide();
		}
	);
	/*
	$(".item .imgholder").click(function(){
		$(this).parent().siblings().animate({opacity: '.1'},600);
        var href = $(this).attr('href');
        setTimeout(function() {window.location = href}, 300);
        return false;
	});
	*/
	
	$('.item .imgholder.on img').bind('click', function(e) {
		
		$(this).parent().siblings('.label').hide();
		$(this).parent().css({'z-index': '100'});
	    
	    var _this = $(this),
	        scale = 5;
	    
	    // Store default width
	    if(_this.data('defWidth') == undefined) {
	        _this.data('defWidth', _this.width());
	    }
	
	    if (_this.width() > _this.data('defWidth')) {
	        
	        // Reset image
	        _this.animate({
	            'left': 0,
	            'top': 0,
	            'width': _this.data('defWidth')
	        });
	        
	    } else {
	    	 // Localise clicked position
	       // alert(_this.offset().left);
	        //alert(_this.offset().top);
	      //  alert(_this.height());
	     //   alert(_this.width());
	        
	        
	        //alert($(document).width());
	        //alert($(document).height());
	        
	        
	        var imgHitX = e.pageX - _this.offset().left,
	           imgHitY = e.pageY - _this.offset().top;
	
	        //alert(_this.width()*scale);
	        
	        
	        // Calculate position offset
	        // var left = ((imgHitX * scale) - imgHitX) * -1.1,
	           top = ((imgHitY * scale) - imgHitY) * -1.1;
	           
	       var left = ($(document).width() - (_this.width()*scale))/2 - _this.offset().left;
	       var top = ($(document).height() - (_this.height()*scale))/2 - _this.offset().top - (_this.height()*scale * .20) + $(window).scrollTop();
	           
	          
	       // alert(left);
	       // alert(top); 
	
	        // Scale image
	        _this.animate({
	            'left': left,
	            'top': top,
	            'width': _this.width() * scale
	        });
	        
	       
	       
	       //alert($(window).scrollTop()); 
	       //return false;
	        /* 
	        // Localise clicked position
	        var imgHitX = e.pageX - _this.offset().left,
	           imgHitY = e.pageY - _this.offset().top;
	
	        // Calculate position offset
	        var left = ((imgHitX * scale) - imgHitX) * -1.1,
	           top = ((imgHitY * scale) - imgHitY) * -1.1;
	
	        // Scale image
	        _this.animate({
	            'left': left,
	            'top': top,
	            'width': _this.width() * scale
	        });
	        */
	    }
		
	});
	
	
	$("#content-inner").animate({opacity: 'show'}, 500);
	$("#bottle-left").hover (
		function(){
			$(this).animate({
				left: '+=20'
			}, 250);
		},function(){
			$(this).animate({
				left: '-=20'
			}, 250);
		}
	);
	$("#bottle-right").hover (
		function(){
			$(this).animate({
				right: '+=20'
			}, 250);
		},function(){
			$(this).animate({
				right: '-=20'
			}, 250);
		}
	);
	
	// $(".colorpop").colorbox({iframe:true, width:560, height:349});
	
	$(".show-holiday-ads").click(function(){
		$(this).slideUp();
		$(".stage").slideDown();
	});
	$(".close-holiday").click(function(){
		$(".show-holiday-ads").slideDown();
		$(".stage").slideUp();
	});
	
	$("#ad-tabs").tabs();
	
});
			
function validate_email(field,alerttxt) {
	with (field) { 
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) {
			alert(alerttxt);
			return false;
		}
		else { return true; }
	}
}
function validate_form(thisform,fieldtovalidate)
{
	with (thisform)
	{
	if (validate_email(fieldtovalidate,"Not a valid e-mail address!")==false)
	  { return false;}
	}
}


function getPassword(thisTable,thisId){ 
	  var retVal = "" 
	  retVal = prompt("A password is required to view this video.", ""); 
	  thisURL="/video.cfm";
	  $.post(thisURL, { variable: thisTable, variable2: thisId, variable3: retVal }, function(data){
	    newAnswer=data.replace(/^\s*/, "").replace(/\s*$/, "");
		if (newAnswer == "No") {
	 	 	alert("Incorrect Password!");
		  	window.location.reload();
		  	return false;
		  }
		  else {
		  	return true;
		  } 
	  });
}

function popUp1(message) {
	var x = 20;
	var y = 20;
	var windowparam = "width=" + 500 + ",height=" + 700 + ",scrollbars=yes,menubar=no,left="+x+",top="+y+",screenX="+x+",screenY="+y;

	popwin = window.open(message, "popwin", windowparam)

	popwin.opener = self;

	popwin.focus()
}

