var ctrl, msgstring, msg, ctrlfocus, msgstring1, msg1
<!--
function gopg(p)
{
	document.frm.p.value = p;
	document.frm.submit();
}

function gosort(field, type)
{
document.frm.order_field.value = field;
document.frm.order_type.value = type;
document.frm.submit();
}

function edit_record(id, redirect_to)
{
document.frm.id.value = id;
document.frm.action = redirect_to;
document.frm.submit();
}

function edit_inplace(id,redirect_to)
{
if ( document.frm.Parent1 ) document.frm.Parent1.value = "";
document.frm.id.value = id;
document.frm.mode.value = 'edit';
document.frm.action=redirect_to;
document.frm.submit();
}

function edit_save(redirect_to, ctrlstring)
{
	submitflag = 1;
	if ( ctrlstring != "" ) {
		if ( checkEmptyString(ctrlstring) ) {
			alert(msgstring);
			eval(ctrlfocus);
			submitflag = 0;
		}
	}
	if ( submitflag == 1 ) {
		document.frm.action = redirect_to;
		document.frm.mode.value = "edit";
		document.frm.submit();
	}	
	else
	{
		return false;
	}
}

function product_group_save(redirect_to, ctrlstring,mode)
{
	submitflag = 1;
	if ( ctrlstring != "" ) {
		if ( checkEmptyString(ctrlstring) ) {
			alert(msgstring);
			eval(ctrlfocus);
			submitflag = 0;
		}
	}
	if ( submitflag == 1 ) {
		document.frm.action = redirect_to;
		document.frm.mode.value = mode;
		document.frm.submit();
	}	
}

function edit_save_format(redirect_to, ctrlstring, checkformat, checkfieldid)
{
	submitflag = 1;
	if ( ctrlstring != "" ) {
		if ( checkEmptyString(ctrlstring) ) {
			alert(msgstring);
			eval(ctrlfocus);
			submitflag = 0;
		}
	}
	if( submitflag == 1 )
	{
		if(checkformat == "confirm")
		{
			ctrl = ctrlstring.split(";");
			var ctrlname1 = ctrl[checkfieldid].split(",");
			var ctrlname2 = ctrl[checkfieldid+1].split(",");
			if(eval(ctrlname1[0]).value != eval(ctrlname2[0]).value)
			{
				alert("New password and Confirm password does not match.");	
				ctrlfocus = ctrlname1[0] + ".focus()";
				eval(ctrlfocus);
				submitflag = 0;
			}
		}	
		if(checkformat == "email")
		{
			ctrl = ctrlstring.split(";");
			var ctrlname1 = ctrl[checkfieldid].split(",");
			if(!isEmail(eval(ctrlname1[0]).value))
			{
				alert("Please enter email in proper format.");	
				ctrlfocus = ctrlname1[0] + ".focus()";
				eval(ctrlfocus);
				submitflag = 0;
			}
		}	
	}
	if ( submitflag == 1 ) {
		
		document.frm.action = redirect_to;
		document.frm.mode.value = "edit";
		document.frm.submit();
	}	
	else
	{
		return false;
	}
}

function cancel_inplace(id)
{
document.frm.id.value = -1;
document.frm.submit();
}

function save_inplace(redirect_to, ctrlstring)
{
	//alert(ctrlstring)
	submitflag = 1;
	if ( ctrlstring != "" ) {
		if ( checkEmptyString(ctrlstring) ) {
			alert(msgstring);
			eval(ctrlfocus);
			submitflag = 0;
		}
	}
	if ( submitflag == 1 ) {
		document.frm.action = redirect_to;
		document.frm.mode.value = "add";
		document.frm.submit();
	}
	else
	{
		return false;
	}
}
function save_inplace_format(redirect_to, ctrlstring, checkformat, checkfieldid)
{
	/*
		redirect_to = file name to be redirected to
		ctrlstring = control name : display name pair string of controls to be varified for null
		checkformat = confirm -------------  confirm field
					  email ---------------  for email format validation
		checkfieldid = number of the control in the ctrlstring variable
	*/
	submitflag = 1;
	if ( ctrlstring != "" ) {
		if ( checkEmptyString(ctrlstring) ) {
			alert(msgstring);
			eval(ctrlfocus);
			submitflag = 0;
		}
	}
	if( submitflag == 1 )
	{
		if(checkformat == "confirm")
		{
			ctrl = ctrlstring.split(";");
			var ctrlname1 = ctrl[checkfieldid].split(",");
			var ctrlname2 = ctrl[checkfieldid+1].split(",");
			if(eval(ctrlname1[0]).value != eval(ctrlname2[0]).value)
			{
				alert("New password and Confirm password does not match.");	
				ctrlfocus = ctrlname1[0] + ".focus()";
				eval(ctrlfocus);
				submitflag = 0;
			}
		}	
		if(checkformat == "email")
		{
			strid = checkfieldid.split(",");
			ctrl = ctrlstring.split(";");
			for(i=0;i<strid.length;i++)
			{
				var ctrlname1 = ctrl[strid[i]].split(",");
				if(!isEmail(eval(ctrlname1[0]).value))
				{
					alert("Please enter email in proper format.");	
					ctrlfocus = ctrlname1[0] + ".focus()";
					eval(ctrlfocus);
					submitflag = 0;
					break;
				}
			}
		}	
	}
	if ( submitflag == 1 ) {
		document.frm.action = redirect_to;
		document.frm.mode.value = "add";
		document.frm.submit();
	}
	else
	{
		return false;
	}
}
//-->


function chksrch()
{
	if(document.frm.srch.value.split(" ").join("").length==0)
	{
	alert("Please enter search keyword.")
	document.frm.srch.focus();
	return false;
	}
	else
	{
	return true;
	}
}

