function popuppage(pgname)
{
	window.open(pgname, 'PopupWindow', 'width=200,height=200,scrollbars=no,resizable=no');
}
function Trim(str)
{
	return str.replace(/\s/g,"");
}
function isNumeric(obj)
{
	if(obj.value.search(/[^0-9]/) != -1) // only number checking
	{
		alert('The field must contain number only');
		obj.value="";
		obj.focus();
		return false;			
	}
	return true;
}
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 IsTrim(obj, msgstr)
{
	if(Trim(obj.value)=="")
	{
		alert(msgstr);
		obj.focus();
		return false;
	}
	return true;
}
function IsEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
		return false;
}

function ImageUploadChecking()
{
/*	var field = "photo";
	var photo = document.forms["main"][field].value
	var type = photo.substring(photo.length-4, photo.length).toUpperCase()
	if ((type != "") &&
		(type != ".JPG") &&
		(type != "JPEG") &&
		(type != ".GIF") &&
		(type != ".PNG") &&
		(type != ".BMP")) 
	{
		alert("Please only enter image file of type JPG, JPEG, GIF, PNG, or BMP.");
		document.forms["main"][field].focus();
		return false;
	}*/
}