function selectItem(list,item)
{	
	for (i = 0;i<list.options.length;i++)
		if (list.options[i].value == item)
			list.options[i].selected = true;
		else
			list.options[i].selected = false;
}

function isNumber(s)
{   
    var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if ((c < "0") || (c > "9")) return false;
    }
    // All characters are numbers.
    return true;
}

function isDouble(x){
	
	return (!isNaN(x) );
	//var reg = /^d+.?d*$/;
	//return( reg.test(x) )
}

function IsValidEmail(Email)
{
	var regex = /^[\w\.-]+@[\w\.-]+\.[a-zA-Z]{2,3}$/
    if (!regex.test(Email)) 
        return (false);
    else
		return (true);   

}

function SetFocus(ControlID)
{
	var Control = document.getElementById(ControlID);
	if (window.event.keyCode == 13)	
			Control.focus(ControlID);
}

function Redirect(Path)
	{
		setTimeout("ToPage('"+Path+ "')",2500);
	}
function ToPage(Path)
	{
 		window.location=Path;
	}
	

function isInteger(s)
{   
    var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if ((c < "0") || (c > "9")) return false;
    }
    // All characters are numbers.
    return true;
}

function Popup(Path,Height,Width)
	{	var result
		//window.open(Path,"","Height="+Height+",width="+Width+",left="+((screen.width/2)-(Width/2))+",top="+((screen.height/2)-(Height/2))+",resizable=no,scrollbars=no,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no");
	  result = window.showModalDialog(Path,"","dialogHeight:"+Height+"px;dialogWidth:"+Width+"px;center:yes;edge:raised;resizable:no;maximize:yes;scroll:no;help:no;status:no");
	  //if (result == null)
		//	result = "";
	  return (result);
	}
	
	function PopupWin(Path,Height,Width)
	{
		window.open(Path,"new_page","Height="+Height+",width="+Width+",left="+((screen.width/2)-(Width/2))+",top="+((screen.height/2)-(Height/2))+",resizable=yes,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no");
	}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			//alert((obj.offsetParent).id);
			//alert("offset to " + (obj.offsetParent).id + " = " + obj.offsetLeft);
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
	

function formatNumber(expr, decimals) {
	var str = "" + Math.round( eval(expr) * Math.pow(10,decimals))
	while (str.length <= decimals) { str = "0" + str } 
	var decpoint = str.length - decimals; 
	var result = str.substring(0,decpoint);
	if (decimals) result += "." + str.substring(decpoint,str.length);
	result = result * 1.0;
	return result;
}

function SetCombo(ControlID,Val)
{
	var Contrl = document.getElementById(ControlID);
	
	for (i=0; i< Contrl.length ; i++)
	{   
		if (Contrl.options[i].value==Val)
			{
				Contrl.selectedIndex = Contrl.options[i].index;
				break;
			}
	}
	
}
	function PopupWin1(Path,Height,Width,Title)
	{
		window.open(Path,Title,"Height="+Height+",width="+Width+",left="+((screen.width/2)-(Width/2))+",top="+((screen.height/2)-(Height/2))+",resizable=no,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,copyhistory=no,location=no");
	   //window.showModalDialog(Path,"","dialogHeight:"+Height+"px;dialogWidth:"+Width+"px;center:yes;edge:raised;resizable:no;scroll:no;help:no;status:no");
	}
