// JavaScript Document
$(document).ready(function(){
	$(".hidethis").click(function(){
		$(this).parent().hide();
	});
	
	$(".RemoveSubmitButt").click(function(){
		var RemoveID = $(this).attr('name');
		RemoveID = RemoveID + "Hidden";
		$("#DID").val($("#" + RemoveID).val());
		$("#EID").val("");
	});

	$(".EditSubmitButt").click(function(){
		var EditID = $(this).attr('name');
		EditID = EditID + "Hidden";
		$("#EID").val($("#" + EditID).val());
		$("#DID").val("");
	});
	$('#accountsummarydetails').show();
	$('#CartProductDetails').hide();
	$('.loader').hide();
	$('.StatusMessageDiv').hide();
	$('.ErrorMessageDiv').hide();
	$('.SuccessMessageDiv').hide();
	$(".rowfortax").hide();
	$(".rowfortaxdisplay").hide();



var styledformCartD = jQuery(".styledformCartD").validate({
		submitHandler: function(form) {
			window.location.hash="ISCEntry";
			jQuery(form).ajaxSubmit({
				target: "#PreFormSummary"
			});
			return false; 
		}
	});

var styledformCartE = jQuery(".styledformCartE").validate({
		submitHandler: function(form) {
			window.location.hash="ISCEntry";
			jQuery(form).ajaxSubmit({
				target: "#PreFormSummary"
			});
			return false; 
		}
	});

var styledformCart = jQuery(".styledformCart").validate({
		submitHandler: function(form) {
			window.location.hash="ISCEntry";
			jQuery(form).ajaxSubmit({
				target: "#PreFormSummary",
				beforeSubmit:	ajaxBefore,   // pre-submit callback 
				success:	  ajaxSuccess,  // post-submit callback 
				clearForm: true,        // clear all form fields after successful submit 
				resetForm: true        // reset the form after successful submit 
			});
			return false; 
		}
	});

var v = jQuery("#entryformb").validate({
		submitHandler: function(form) {
			window.location.hash="ISCEntry";
			jQuery(form).ajaxSubmit({
				target: "#PreFormSummary", //Shopping Cart and status messages
				beforeSubmit:	ajaxBefore,   // pre-submit callback 
				success:	  ajaxSuccess,  // post-submit callback 
				clearForm: true,        // clear all form fields after successful submit 
				resetForm: true        // reset the form after successful submit 
			});
			return false; 
		},
		rules: {
			//SPIRIT RULES START
			strBrandName: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			strPrimaryCategory: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			strBrandSpiritTypeCode: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			dblAlcoholicStrength: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";},
				range: [0.01,100]
			},
			dblRRPAmt: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";},
				number:true
			},
			dblRRPCurrency: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			strOwner: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			strCountryofOrigin: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			strDistiller: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			strDistiller: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			boolMarketDomestic: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry" && !($('#boolMarketDomestic').attr("checked") || $('#boolMarketDutyfree').attr("checked") || $('#boolMarketOfftrade').attr("checked") || $('#boolMarketOntrade').attr("checked")); }
			},
			strUKDistribution: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			strRecentLaunch: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry";}
			},
			boolRegionEurope: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "TastingEntry" && !($('#boolRegionEurope').attr("checked") || $('#boolRegionAfrica').attr("checked") || $('#boolRegionAustralasia').attr("checked") || $('#boolRegionAsia').attr("checked") || $('#boolRegionNAmerica').attr("checked") || $('#boolRegionSAmerica').attr("checked")); }
			},
			//SPIRIT RULES END
			//DP RULES START
			strTypeDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly"|| ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked"));}
			},
			strCategoryDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly"|| ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked"));}
			},
			strBrandNameDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true");}
			},
			strOwnerDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true");}
			},
			strPrimaryCategoryDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true");}
			},
			strCountryofOriginDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true");}
			},
			dblRRPAmtDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true");},
				number:true
			},
			dblRRPCurrencyDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true");}
			},
			boolMarketDomesticDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" && !($('#boolRegionEuropeDP').attr("checked") || $('#boolRegionAfricaDP').attr("checked") || $('#boolRegionAustralasiaDP').attr("checked") || $('#boolRegionAsiaDP').attr("checked") || $('#boolRegionNAmericaDP').attr("checked") || $('#boolRegionSAmericaDP').attr("checked")) || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true" && !($('#boolMarketDomesticDP').attr("checked") || $('#boolMarketDutyfreeDP').attr("checked") || $('#boolMarketOfftradeDP').attr("checked") || $('#boolMarketOntradeDP').attr("checked"))); }
			},
			strRecentLaunchDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true");}
			},
			boolRegionEuropeDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" && !($('#boolRegionEuropeDP').attr("checked") || $('#boolRegionAfricaDP').attr("checked") || $('#boolRegionAustralasiaDP').attr("checked") || $('#boolRegionAsiaDP').attr("checked") || $('#boolRegionNAmericaDP').attr("checked") || $('#boolRegionSAmericaDP').attr("checked")) || ($('input[name=entryformbchoice]:checked').val() == "TastingEntry" && $("#product2check").attr("checked") && $("#UsingNewDPDetails").val()=="true" && !($('#boolRegionEuropeDP').attr("checked") || $('#boolRegionAfricaDP').attr("checked") || $('#boolRegionAustralasiaDP').attr("checked") || $('#boolRegionAsiaDP').attr("checked") || $('#boolRegionNAmericaDP').attr("checked") || $('#boolRegionSAmericaDP').attr("checked"))); }
			},
			strDesignPackageAwardsStatement: {
				required: function(element) {
					if ($('input[name=entryformbchoice]:checked').val() == "DPOnly") {
						return true;
					} else if ($("#product2check").attr("checked") && ($("#strDPAwardsCategory").val() != "" || $("#strDPAwardsCategory_fake").val() != "Please Select")) { 
						return true;
					} else {
						return false;
					}
				}
			},
			strContactNameDP: {
				required: function(element) { return $('input[name=entryformbchoice]:checked').val() == "DPOnly" && $("#UsingNewDPDetails").val()=="true";}
			},
			//DP RULES END
			//RETAIL RULES START
			strRetailUKMultiple1: {
				required: function(element) {
					return $("#product3check").attr("checked") && !($('#strRetailUKMultiple1').val()!="" || $('#strRetailUKIndep1').val()!="" || $('#strRetailIntMultiple1').val()!="" || $('#strRetailIntIndep1').val()!="" || $('#strRetailIntOnTrade1').val()!="");
				}
			}
			//RETAIL RULES END
		},
		errorPlacement: function(error, element) {
			error.appendTo( element.parent("td") );
		},
		errorClass: "errorawesome",
		errorElement: "div",
		invalidHandler: function(form, validator) {
			alerttext = "";
			if(validator.numberOfInvalids()==1){
				alerttext = validator.numberOfInvalids() + " detail is invalid - please review your answers";
			}else{
				if(validator.numberOfInvalids()>1){
					alerttext = validator.numberOfInvalids() + " details are invalid - please review your answers";
				}
			}
			$("#validationerrorinfotop").text(alerttext);
			$("#validationerrorinfobottom").text(alerttext);
			$('.validationinfo').show();
			window.location.hash="ISCEntry";
	//		$('#productdetails1').show();
	//		$('#productdetails2').show();
	//		$('#productdetails3').show();
		}
	});



	jQuery("#ClearFormButt").click(function() {
		if (confirm("Clearing this form will lose any unsaved information.")) {
			$('.SuccessMessageDiv').hide();
			$('.StatusMessageDiv').hide();
			$('.ErrorMessageDiv').hide();
			$('.validationinfo').hide();
			v.resetForm();
			$('#ProductID').val(0);
			product1change();
			window.location.hash="ISCEntry";
		}
	});


	$('.fontreplace').each(function(i){var strHTML=this.innerHTML;this.innerHTML="";this.innerHTML="<img src=" + curdir() + "_images/_titles/"+fnString2File(strHTML)+".jpg />";$(this).removeClass("fontreplace");});
	$("form#entryforma input#strEmailConf").attr("equalto","#strEmailAddress");
	$('#resendemailform').hide();
	$('#resetpasswordform').hide();
	$('#DPUseNewbuttRow').hide();
	$("#DPUseExistingbuttRow").hide();
	$("#DPOnlyEntry").hide();
	$("form#entryforma").validate({
	rules: {
		strAccountPword: {
			minlength: 4,
			maxlength: 15
		}
	},
	errorPlacement: function(error, element) {
		error.appendTo( element.parent("div") );
		$('.validationinfo').show();
	}
  });
	$('#strAccountPword').css( {backgroundPosition: "0 0"} );
	$('#strAccountPword').keyup(function(){
		var bpos = "";
		var perc = 0 ;
		var minperc = 0 ;
		$('#result').html(passwordStrength($('#strAccountPword').val(),$('#strAccountUserNameHidden').val())) ; 
		perc = passwordStrengthPercent($('#strAccountPword').val(),$('#strAccountUserNameHidden').val());
		bpos=" $('#colorbar').css( {backgroundPosition: \"0px -" ;
		bpos = bpos + perc + "px";
		bpos = bpos + "\" } );";
		bpos=bpos +" $('#colorbar').css( {width: \"" ;
		bpos = bpos + (perc * 2.75) + "px";
		bpos = bpos + "\" } );";
		eval(bpos);
		$('#percent').html(" " + perc  + "% ");
	});

	$('#strResetPword').css( {backgroundPosition: "0 0"} );
	$('#strResetPword').keyup(function(){
		var bpos = "";
		var perc = 0 ;
		var minperc = 0 ;
		$('#result').html(passwordStrength($('#strResetPword').val(),$('#strResetEmailAddress').val())) ; 
		perc = passwordStrengthPercent($('#strResetPword').val(),$('#strResetEmailAddress').val());
		bpos=" $('#colorbar').css( {backgroundPosition: \"0px -" ;
		bpos = bpos + perc + "px";
		bpos = bpos + "\" } );";
		bpos=bpos +" $('#colorbar').css( {width: \"" ;
		bpos = bpos + (perc * 2.75) + "px";
		bpos = bpos + "\" } );";
		eval(bpos);
		$('#percent').html(" " + perc  + "% ");
	});


	$('#strCompanyName').keyup(function(){
		strSanitisedCompanyName = SanitisedString($('#strCompanyName').val());
		$('#strAccountUserNameHidden').val(strSanitisedCompanyName);
	});

	$('#DPUseExistingbutt').click(function () {
		$("#UsingNewDPDetails").val("false");
		$("#DPUseExistingbuttRow").hide();
		$("#DPUseNewbuttRow").show();
		$("#SpiritAndDPEntry").hide();
		$("#DPOnlyEntry").hide();
	});

	$('#DPUseNewbutt').click(function () {
		$("#UsingNewDPDetails").val("true");
		$("#DPUseExistingbuttRow").show();
		$("#DPUseNewbuttRow").hide();
		$("#SpiritAndDPEntry").show();
		$("#DPOnlyEntry").hide();
	});

	$('#strBrandName').change(function () {
		if($('#strBrandName').val()!=""){
			if($('#strBrandNameDP').val()==""){
				$("#UsingNewDPDetails").val("false");
				$("#DPUseExistingbuttRow").hide();
				$("#DPUseNewbuttRow").show();
				$("#SpiritAndDPEntry").hide();
				$("#DPOnlyEntry").hide();
				$("#CurrentBrandSpan").html($('#strBrandName').val());
			}else{
				$("#UsingNewDPDetails").val("true");
				$("#DPUseExistingbuttRow").show();
				$("#DPUseNewbuttRow").hide();
				$("#SpiritAndDPEntry").show();
				$("#DPOnlyEntry").hide();
				$("#CurrentBrandSpan").html($('#strBrandName').val())
			}
		}else{
			$("#UsingNewDPDetails").val("true");
			$("#DPUseExistingbuttRow").hide();
			$("#DPUseNewbuttRow").hide();
			$("#SpiritAndDPEntry").show();
			$("#DPOnlyEntry").show();
		};
	});

	$('#BillingVATNumbercc').change(function () {
		TaxEntryBox('cc');
	});

	$('#BillingVATNumberinv').change(function () {
		TaxEntryBox('inv');
	});

	$('#AccountDetailsButton').click(function () {
		$('#accountsummarydetails').slideToggle("fast");
	});

	$('#PreviousWinnersSearchButt').click(function () {
		$('#PreviousWinnersSearch').slideToggle("fast");
	});


	$('#dbdownloadbutt').click(function () {
		$('#dbdownload').slideToggle("fast");
	});



	$('#PreviousWinnersResultsButt').click(function () {
		$('#PreviousWinnersResults').slideToggle("fast");
	});

	$('#CartDetailsButton').click(function () {
		$('#CartProductDetails').slideToggle("fast");
	});

	$('#CurrentEntrySummaryButt').click(function () {
		$('#CurrentEntrySummary').slideToggle("fast");
	});


	$("form#resendemailform").validate({
		errorPlacement: function(error, element) {
		error.appendTo( element.parent("div") );
		$('.validationinfo').show();
	}
	});

	$("form#resetpasswordform").validate({
		errorPlacement: function(error, element) {
		error.appendTo( element.parent("div") );
		$('.validationinfo').show();
	}
	});

	$("form#myaccountlogin").validate({
		errorPlacement: function(error, element) {
		error.appendTo( element.parent("div") );
		$('.validationinfo').show();
	}
	});

	$("form#entryformc").validate({
		errorPlacement: function(error, element) {
		error.appendTo( element.parent("div") );
		$('.validationinfo').show();
	}
	});  

	$("form#entryformc1").validate({
		errorPlacement: function(error, element) {
		error.appendTo( element.parent("div") );
		$('.validationinfo').show();
	}
	});  


NavHovers();

$('.styledform').jForms({
	imagePath: curdir() + '_images/niceforms/',
	listSize: 10
});

$('.styledformCart').jForms({
	imagePath: curdir() + '_images/niceforms/',
	listSize: 10
});

$('.styledformCartPayment').jForms({
	imagePath: curdir() + '_images/niceforms/',
	listSize: 10
});


$('.styledformCartD').jForms({
	imagePath: curdir() + '_images/niceforms/',
	listSize: 10
});

$('.styledformCartE').jForms({
	imagePath: curdir() + '_images/niceforms/',
	listSize: 10
});


//  $('.styledform > fieldset').dropShadow({
//	left    : 1,
//	top     : 1,
//	blur    : 1,
//	opacity : 0.45,
//	color   : "#000000",
//	swap    : false
//  });
  PaymentOption();
  $("a.newwin").attr({target:"_blank"});
  $('tr#rows4').hide();
  $('tr#doming').hide();
$("#boolMarketAllSpirit,#boolMarketAllSpirit_fake").click(function(){
AllChecksMarketSpirit();
  });
  $("#boolRegionAllSpirit,#boolRegionAllSpirit_fake").click(function(){
	AllChecksRegionSpirit();
  });

$("#boolMarketAllDP,#boolMarketAllDP_fake").click(function(){
	AllChecksMarketDP();
  });
  $("#boolRegionAllDP,#boolRegionAllDP_fake").click(function(){
	AllChecksRegionDP();
  });
  $("#entryformbchoice_1_fake,#entryformbchoice_1,#entryformbchoice_2,#entryformbchoice_2_fake").click(function(){
	product1change();
  });

$("#product2check_fake,#product2check").click(function(){
	product1change ();
});
 
product1change ();


});



function product1change () {
	if($('input[name=entryformbchoice]:checked').val() == "DPOnly"){
		$('#productdetails1').hide();
		$('#productdetails2').show();
		$("#UsingNewDPDetails").val("true");
		$("#DPUseExistingbuttRow").hide();
		$("#DPUseNewbuttRow").hide();
		$("#SpiritAndDPEntry").show();
		$("#DPOnlyEntry").show();
	}else{
		$('#productdetails1').show();
		$('#productdetails2').hide();
		$("#DPOnlyEntry").hide();
		if($('#strBrandName').val()!=""){
			$('#productdetails2').show();
 			if($("#product2check").attr("checked")){
				if($('#strBrandNameDP').val()==""){
					$("#UsingNewDPDetails").val("false");
					$("#DPUseExistingbuttRow").hide();
					$("#DPUseNewbuttRow").show();
					$("#SpiritAndDPEntry").hide();
				}else{
					$("#UsingNewDPDetails").val("true");
					$("#DPUseExistingbuttRow").show();
					$("#DPUseNewbuttRow").hide();
				}
			}else{
				$('#productdetails2').hide();
			}
		}else{
 			if($("#product2check").attr("checked")){
				if($('#strBrandNameDP').val()==""){

				}else{

				}
				$('#productdetails2').show();
			}else{
				var to1=setTimeout("$('#productdetails2').show()",0.1);
				var to1=setTimeout("$('#productdetails2').hide()",0.1);
			}
		}
	}
}

function AllChecksMarketSpirit() {
	if ($("#boolMarketAllSpirit").attr("checked") == true) {
		$(".marketcheckspirit").each(function(i){
			$(this).attr("checked","checked");
			id = $(this).attr("id");
			$("#"+id+"_fake").addClass("checkboxAreaChecked");
		});
	} else {
		$(".marketcheckspirit").each(function(i){
			$(this).removeAttr("checked");
			id = $(this).attr("id");
			$("#"+id+"_fake").removeClass("checkboxAreaChecked");
			$("#"+id+"_fake").addClass("checkboxArea");
		});
	}
}
function AllChecksRegionSpirit() {
	if ($("#boolRegionAllSpirit").attr("checked") == true) {
		$(".regioncheckspirit").each(function(i){
			$(this).attr("checked","checked");
			id = $(this).attr("id");
			$("#"+id+"_fake").addClass("checkboxAreaChecked");
		});
	} else {
		$(".regioncheckspirit").each(function(i){
			$(this).removeAttr("checked");
			id = $(this).attr("id");
			$("#"+id+"_fake").removeClass("checkboxAreaChecked");
			$("#"+id+"_fake").addClass("checkboxArea");
		});
	}
}

function AllChecksMarketDP() {
	if ($("#boolMarketAllDP").attr("checked") == true) {
		$(".marketcheckdp").each(function(i){
			$(this).attr("checked","checked");
			id = $(this).attr("id");
			$("#"+id+"_fake").addClass("checkboxAreaChecked");
		});
	} else {
		$(".marketcheckdp").each(function(i){
			$(this).removeAttr("checked");
			id = $(this).attr("id");
			$("#"+id+"_fake").removeClass("checkboxAreaChecked");
			$("#"+id+"_fake").addClass("checkboxArea");
		});
	}
}
function AllChecksRegionDP() {
	if ($("#boolRegionAllDP").attr("checked") == true) {
		$(".regioncheckdp").each(function(i){
			$(this).attr("checked","checked");
			id = $(this).attr("id");
			$("#"+id+"_fake").addClass("checkboxAreaChecked");
		});
	} else {
		$(".regioncheckdp").each(function(i){
			$(this).removeAttr("checked");
			id = $(this).attr("id");
			$("#"+id+"_fake").removeClass("checkboxAreaChecked");
			$("#"+id+"_fake").addClass("checkboxArea");
		});
	}
}

function revealresendemailform() {
	$('#resendemailform').show();
}

function revealresetpasswordform() {
	$('#resetpasswordform').show();
	$('#myaccountlogin').hide();
}

function revealmyaccountlogin() {
	$('#resetpasswordform').hide();
	$('#myaccountlogin').show();
}


function CopyCCAddress()
 {
  if($("#boolCopyCCAddress").attr("checked") == true)
   {
    $("#CardHolderName").val($("#BillingTitlecc").val() + " " + $("#BillingFirstNamecc").val() + " " + $("#BillingSurNamecc").val());
    $("#CardHolderAddress1").val($("#BillingAddress1cc").val());
    $("#CardHolderAddress2").val($("#BillingAddress2cc").val());
    $("#CardHolderTownCity").val($("#BillingTownCitycc").val());
    $("#CardHolderCountyState").val($("#BillingCountyStatecc").val());
    $("#CardHolderPostZIPCode").val($("#BillingPostZIPCodecc").val());
    $("#CardHolderCountry").val($("#BillingCountrycc").val());
    $("#CardHolderCountry_fake").val($("#CardHolderCountry").children("option:selected").text());
    $("label[for=boolCopyCCAddress" + "]").removeClass('chosen');
    $("#boolCopyCCAddress" + " +_fake").addClass($("#boolCopyCCAddress").attr("checked")?"checkboxArea":"checkboxAreaChecked").removeClass($("#boolCopyCCAddress").attr("checked")?"checkboxAreaChecked":"checkboxArea");
   }
 }

function CopyAddress(FormRef)
 {
  if($("#boolCopyInvoiceAddress"+FormRef).attr("checked") == true)
   {
    $("#BillingTitle"+FormRef).val($("#ContactTitleHidden"+FormRef).val());
    $("#BillingTitle"+FormRef + "_fake").val($("#ContactTitleHidden"+FormRef).val());
    $("#BillingFirstName"+FormRef).val($("#ContactFirstNameHidden"+FormRef).val());
    $("#BillingSurName"+FormRef).val($("#ContactSurNameHidden"+FormRef).val());
    $("#BillingCompanyName"+FormRef).val($("#CompanyNameHidden"+FormRef).val());
    $("#BillingEmailAddress"+FormRef).val($("#EmailAddressHidden"+FormRef).val());
    $("#BillingTelephoneNumber"+FormRef).val($("#PhoneNumberHidden"+FormRef).val());
    $("label[for=boolCopyInvoiceAddress"+FormRef + "]").removeClass('chosen');
    $("#boolCopyInvoiceAddress" + FormRef + " +_fake").addClass($("#boolCopyInvoiceAddress"+FormRef).attr("checked")?"checkboxArea":"checkboxAreaChecked").removeClass($("#boolCopyInvoiceAddress"+FormRef).attr("checked")?"checkboxAreaChecked":"checkboxArea");
    TaxEntryBox(FormRef);
   }
 }
function TaxEntryBox(FormRef){

	var strCartHidden = ($('#CartProductDetails').is(":visible")?false:true);
	var strBillingCountry = $("#BillingCountry" + FormRef).val();
	var strBillingVATNumber = "";
	var boolShowVATBox = (strBillingCountry.substr(0,3)=="EU-" && strBillingCountry!="EU-United Kingdom" && strBillingCountry!=""?"y":"n");
	if(boolShowVATBox=="y"){
		strBillingVATNumber = $("#BillingVATNumber"+FormRef).val();
	}

	$.ajax({
	url:"../entry/_entryincludes/UpdateShoppingCart_ajax.php",
	success: function(data){
		$("#PreFormSummary").html(data);
		$("#TxnTotalIncVATHiddenCC").val($("#TxnTotalIncVATHidden").val());
		$("#TxnTotalexVATHiddenCC").val($("#TxnTotalexVATHidden").val());
		$("#VATAmountHiddenCC").val($("#VATAmountHidden").val());
		$("#TxnTotalIncVATHiddenINV").val($("#TxnTotalIncVATHidden").val());
		$("#TxnTotalexVATHiddenINV").val($("#TxnTotalexVATHidden").val());
		$("#VATAmountHiddenINV").val($("#VATAmountHidden").val());

		$("#TxnTotalIncVATDisplay").html($("#TxnTotalIncVATHidden").val());
		$("#TxnTotalIncVATDisplayINV").html($("#TxnTotalIncVATHidden").val());

		$("#VATAmountDisplay").html($("#VATAmountHidden").val());
		$("#VATAmountDisplayINV").html($("#VATAmountHidden").val());
		if(boolShowVATBox=="y"){
			$(".rowfortax").show();
			if($("#VATAmountHidden").val()!="0.00"){
				$(".rowfortaxdisplay").show();
			}else{
				$(".rowfortaxdisplay").hide();
			}
		}else{
			$(".rowfortax").hide();
			if(strBillingCountry=="EU-United Kingdom"){
				$(".rowfortaxdisplay").show();
			}else{
				$(".rowfortaxdisplay").hide();
			}
		}
		if(strCartHidden){$('#CartProductDetails').hide();}
	},
	data:{
		strBillingCountry:strBillingCountry,
		FormRef: FormRef,
		strBillingVATNumber:strBillingVATNumber,
		boolShowVATBox:boolShowVATBox,
		strPaymentType:$('#RequestType').val()
	},
	async:true
}); 


}
function SpiritsSelectTertiary()
 {
  var strPrimaryCategory = $("form#entryformb select#strPrimaryCategory").val();
  if(strPrimaryCategory=="LISO"){
   $('tr#doming').show();
  }else{
   $('tr#doming').hide();
  }
  $('tr#rows3').hide();
  $('tr#rows4').show();
  $.ajax({
         url:    "../_xml/spirittertiarycategory.php",
         success: function(data){ fnDropDownReplace(document.getElementById("strBrandSpiritTypeCode"),0,data);$('tr#rows4').hide();$('tr#rows3').show();},
			data: { Primary: strPrimaryCategory},
         async:   false,
			dataType: "json"
    }); 
  //$.post("../_xml/spirittertiarycategory.php", { Primary: strPrimaryCategory}, function(data){ fnDropDownReplace(document.getElementById("strBrandSpiritTypeCode"),0,data);$('tr#rows4').hide();$('tr#rows3').show();}, "json");
  $("div.loader").hide();
  $('.fake_list').remove();
  $('.selectArea').remove();
}


function SaveCart(intCompanyID){
	$("div.loader").show();
	$.post("../_xml/SaveCart.php", { intCompanyID: intCompanyID}, function(data){ alert(data);});
	$("div.loader").hide();
}





function PrevSelectSecondary()
 {
  var strPrimaryCategory = $("form#previouswinners select#CategoryName").val();
  $.post("../_xml/prevsecondarycategory.php", 
	{
		Primary: strPrimaryCategory 
	},
	function(data){
		fnDropDownReplace(document.getElementById("SubCategoryName"),1,data);
		RemakeDropDowns();
	},
	"json"
  );
 }



function DBPrevSelectSecondary()
 {

  var strPrimaryCategory = $("#DBCategoryName").val();
  $.ajax({
         url:    "../_xml/spirittertiarycategory.php",
         success: function(data){ fnDropDownReplace(document.getElementById("DBSubCategoryName"),1,data);},
			data: { Primary: strPrimaryCategory},
         async:   true,
			dataType: "json"
    }); 
  //$.post("../_xml/spirittertiarycategory.php", { Primary: strPrimaryCategory}, function(data){ fnDropDownReplace(document.getElementById("strBrandSpiritTypeCode"),0,data);$('tr#rows4').hide();$('tr#rows3').show();}, "json");
 }


function RemakeDropDowns()
 {
$('select').each(function ()
  {
	$('ul#'+this.id+'_fake_list').remove();
	$('#'+this.id+'_fake').parent().remove();

	$('body').append('<ul id = "'+this.id+'_fake_list" class="fake_list"></ul>');
	$(this).children().each(function()
	{
		$('#'+$(this).parent().attr('id')+'_fake_list').append('<li>'+$(this).text()+'</li>');
	});
	$('#'+this.id+'_fake_list').css('height',($('#'+this.id+'_fake_list li:first').height()+4)*($('#'+this.id+'_fake_list li').size()<10?$('#'+this.id+'_fake_list li').size():10)).css('width',$(this).width()+18).toggle();

$('#'+this.id+'_fake_list > li').hover(function(){$(this).addClass('selected')},function(){$(this).removeClass('selected');}).each(function(i)
	{
		$(this).click(function(){
		var id = $(this).parent().attr('id');
		$('#'+id).toggle();
		$('#'+id.replace('_list','')).attr('value',$(this).text());
		$('#'+id.replace('_fake_list','')).attr('selectedIndex',i).change();
		$('#'+id+' >  li').removeClass('selected');
		$(this).addClass('selected');
		if(id.replace('_fake_list','')=="BillingCountrycc")TaxEntryBox('cc');
		if(id.replace('_fake_list','')=="BillingCountryinv")TaxEntryBox('inv');
	});
	});

$(this).before('<div class="selectArea" style="width:'+($(this).width()+43)+'px"><div class="left"></div><div class="right"><a class="selectButton" href="javascript:;" onclick="$(\'#'+this.id+'_fake\').focus().click()"></a></div><input type = "text" class="center" style="width:'+($(this).width())+'px;cursor:default" id="'+this.id+'_fake"  value="'+this[this.selectedIndex].text+'"  /></div>').css('position','absolute').css('left','-6000px');

	$('#'+this.id+'_fake').click(function(){
		$('#'+this.id+'_list').focus();
		$('#'+this.id+'_list').css('left',$(this).offset().left-8);
		
		if(($('#'+this.id+'_list').height()+$(this).offset().top -document.documentElement.scrollTop) > $(window).height())
		{
			$('#'+this.id+'_list').css('top',$(this).offset().top-$('#'+this.id+'_list').height()-4);
		}
		else
		{
			$('#'+this.id+'_list').css('top',$(this).offset().top+$(this).height()+4);
		}
		$('#'+this.id+'_list > li').removeClass('selected');
		$('#'+this.id+'_list > li').get($('#'+this.id.replace('_fake','')).attr('selectedIndex')).className='selected';

		
		$('.fake_list:visible:not(#'+this.id+'_list)').toggle();
		$list = $('#'+this.id+'_list');
		$list.toggle();
		var offSet = (($('.selected', $list).length>0? $('.selected', $list).offset().top:0)- $list.offset().top);
		$list.animate({scrollTop: offSet});
		}).css('font-size',$(this).css('font-size')).css('padding','2px 0px 2px 2px').keyup(function(e)
		{
			var pressedKey = e.charCode || e.keyCode || -1;
			var $dd = $('#'+this.id.replace('_fake',''));
			$('#'+this.id+'_list > li').removeClass('selected');
			switch(pressedKey)
			{
				//down
				case 40:
					var curr = ($dd.attr('selectedIndex')+1>=$('option',$dd).length?0:$dd.attr('selectedIndex')+1);
				break;
				case 38:
					var curr = ($dd.attr('selectedIndex')-1<0?$('option',$dd).length-1:$dd.attr('selectedIndex')-1);
				break;
				case 13:
					$('#'+this.id+'_list').toggle();
					return false;
				break;
				default:
				var t = new Date();
				if(t.getTime()-lastKeypress>1000)
				{
					lastKeypress=t.getTime();
					keyBuffer ='';
				}
					keyBuffer +=String.fromCharCode(pressedKey).toLowerCase();
					curr=-1;
					$('#'+this.id+'_list > li').each(function(i)
					{
						if($(this).text().toLowerCase().indexOf(keyBuffer)==0&&curr==-1)
						{
							curr = i;
							return;
						}
					});
					break;
			}
			if(curr==-1)
			{
				curr=0;
			}
			$($('#'+this.id+'_list > li').get(curr)).addClass('selected').focus();
			$list = $('#'+this.id+'_list');
			var offSet = (($('.selected', $list).length>0? $('.selected', $list).offset().top:0)- $list.offset().top);
			$list.attr('scrollTop',offSet);
			$dd.attr('selectedIndex',curr).change();
			$(this).attr('value', $($('#'+this.id+'_list > li').get(curr)).text());
			if(this.id.replace('_fake','')=="BillingCountrycc")TaxEntryBox('cc');
			if(this.id.replace('_fake','')=="BillingCountryinv")TaxEntryBox('inv');
			return false;
						
		}).focus(function()
		{
			$(document).keypress(function(e)
			{
				var pressedKey = e.charCode || e.keyCode || -1;
				if(pressedKey==13)
				{
					return false;
				}
			});
		}).blur(function()
		{
			$(document).unbind('keypress').unbind('click');
		});
});
}
function NavHovers() {
	$('ul.mainnav > li.inactive').hover(function(i){
		$(this).css({'background-image' : 'url('+curdir() + '_images/navigation/menu-bg-left.jpg)', 'background-repeat' : 'no-repeat'});
		$(this).find('a').css({'background-image' : 'url('+curdir() + '_images/navigation/menu-bg-right.jpg)', 'background-repeat' : 'no-repeat', 'background-position' : 'right'});
		$(this).append("<img src='"+curdir() + "_images/navigation/menu-bg-centre.jpg' alt='Menu Background' title='' class='menubackgroundhover' />");
		imgwidth = $(this).find("a").width();
		$('img.menubackgroundhover').width(imgwidth+3);
		$('img.menubackgroundhover').height(24);
		},
		function(i) {
		$(this).css({'background-image' : 'none'});
		$(this).find('a').css({'background-image' : 'none'});
		$(this).find("img.menubackgroundhover").remove();
	});
	imgwidth = $('ul.mainnav > li.active > a').width();
	$('img.menubackground').width(imgwidth+3);
	$('img.menubackground').height(24);
 }

function NavHovers() {
	$('ul.mainnav > li.inactive').hover(function(i){
		$(this).css({'background-image' : 'url('+curdir() + '_images/navigation/menu-bg-left.jpg)', 'background-repeat' : 'no-repeat'});
		$(this).find('a').css({'background-image' : 'url('+curdir() + '_images/navigation/menu-bg-right.jpg)', 'background-repeat' : 'no-repeat', 'background-position' : 'right'});
		$(this).append("<img src='"+curdir() + "_images/navigation/menu-bg-centre.jpg' alt='Menu Background' title='' class='menubackgroundhover' />");
		imgwidth = $(this).find("a").width();
		$('img.menubackgroundhover').width(imgwidth+3);
		$('img.menubackgroundhover').height(24);
		},
		function(i) {
		$(this).css({'background-image' : 'none'});
		$(this).find('a').css({'background-image' : 'none'});
		$(this).find("img.menubackgroundhover").remove();
	});
	imgwidth = $('ul.mainnav > li.active > a').width();
	$('img.menubackground').width(imgwidth+3);
	$('img.menubackground').height(24);
 }
 


function PaymentOption(){
	if ($('#BoolInvoice1:checked')) {//Pay by Credit Card
		$('#RequestType').val("CC");
		$('.hiddeninv').parent().hide();
		$('.hiddentnc').hide();
		$('#hiddeninvDetails').hide();
}
	 $("[id^='BoolInvoice1']").click(function(){
			$('#RequestType').val("CC");
			$('input.hiddeninv').parent().hide();
			$('.hiddeninv').hide();
			$('.hiddentnc').hide();
			$('#hiddeninvDetails').hide();
			$('input.hiddenccv').parent().show();
			$('.hiddencc').show();
			TaxEntryBox('inv');
	});
	 $("[id^='BoolInvoice2']").click(function(){
		$('#RequestType').val("Invoice");
		$('input.hiddenccv').parent().hide();
		$('.hiddencc').hide();
		$('input.hiddeninv').parent().show();
		$('.hiddeninv').show();
		$('.hiddentnc').show();
		$('#hiddeninvDetails').show();
		TaxEntryBox('inv');
	});
	 $("[id^='BoolInvoice3']").click(function(){
		$('#RequestType').val("ManualInvExDisIncFee");
		$('input.hiddenccv').parent().hide();
		$('.hiddencc').hide();
		$('input.hiddeninv').parent().show();
		$('.hiddeninv').show();
		$('.hiddentnc').show();
		$('#hiddeninvDetails').show();
		TaxEntryBox('inv');
	}); 
	 $("[id^='BoolInvoice4']").click(function(){//Payment override (ignore admin fee)
		$('#RequestType').val("ManualInvIncDisExFee");
		$('input.hiddenccv').parent().hide();
		$('.hiddencc').hide();
		$('input.hiddeninv').parent().show();
		$('.hiddeninv').show();
		$('.hiddentnc').show();
		$('#hiddeninvDetails').show();
		TaxEntryBox('inv');
	}); 
	 $("[id^='BoolInvoice5']").click(function(){
			$('#RequestType').val("ManualCCExDis");
			$('input.hiddeninv').parent().hide();
			$('.hiddeninv').hide();
			$('.hiddentnc').hide();
			$('#hiddeninvDetails').hide();
			$('input.hiddenccv').parent().show();
			$('.hiddencc').show();
			TaxEntryBox('inv');
	});
	 $("[id^='BoolInvoice6']").click(function(){//Payment override (ignore admin fee)
		$('#RequestType').val("ManualInvExDisExFee");
		$('input.hiddenccv').parent().hide();
		$('.hiddencc').hide();
		$('input.hiddeninv').parent().show();
		$('.hiddeninv').show();
		$('.hiddentnc').show();
		$('#hiddeninvDetails').show();
		TaxEntryBox('inv');
	}); 

}
 
 
 function curdir() {
	dir = window.location.pathname;
	dirlength = dir.length;
	newlength = dirlength - dir.replace(/\//g, "").length;
	if (window.location.hostname == "eupds01.prowebgroup.co.uk" || window.location.hostname == "eupds01")  {
		newlength = newlength - 1;
	}
	newdir = "./";
	newlength = newlength - 1;
	while (newlength > 0) {
		newdir = newdir + "../";
		newlength = newlength - 1;
	}
	return newdir;
 }
 
 
// Password strength meter
// This jQuery plugin is written by Firas Kassem [2007.04.05] and modified by Amin Rajaee [2009.07.26]
// Firas Kassem  phiras.wordpress.com || phiras at gmail {dot} com
// Amin Rajaee  rajaee at gmail (dot) com

// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/

var shortPass = '4 characters minimum - please use more characters'
var longPass = '15 characters maximum - please shorten your password'
var badPass = 'Weak - Use letters and numbers for a stronger password'
var goodPass = 'Medium - Use special characters for a stronger password'
var strongPass = 'Strong Password'
var sameAsUsername = 'Weak - Password is the same as username.'


function passwordStrength(password,username)
{
    score = 0 
    
    //password < 4
    if (password.length < 4 ) { return shortPass }
    
    if (password.length > 15 ) { return longPass }
    //password == username
    if (password.toLowerCase() == username.toLowerCase()) return sameAsUsername
    
    //password length
    score += password.length * 4
    score += ( checkRepetition(1,password).length - password.length ) * 1
    score += ( checkRepetition(2,password).length - password.length ) * 1
    score += ( checkRepetition(3,password).length - password.length ) * 1
    score += ( checkRepetition(4,password).length - password.length ) * 1

    //password has 3 numbers
    if (password.match(/(.*[0-9].*[0-9].*[0-9])/))  score += 5 
    
    //password has 2 sybols
    if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5 
    
    //password has Upper and Lower chars
    if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))  score += 10 
    
    //password has number and chars
    if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/))  score += 15 
    //
    //password has number and symbol
    if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/))  score += 15 
    
    //password has char and symbol
    if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/))  score += 15 
    
    //password is just a nubers or chars
    if (password.match(/^\w+$/) || password.match(/^\d+$/) )  score -= 10 
    
    //verifing 0 < score < 100
    if ( score < 0 )  score = 0 
    if ( score > 100 )  score = 100 
    
    if (score < 34 )  return badPass 
    if (score < 68 )  return goodPass
    return strongPass
}



function passwordStrengthPercent(password,username)
{
    score = 0 
    
    //password < 4
    if (password.length < 4 ) { return 0 }
    
    //password == username
    if (password.toLowerCase()==username.toLowerCase()) return 0
    
    //password length
    score += password.length * 4
    score += ( checkRepetition(1,password).length - password.length ) * 1
    score += ( checkRepetition(2,password).length - password.length ) * 1
    score += ( checkRepetition(3,password).length - password.length ) * 1
    score += ( checkRepetition(4,password).length - password.length ) * 1

    //password has 3 numbers
    if (password.match(/(.*[0-9].*[0-9].*[0-9])/))  score += 5 
    
    //password has 2 sybols
    if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5 
    
    //password has Upper and Lower chars
    if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))  score += 10 
    
    //password has number and chars
    if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/))  score += 15 
    //
    //password has number and symbol
    if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/))  score += 15 
    
    //password has char and symbol
    if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/))  score += 15 
    
    //password is just a nubers or chars
    if (password.match(/^\w+$/) || password.match(/^\d+$/) )  score -= 10 
    if (score > 100) return 100
  return (score)
 
}

// checkRepetition(1,'aaaaaaabcbc')   = 'abcbc'
// checkRepetition(2,'aaaaaaabcbc')   = 'aabc'
// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd'

function checkRepetition(pLen,str) {
    res = ""
    for ( i=0; i<str.length ; i++ ) {
        repeated=true
        for (j=0;j < pLen && (j+i+pLen) < str.length;j++)
            repeated=repeated && (str.charAt(j+i)==str.charAt(j+i+pLen))
        if (j<pLen) repeated=false
        if (repeated) {
            i+=pLen-1
            repeated=false
        }
        else {
            res+=str.charAt(i)
        }
    }
    return res
}

function SanitisedString(origstring){
	re="";
	res = origstring.replace(/ /g,"-").toLowerCase();
	res = res.replace(/[^a-z0-9-]/g,"");
	res = res.replace(/\-$/,"");
	res = res.replace(/(\-){2,}/g,"-");
return res
}

function loadProduct(){
if($("#EIDDetail0").val() == "DPOnly"){
	$('input[name="entryformbchoice"]')[1].checked = true;
}else{
	$('input[name="entryformbchoice"]')[0].checked = true;
	$("#strBrandName").val($("#EIDDetail1").val());
	$("#strPrimaryCategory").val($("#EIDDetail2").val());//tbc - need to call database loojup
	SpiritsSelectTertiary();
	$("#strBrandSpiritTypeCode").val($("#EIDDetail3").val());//tbc - need to call database loojup
	$("#strDominantIngredient").val($("#EIDDetail4").val());
	$("#dblAlcoholicStrength").val($("#EIDDetail5").val());
	$("#dblRRPAmt").val($("#EIDDetail6").val());
	$("#dblRRPCurrency").val($("#EIDDetail7").val());
	$("#strOwner").val($("#EIDDetail8").val());
	$("#strCountryofOrigin").val($("#EIDDetail9").val());
	$("#strDistiller").val($("#EIDDetail10").val());

	if($("#EIDDetail11").val()=="1"){$("#boolMarketDomestic").attr('checked', true);}
	if($("#EIDDetail12").val()=="1"){$("#boolMarketDutyfree").attr('checked', true);}
	if($("#EIDDetail13").val()=="1"){$("#boolMarketOfftrade").attr('checked', true);}
	if($("#EIDDetail14").val()=="1"){$("#boolMarketOntrade").attr('checked', true);}

	$("#strTargetMarket").val($("#EIDDetail15").val());

	if($("#EIDDetail16").val()==="yes"){$("#strUKDistribution").val("yes");}else{$("#strUKDistribution").val("no");}
	if($("#EIDDetail17").val()==="yes"){$("#strRecentLaunch").val("yes");}else{$("#strRecentLaunch").val("no");}


	if($("#EIDDetail18").val()=="1"){$("#boolRegionEurope").attr('checked', true);}
	if($("#EIDDetail19").val()=="1"){$("#boolRegionAfrica").attr('checked', true);}
	if($("#EIDDetail20").val()=="1"){$("#boolRegionAustralasia").attr('checked', true);}
	if($("#EIDDetail21").val()=="1"){$("#boolRegionAsia").attr('checked', true);}
	if($("#EIDDetail22").val()=="1"){$("#boolRegionNAmerica").attr('checked', true);}
	if($("#EIDDetail23").val()=="1"){$("#boolRegionSAmerica").attr('checked', true);}
}

if($("#EIDDetail0").val() == "DPOnly" || ($("#EIDDetail0").val() == "TastingEntry" && $("#EIDDetail24").val() == "Y")){
	$("#product2check").attr('checked', true);
	if($("#EIDDetail25").val()=="individual"){
		$("#strTypeDP").val("An individual product");
	}else{
		$("#strTypeDP").val("A product range");
	}
	
	$("#strCategoryDP").val($("#EIDDetail26").val());
	$("#strBrandNameDP").val($("#EIDDetail27").val());
	$("#strPrimaryCategoryDP").val($("#EIDDetail28").val());
	$("#strOwnerDP").val($("#EIDDetail29").val());
	$("#strCountryofOriginDP").val($("#EIDDetail30").val());
	$("#dblRRPAmtDP").val($("#EIDDetail31").val());
	$("#dblRRPCurrencyDP").val($("#EIDDetail32").val());
	if($("#EIDDetail33").val()=="1"){$("#boolMarketDomesticDP").attr('checked', true);}
	if($("#EIDDetail34").val()=="1"){$("#boolMarketDutyfreeDP").attr('checked', true);}
	if($("#EIDDetail35").val()=="1"){$("#boolMarketOfftradeDP").attr('checked', true);}
	if($("#EIDDetail36").val()=="1"){$("#boolMarketOntradeDP").attr('checked', true);}
	if($("#EIDDetail37").val()=="1"){$("#boolRegionEuropeDP").attr('checked', true);}
	if($("#EIDDetail38").val()=="1"){$("#boolRegionAfricaDP").attr('checked', true);}
	if($("#EIDDetail39").val()=="1"){$("#boolRegionAustralasiaDP").attr('checked', true);}
	if($("#EIDDetail40").val()=="1"){$("#boolRegionAsiaDP").attr('checked', true);}
	if($("#EIDDetail41").val()=="1"){$("#boolRegionNAmericaDP").attr('checked', true);}
	if($("#EIDDetail42").val()=="1"){$("#boolRegionSAmericaDP").attr('checked', true);}
	$("#strRecentLaunchDP").val($("#EIDDetail43").val());
	$("#strDesignAgencyDP").val($("#EIDDetail44").val());
	$("#strSupportingStatementDP").val($("#EIDDetail45").val());
	$("#strContactNameDP").val($("#EIDDetail46").val());
	$("#strJobTitleDP").val($("#EIDDetail47").val());
}
$("#CurrentBrandSpan").html($('#strBrandName').val());

//Retail
if($("#EIDDetail60").val() == "Y"){
	$('input[name="product3check"]').attr('checked', true);
	$("#strRetailUKMultiple1").val($("#EIDDetail61").val());
	$("#strRetailUKMultiple2").val($("#EIDDetail62").val());
	$("#strRetailUKMultiple3").val($("#EIDDetail63").val());
	$("#strRetailUKIndep1").val($("#EIDDetail64").val());
	$("#strRetailUKIndep2").val($("#EIDDetail65").val());
	$("#strRetailUKIndep3").val($("#EIDDetail66").val());
	$("#strRetailIntMultiple1").val($("#EIDDetail67").val());
	$("#strRetailIntMultiple2").val($("#EIDDetail68").val());
	$("#strRetailIntMultiple3").val($("#EIDDetail69").val());
	$("#strRetailIntIndep1").val($("#EIDDetail70").val());
	$("#strRetailIntIndep2").val($("#EIDDetail71").val());
	$("#strRetailIntIndep3").val($("#EIDDetail72").val());
	$("#strRetailIntOnTrade1").val($("#EIDDetail73").val());
	$("#strRetailIntOnTrade2").val($("#EIDDetail74").val());
	$("#strRetailIntOnTrade3").val($("#EIDDetail75").val());
}

	//Extra nominations
	if($("#EIDDetail54").val()=="1"){$("#boolInnovPackDP").attr('checked', true);}
	if($("#EIDDetail55").val()=="1"){$("#boolInnovGraphDesDP").attr('checked', true);}
	if($("#EIDDetail56").val()=="1"){$("#boolBestOnTradeDP").attr('checked', true);}
	if($("#EIDDetail57").val()=="1"){$("#boolBestTravelRetailDP").attr('checked', true);}
	$("#strExtraSupportingNotesDP").val($("#EIDDetail58").val());
	$("#strExtraAgencyDP").val($("#EIDDetail59").val());
	$("#ProductID").val($("#EIDDetail999").val());
	product1change();
	$('#CartProductDetails').show();
}

ajaxBefore = function() {
		$('.loader').show();
		$('#CartProductDetails').hide();
		$('.Entry3StatusMessageDiv').hide();
		$('.StatusMessageDiv').hide();
		$('.ErrorMessageDiv').hide();
		$('.SuccessMessageDiv').hide();
		$('#SaveProductButtDiv,#SaveProductButtDiv_fake').hide();
		$('.validationinfo').hide();
		message = "";
		$("#productdetails3").find("input.retailinput").each(function(){
			if($(this).val() != "") {
				message += "x";
			}
		});
		if(message != "" && !$("#product3check").attr("checked")) {
			var answer = confirm("You have entered information into the Retailer Awards Nomination section but have not checked the box to confirm that you wish to make a nomination.\n\nTo continue without entering a nomination click the 'OK' button below. Otherwise click 'Cancel' and check the box before continuing.")
			if (!answer){
			$('#CartProductDetails').hide();
			$('#SaveProductButtDiv,#SaveProductButtDiv_fake').show();
				$(".loader").hide();
				return false;
			}
		}
}

ajaxSuccess = function() {
		$('#CartProductDetails').hide();
		$('#SaveProductButtDiv,#SaveProductButtDiv_fake').show();
		if ($('.SuccessMessageDiv').is(":visible")) {
			$("#entryformbchoice_1").attr("checked","checked");
			product1change();
			$('#ProductID').val(0);
		}
		if ($('.StatusMessageDiv').is(":visible")) {//EDIT REQUEST ONLY
			loadProduct();
		}
		$('.loader').hide();
}

