/// Email validation //

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

// end email validation ///


function model_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.model.item_name.value=="")
		{
		alert("Please mention model");
		document.model.item_name.focus();
		return false;
		}


		fnm=document.model.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.model.item_name.focus();
		return false;
		}
	}


}

function rating_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.rating.item_name.value=="")
		{
		alert("Please mention rating");
		document.rating.item_name.focus();
		return false;
		}


		fnm=document.rating.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.rating.item_name.focus();
		return false;
		}
	}


}

function flange_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.flange.item_name.value=="")
		{
		alert("Please mention flange alignment");
		document.flange.item_name.focus();
		return false;
		}


		fnm=document.flange.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.flange.item_name.focus();
		return false;
		}
	}


}


function body_material_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.body_mat.item_name.value=="")
		{
		alert("Please mention body material");
		document.body_mat.item_name.focus();
		return false;
		}


		fnm=document.body_mat.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.body_mat.item_name.focus();
		return false;
		}
	}


}


function disc_material_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.disc_mat.item_name.value=="")
		{
		alert("Please mention disc material");
		document.disc_mat.item_name.focus();
		return false;
		}


		fnm=document.disc_mat.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.disc_mat.item_name.focus();
		return false;
		}
	}


}



function seat_material_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.seat_mat.item_name.value=="")
		{
		alert("Please mention seat material");
		document.seat_mat.item_name.focus();
		return false;
		}


		fnm=document.seat_mat.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.seat_mat.item_name.focus();
		return false;
		}
	}


}



function stem_material_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.stem_mat.item_name.value=="")
		{
		alert("Please mention stem material");
		document.stem_mat.item_name.focus();
		return false;
		}


		fnm=document.stem_mat.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.stem_mat.item_name.focus();
		return false;
		}
	}


}



function operation_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.operation.item_name.value=="")
		{
		alert("Please mention operation");
		document.operation.item_name.focus();
		return false;
		}


		fnm=document.operation.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.operation.item_name.focus();
		return false;
		}
	}


}




function size_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.size.item_name.value=="")
		{
		alert("Please mention size");
		document.size.item_name.focus();
		return false;
		}


		fnm=document.size.item_name.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.size.item_name.focus();
		return false;
		}
	}


}



function enq_validate()
{


		if (document.enq_form.fname.value=="")
		{
		alert("Please mention name");
		document.enq_form.fname.focus();
		return false;
		}


		fnm=document.enq_form.fname.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.enq_form.fname.focus();
		return false;
		}


	
		if (document.enq_form.email.value=="")
		{
		alert("Please mention email");
		document.enq_form.email.focus();
		return false;
		}




		fnm=document.enq_form.email.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.enq_form.email.focus();
		return false;
		}
		
		if(echeck(document.enq_form.email.value)==false)
		{
		document.enq_form.email.select();
		return false; 
		}



}



function prod_image_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.prod.title.value=="")
		{
		alert("Please mention title");
		document.prod.title.focus();
		return false;
		}


		fnm=document.prod.title.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.prod.title.focus();
		return false;
		}

		
		if (document.prod.prod_desc.value=="")
		{
		alert("Please mention details");
		document.prod.prod_desc.focus();
		return false;
		}


		fnm=document.prod.prod_desc.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.prod.prod_desc.focus();
		return false;
		}

	}

if(type=="ADD")
	{
		
		if (document.prod.photo.value=="")
		{
		alert("Please upload image");
		document.prod.photo.focus();
		return false;
		}


		fnm=document.prod.photo.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.prod.photo.focus();
		return false;
		}
	}

}




function subcat_validate(type)
{
var type=type;


if(type=="EDIT")
	{
		
		
		if(document.add_subcat.cat_nm.value=="#")
		{
		 alert("Please select category"); 
		 document.add_subcat.cat_nm.focus();
		 return false;
		}
		
		if(document.add_subcat.subcat_nm.value=="#")
		{
		 alert("Please select sub-category"); 
		 document.add_subcat.subcat_nm.focus();
		 return false;
		}
	}

if(type=="ADD" || type=="EDIT")
	{
		
		if(document.add_subcat.cat_nm.value=="#")
		{
		 alert("Please select category"); 
		 document.add_subcat.cat_nm.focus();
		 return false;
		}

		if (document.add_subcat.subcategory_title.value=="")
		{
		alert("Please mention sub-category");
		document.add_subcat.subcategory_title.focus();
		return false;
		}


		fnm=document.add_subcat.subcategory_title.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_subcat.subcategory_title.focus();
		return false;
		}
	}


}

/// end category validation ///

function content_validate(type)
{

var type=type;


if(type=="DELETE")
	{
	
		
		if(document.add_content.cat_nm.value=="#")
		{
		 alert("Please select category"); 
		 document.add_content.cat_nm.focus();
		 return false;
		}

		if(document.add_content.stock_ref_list.value=="#")
		{
		 alert("Please select stcok reference"); 
		 document.add_content.stock_ref_list.focus();
		 return false;
		}
	
	var agree=confirm("Are you sure you wish to delete?");
	if (agree)

	return true ;
	
else
	return false ;
	
	document.forms[0].submit();
	
	}

if(type=="EDIT")
	{
	
		
		if(document.add_content.cat_nm.value=="#")
		{
		 alert("Please select category"); 
		 document.add_content.cat_nm.focus();
		 return false;
		}

		if(document.add_content.stock_ref_list.value=="#")
		{
		 alert("Please select stcok reference"); 
		 document.add_content.stock_ref_list.focus();
		 return false;
		}


		if (document.add_content.stock_ref.value=="")
		{
		alert("Please mention STOCK REFERENCE");
		document.add_content.stock_ref.focus();
		return false;
		}


		fnm=document.add_content.stock_ref.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_content.stock_ref.focus();
		return false;
		}

		if(document.add_content.veh_type.value=="#")
		{
		alert("Please select VEHICLE TYPE"); 
		document.add_content.veh_type.focus();
		return false;
		}

		if (document.add_content.manuf.value=="")
		{
		alert("Please mention MANUFACTURER");
		document.add_content.manuf.focus();
		return false;
		}


		fnm=document.add_content.manuf.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_content.manuf.focus();
		return false;
		}

		if (document.add_content.model.value=="")
		{
		alert("Please mention MODEL");
		document.add_content.model.focus();
		return false;
		}


		fnm=document.add_content.model.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_content.model.focus();
		return false;
		}


		if(document.add_content.drive.value=="#")
		{
		alert("Please select DRIVE"); 
		document.add_content.drive.focus();
		return false;
		}


		if (document.add_content.berth.value=="")
		{
		alert("Please mention BERTHS");
		document.add_content.berth.focus();
		return false;
		}


		fnm=document.add_content.berth.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_content.berth.focus();
		return false;
		}

	}

	
if(type=="ADD")
	{
	
		
		if(document.add_content.cat_nm.value=="#")
		{
		 alert("Please select category"); 
		 document.add_content.cat_nm.focus();
		 return false;
		}



		if (document.add_content.stock_ref.value=="")
		{
		alert("Please mention STOCK REFERENCE");
		document.add_content.stock_ref.focus();
		return false;
		}


		fnm=document.add_content.stock_ref.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_content.stock_ref.focus();
		return false;
		}

		if(document.add_content.veh_type.value=="#")
		{
		alert("Please select VEHICLE TYPE"); 
		document.add_content.veh_type.focus();
		return false;
		}

		if (document.add_content.manuf.value=="")
		{
		alert("Please mention MANUFACTURER");
		document.add_content.manuf.focus();
		return false;
		}


		fnm=document.add_content.manuf.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_content.manuf.focus();
		return false;
		}

		if (document.add_content.model.value=="")
		{
		alert("Please mention MODEL");
		document.add_content.model.focus();
		return false;
		}


		fnm=document.add_content.model.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_content.model.focus();
		return false;
		}


		if(document.add_content.drive.value=="#")
		{
		alert("Please select DRIVE"); 
		document.add_content.drive.focus();
		return false;
		}


		if (document.add_content.berth.value=="")
		{
		alert("Please mention BERTHS");
		document.add_content.berth.focus();
		return false;
		}


		fnm=document.add_content.berth.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_content.berth.focus();
		return false;
		}

	}

}
/* function to check edit category Details*/
function chkdrop1()
	{
		
		
				if (document.add_cat.cat_nm.value=="#")
				{
				alert("Please select category");
				document.add_cat.cat_nm.focus();
				return false;
				}
				document.add_cat.flg.value="2";
				document.add_cat.submit();

}


/// link validation ///


/* function to check edit category Details*/
function chkdrop2()
	{
		
		
				if (document.add_subcat.cat_nm.value=="#")
				{
				alert("Please select category");
				document.add_subcat.cat_nm.focus();
				return false;
				}
				document.add_subcat.flg.value="2";
				document.add_subcat.submit();

}
/// link validation ///

/* function to check edit category Details*/
function chkdrop3()
	{
		
		
				if (document.add_subcat.subcat_nm.value=="#")
				{
				alert("Please select category");
				document.add_subcat.subcat_nm.focus();
				return false;
				}
				document.add_subcat.flg.value="2";
				document.add_subcat.submit();

}
/// link validation ///



/* function to check edit category Details*/
function chkdrop4()
	{
		
		
				if (document.add_content.cat_nm.value=="#")
				{
				alert("Please select category");
				document.add_content.cat_nm.focus();
				return false;
				}
				document.add_content.flg.value="2";
				document.add_content.submit();

}
/// link validation ///


/* function to check edit category Details*/
function chkdrop5()
	{
		
		
				if (document.add_content.subcat_nm.value=="#")
				{
				alert("Please select category");
				document.add_content.subcat_nm.focus();
				return false;
				}
				document.add_content.flg.value="2";
				document.add_content.submit();

}
/// link validation ///
/// photo upload///

function image_validate(type)
{

var type=type;

if(type=="ADD" || type=="EDIT")
	{
	
		
		if(document.add_photo.cat_nm.value=="#")
		{
		 alert("Please select category"); 
		 document.add_photo.cat_nm.focus();
		 return false;
		}

		if(document.add_photo.stock_ref_list.value=="#")
		{
		 alert("Please select stock reference"); 
		 document.add_photo.stock_ref_list.focus();
		 return false;
		}
	
	}


if(type=="ADD")
	{
		if(document.add_photo.image_file1.value=="")
		{
		 alert("Please select image to upload"); 
		 document.add_photo.image_file1.focus();
		 return false;
		}

	}
}
/* end photo upload */

/* function to check edit category Details*/
function chkdrop6()
	{
		
		
				if (document.add_photo.cat_nm.value=="#")
				{
				alert("Please select category");
				document.add_photo.cat_nm.focus();
				return false;
				}
				document.add_photo.flg.value="2";
				document.add_photo.submit();

}
/// link validation ///


/* function to check edit category Details*/
function chkdrop7()
	{
		
		
				if (document.add_photo.subcat_nm.value=="#")
				{
				alert("Please select sub category");
				document.add_photo.subcat_nm.focus();
				return false;
				}
				document.add_photo.flg.value="2";
				document.add_photo.submit();

}
/// link validation ///



/* function to check edit content Details*/
function chkdrop_stref()
	{
		
		
				if (document.add_content.stock_ref_list.value=="#")
				{
				alert("Please select stock reference");
				document.add_content.stock_ref_list.focus();
				return false;
				}
				document.add_content.flg.value="2";
				document.add_content.submit();

}
/// link validation ///


/* function to check edit content Details*/
function chkdrop_stref_del()
	{
		
		
				if (document.add_content.stock_ref_list.value=="#")
				{
				alert("Please select stock reference");
				document.add_content.stock_ref_list.focus();
				return false;
				}
				document.add_content.flg.value="2";
				document.add_content.submit();

}
/// link validation ///

/* function to check edit category Details*/
function chkdrop_imged()
	{
		
		
				if (document.add_photo.stock_ref_list.value=="#")
				{
				alert("Please select staock reference");
				document.add_photo.stock_ref_list.focus();
				return false;
				}
				document.add_photo.flg.value="2";
				document.add_photo.submit();

}
/// link validation ///


function dateupdate_validate()
{
	
		
		if(document.add_date.dt.value=="#")
		{
		 alert("Please select date"); 
		 document.add_date.dt.focus();
		 return false;
		}

		if(document.add_date.mm.value=="#")
		{
		 alert("Please select month"); 
		 document.add_date.mm.focus();
		 return false;
		}

		if(document.add_date.yr.value=="#")
		{
		 alert("Please select year"); 
		 document.add_date.yr.focus();
		 return false;
		}
		if(document.add_date.m_type.value=="#")
		{
		 alert("Please select type"); 
		 document.add_date.m_type.focus();
		 return false;
		}

}

/////////////////////////////////////////


/* function to check edit category Details*/
function chkdrop_vtype()
	{
		
		
				if (document.add_content.veh_type.value=="#")
				{
				alert("Please select vehicle type");
				document.add_content.veh_type.focus();
				return false;
				}
				document.add_content.flg.value="2";
				document.add_content.submit();

}


/// link validation ///
function page_cont()
{

		if(document.add_page_cont.page_nm.value=="#")
		{
		 alert("Please select page"); 
		 document.add_page_cont.page_nm.focus();
		 return false;
		}
}
///////////

/* function to check edit category Details*/
function chkdrop_cont_update()
	{
		
		
				if (document.add_page_cont.page_nm.value=="#")
				{
				alert("Please select vehicle type");
				document.add_page_cont.page_nm.focus();
				return false;
				}
				document.add_page_cont.flg.value="2";
				document.add_page_cont.submit();

}


/// link validation ///


/// category validation ///
function fne_cont_validate(type)
{
var type=type;


if(type=="ADDE" || type=="EDITE" || type=="ADDN" || type=="EDITN" || type=="ADDF" || type=="EDITF")
	{

		if (document.add_cont.title.value=="")
		{
		alert("Please mention title");
		document.add_cont.title.focus();
		return false;
		}


		fnm=document.add_cont.title.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_cont.title.focus();
		return false;
		}

		if (document.add_cont.desc.value=="")
		{
		alert("Please mention details");
		document.add_cont.desc.focus();
		return false;
		}


		fnm=document.add_cont.desc.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please Enter Proper Value");
		document.add_cont.desc.focus();
		return false;
		}

	}


}
///////

/// link validation ///
function page_cont_img()
{

		if(document.add_page_cont.page_nm.value=="#")
		{
		 alert("Please select page"); 
		 document.add_page_cont.page_nm.focus();
		 return false;
		}

		if(document.add_page_cont.photo_nos.value=="#")
		{
		 alert("Please mention no. of image to be uploaded"); 
		 document.add_page_cont.photo_nos.focus();
		 return false;
		}

}
///////////

function chkdrop_eventpic()
	{
		
		
				//check for event name
				if (document.add_page_cont.photo_nos.value=="#")
				{
				alert("Please select no. of photos");
				document.add_page_cont.photo_nos.focus();
				return false;
				}
				document.forms[0].flg.value=2;
				document.forms[0].submit();

}
//// End check no. of photos uploaded for event ////
/// link validation ///
function page_cont_img_edt()
{

		if(document.add_page_cont.page_nm.value=="#")
		{
		 alert("Please select page"); 
		 document.add_page_cont.page_nm.focus();
		 return false;
		}

}
///////////


/* function to check edit category Details*/
function chkdrop_pic_update()
	{
		
		
				if (document.add_page_cont.page_nm.value=="#")
				{
				alert("Please select vehicle type");
				document.add_page_cont.page_nm.focus();
				return false;
				}
				document.add_page_cont.flg.value="2";
				document.add_page_cont.submit();

}


/// link validation ///

//// Checking for deleting images with check box
function chk_all(no)
{
	var pic = document.getElementsByName("picid[]");

for(var i=0;i<no;i++)
	{
	pic[i].checked=true;
	}
return true;
}

function frm_submit(arg)
{
var pic = document.getElementsByName("picid[]");
var ok=0;

for(var i=0;i<arg;i++)
	{
	if(pic[i].checked==true)
		{
		ok=1;
		}
	}
if(ok==0)
	{
    alert("Select atleast one checkbox");
	return false;
	}else {
//document.frm.action="showpicdel.php?recno="+arg;
document.frm.submit();
return true;
	}
}

//// End checking for deleting images with check box


function frm_submit(arg)
{
var pic = document.getElementsByName("picid[]");
var ok=0;

for(var i=0;i<arg;i++)
	{
	if(pic[i].checked==true)
		{
		ok=1;
		}
	}
if(ok==0)
	{
    alert("Select atleast one checkbox");
	return false;
	}else {
//document.frm.action="showpicdel.php?recno="+arg;
document.frm.submit();
return true;
	}
}

//// End checking for deleting images with check box





function ditem_validate(type)
{
var type=type;


if(type=="ADD" || type=="EDIT")
	{

		if (document.prod.title.value=="")
		{
		alert("Please mention title");
		document.prod.title.focus();
		return false;
		}


		fnm=document.prod.title.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.prod.title.focus();
		return false;
		}

		

	}

if(type=="ADD")
	{
		
		if (document.prod.photo.value=="")
		{
		alert("Please upload file");
		document.prod.photo.focus();
		return false;
		}


		fnm=document.prod.photo.value;

		if (fnm==0 || fnm==null)
		{
		alert("Please enter proper value");
		document.prod.photo.focus();
		return false;
		}
	}

}
