/* ##################### */
/*general functions to check the users email, alphabets, name, password, remove spaces form the Name through trim() etc..*/

function trim (strVar) 
{ 
	if(strVar.length >0)
	{
		while(strVar.charAt(0)==" ") 
			strVar=strVar.substring(1,strVar.length); 
		while(strVar.charAt(strVar.length-1)==" ") 
			strVar=strVar.substring(0,strVar.length-1);
	}
	return strVar;
}
function isNotNumeric(str)
{
	for (var i = 0; i < str.length; i++)
	{
		var ch = str.substring(i, i + 1);
		if((ch < '0' || '9' < ch)) 
		{
			if(ch == "-" || ch == ".") continue;
			return true;
		}
	}
	return false;
}
function checkAll(checked)
{
	for(var i=0;i<document.productForm.elements.length;i++)
	{
		var e = document.productForm.elements[i];
		var n= e.name;
		var str= n.substring(0,11);		
		if(e.type == "checkbox" && str=="accessories")
			e.checked = checked;
	}
}
<!--
function checkForm(theForm)
{
	var stock_number = trim(theForm.stock_number.value);
	var price = trim(theForm.price.value);
	var mfg_year = trim(theForm.mfg_year.value);
	var type = theForm.type_id.value;
	var make = theForm.make_id.value;
	var type_std = theForm.type_std.value;
	var make_std = theForm.make_std.value;

//Stock Number
	theForm.stock_number.value = stock_number; //Trim Value
	if(stock_number.length == 0)
	{
		alert("Please enter Stock Number !");
		theForm.stock_number.focus();
		return false;	
	}

//Price
	if(price.length == 0)
	{
		alert("Please enter Price !");
		theForm.price.value = "";
		theForm.price.focus();
		return false;	
	}
	var ask=price.toLowerCase();
	if(ask!="ask")
	{
		if(price <= 0)
		{
			alert("Invalid Price !");
			theForm.price.focus();
			return false;	
		}
		if(price.length > 0)
		{	
			if(isNotNumeric(price))
			{
				alert("Invalid Price !");
				theForm.price.focus();
				return false;	
			}
		}
	}
	if(make.length == 0 && make_std.length==0)
	{
		alert("Please Select or enter Maker !");
		theForm.make_id.focus();
		return false;	
	}
	return true;
}
//-->
/*CHECK VEHICLE TYPE*/
function fun_type(val)
{
	if(val==1)
		productForm.type_std.value="";
	if(val==2)
		productForm.type_id.value="";
}
/*CHECK BODY SHAPE*/
function fun_shape(val)
{
	if(val==1)
		productForm.subtype_std.value="";
	if(val==2)
		productForm.subtype_id.value="";
}
/*CHECK MANUFACTURES*/
function fun_manufacture(val)
{
	if(val==1)
		productForm.make_std.value="";
	if(val==2)
		productForm.make_id.value="";
}
/*CHECK BRANDS*/
function fun_brand(val)
{
	if(val==1)
		productForm.maker_std.value="";
	if(val==2)
		productForm.maker_id.value="";
}
/*CHECK MODELS*/
function fun_model(val)
{
	if(val==1)
		productForm.model_std.value="";
	if(val==2)
		productForm.model_id.value="";
}
/*CHECK TRANSMISSION*/
function fun_trans(val)
{
	if(val==1)
		productForm.transmission_std.value="";
	if(val==2)
		productForm.transmission.value="";
}
/*CHECK FUEL*/
function fun_fuel(val)
{
	if(val==1)
		productForm.fuel_std.value="";
	if(val==2)
		productForm.fuel.value="";
}
/*CHECK BODY COLOR*/
function fun_bcolor(val)
{
	if(val==1)
		productForm.color_std.value="";
	if(val==2)
		productForm.color.value="";
}