// JavaScript Document

function validateEmail(email) {
/*	new version by Laurence 2004 Nov 26
	revised 2005 Nov 04 by Laurence: allow hyphens before @ symbol; rename 'verifyEmail' to 'validateEmail'

	RegExp is a Javascript1.2 feature; tested successfully in WinIE 5.0+, MacIE 5.1, Safari 1.0, WinNN 4.7, WinNN 6.2, WinMoz 1.7
	The pattern matches: 
	- at least one word character ( a-zA-Z0-9_ )
	- followed by any number more including periods and hyphens
	- then a single @
	- then at least one alphanumeric character plus any number more including hyphens and periods
	- plus an ending of an alphanumeric char, a single period, and at least 2 more letters. 
	There can be nothing before or after the pattern; all whitespace, punctuation, etc. not explicitly allowed is forbidden.
*/
	var myRegExp = /^[\w][\w\.\-]*@[a-zA-Z0-9]+[\w\.\-]*[a-zA-Z0-9]\.[a-zA-Z]{2,}$/;
	var sPos = email.search(myRegExp);
	if (sPos >= 0) {
		return true;
	} else {
		return false;
	}
}

function isPostCode(entry){ // CANADIAN CODES ONLY
	strlen = entry.length; 
	if (strlen != 7) {return false;}
	entry=entry.toUpperCase();        // in case of lowercase characters
	// Check for legal characters in string - note index starts at zero
	if ('ABCEHJKLMNPRSTVXY'.indexOf(entry.charAt(0)) < 0) {return false;}
	if ('0123456789'.indexOf(entry.charAt(1)) < 0) {return false;}
	if ('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(2)) < 0) {return false;}
	if ('0123456789'.indexOf(entry.charAt(4)) < 0) {return false;}
	if ('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(5)) < 0) {return false;}
	if ('0123456789'.indexOf(entry.charAt(6)) < 0) {return false;}
	
	return true; 
}


function validateUser() {
	var theForm = document.frmUser;
	var emptyFields = "";

	if (theForm.firstName.value == ""){
		emptyFields += "First Name cannot be blank." + "\n" ;
	} else if (theForm.firstName.value.length > 50){
		emptyFields += "First Name is " + (theForm.firstName.value.length - 50).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.lastName.value == ""){
		emptyFields += "Last Name cannot be blank." + "\n" ;
	} else if (theForm.lastName.value.length > 50){
		emptyFields += "Last Name is " + (theForm.lastName.value.length - 50).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.email.value == ""){
		emptyFields += "E-mail address cannot be blank." + "\n" ;
	} else if (theForm.email.value.length > 150){
		emptyFields += "E-mail is " + (theForm.email.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	} else if (!validateEmail(theForm.email.value)) {
		emptyFields += "The email address must be correctly formatted." + "\n" ;
	}
	
	if (theForm.password.value == ""){
		emptyFields += "Password cannot be blank." + "\n" ;
	} else if (theForm.password.value.length > 12){
		emptyFields += "Password is " + (theForm.password.value.length - 12).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		theForm.submit();
		return true;
	}
}

function validateSubCategory() {
	var theForm = document.frmSubCategory;
	var emptyFields = "";

	if (theForm.subCategoryNameEn.value == ""){
		emptyFields += "English Sub category name cannot be blank." + "\n" ;
	} else if (theForm.subCategoryNameEn.value.length > 150){
		emptyFields += "English Sub category name is " + (theForm.subCategoryNameEn.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	/*
	if (theForm.subCategoryNameFr.value == ""){
		emptyFields += "French Sub category name cannot be blank." + "\n" ;
	} else if (theForm.subCategoryNameFr.value.length > 150){
		emptyFields += "French Sub category name is " + (theForm.subCategoryNameFr.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.subCategoryNameEs.value == ""){
		emptyFields += "Spanish Sub category name cannot be blank." + "\n" ;
	} else if (theForm.subCategoryNameEs.value.length > 150){
		emptyFields += "Spanish Sub category name is " + (theForm.subCategoryNameEs.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	} */
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		theForm.submit();
		return true;
	}
}

function validateProduct(thisForm) {
	var theForm = frmProduct;
	var emptyFields = "";

	if (theForm.productName_en.value == ""){
		emptyFields += "English product name cannot be blank." + "\n" ;
	} else if (theForm.productName_en.value.length > 150){
		emptyFields += "English product name is " + (theForm.productName_en.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	/*if (theForm.productName_fr.value == ""){
		emptyFields += "French product name cannot be blank." + "\n" ;
	} else if (theForm.productName_fr.value.length > 150){
		emptyFields += "French product name is " + (theForm.productName_fr.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.productName_es.value == ""){
		emptyFields += "Spanish product name cannot be blank." + "\n" ;
	} else if (theForm.productName_es.value.length > 150){
		emptyFields += "Spanish product name is " + (theForm.productName_es.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}*/
	
	if (theForm.ShortDescription_en.value == ""){
		emptyFields += "English short description cannot be blank." + "\n" ;
	} else if (theForm.ShortDescription_en.value.length > 500){
		emptyFields += "English short description is " + (theForm.ShortDescription_en.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	/*
	if (theForm.ShortDescription_fr.value == ""){
		emptyFields += "French short description cannot be blank." + "\n" ;
	} else if (theForm.ShortDescription_fr.value.length > 500){
		emptyFields += "French short description is " + (theForm.ShortDescription_fr.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.ShortDescription_es.value == ""){
		emptyFields += "Spanish short description cannot be blank." + "\n" ;
	} else if (theForm.ShortDescription_es.value.length > 500){
		emptyFields += "Spanish short description is " + (theForm.ShortDescription_es.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}*/
	
	if (theForm.longDescription_en.value == ""){
		emptyFields += "English long description cannot be blank." + "\n" ;
	} else if (theForm.longDescription_en.value.length > 1000){
		emptyFields += "English long description is " + (theForm.longDescription_en.value.length - 1000).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	/*
	if (theForm.longDescription_fr.value == ""){
		emptyFields += "French long description cannot be blank." + "\n" ;
	} else if (theForm.longDescription_fr.value.length > 1000){
		emptyFields += "French long description is " + (theForm.longDescription_fr.value.length - 1000).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.longDescription_es.value == ""){
		emptyFields += "Spanish long description cannot be blank." + "\n" ;
	} else if (theForm.longDescription_es.value.length > 1000){
		emptyFields += "Spanish long description is " + (theForm.longDescription_es.value.length - 1000).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}*/
	
	if (theForm.imageFile.value == ""){
		emptyFields += "You must upload a product image." + "\n" ;
	}
	
	
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

function validateEditProduct(thisForm) {
	var theForm = frmProduct;
	var emptyFields = "";

	if (theForm.productName_en.value == ""){
		emptyFields += "English product name cannot be blank." + "\n" ;
	} else if (theForm.productName_en.value.length > 150){
		emptyFields += "English product name is " + (theForm.productName_en.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	/*
	if (theForm.productName_fr.value == ""){
		emptyFields += "French product name cannot be blank." + "\n" ;
	} else if (theForm.productName_fr.value.length > 150){
		emptyFields += "French product name is " + (theForm.productName_fr.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.productName_es.value == ""){
		emptyFields += "Spanish product name cannot be blank." + "\n" ;
	} else if (theForm.productName_es.value.length > 150){
		emptyFields += "Spanish product name is " + (theForm.productName_es.value.length - 150).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}*/
	
	if (theForm.ShortDescription_en.value == ""){
		emptyFields += "English short description cannot be blank." + "\n" ;
	} else if (theForm.ShortDescription_en.value.length > 500){
		emptyFields += "English short description is " + (theForm.ShortDescription_en.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	/*
	if (theForm.ShortDescription_fr.value == ""){
		emptyFields += "French short description cannot be blank." + "\n" ;
	} else if (theForm.ShortDescription_fr.value.length > 500){
		emptyFields += "French short description is " + (theForm.ShortDescription_fr.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.ShortDescription_es.value == ""){
		emptyFields += "Spanish short description cannot be blank." + "\n" ;
	} else if (theForm.ShortDescription_es.value.length > 500){
		emptyFields += "Spanish short description is " + (theForm.ShortDescription_es.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}*/
	
	if (theForm.longDescription_en.value == ""){
		emptyFields += "English long description cannot be blank." + "\n" ;
	} else if (theForm.longDescription_en.value.length > 1000){
		emptyFields += "English long description is " + (theForm.longDescription_en.value.length - 1000).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	/*
	if (theForm.longDescription_fr.value == ""){
		emptyFields += "French long description cannot be blank." + "\n" ;
	} else if (theForm.longDescription_fr.value.length > 1000){
		emptyFields += "French long description is " + (theForm.longDescription_fr.value.length - 1000).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.longDescription_es.value == ""){
		emptyFields += "Spanish long description cannot be blank." + "\n" ;
	} else if (theForm.longDescription_es.value.length > 1000){
		emptyFields += "Spanish long description is " + (theForm.longDescription_es.value.length - 1000).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}*/
		
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

function validateProductSize(thisForm) {
	var theForm = frmProductSize;
	var emptyFields = "";

	if (theForm.sizeName.value == ""){
		emptyFields += "The size cannot be blank." + "\n" ;
	} 
	
	if (theForm.SizeDescription.value != "") {
		if (theForm.SizeDescription.value.length > 500){
		emptyFields += "The size description is " + (theForm.SizeDescription.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	}
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

function validateEditProductSize(thisForm) {
	var theForm = eval(thisForm);
	var emptyFields = "";
	
	if (theForm.SizeName.value == ""){
		emptyFields += "The size cannot be blank." + "\n" ;
	}
	
	if (theForm.SizeDescription.value != "") {
		if (theForm.SizeDescription.value.length > 500){
		emptyFields += "The size description is " + (theForm.SizeDescription.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	}
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

function validateProductFile(thisForm) {
	var theForm = frmProductFile;
	var emptyFields = "";

	if (theForm.filename.value == ""){
		emptyFields += "You must select a file to upload." + "\n" ;
	} 
	
	if (theForm.fileLabel.value == ""){
		emptyFields += "The file label cannot be blank." + "\n" ;
	} 
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

function validateSpecial(thisForm) {
	var theForm = frmSpecial;
	var emptyFields = "";

	if (theForm.title_en.value == ""){
		emptyFields += "English title cannot be blank." + "\n" ;
	} else if (theForm.title_en.value.length > 50){
		emptyFields += "English title is " + (theForm.title_en.value.length - 50).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.ShortDescription_en.value == ""){
		emptyFields += "English short description cannot be blank." + "\n" ;
	} else if (theForm.ShortDescription_en.value.length > 500){
		emptyFields += "English short description is " + (theForm.ShortDescription_en.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.specialNumber.value == ""){
		emptyFields += "Special SKU cannot be blank." + "\n" ;
	}
	
	if (theForm.price.value == ""){
		emptyFields += "Price cannot be blank." + "\n" ;
	}

	if (theForm.imageFile.value == ""){
		emptyFields += "You must upload a product image." + "\n" ;
	}
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

function validateEditSpecial(thisForm) {
	var theForm = frmSpecial;
	var emptyFields = "";

	if (theForm.title_en.value == ""){
		emptyFields += "English title cannot be blank." + "\n" ;
	} else if (theForm.title_en.value.length > 50){
		emptyFields += "English title is " + (theForm.title_en.value.length - 50).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.ShortDescription_en.value == ""){
		emptyFields += "English short description cannot be blank." + "\n" ;
	} else if (theForm.ShortDescription_en.value.length > 500){
		emptyFields += "English short description is " + (theForm.ShortDescription_en.value.length - 500).toString() + " characters too long. Please edit text to fit." + "\n" ;
	}
	
	if (theForm.specialNumber.value == ""){
		emptyFields += "Special SKU cannot be blank." + "\n" ;
	}
	
	if (theForm.price.value == ""){
		emptyFields += "Price cannot be blank." + "\n" ;
	}

	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}


function validateLogin(thisForm) {
	var theForm = document.getElementById('frmLogin');
	var emptyFields = "";
	
	if (theForm.username.value == ""){
		emptyFields += "Username cannot be blank." + "\n" ;
	}
	
	if (theForm.password.value == ""){
		emptyFields += "Password cannot be blank." + "\n" ;
	}
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

function validatePublicLogin(thisForm) {
	var theForm = document.getElementById('frmLogin');
	var emptyFields = "";
	
	if (theForm.email.value == ""){
		emptyFields += "Email cannot be blank." + "\n" ;
	} else if (!validateEmail(theForm.email.value)) {
		emptyFields += "The email address must be correctly formatted." + "\n" ;
	}
	
	if (theForm.password.value == ""){
		emptyFields += "Password cannot be blank." + "\n" ;
	}
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}


function validateRegister(thisForm) {
	var theForm = document.getElementById('frmRegister');
	var emptyFields = "";
	
	
	if (theForm.firstname.value == ""){
		emptyFields += "First Name cannot be blank." + "\n" ;
	}
	
	if (theForm.lastname.value == ""){
		emptyFields += "Last Name cannot be blank." + "\n" ;
	}
	
	if (theForm.email.value == ""){
		emptyFields += "Email cannot be blank." + "\n" ;
	} else if (!validateEmail(theForm.email.value)) {
		emptyFields += "The email address must be correctly formatted." + "\n" ;
	}
	
	if (theForm.password.value == ""){
		emptyFields += "Password cannot be blank." + "\n" ;
	} 
	
	if (theForm.organization.value == ""){
		emptyFields += "Organization cannot be blank." + "\n" ;
	}
	
	if (theForm.telephone.value == ""){
		emptyFields += "Telephone cannot be blank." + "\n" ;
	}
	
	if (theForm.address1.value == ""){
		emptyFields += "Mailing address cannot be blank." + "\n" ;
	}
	
	if (theForm.city.value == ""){
		emptyFields += "Mailing address City cannot be blank." + "\n" ;
	}
	
	if (theForm.PoCode.value == ""){
		emptyFields += "Mailing address Postal/Zip Code cannot be blank." + "\n" ;
	}
	
	if (theForm.address1_shipping.value == ""){
		emptyFields += "Shipping address cannot be blank." + "\n" ;
	}
	
	if (theForm.city_shipping.value == ""){
		emptyFields += "Shipping address City cannot be blank." + "\n" ;
	}
	
	if (theForm.PoCode_shipping.value == ""){
		emptyFields += "Shipping address Postal/Zip Code cannot be blank." + "\n" ;
	}
	
	

	if (theForm.FkCountryId.value == 1 && theForm.FkStateProvinceIdCountry1.value == 0 ){
			emptyFields += "Please select a State or Province." + "\n" ;
	}else if (theForm.FkCountryId.value == 2 && theForm.FkStateProvinceIdCountry2.value == 0 ){
			emptyFields += "Please select a State or Province." + "\n" ;
	}else if (theForm.FkCountryId.value == 3 && theForm.FkStateProvinceIdCountry3.value == 0 ){
			emptyFields += "Please select a State or Province." + "\n" ;
	}else if (theForm.FkCountryId.value == 4 && theForm.FkStateProvinceIdCountry4.value == 0 ){
			emptyFields += "Please select a State or Province." + "\n" ;
	}
	
	
	if (theForm.FkCountryId_shipping.value == 1 && theForm.FkStateProvinceIdCountryShip1.value == 0 ){
			emptyFields += "Please select a State or Province for shipping." + "\n" ;
	}else if (theForm.FkCountryId_shipping.value == 2 && theForm.FkStateProvinceIdCountryShip2.value == 0 ){
			emptyFields += "Please select a State or Province for shipping." + "\n" ;
	}else if (theForm.FkCountryId_shipping.value == 3 && theForm.FkStateProvinceIdCountryShip3.value == 0 ){
			emptyFields += "Please select a State or Province for shipping." + "\n" ;
	}else if (theForm.FkCountryId_shipping.value == 4 && theForm.FkStateProvinceIdCountryShip4.value == 0 ){
			emptyFields += "Please select a State or Province for shipping." + "\n" ;
	}	
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

function validateProfile(thisForm) {
	var theForm = document.getElementById('frmProfile');
	var emptyFields = "";

	if (theForm.firstname.value == ""){
		emptyFields += "First Name cannot be blank." + "\n" ;
	}
	
	
	if (theForm.lastname.value == ""){
		emptyFields += "Last Name cannot be blank." + "\n" ;
	}
	
	if (theForm.email.value == ""){
		emptyFields += "Email cannot be blank." + "\n" ;
	} else if (!validateEmail(theForm.email.value)) {
		emptyFields += "The email address must be correctly formatted." + "\n" ;
	}
	
	if (theForm.password.value == ""){
		emptyFields += "Password cannot be blank." + "\n" ;
	} 
	
	if (theForm.organization.value == ""){
		emptyFields += "Organization cannot be blank." + "\n" ;
	}
	
	if (theForm.telephone.value == ""){
		emptyFields += "Telephone cannot be blank." + "\n" ;
	}
	
	if (theForm.address1.value == ""){
		emptyFields += "Mailing address cannot be blank." + "\n" ;
	}
	
	if (theForm.city.value == ""){
		emptyFields += "Mailing address City cannot be blank." + "\n" ;
	}
	
	if (theForm.PoCode.value == ""){
		emptyFields += "Mailing address Postal/Zip Code cannot be blank." + "\n" ;
	}
	
	if (theForm.address1_shipping.value == ""){
		emptyFields += "Shipping address cannot be blank." + "\n" ;
	}
	
	if (theForm.city_shipping.value == ""){
		emptyFields += "Shipping address City cannot be blank." + "\n" ;
	}
	
	if (theForm.PoCode_shipping.value == ""){
		emptyFields += "Shipping address Postal/Zip Code cannot be blank." + "\n" ;
	}
	
	if (theForm.FkCountryId.value == 1 && theForm.FkStateProvinceIdCountry1.value == 0 ){
			emptyFields += "Please select a State or Province." + "\n" ;
	}else if (theForm.FkCountryId.value == 2 && theForm.FkStateProvinceIdCountry2.value == 0 ){
			emptyFields += "Please select a State or Province." + "\n" ;
	}else if (theForm.FkCountryId.value == 3 && theForm.FkStateProvinceIdCountry3.value == 0 ){
			emptyFields += "Please select a State or Province." + "\n" ;
	}else if (theForm.FkCountryId.value == 4 && theForm.FkStateProvinceIdCountry4.value == 0 ){
			emptyFields += "Please select a State or Province." + "\n" ;
	}
	
	
	if (theForm.FkCountryId_shipping.value == 1 && theForm.FkStateProvinceIdCountryShip1.value == 0 ){
			emptyFields += "Please select a State or Province for shipping." + "\n" ;
	}else if (theForm.FkCountryId_shipping.value == 2 && theForm.FkStateProvinceIdCountryShip2.value == 0 ){
			emptyFields += "Please select a State or Province for shipping." + "\n" ;
	}else if (theForm.FkCountryId_shipping.value == 3 && theForm.FkStateProvinceIdCountryShip3.value == 0 ){
			emptyFields += "Please select a State or Province for shipping." + "\n" ;
	}else if (theForm.FkCountryId_shipping.value == 4 && theForm.FkStateProvinceIdCountryShip4.value == 0 ){
			emptyFields += "Please select a State or Province for shipping." + "\n" ;
	}	
	

	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
	
}


function validatePasswordReminder(thisForm) {
	var theForm = document.getElementById('frmPasswordReminder');
	var emptyFields = "";
	
	if (theForm.email.value == ""){
		emptyFields += "Email cannot be blank." + "\n" ;
	} else if (!validateEmail(theForm.email.value)) {
		emptyFields += "The email address must be correctly formatted." + "\n" ;
	}
	
	if (emptyFields.length >= 1) {
		alert("Please ensure that the following fields are completed correctly:" + "\n" + emptyFields);
		return false;
	} else {
		return true;
	}
}

	function checkCountry(thisForm){
/*	
		var theForm = "";
		theForm = thisForm;
		if (theForm.FkCountryId.value == 3){
			theForm.FkStateProvinceId.disabled = true;
			theForm.FkStateProvinceId.value = 75;
		}else{
			theForm.FkStateProvinceId.disabled = false;
		}
		
		if (theForm.FkCountryId_shipping.value == 3){
			theForm.FkStateProvinceId_shipping.disabled = true;
			theForm.FkStateProvinceId_shipping.value = 75;
		}else{
			theForm.FkStateProvinceId_shipping.disabled = false;
		}	*/
	}	

	
	function countrySwitcher( countryFormName, provinceFormName){
		$(document).ready(function() {	
			$("#"+countryFormName).change(function () {
				
				var thisCountry = $(this).attr("value");
				
				$("#"+countryFormName+" > option").each(function(){
	
					if ( thisCountry == $(this).attr("value") ){
						$("#"+provinceFormName + $(this).attr("value")).css("display", "block");
					}else{
						$("#"+provinceFormName + $(this).attr("value")).css("display", "none");
					}
				});
										
	
				
			});
		});
	}
	
	function copyAddress(thisForm) {
		var theForm = "";
		
		theForm = thisForm;
		/*if(thisForm == 'frmRegister'){
			theForm = document.getElementById('frmRegister');	
		} elseif (thisForm == 'frmProfile'){
			theForm = document.getElementById('frmProfile');	
		}*/
	
		theForm.address1_shipping.value = theForm.address1.value;
		theForm.address2_shipping.value = theForm.address2.value;
		theForm.city_shipping.value = theForm.city.value;
		theForm.PoCode_shipping.value = theForm.PoCode.value;
		theForm.FkCountryId_shipping.selectedIndex = theForm.FkCountryId.selectedIndex;
		$(document).ready(function() {	
			$("#FkCountryId_shipping > option").each(function(){
				if ( $(this).attr("value") == $("#FkCountryId").attr("value") ){
					$("#FkStateProvinceIdCountryShip" + $(this).attr("value")).css("display", "block");
					$("#FkStateProvinceIdCountryShip" + $(this).attr("value")).attr("value", $("#FkStateProvinceIdCountry" + $(this).attr("value") ).attr("value") );
				
					
				}else{
					$("#FkStateProvinceIdCountryShip"+ $(this).attr("value")).css("display", "none");
				}
			});
		});
		
	}
		
	countrySwitcher("FkCountryId", "FkStateProvinceIdCountry");
	countrySwitcher("FkCountryId_shipping", "FkStateProvinceIdCountryShip");
		
		 
		
	$(document).ready(function() {	
	
		$("#FkStateProvinceIdCountry" + $("#FkCountryId").attr("value")).css("display", "block");
		$("#FkStateProvinceIdCountryShip" + $("#FkCountryId_shipping").attr("value")).css("display", "block");
	
	});	
	

	


