function UpdateQty(item)
{
	itemId = item.name;
	newQty = item.options[item.selectedIndex].text;

	document.location.href = 'main.php?section=viewcart&cartaction=additem&pid='+itemId+'&qty='+newQty;
}

function start() {
	submit_shipping_form.b_firstname.disabled = true;
	submit_shipping_form.b_lastname.disabled = true;
	submit_shipping_form.b_address.disabled = true;
	submit_shipping_form.b_city.disabled = true;
	submit_shipping_form.b_province.disabled = true;
	submit_shipping_form.b_postalcode.disabled = true;
	submit_shipping_form.b_country.disabled = true;			
}

//onload = start;

function chgtx() {
	submit_shipping_form.b_firstname.disabled = submit_shipping_form.billing_same.checked;
	submit_shipping_form.b_lastname.disabled = submit_shipping_form.billing_same.checked;
	submit_shipping_form.b_address.disabled = submit_shipping_form.billing_same.checked;
	submit_shipping_form.b_city.disabled = submit_shipping_form.billing_same.checked;
	submit_shipping_form.b_province.disabled = submit_shipping_form.billing_same.checked;
	submit_shipping_form.b_postalcode.disabled = submit_shipping_form.billing_same.checked;
	submit_shipping_form.b_country.disabled = submit_shipping_form.billing_same.checked;
}


function checkform(form)
{
    if (form.s_firstname.value == "") {
        alert( "Please enter your (shipping) first name" );
        form.s_firstname.focus();
        return false ;
    }
    if (form.s_lastname.value == "") {
        alert( "Please enter your (shipping) last name" );
        form.s_lastname.focus();
        return false ;
    }
    if (form.s_address.value == "") {
        alert( "Please enter your (shipping) address" );
        form.s_address.focus();
        return false ;
    }
    if (form.s_city.value == "") {
        alert( "Please enter your (shipping) city" );
        form.s_city.focus();
        return false ;
    }
    if (form.s_province.value == "") {
        alert( "Please enter your (shipping) province or state" );
        form.s_province.focus();
        return false ;
    }
    if (form.s_postalcode.value == "") {
        alert( "Please enter your (shipping) postal code or zip code" );
        form.s_postalcode.focus();
        return false ;
    }

if (submit_shipping_form.b_firstname.disabled != true){

    if (form.b_firstname.value == "") {
        alert( "Please enter your (billing) first name" );
        form.b_firstname.focus();
        return false ;
    }
    if (form.b_lastname.value == "") {
        alert( "Please enter your (billing) last name" );
        form.b_lastname.focus();
        return false ;
    }
    if (form.b_address.value == "") {
        alert( "Please enter your (billing) address" );
        form.b_address.focus();
        return false ;
    }
    if (form.b_city.value == "") {
        alert( "Please enter your (billing) city" );
        form.b_city.focus();
        return false ;
    }
    if (form.b_province.value == "") {
        alert( "Please enter your (billing) province or state" );
        form.b_province.focus();
        return false ;
    }
    if (form.b_postalcode.value == "") {
        alert( "Please enter your (billing) postal code or zip code" );
        form.b_postalcode.focus();
        return false ;
    }
}
    if (form.email.value == "") {
        alert( "Please enter your email address" );
        form.email.focus();
        return false ;
    }
    if (form.email.value != form.email_verify.value) {
        alert( "Please make sure your email matches the one you previously entered" );
        form.email_verify.focus();
        return false ;
    }
    if (form.phone_p1.value == "") {
        alert( "Please enter your phone number" );
        form.phone_p1.focus();
        return false ;
    }
    else{
         var myMod = form.phone_p1.value % 1;    
    
         if (myMod != 0) {
		 	alert( "Please enter a valid phone number" );
        	submit_shipping_form.phone_p1.focus();
            return false;
         }
    }
    if (form.phone_p2.value == "") {
        alert( "Please enter your phone number" );
        form.phone_p2.focus();
        return false ;
    }
    else{
         var myMod = form.phone_p2.value % 1;    
    
         if (myMod != 0) {
		 	alert( "Please enter a valid phone number" );
        	submit_shipping_form.phone_p2.focus();
            return false;
         }
    }
    if (form.phone_p3.value == "") {
        alert( "Please enter your phone number" );
        form.phone_p3.focus();
        return false ;
    }     
    else{
         var myMod = form.phone_p3.value % 1;    
    
         if (myMod != 0) {
		 	alert( "Please enter a valid phone number" );
        	submit_shipping_form.phone_p3.focus();
            return false;
         }
    }
	return true ;
}


function isInt(myNum) {
         // get the modulus: if it's 0, then it's an integer
         var myMod = myNum % 1;

         if (myMod != 0) {
		 	alert( "Please enter a valid phone number" );
        	submit_shipping_form.phone_p1.focus();
            return false;
         }
}

function checkcreditcard(submit_billing_form)
{
    if (submit_billing_form.creditcard_num.value == "") {
        alert( "Please enter a valid credit card number." );
        submit_billing_form.creditcard_num.focus();
        return false ;
    }
    else if ((submit_billing_form.payment_method.value == "AMEX")&&(submit_billing_form.creditcard_num.value.length != 15)){
		 	alert( "Please enter a valid AMERICAN EXPRESS card number" );
        	submit_billing_form.creditcard_num.focus();
            return false;
    }
    else if ((submit_billing_form.payment_method.value == "MC")&&(submit_billing_form.creditcard_num.value.length != 16)){
		 	alert( "Please enter a valid MASTERCARD number" );
        	submit_billing_form.creditcard_num.focus();
            return false;
    }
    else if ((submit_billing_form.payment_method.value == "VISA")&&(submit_billing_form.creditcard_num.value.length != 16)){
		 	alert( "Please enter a valid VISA card number" );
        	submit_billing_form.creditcard_num.focus();
            return false;
    }
    else{
         var myMod = submit_billing_form.creditcard_num.value % 1;    
    
         if (myMod != 0) {
		 	alert( "Please enter a valid credit card number" );
        	submit_billing_form.creditcard_num.focus();
            return false;
         }
    }
    if (submit_billing_form.creditcard_cvv2.value == "") {
        alert( "Please enter the CVV2 code of your credit card" );
        submit_billing_form.creditcard_cvv2.focus();
        return false;
    }
    else if ((submit_billing_form.payment_method.value == "AMEX")&&(submit_billing_form.creditcard_cvv2.value.length != 4)){
		 	alert( "Please enter a valid AMERICAN EXPRESS CVV2 number. This 4-digit code is on the front of the card." )
        	submit_billing_form.creditcard_cvv2.focus();
        	return false;
    }
    else if ((submit_billing_form.payment_method.value == "MC")&&(submit_billing_form.creditcard_cvv2.value.length != 3)){
		 	alert( "Please enter a valid MASTERCARD CVV2 number. This 3-digit code is located on the signature strip." )
        	submit_billing_form.creditcard_cvv2.focus();
        	return false;
    }
    else if ((submit_billing_form.payment_method.value == "VISA")&&(submit_billing_form.creditcard_cvv2.value.length != 3)){
		 	alert( "Please enter a valid VISA CVV2 number. This 3-digit code is located on the signature strip." )
        	submit_billing_form.creditcard_cvv2.focus();
        	return false;
    }
    else{
         var myMod = submit_billing_form.creditcard_cvv2.value % 1;    
    
         if (myMod != 0) {
		 	alert( "Please enter a valid credit card CVV2 number" );
        	submit_billing_form.creditcard_cvv2.focus();
            return false;
         }
    }
	return true;
}

function newWindow(newin,x,y) {
	flyout=window.open(newin,"flyout","resizable=yes,scrollbars=yes,width="+x+",height="+y+",top=20,left=20")
}

function newUploadWindow2(newin,x,y) {

	if (products_edit_form.item_name.value == ""){
		alert("Please enter an item name before adding photos");
		products_edit_form.item_name.focus();
	}
	else if (products_edit_form.item_num.value == ""){
		alert("Please enter an item number before adding photos");
		products_edit_form.item_num.focus();
	}

	else{
		flyout=window.open(newin+"?item_num="+products_edit_form.item_num.value+"&item_name="+products_edit_form.item_name.value,"flyout","resizable=yes,scrollbars=yes,width="+x+",height="+y+",top=20,left=20")
	}
}
function newUploadWindow3(newin,x,y) {

	if (products_edit_form.item_name.value == ""){
		alert("Please enter an item name before adding photos");
		products_edit_form.item_name.focus();
	}
	else if (products_edit_form.item_num.value == ""){
		alert("Please enter an item number before adding photos");
		products_edit_form.item_num.focus();
	}

	else{
		flyout=window.open(newin+"&item_num="+products_edit_form.item_num.value+"&item_name="+products_edit_form.item_name.value,"flyout","resizable=yes,scrollbars=yes,width="+x+",height="+y+",top=20,left=20")
	}
}

function checkRegForm(form1)
{
    if (form1.firstname_submit.value == "") {
        alert( "Please enter your first name" );
        form1.firstname_submit.focus();
        return false ;
    }
    if (form1.lastname_submit.value == "") {
        alert( "Please enter your last name" );
        form1.lastname_submit.focus();
        return false ;
    }
    if (form1.country_submit.value == "") {
        alert( "Please enter your country" );
        form1.country_submit.focus();
        return false ;
    }
    if (form1.email_submit.value == "") {
        alert( "Please enter your email address" );
        form1.email_submit.focus();
        return false ;
    }
    if (form1.gender_submit.value == "") {
        alert( "Please select your gender" );
        form1.gender_submit.focus();
        return false ;
    }
    if (form1.relationshipstatus_submit.value == "") {
        alert( "Please select your relationship status" );
        form1.relationshipstatus_submit.focus();
        return false ;
    }
    if (form1.password_submit.value == "") {
        alert( "Please enter a password" );
        form1.password_submit.focus();
        return false ;
    }
    if (form1.passwordconfirm_submit.value != form1.password_submit.value) {
        alert( "Please make sure your password matches the one you previously entered" );
        form1.passwordconfirm_submit.focus();
        return false ;
    }    
    
	return true ;
}

function checkSubmitBlogForm(form2)
{
    if (form2.channelid_submit.value == "") {
        alert( "Please select a channel" );
        form2.channelid_submit.focus();
        return false ;
    }
    if (form2.subject_submit.value == "") {
        alert( "Please enter a blog title" );
        form2.subject_submit.focus();
        return false ;
    }
    if (form2.summary_submit.value == "") {
        alert( "Please enter a blog summary" );
        form2.summary_submit.focus();
        return false ;
    }
/*    if (form2.content_submit.value == "") {
        alert( "Please enter some content for this blog" );
        form2.content_submit.focus();
        return false ;
    } */   
	return true ;
}
