// JavascriptStore

function OpenDialogWindow(url, name, w, h)
{
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);	
	win = window.open(url, name, 'toolbar=0, status=1, menubar=0, location=0, resizable=1, scrollbars=auto, dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
	win.focus();
}

function GetDialogResult(command, parameter)
{
	FindObject('DialogResultCommand').value=command;
	FindObject('DialogResultParameter').value=parameter;
	FindObject('DialogResultIsReceipt').value='1';
	FindObject('Form1').submit();
}

function Popup(url,w,h,rs,sc){
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);	
	window.open(url,'','toolbar=0, status=1, menubar=0, location=0, resizable='+rs+', scrollbars='+sc+', dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l).focus();
}

// End Javascript store




var isNS = (navigator.appName.indexOf("Netscape")!=-1); 

function FindObject(n, d)
{
  var p,i,x;  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
		for (i=0;!x&&i<d.forms.length;i++) 
				x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=FindObject(n,d.layers[i].document);
  if(!x && document.getElementById) 
		x=document.getElementById(n); 
	return x;
}

function onlyNumber(e) 
{
	var keyCode = (isNS) ? e.which : e.keyCode;
	if ((keyCode<48 || keyCode>57)&&keyCode!=8&&keyCode!=0){
	return false;}
}

function onlyLetter(e) 
{
	var keyCode = (isNS) ? e.which : e.keyCode;
	if (keyCode > 47 && keyCode<58){
		return false;
	}
}

function CheckEmail(TmpStr) 
{
	if (TmpStr=="")
	{
		return true;
	}
	else
	{
		var i, atPos, atPos2, InvalidChars=" üÜðÐýþÞÝçÇöÖ!#/*{[()]}";

		for (i=0; i<InvalidChars.length; i++)
			if (TmpStr.indexOf(InvalidChars.charAt(i)) != -1) {
				return false;
			}
		atPos = TmpStr.indexOf("@");
		atPos1 = TmpStr.indexOf(".");
		atPos2 = TmpStr.indexOf("@", atPos+1);
		if ((atPos < 1) || (atPos1 < 1) || (atPos2 != -1)) {
			return false;
		}
	}
}

function autoTab(input,focus, len, e) { 
	var keyCode = (isNS) ? e.which : e.keyCode; 
	if (keyCode == 13)  window.event.keyCode = 9;
	var filter = (isNS) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
	if(input.value.length >= len && !containsElement(filter,keyCode)) { 
		input.value = input.value.slice(0, len); 
		document.all[focus].focus();
	//	input.form[(getIndex(input)+1) % input.form.length].focus(); 
	} 
	return true; 
}

function trim(str)
{
	while(str.charAt(0)==' ')
		str=str.substring(1,str.length);
	while(str.charAt(str.length-1)==' ')
		str=str.substring(0,str.length-1);
	return str;
}

function isNumber(theElement)
{
	var s = Math.abs(theElement.value);
	var filter=/(^\d+$)/;
	if (s.length == 0 ) return true;
	if (isNaN(theElement)) return true;
	if (filter.test(s))
		return true;
	else {
		return false;
	}
}

function PressTabInsteadOfEnter(elementIDToFocus, doPostBackForElement){
		keyCode=(document.layers)?e.which:window.event.keyCode;
		if (keyCode == 13){
			window.event.keyCode = 9;
			FindObject(elementIDToFocus).focus();
			if (doPostBackForElement)
				__doPostBack(elementIDToFocus,'');
		}
		return true;
}

function Flash(objID)
{
		var obj  = FindObject(objID);
		
		if (obj.style.visibility == 'hidden')
			obj.style.visibility = 'visible';
		else
			obj.style.visibility = 'hidden';
		
		window.setTimeout("Flash('"+objID +"')", 500);
}

function SetVisibilityForElement(objID)
{
    var obj  = FindObject(objID);
    if (obj.style.display == 'none')
			obj.style.display = 'block';
		else
			obj.style.display = 'none';
		
}


