var Phone1_initial = '';
var Phone2_initial = '';

var BillingPhone1_initial = '';
var BillingPhone2_initial = '';
var BillingPhone3_initial = '';
var ShippingPhone1_initial = '';
var ShippingPhone2_initial = '';
var ShippingPhone3_initial = '';

function dontMoveYet(field){
	if(field.value != ''){
		var SetInitial = field.name + "_initial = " + field.value;
		eval(SetInitial)
	}
}

function moveOnMax(field,nextFieldID){	
	var noChange = 0;
	var InitialValue = eval(field.name + "_initial");
	if(InitialValue == ''){
		InitialValue = 0;
	}
	
	if(field.value != ''){
		var Initial = 'noChange = (' + field.value + " == " + InitialValue + ")";
		eval(Initial);
	}
	
	var ResetInitial = field.name + "_initial = ''";
	if(!noChange){
		eval(ResetInitial);
	}
	
	if(field.value.length >= field.maxLength && !noChange){
		document.getElementById(nextFieldID).focus();
	}
}

function showImageCatering(image, alt){
	document.getElementById('ItemImage').innerHTML = '<img src="/media/' + image + '" alt="' + alt + '" />';
}

function showImage(image, alt){
	document.getElementById('ItemImage').innerHTML = '<img src="' + image + '" alt="' + alt + '" />';
}

function openHelp( dialog ){

	switch ( dialog ){
		case 'CCSecCode':
			window.open('http://www.haciendafiesta.com/cvv2.htm', 'CVV2', 'width=820,height=350,toolbar=no,menubar=no,directories=no');
		break;
	}
}

function disableSubmit( button1_name, button2_name ){
	document.getElementById(button1_name).disabled = true;
	document.getElementById(button2_name).disabled = true;
}
	
function copyBilling(){
	SameAsBilling = document.getElementById('ShippingSameAsBilling').checked;
	
	if (SameAsBilling){
		document.getElementById('ShippingName').value = document.getElementById('BillingName').value;
		document.getElementById('ShippingAddress1').value = document.getElementById('BillingAddress1').value;
		document.getElementById('ShippingAddress2').value = document.getElementById('BillingAddress2').value;
		document.getElementById('ShippingApt').value = document.getElementById('BillingApt').value;
		document.getElementById('ShippingCity').value = document.getElementById('BillingCity').value;
		document.getElementById('ShippingState').value = document.getElementById('BillingState').value;
		document.getElementById('ShippingZip5').value = document.getElementById('BillingZip5').value;
		document.getElementById('ShippingZip4').value = document.getElementById('BillingZip4').value;
		document.getElementById('ShippingPhone1').value = document.getElementById('BillingPhone1').value;
		document.getElementById('ShippingPhone2').value = document.getElementById('BillingPhone2').value;
		document.getElementById('ShippingPhone3').value = document.getElementById('BillingPhone3').value;
	}
	
	document.getElementById('ShippingName').disabled = SameAsBilling;
	document.getElementById('ShippingAddress1').disabled = SameAsBilling;
	document.getElementById('ShippingAddress2').disabled = SameAsBilling;
	document.getElementById('ShippingApt').disabled = SameAsBilling;
	document.getElementById('ShippingCity').disabled = SameAsBilling;
	document.getElementById('ShippingState').disabled = SameAsBilling;
	document.getElementById('ShippingZip5').disabled = SameAsBilling;
	document.getElementById('ShippingZip4').disabled = SameAsBilling;
	document.getElementById('ShippingPhone1').disabled = SameAsBilling;
	document.getElementById('ShippingPhone2').disabled = SameAsBilling;
	document.getElementById('ShippingPhone3').disabled = SameAsBilling;

}
