function popuppage(pgname)
{
	window.open(pgname, "PopupWindow", "width=200, height=200, resizable=0, scrollbars=0");
}
function Trim(str) 
{
	return str.replace(/\s/g,"");
}
function isNumeric(obj)
{		
	if(obj.value.search(/[^0-9]/) != -1) // only number checking
	{
		alert('The Order ID field must contain number only');
		obj.value="";
		obj.focus();
		return false;			
	}
}
function isPrice(obj)
{	
	if((obj.value.search(/[^0-9.]/) != -1) || (dotCheck(obj.value) > 1))  
	{
		alert('Amount must be valid');
		obj.value="";
		obj.focus();
		return false;			
	}
}
function dotCheck(val)
{
	count = 0;
	for(dot=0; dot<val.length; dot++)
	{
		if(val.substring(dot,dot+1) == '.') 
			count++;
	}
	return count;
}
function dateformat(obj)
{
	var f = eval(obj); 
	var f_val = f.value;
	ind1 = f_val.charAt(2);
	ind2 = f_val.charAt(5);
	if(f_val!= "" && ind1!="-" && ind2!="-")
	{
		if(f_val.length < 8)
		{
			alert("Date must have at least 8 digits (MMDDYYYY).")	
			f.focus();
		}
		else
			f.value = f_val.substring(0,2) +"-"+ f_val.substring(2,4) +"-"+ f_val.substring(4,f_val.lenght);
	}	
}

function emailvalidation(field)
{
	var i=0;
	var j=0;
	var str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var strchr = "!#$%^,&*()=+''?{}[]|\/:;~`";
	var strat = "@";
	var strdot = ".";
	var flag = 0;	
	var countat = 0;
	var countdt = 0;
			
	if (field.length < 6)
	{
		flc=1;		
		return("Not a valid E-mail address");
	}
	else 
	{
		flag = 0;			
		for(i=0; i<=field.length-1; i++)
		{
			if(field.substring(i,i+1) == strat)
			{						
				flag = 1;
				break;	
			}
			countat = countat +1;
		}			
		if (flag == 0 ) 
		{
			flc=1;			
			return("There must be an @");
		}
		else
		{
			flag = 0;		
			for(i=0; i<=field.length-1; i++)
			{
				if(field.substring(i,i+1) == strdot)
				{
					flag = 1;
					break;	
				}
			countdt = countdt + 1;
			}
			
			if (flag == 0 ) 
			{
				flc=1;						
				return("There must be atleast one dot");				
			}
			else if (countdt == field.length - 1)
			{
				flc=1;				
				return("Not a vaild E-mail address");
			}
			else if (countat == countdt-1)
			{
				flc=1;				
				return("Not a valid E-mail address VERY NEXT");
			}
			else 
			{					
			 for (i=0; i<field.length; i++)
			 {
			 	for (j=0; j<strchr.length-1; j++)
		        {
					if (field.substring(i,i+1) == strchr.substring(j,j+1))
					{					
						flc=1;						
						return("Not a valid character " + strchr.substring(j,j+1));
						break;
		             }
	 		   	 }
			  }
		    }																	
		}							
	}
   return("0");
}
function verifymail(field)
{
	var i=0;
	var j=0;
	var str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var strchr = "!#$%^,&*()=+''?{}[]|\/:;~`";
	var strat = "@";
	var strdot = ".";
	var flag = 0;	
	var countat = 0;
	var countdt = 0;
			
	if (field.value.length < 6)
	{
		flc=1;
		alert("Not a valid E-mail address");
		field.focus();
		field.value="";
		return false;
	}
	else 
	{
		flag = 0;
			
		for(i=0; i<=field.value.length-1; i++)
		{
			if(field.value.substring(i,i+1) == strat)
			{						
				flag = 1;
				break;	
			}
			countat = countat +1;
		}
			
		if (flag == 0 ) 
		{
			flc=1;
			alert("There must be an @");
			field.focus();		
			field.value="";
			return false;
		}
		else
		{
			flag = 0;
		
			for(i=0; i<=field.value.length-1; i++)
			{
				if(field.value.substring(i,i+1) == strdot)
				{
					flag = 1;
					break;	
				}
			countdt = countdt + 1;
			}
			
			if (flag == 0 ) 
			{
				flc=1;
				alert("There must be atleast one dot");
				field.focus();				
				return false;				
			}
			else if (countdt == field.value.length - 1)
			{
				flc=1;
				alert("Not a vaild E-mail address");
				field.focus();
				field.value="";
				return false;
			}
			else if (countat == countdt-1)
			{
				flc=1;
				alert("Not a valid E-mail address VERY NEXT");
				field.focus();
				field.value="";
				return false;
			}
			else 
			{					
			 for (i=0; i<field.value.length; i++)
			 {
			 	for (j=0; j<strchr.length-1; j++)
		        {
					if (field.value.substring(i,i+1) == strchr.substring(j,j+1))
					{					
						flc=1;
						alert("Not a valid character " + strchr.substring(j,j+1));
						field.focus();
						field.value="";
						return false;
						break;
		             }
	 		   	 }
			  }
		    }																	
		}							
	}
   return true;
}