function addtocart(packageId){
	var frmDetail = document.getElementById('frmDetail');
	var objPackage = document.getElementById("package");
	objPackage.value = packageId;
	frmDetail.submit();
}
function cartDelete(packageId){
	var frmCheckout = document.getElementById('frmCheckout');
	var deleteItem = document.getElementById("deleteItem");
	var action = frmCheckout.elements['action'];
	deleteItem.value = packageId;
	action.value ="delete";
	frmCheckout.submit();
}
function updateCart(){
	var frmCheckout = document.getElementById('frmCheckout');
	var action = frmCheckout.elements['action'];
	action.value ="update";
	frmCheckout.submit();
}
function setAction(status){
	var frmCheckout = document.getElementById('frmCheckout');
	var action = frmCheckout.elements['action'];
	action.value = status;
	frmCheckout.submit();
}
function submitOrder(button){
	var frmCheckout = document.getElementById('frmCheckout');
	var action = frmCheckout.elements['action'];
	var agree = frmCheckout.elements['agree']; //document.getElementById("agree");
	if(agree.checked){
		action.value = 'submitOrder';
		button.disabled  = true;
		frmCheckout.submit();
	}else{
		alert('Order cannot be submitted until you have agreed to the terms of use.');
	}
	
}
function changePaymentMethod(){
	var frmCheckout = document.getElementById('frmCheckout');
	var action = frmCheckout.elements['action'];
	action.value = "CHAGE_PAYMENT_METHOD";
	frmCheckout.submit();
}
function checkValueLogin()
{
	var frmReturnCustomer = document.getElementById('frmReturnCustomer');
	var username = frmReturnCustomer.elements['username'];
	var password = frmReturnCustomer.elements['password'];

	if(username.value == "")
	{
		alert('Please enter your username.');
		return false;
	}
	if(password.value == "")
	{
		alert('Please enter your password.');
		return false;		
	}
	else
	{
		frmReturnCustomer.submit();
	}
}
function checkActionShipping(){
	var frmProcessCheckout = document.getElementById('frmProcessCheckout');
	var state = frmProcessCheckout.elements['state'];
	state.value = "shipping";
	frmProcessCheckout.submit();
}
function checkActionSave(save){
	var frmShippingInfo = document.getElementById('frmShippingInfo');
	var action = frmShippingInfo.elements['action'];
	action.value = save;
	frmShippingInfo.submit();
}
function usingShippingCheckBox(check)
{
	if(check.checked==true)
	{
		document.frmShippingInfo.BillingAddress1.disabled=true;	
		document.frmShippingInfo.BillingAddress2.disabled=true;	
		document.frmShippingInfo.BillingAddress3.disabled=true;	
		document.frmShippingInfo.BillingCity.disabled=true;	
		document.frmShippingInfo.BillingCountry.disabled=true;	
		document.frmShippingInfo.BillingState.disabled=true;
		document.frmShippingInfo.BillingZipCode.disabled=true;	
		document.frmShippingInfo.AreaBillingPhone.disabled=true;
		document.frmShippingInfo.BillingPhone.disabled=true;			
	}
	else
	{
		document.frmShippingInfo.BillingAddress1.disabled=false;	
		document.frmShippingInfo.BillingAddress2.disabled=false;	
		document.frmShippingInfo.BillingAddress3.disabled=false;	
		document.frmShippingInfo.BillingCity.disabled=false;	
		document.frmShippingInfo.BillingCountry.disabled=false;	
		document.frmShippingInfo.BillingState.disabled=false;
		document.frmShippingInfo.BillingZipCode.disabled=false;	
		document.frmShippingInfo.AreaBillingPhone.disabled=false;
		document.frmShippingInfo.BillingPhone.disabled=false;			
	}
}
function thankyou_submit(button){
	button.disabled  = true;
	var frmCheckout = document.getElementById('frmCheckout');
	var action = frmCheckout.elements['action'];
	action.value= 'submit';
	frmCheckout.submit();
}
jQuery(document).ready(function() {

jQuery('#pw_emailLogo_button').click(function() {
 formfield = jQuery('#pw_emailLogo').attr('name');
 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
 return false;
});

window.send_to_editor = function(html) {
 imgurl = jQuery('img',html).attr('src');
 jQuery('#pw_emailLogo').val(imgurl);
 tb_remove();
}

jQuery('a.show-alternatives').click(function(event) {
	event.preventDefault();
	if(this.text === 'Show Alternatives') {
		jQuery('#' + event.target.id +'-alternatives').slideDown();
		jQuery(this).text('Hide Alternatives');
	} else {
		jQuery('#' + event.target.id +'-alternatives').slideUp();
		jQuery(this).text('Show Alternatives');
	}
});

});

