// JavaScript Document

function ProductAJAX(){

		url='/site/1/ajax/product.php?ProductID=' + escape($("#ProductID").val()) + '&Quantity=' + escape($("#Quantity").val());
		ajaxCall(url);
	
}
	
function ProjectProductAJAX(){

		url='/site/1/ajax/product.php?ProjectProduct=1&ProductID=' + escape($("#ProductID").val()) + '&Quantity=' + escape($("#Quantity").val());
		ajaxCall(url);
	
}
	
	
var addthis_config =
{
	ui_click : true,
	data_track_clickback:true
};	


$(document).ready(function(){

	jsddm_init('#Menu');



	$('#btnAddToBasket').click(function(){
		ProductID = $('#ProductID').val();
		Quantity = $('#Quantity').val();
		url = '/ajax/addtobasket.php?ProductID=' + ProductID + '&Quantity=' + Quantity;

		
		$('#BasketSummary').load(url, function(response, status, xhr) {
			$('#Popup_AddToBasket').show();
			$('.Popup_AddToBasket_Close').click(function(){
				$('#Popup_AddToBasket').hide();
				return false;
			});
		});

return false;
	});


	$('.OrderItemRemove').click(function(){
										 
		if(confirm('Are you sure?'))return true;	
		return false;
	});
						   
	$('.ImageZoomOpen').click(function(){
	   //alert('guy');
		$('#ImagePopupBG').show();
		//alert($('#ZoomImage').height());


		PopupWidth = $('#ZoomImage').width();
		$('#ImagePopup').css('width', PopupWidth);
		
		PopupWidth = (PopupWidth + 44);
		
		PopupHeight = ($('#ZoomImage').height() + 44);
		
		$('#ImagePopup').css('margin-left', ($('#ImagePopupBG').width()/2)-(PopupWidth/2));
		$('#ImagePopup').css('margin-top', ($('#ImagePopupBG').height()/2)-(PopupHeight/2));
		
	
		return false;
	});


	$('.ImageZoomClose').click(function(){
	   //alert('guy');
		$('#ImagePopupBG').hide();
		return false;
	});


	$("#Postcode").Watermark("RH13 ","#cccccc");



	$("#btnDeliveryServicesFind").click(function(){$.Watermark.HideAll();});
	$("#btn_Go").click(function(){$.Watermark.HideAll();});


    $('.HomepageSlideShow').cycle({
		fx: 'fade',
		timeout:       6000,  // milliseconds between slide transitions (0 to disable auto advance)
		speed:         1000  // speed of the transition (any valid fx speed value)
		
	});


	$('.JoinMailingList').click(function(){
		$('#MailingPopupBG').show();
		return false;										 
	});

	$('.MalingListClose').click(function(){
		$('#MailingPopupBG').hide();
		return false;										 
	});


	jQuery.validator.messages.required = "";
	$("#frmJoinMailingList").validate({
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				alert('Please fix the fields marked in red.');
			} else {
			}
		},
		submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#JoinMailingListContainer"
				});
		}
	});
});
