
$(document).ready(function(){
	
	var _count = 1;
	$("#home .itemWrap").css("display", "none");
	
	function rollHighlights() {
		var _item = ".item"+_count;
		$("#home_highlight .active").fadeOut(500,function(){
			$(this).removeClass("active");
			$(_item).fadeIn(500,function(){
				$(this).css("filter", "");
				$(this).addClass("active");
				$(_item).animate({opacity:1},4000,function(){
					_count++;
					if (_count == 4) {
						_count = 1;
					}
					rollHighlights();
				});
			});
		});
	}
	
	$("#home .item1").fadeIn(500,function(){
		$(this).css("filter", "");
		$(this).addClass("active");
		$(this).animate({opacity:1},3000,function(){
			_count++;
			rollHighlights();
		});
	});
	
	/*$("form").submit(function(){
		$("input.button").click();
		return false;
		
	});*/
	
	$("input#email_input").click(function(){
		
		if($(this).attr("value") == "Your email address")
		{
			$(this).attr("value", "");
		}
		
	});
	
	$("input.image").click(function(){
		
		var _email = $("#email_input").attr("value");
		
		//alert("Hello "+ _email);
		
		//return false;
		
		var _this_container = $(this).parent();
		
		$.ajax({
			type: "POST",
			url: "/handlers/register.php",
			data: "email="+ _email,
			success: function(msg){
				if(msg == 1)
				{
					_this_container.html("<p>Thank you for signing up.</p>");
				}
			}
		});
		
	});
	
	$("#pop_button").click(function(){
		
		 window.open("http://www.altacolinawine.com/sign_up.php" ,"New_Window","menubar=no,resizable=no,width=377,height=530");
		
		return false;
	});
	
	$("a.description").click(function(){
				
				var _id = $(this).attr("href");
				
				//alert(_id);
				
				$.fn.colorbox({open:true, width:"520px", inline:true, href:_id, opacity: "0.74"});
				
				return false;
			});

	
});

function copyFields()
{
	document.getElementById('Shipping_Name').value = "";
	document.getElementById('Shipping_Address_Line_1').value    = "";
	document.getElementById('Shipping_Address_Line_2').value = "";
	document.getElementById('Shipping_State').value = "";
	document.getElementById('Shipping_City').value    = "";
	document.getElementById('Shipping_Zip').value     = "";
	document.getElementById('Shipping_Phone').value   = "";
	
	document.getElementById('Shipping_State').value    = document.getElementById('Billing_State').value;
	if(!document.getElementById('Shipping_State').value){ 
		alert("You Can Not ship to this state, please select another state.");
		return false;
	}
	
	document.getElementById('Shipping_Name').value  =(document.getElementById('Billing_Name').value)? document.getElementById('Billing_Name').value: '';
	document.getElementById('Shipping_Address_Line_1').value    = document.getElementById('Billing_Address_Line_1').value;
	document.getElementById('Shipping_Address_Line_2').value = (document.getElementById('Billing_Address_Line_2').value)? document.getElementById('Billing_Address_Line_2').value: '';
	
	document.getElementById('Shipping_City').value    = document.getElementById('Billing_City').value;
	document.getElementById('Shipping_Zip').value     = document.getElementById('Billing_Zip').value;
	document.getElementById('Shipping_Phone').value   = document.getElementById('Billing_Phone').value;
	

	return;
}
