function validateContact(frm){
	if (frm.requests.selectedIndex == 0)
	{
		alert("Please select Subject");
		frm.requests.focus();
		return (false);
	}

	if (frm.name.value.length == 0)
	{
		alert("Please enter Name");
		frm.name.focus();
		return (false);
	}

	if (frm.email.value.length == 0)
	{
		alert("Please enter E-mail");
		frm.email.focus();
		return (false);
	}
	
	if (!isEmail(frm.email.value))
	{
		alert("Please enter your real email address.");
		frm.email.focus();
		return (false);
	}

	if (frm.message.value.length == 0)
	{
		alert("Please enter Message");
		frm.message.focus();
		return (false);
	}
}


function validateSignUp(frm){

	// JavaScript Document

	if (frm.cust_username.value.length < 6)

	{

		alert("Your Login ID must contain at least 6 characters");

		frm.cust_username.focus();

		return (false);

	}



	if (frm.cust_passwd.value.length < 6)

	{

		alert("Your  password must contain at least 6 characters");

		frm.cust_passwd.focus();

		return (false);

	}

	

	if (frm.cust_confirm_passwd.value.length == 0)

	{

		alert("Please confirm your password contains at least 6 characters");

		frm.cust_confirm_passwd.focus();

		return (false);

	}

	

	if (frm.cust_passwd.value != frm.cust_confirm_passwd.value)

	{

		alert("Your confirmed password doesn't match the password that you have entered");

		frm.cust_passwd.value = "";

		frm.cust_confirm_passwd.value = "";

		frm.cust_passwd.focus();

		return (false);

	}



	if (frm.cust_company_name.value.length == 0)

	{

		alert("Please enter Company Name");

		frm.cust_company_name.focus();

		return (false);

	}



	if (frm.cust_physical_add1.value.length == 0)

	{

		alert("Please enter Physical Address 1");

		frm.cust_physical_add1.focus();

		return (false);

	}





	if (frm.cust_physical_city.value.length == 0)

	{

		alert("Please enter City");

		frm.cust_physical_city.focus();

		return (false);

	}



	if (frm.cust_physical_state.value.length == 0)

	{

		alert("Please enter State/Province");

		frm.cust_physical_state.focus();

		return (false);

	}



	if (frm.cust_physical_zipcode.value.length == 0)

	{

		alert("Please enter Zip Code/Postal Code");

		frm.cust_physical_zipcode.focus();

		return (false);

	}



	if (frm.cust_physical_country.value.length == 0)

	{

		alert("Please enter Country");

		frm.cust_physical_country.focus();

		return (false);

	}



	if (frm.cust_tel_no.value.length == 0)

	{

		alert("Please enter Tel Number");

		frm.cust_tel_no.focus();

		return (false);

	}



	if (frm.cust_fax_no.value.length == 0)

	{

		alert("Please enter Fax Number");

		frm.cust_fax_no.focus();

		return (false);

	}





	if (frm.cust_email.value.length == 0)

	{

		alert("Please enter Email Address");

		frm.cust_email.focus();

		return (false);

	}



	if (!isEmail(frm.cust_email.value))

	{

		alert("Please enter your real email address.");

		frm.cust_email.focus();

		return (false);

	}

	

	if (frm.cust_contact_person.value.length == 0)

	{

		alert("Please enter Contact Person");

		frm.cust_contact_person.focus();

		return (false);

	}



	if (frm.cust_contact_phone.value.length == 0 && frm.cust_contact_mobile.value.length == 0)

	{

		alert("Please enter your office number or your mobile number");

		frm.cust_contact_phone.focus();

		return (false);

	}

	

	if (document.forms[0].cust_industry.selectedIndex== 0)

	{

		alert ("Please specify your industry");

		document.forms[0].cust_industry.focus();

		return (false);

	}



	if (document.forms[0].cust_industry.options[document.forms[0].cust_industry.selectedIndex].value == "Other" && document.forms[0].cust_industry_specify.value.length == 0)

	{

		alert ("Please specify your industry");

		document.forms[0].cust_industry_specify.focus();

		return (false);

	}



	return true;

}



function validateEditProfile(frm){



	// JavaScript Document

	

	if (frm.cust_passwd.value.length >0 && frm.cust_passwd.value.length < 6)

	{

		alert("Your password has to be at least 6 characters");

		frm.cust_passwd.focus();

		return (false);

	}

	

	if (frm.cust_passwd.value.length >0 && frm.cust_confirm_passwd.value.length < 6)

	{

		alert("Your confirm password has to be at least 6 characters");

		frm.cust_confirm_passwd.focus();

		return (false);

	}

		

	if (frm.cust_passwd.value.length >0 && (frm.cust_passwd.value != frm.cust_confirm_passwd.value))

	{

		alert("Your confirmed password doesn't match the password that you have entered");

		frm.cust_passwd.value = "";

		frm.cust_confirm_passwd.value = "";

		frm.cust_passwd.focus();

		return (false);

	}



	if (frm.cust_company_name.value.length == 0)

	{

		alert("Please enter Company Name");

		frm.cust_company_name.focus();

		return (false);

	}



	if (frm.cust_physical_add1.value.length == 0)

	{

		alert("Please enter Physical Address");

		frm.cust_physical_add1.focus();

		return (false);

	}





	if (frm.cust_physical_city.value.length == 0)

	{

		alert("Please enter City");

		frm.cust_physical_city.focus();

		return (false);

	}



	if (frm.cust_physical_state.value.length == 0)

	{

		alert("Please enter State/Province");

		frm.cust_physical_state.focus();

		return (false);

	}



	if (frm.cust_physical_zipcode.value.length == 0)

	{

		alert("Please enter Zip Code/Postal Code");

		frm.cust_physical_zipcode.focus();

		return (false);

	}



	if (frm.cust_physical_country.value.length == 0)

	{

		alert("Please enter Country");

		frm.cust_physical_country.focus();

		return (false);

	}



	if (frm.cust_tel_no.value.length == 0)

	{

		alert("Please enter Tel Number");

		frm.cust_tel_no.focus();

		return (false);

	}



	if (frm.cust_fax_no.value.length == 0)

	{

		alert("Please enter Fax Number");

		frm.cust_fax_no.focus();

		return (false);

	}





	if (frm.cust_email.value.length == 0)

	{

		alert("Please enter Email Address");

		frm.cust_email.focus();

		return (false);

	}



	if (!isEmail(frm.cust_email.value))

	{

		alert("Please enter your real email address.");

		frm.cust_email.focus();

		return (false);

	}

	

	if (frm.cust_contact_person.value.length == 0)

	{

		alert("Please enter Contact Person");

		frm.cust_contact_person.focus();

		return (false);

	}



	if (frm.cust_contact_phone.value.length == 0 && frm.cust_contact_mobile.value.length == 0)

	{

		alert("Please enter either a Contact Number (Tel) or Contact Number (Mobile)");

		frm.cust_contact_phone.focus();

		return (false);

	}

	

	if (document.forms[0].cust_industry.selectedIndex== 0)

	{

		alert ("Please Specify your Customer's Industry");

		document.forms[0].cust_industry.focus();

		return (false);

	}



	if (document.forms[0].cust_industry.options[document.forms[0].cust_industry.selectedIndex].value == "Other" && document.forms[0].cust_industry_specify.value.length == 0)

	{

		alert ("Please Specify your Customer's Industry");

		document.forms[0].cust_industry_specify.focus();

		return (false);

	}



	return true;

}





function validateCheckoutSubmit(frm){



	//Prompt user to select container if container is not selected

	if ((frm.selected_container.value == 0) || (frm.selected_container.value == "")){

		alert("Please select a Container Type");

		return false;

	}

	// no need to calculate the left space for container

	else if (frm.selected_container_info_calculate.value == 0){

		return true;

	}

	else {

		if (frm.container_left_volume.value < 0){

			alert("The Total Carton CBM left is less than 0. Please increase the quantity of container");

			return false;

		}

		else if (frm.container_left_weight.value < 0){

			alert("The Total Carton Gross Weight left is less than 0. Please increase the quantity of container");

			return false;

		}

	}

	return true;

}



function checkIndustry(select_box,text_specify,layer_name){

	var industry_value = select_box.options[select_box.selectedIndex].value;

	var elm = document.getElementById(layer_name);

	if (industry_value == "Other"){

		if (elm){ elm.style.display = 'block'; }

		if (text_specify.value == ""){

			alert ("Please Specify");
		}

		text_specify.select();
		text_specify.focus();

	}

	else{

		if (elm){ elm.style.display = 'none'; }

	}

}



// validate email

function isEmail(str) {

	// are regular expressions supported?

	var supported = 0;

	if (window.RegExp)

	{

			var tempStr = "a";

			var tempReg = new RegExp(tempStr);

			if (tempReg.test(tempStr)) supported = 1;

	}

	if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");

	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");

	return (!r1.test(str) && r2.test(str));

}



function validateLogin(frm){



	// JavaScript Document

	

	if (frm.cust_username.value.length < 6)

	{

		alert("Your Login ID must contain at least 6 characters");

		frm.cust_username.focus();

		return (false);

	}



	if (frm.cust_passwd.value.length < 6)

	{

		alert("Your  password must contain at least 6 characters");

		frm.cust_passwd.focus();

		return (false);

	}

	

}



function validateOrderForm(frm){



	if (frm.order_company_name.value.length == 0)

	{

		alert("Please enter Company Name");

		frm.order_company_name.focus();

		return (false);

	}



	if (frm.order_physical_add1.value.length == 0)

	{

		alert("Please enter Physical Address");

		frm.order_physical_add1.focus();

		return (false);

	}



	if (frm.order_physical_city.value.length == 0)

	{

		alert("Please enter City");

		frm.order_physical_city.focus();

		return (false);

	}



	if (frm.order_physical_state.value.length == 0)

	{

		alert("Please enter State");

		frm.order_physical_state.focus();

		return (false);

	}



	if (frm.order_physical_zipcode.value.length == 0)

	{

		alert("Please enter Physical Zip Code/ Postal Code");

		frm.order_physical_zipcode.focus();

		return (false);

	}



	if (frm.order_physical_country.selectedIndex == 0)

	{

		alert("Please enter Country");

		frm.order_physical_country.focus();

		return (false);

	}



	if (frm.order_tel_no.value.length == 0)

	{

		alert("Please enter Tel Number");

		frm.order_tel_no.focus();

		return (false);

	}



	if (frm.order_fax_no.value.length == 0)

	{

		alert("Please enter Fax Number");

		frm.order_fax_no.focus();

		return (false);

	}



	if (frm.order_email.value.length == 0)

	{

		alert("Please enter Email Address");

		frm.order_email.focus();

		return (false);

	}



	if (frm.order_contact_person.value.length == 0)

	{

		alert("Please enter Contact Person");

		frm.order_contact_person.focus();

		return (false);

	}



	if ((frm.order_contact_phone.value.length == 0) && (frm.order_contact_mobile.value.length == 0))

	{

		alert("Please enter Contact Number");

		frm.order_contact_phone.focus();

		return (false);

	}



	if (frm.order_industry.selectedIndex == 0)

	{

		alert ("Please Specify your Industry");

		frm.order_industry.focus();

		return (false);

	}



	if (frm.order_industry.options[frm.order_industry.selectedIndex].value == "Other" && frm.order_industry_specify.value.length == 0)

	{

		alert ("Please Specify your Industry");

		frm.order_industry_specify.focus();

		return (false);

	}



	if (frm.order_delivery_address1.value.length == 0)

	{

		alert("Please enter Delivery Address");

		frm.order_delivery_address1.focus();

		return (false);

	}



	if (frm.order_delivery_city.value.length == 0)

	{

		alert("Please enter City");

		frm.order_delivery_city.focus();

		return (false);

	}



	if (frm.order_delivery_state.value.length == 0)

	{

		alert("Please enter State");

		frm.order_delivery_state.focus();

		return (false);

	}



	if (frm.order_delivery_zipcode.value.length == 0)

	{

		alert("Please enter Zip Code / Postal Code");

		frm.order_delivery_zipcode.focus();

		return (false);

	}



	if (frm.order_delivery_country.selectedIndex == 0)

	{

		alert("Please enter Country");

		frm.order_delivery_country.focus();

		return (false);

	}



	if (frm.order_delivery_port_of_discharge.value.length == 0)

	{

		alert("Please enter Port of Discharge");

		frm.order_delivery_port_of_discharge.focus();

		return (false);

	}





	if (frm.order_place_of_delivery_place.value.length == 0)

	{

		alert("Please enter Place of Delivery (Place)");

		frm.order_place_of_delivery_place.focus();

		return (false);

	}



	if (frm.order_place_of_delivery_country.selectedIndex == 0)

	{

		alert("Please enter Place of Delivery (Country)");

		frm.order_place_of_delivery_country.focus();

		return (false);

	}


	if (frm.order_delivery_tod.selectedIndex == 0)

	{

		alert("Please enter Term of Delivery");

		frm.order_delivery_tod.focus();

		return (false);

	}


	if (frm.order_shipping_mode.selectedIndex == 0)

	{

		alert("Please enter Shipping Mode");

		frm.order_shipping_mode.focus();

		return (false);

	}



	if (frm.order_shipping_freight.selectedIndex == 0)

	{

		alert("Please enter Freight");

		frm.order_shipping_freight.focus();

		return (false);

	}


	if (frm.order_shipping_company_name.value.length == 0)

	{

		alert("Please enter Appointed Shipping Agent's Company Name");

		frm.order_shipping_company_name.focus();

		return (false);

	}





	if (frm.order_shipping_tel_no.value.length == 0)

	{

		alert("Please enter Appointed Shipping Agent's Tel Number");

		frm.order_shipping_tel_no.focus();

		return (false);

	}

}



function popupwin(win_url,win_width,win_height){

	window.open( win_url, '', 'top=250,left=250,width='+win_width+', height='+win_height+', scrollbars=yes' );

}





function printpage(){
	window.print();  
}



function isemp1() {



	if (document.forgotform.loginid.value == "")

	{

		alert("Please key in your Login ID")

		document.forgotform.loginid.focus();

		return false;

	}

	return true;

}





function isemp2() {



	if (document.forgotform2.email.value == "")

	{

		alert("Please key in your Email")

		document.forgotform2.email.focus();

		return false;

	}

	if (!isEmail(document.forgotform2.email.value))

	{

		alert("Please enter your real email address.");

		document.forgotform2.email.focus();

		return (false);

	}

	

	return true;



}



function show_this(id){

	hide_layer('wonderfarm_'+id+'_normal', 0);

	show_layer('wonderfarm_'+id+'_show', 0);	

	return false;

}



function cancel_this(id){

	hide_layer('wonderfarm_'+id+'show', 0);

	show_layer('wonderfarm_'+id+'_normal', 0);

}

function hide_layer(name, row){

	var elm = document.getElementById(name);

	if (elm){ elm.style.display = 'none'; }

}



function show_layer(name, row){

	var elm = document.getElementById(name);

	if (elm){ elm.style.display = row?ll_show_mode:'block'; }

}

function newPWindow(wide,high){

 winFeatures="'status=no,location=no,toolbar=no,scrollbars=yes,width="+wide+",height="+high+"'"; 
 showcase=window.open("",'wonder',winFeatures);
 showcase.focus();
 
}
