function WindowXPosition(widthX,heightX,windowName)
{
	var width = (screen.width);
	var height = (screen.height - 25);
	var centerleft = 0;
	var centertop = 0;
	var centerleft = (width/2) - (widthX/2);
	var centertop = (height/2) - (heightX/2);
	var width=widthX;
	var height=heightX;
	windowName.moveTo(centerleft,centertop);
	windowName.resizeTo(width, height);
	windowName.focus();
}

function WindowXXPosition(widthX,heightX,windowName) //same as above, only it takes %age vals as params for width n height
{
	var width = (screen.width);
	var height = (screen.height - 25);
		
	var wt = (width * widthX) / 100;
	var ht = (height * heightX) / 100;

	var centerleft = (width/2) - (wt/2);
	var centertop = (height/2) - (ht/2);

	windowName.resizeTo(wt, ht);
	windowName.moveTo(centerleft,centertop);
	windowName.focus();
}

function CheckRealNum(obj)
{
	regExpr=new RegExp(/^-?\d*(\.\d{1,2})?$/);
	
	if(!regExpr.test(obj.value))
	{
		alert("Please Enter Valid Amount");
		obj.value="0";		
	}
}

function CheckNum(obj)
{	
	regExpr=new RegExp(/^\d*$/);
	
	if(!regExpr.test(obj.value))
	{
		alert("Please Enter Valid Numbers");
		obj.value="0";		
	}
}

function CheckIfImageFile(path)
{
	if(path!="")
	{
		index=path.lastIndexOf(".");
		ext=path.substr(index);
		if(ext!='.jpg'&&ext!='.gif'&&ext!='.jpeg'&&ext!='.png'&&ext!='.JPG'&&ext!='.PNG')
		{
			alert("Please Enter only Image files");
			return 1;
		}
	}
	return 0;

}// JavaScript Document

function IsNumeric(obj)
{   
	var sText = obj.value;
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 

		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
			obj.value="";
			obj.focus();
			alert("Please Enter Numerics Only");
		}
	}
	return IsNumber;   
}

function doHourglass()
{
	document.body.style.cursor = 'wait';
}

function undoHourglass()
{
	document.body.style.cursor = 'default';
}

//given the value, str_trim trims down the string from all padded whitespaces...
function str_trim(str)
{	
	if(str.length > 0)
		while(str.charAt(0)==' ')
			str = str.substr(1);
		
	if(str.length > 0)
		while(str.charAt((str.length - 1))==' ')
			str = str.substring(0, str.length-1);
	
	return str;
}

function DeleteData(frm, txt)
{
	var frm = eval("document." + frm);
	var msg = "You Are About To Delete this " + txt + "! Continue?";
	if(confirm(msg))
	{
		frm.mode.value = 'D';
		frm.submit();
	}
}

function validate_email(email_txt)
{
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@([\\w].+)\.[\\w]$";
	var regex = new RegExp(emailReg);
	return regex.test(email_txt);
}