/* Checks memo field length */
function chkMemoLength(strValue,strMsg)
{
	if (strValue.length	> 65535)
	{
		alert(strMsg);
		return false;
	}
	return true;
}
function chkMemoLength1(strValue,strMsg)
{
	if (strValue.length	> 60000)
	{
		alert("Descriptio Can not be greater then the 60,000 character ");
		return false;
	}
	return true;
}

function validstconcity(strValue, strMsg)
{
	var i, strnum;
	for(i=0; i<=strValue.length-1; i++)
	{
		strnum = strValue.charCodeAt(i);
		
		if ((strnum >= 48 && strnum <=57) || (strnum >= 65 && strnum <=90) || (strnum >= 97 && strnum <=122) ||  strnum == 45 || strnum == 39 || strnum == 32)
		{
		}
		else
		{
			alert(strMsg);
			return false;
		}
	}
	return true;
}

function checkvaluerate(strValue,strMsg)
{ 	var strsub
	strsub=strValue.indexOf(".")
	if(strsub>=0)
	{	
		if (strValue.substring(0,strValue.indexOf("."))>99999)
			{
			alert(strMsg);
			return false;
			}
	}
	else
	{ 	
		if (strValue>99999)
			{
			alert(strMsg);
			return false;
			}
	}
	return true;
}

function chkExtension(strVal,strMsg)
{
	var dotpos;
	var strExtension = new String;
	var arrExtension = new Array();
	arrExtension[0] = ".jpg";
	arrExtension[1] = "jpeg";
	arrExtension[2] = ".bmp";
	arrExtension[3] = ".tif";
	arrExtension[4] = ".tiff";
	arrExtension[5] = ".gif";
	dotpos = strVal.indexOf(".");
	strExtension = strVal.substring(dotpos);
	for (i=0;i<=arrExtension.length-1;i++)
	{
		 
		if (arrExtension[i] == strExtension)
		{		
				return true;
		}
	}
	alert(strMsg);
	return false;
}
function checkDecimal(strValue, strMsg, noofdecimal)
{ 
	if (strValue.indexOf(".") >= 0 )
	{
		if (strValue.indexOf(".") != strValue.lastIndexOf("."))
		{
			alert("Only one decimal point is allowed");
			return false;
		}
		else
		{
			var strDecimal;
			strDecimal = strValue.substring(strValue.indexOf("."), strValue.length)
			if (strDecimal.length > noofdecimal )
			{
				tmpno = noofdecimal-1 ;
				alert("Only 2 digits allowed after decimal points");
				//ctrlName.value = strVal.substring(0,strVal.length -1);
				return false
			}
			else
			{
				if (strValue.length == 1)
				{
					alert("Only decimal point not allowed");
					return false;
				}
				else
					return true;
			}
		}
	}
	else
	{
		return true;
	}
}

function chkEmail(strValue,strMsg)
{
	var atsign;
	var dotsign;
	atsign = strValue.indexOf("@") 
	dotsign = strValue.indexOf(".") 
	if (atsign > 0 && dotsign > 0 && dotsign > atsign)
	{
		return true;
	}
	else
	{
		alert(strMsg);
		return false;
	}
}//end of chkmail

function checkspace(strValue, strMsg)
{
		if(strValue== "" )
		{
				alert(strMsg);
				return false;
		}
		return true;
}

function validatechar(strValue, strMsg)
{
	var i, strnum;
	for(i=0; i<=strValue.length-1; i++)
	{
		strnum = strValue.charCodeAt(i);
		if ((strnum >= 48 && strnum <=57) || (strnum >= 65 && strnum <=90) || (strnum >= 97 && strnum <=122) || strnum == 39 || strnum == 32 || strnum == 45)
		{
		}
		else
		{
			alert(strMsg);
			return false;
		}
	}
	return true;
}
function validatechar1(strValue, strMsg)
{
	var i, strnum;
	for(i=0; i<=strValue.length-1; i++)
	{
		strnum = strValue.charCodeAt(i);
		if ((strnum >= 48 && strnum <=57) || (strnum >= 65 && strnum <=90) || (strnum >= 97 && strnum <=122) || strnum == 39 || strnum == 32 || strnum == 45 || strnum == 44)
		{
		}
		else
		{
			alert(strMsg);
			return false;
		}
	}
	return true;
}

function num(strValue, strMsg)
{
	var i, strnum;
	for(i=0; i<=strValue.length-1; i++)
	{
		strnum = strValue.charCodeAt(i);
		if (strnum >= 48 && strnum <=57)
		{
		}
		else
		{
			alert(strMsg);
			return false;
		}
	}
	return true;
}

function alphanum(strValue, strMsg)
{
	var i, strnum;
	for(i=0; i<=strValue.length-1; i++)
	{
		strnum = strValue.charCodeAt(i);
		if ((strnum >= 48 && strnum <=57) || (strnum >= 65 && strnum <=90) || (strnum >= 97 && strnum <=122))
		{
		}
		else
		{
			alert(strMsg);
			return false;
		}
	}
	return true;
}
function validatecard(strcardnum,cardtype)
{
	if (cardtype == 1)
	{
		if (strcardnum.substr(0,1) == "4" && strcardnum.split(" ").join().length == 16)
			return true;
		else
		{
			alert("Not a valid VISA card number");
			return false;
		}
	}
	else
	{
		if (cardtype == 2)
		{
			if (strcardnum.substr(0,1) == "5" && strcardnum.split(" ").join().length == 16)
				return true;
			else
			{
				alert("Not a valid MASTER card number");
				return false;
			}
		}
		else		
		{
			if (strcardnum.substr(0,1) == "3" && strcardnum.split(" ").join().length == 14)
				return true;
			else
			{
				alert("Not a valid AMERICAN EXPRESS card number");
				return false;
			}
		}
	}
}
function validpno(strValue, strMsg)
{
	var i, strnum;
	for(i=0; i<=strValue.length-1; i++)
	{
		strnum = strValue.charCodeAt(i);
		
		if ((strnum >= 48 && strnum <=57) || strnum == 32 || strnum == 45 || strnum == 40 || strnum == 41)
		{
		}
		else
		{
			alert(strMsg);
			return false;
		}
	}
	return true;
}

function numdot(strValue, strMsg)
{
	var i, strnum;
	for(i=0; i<=strValue.length-1; i++)
	{ 
		strnum = strValue.charCodeAt(i);
		if ((strnum >= 48 && strnum <=57) || (strnum==46))
		{ 
		}
		else
		{
			alert(strMsg);
			return false;
		}
	}
	return true;
}

function Trim(myval)
{
	var chklen=myval.length; 
	var pos=0;
	mychar = myval.charAt(0);

	while(pos>=0 || lstpos >=0)
	{
		pos=myval.indexOf(" ");
		if (pos==0)
		{
			myval=myval.substring(1,chklen);
			chklen = myval.length;
			mychar = myval.charAt(0);
		}
		lstpos=myval.lastIndexOf(" ");

		if (lstpos==chklen-1)
		{	
			myval=myval.substring(0,chklen-1);
			chklen=myval.length;
			mychar = myval.charAt(chklen-1);
		}
		
		if(mychar!=" ")
			break;
	}
	return myval;			
}

function changepage(filenm,i)
{

	document.listform111.cpage1.value = i;
	document.listform111.action = filenm;
	document.listform111.submit(); 	
}

function changepage(filenm,i)
{

	document.listform111.cpage1.value = i;
	document.listform111.action = filenm;
	document.listform111.submit(); 	
}

function changepage(filenm,i)
{

	document.listform111.cpage1.value = i;
	document.listform111.action = filenm;
	document.listform111.submit(); 	
}

function searchcheck()
{


if (!checkInt1(document.frmpsearch.txtprice.value))
		{
			alert("Please enter only numeric value in price.");
			document.frmpsearch.txtprice.value = "";
			document.frmpsearch.txtprice.focus();
			return false;
		}	
}

function checkInt1(a)
	{
		
		var Anum = "0123456789.,";
		for (i=0;i<a.length;i++)
		{
			if (Anum.indexOf(a.substr(i,1)) == -1)
			{
				//alert(Anum.indexOf(a.substr(i,1)) + "," + a.substr(i,1));
				return false;
			}
			
		}
		return true
		} 


function changepage(filenm,i)
{

	document.listform111.cpage1.value = i;
	document.listform111.action = filenm;
	document.listform111.submit(); 	
}









