// Change Password

function validatechPass() { 
var frm = document.chPass;

if(frm.oldPass.value == "")	{	
	alert("Please Enter Old Password");
	frm.oldPass.focus();
	return false;
}
if(frm.newPass.value == "")	{	
	alert("Please Enter New Password");
	frm.newPass.focus();
	return false;
}
if(frm.newPass.value == frm.oldPass.value)	{	
	alert("New Password should not be equal to Old Password");
	frm.newPass.value='';
	frm.newPass.focus();
	return false;
}
if(frm.newPass.value !=  frm.CnewPass.value) {
		alert('Confirmpassword Does not match');
		frm.newPass.value='';
		frm.CnewPass.value='';
		frm.newPass.focus();
		return false;
	}
return true;
}

// Promotion Code Management

function validatePCode()	{

var frm = document.CreatePCode;
if(frm.pcode.value == "")	{	
	alert("Please Enter Promotion Code");
	frm.pcode.focus();
	return false;
}
if(frm.sdate.value == "")	{	
	alert("Please Enter Start Date");
	frm.sdate.focus();
	return false;
}
if(frm.edate.value == "")	{	
	alert("Please Enter End Date");
	frm.edate.focus();
	return false;
}
return true;
}

// Package Management

function validatepk()	{

var frm = document.createpk;
if(frm.amount.value == "")	{	
	alert("Please Enter Package Amount");
	frm.amount.focus();
	return false;
}
if(isNaN(frm.amount.value))	{	
	alert("Please Enter Numeric Value");
	frm.amount.select();
	frm.amount.focus();
	return false;
}
if(frm.validity.value == "")	{	
	alert("Please Enter Package Validity in Months");
	frm.validity.focus();
	return false;
}
if(isNaN(frm.validity.value))	{	
	alert("Please Enter Numeric Value");
	frm.validity.select();
	frm.validity.focus();
	return false;
}
if(frm.desc.value == "")	{	
	alert("Please Enter the Description");
	frm.desc.focus();
	return false;
}
return true;
}

// Seller Management

function validateSel()	{

var frm = document.addSel;
if(frm.selName.value == "")	{	
	alert("Please Enter Seller Name");
	frm.selName.focus();
	return false;
}
if(frm.pass.value == "")	{	
	alert("Please Enter Password");
	frm.pass.focus();
	return false;
}

//EMAIL
	var m=frm.email;
	var n=frm.email.value;
	if ((n==null)||(n=="")){
		alert("Please Enter your Email ID")
		m.select()
		return false
	}
	if (echeck(n)==false){
		alert('Please enter valid email ID');
		m.select();
		return false;
	}
	function echeck(str) {
		at = str.indexOf("@");
		dot = str.lastIndexOf(".");
		lengt = str.length;
		con1 = str.substring(0,at);
		con2 = str.substring(at+1,dot);
		con3 = str.substring(dot+1,lengt);

		if(con1=='' || con2=='' || con3=='') return false;

		if(str.indexOf("  ") > -1 || str.indexOf("..") > -1 || str.indexOf("__") > -1 || str.indexOf("--") > -1) return false;
		
		if(at==-1 || dot==-1) return false;

		x = con1.substring(0,1);
		if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

		x = con1.substring((con1.length)-1,(con1.length));
		if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

		x = con1.substring(1,(con1.length)-1);
		for(i=0, y=0; i<con1.length-2; i++, y=x.substring(i, i+1)) if ((y < "a" || "z" < y) && (y < "A" || "Z" < y) && isNaN(y) && y!='.' && y!='_' && y!='-') return false;
		
		x = con2.substring(0,1);
		if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

		x = con2.substring((con2.length)-1,(con2.length));
		if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;
		
		x = con2.substring(1,(con2.length)-1);
		for(i=0, y=0; i<con2.length-2; i++, y=x.substring(i, i+1)) if ((y < "a" || "z" < y) && (y < "A" || "Z" < y) && isNaN(y) && y!='.' && y!='_' && y!='-') return false;		
		
		for(i=0, x=0; i<con3.length; i++, x = con3.substring(i, i+1)) if ((x < "a" || "z" < x) && (x < "A" || "Z" < x)) return false;
		if ((con3.length)<2 || (con3.length)>4)  return false;
	}
	
	var choice = false;
	var i;
	for (i = 0;  i < frm.pkGroup.length; i++) {
		if (frm.pkGroup[i].checked) choice = true; 
	}

	if (!choice)	{
		alert("Please select a Package")
		return (false);
	}
return true;
}

// Car Type Management

function validateType()	{

var frm = document.createType;
	if(frm.tname.value == "")	{	
		alert("Please Enter Car Type");
		frm.tname.focus();
		return false;
	}
	return true;
}

// Car Make Management

function validateMK()	{

var frm = document.createMK;
	if(frm.mname.value == "")	{	
		alert("Please Enter Car Make");
		frm.mname.focus();
		return false;
	}
	return true;
}

// Car Model Management

function validateMD()	{

var frm = document.createMD;

if(frm.Make.selectedIndex <= 0 )	{	
	alert("Please Select Car Make");
	frm.Make.focus();
	return false;
}

if(frm.mname.value == "")	{	
	alert("Please Enter Car Model");
	frm.mname.focus();
	return false;
}
return true;
}

// Car Accessories Management

function validateACC()	{

var frm = document.createACC;
	if(frm.Accname.value == "")	{	
		alert("Please Enter the Accessorie Name");
		frm.Accname.focus();
		return false;
	}
	return true;
}

// Car Make Management

function validateLK()	{

var frm = document.createLK;
	if(frm.lnname.value == "")	{	
		alert("Please Enter Site Name");
		frm.lnname.focus();
		return false;
	}
	if(frm.lnurl.value == "")	{	
		alert("Please Enter the Site URL");
		frm.lnurl.focus();
		return false;
	}
	return true;
}