if (document.layers){
	 document.captureEvents(Event.KEYPRESS);
	 document.onkeypress=function (evt) {
		 var key=document.all ? event.keyCode : evt.which ? evt.which : evt.keyCode;
		 if (key==13)
		 this.form.submit();
	}
}

//tak 12/24/2003 Added function.
function SendPassword()
{
var aUserName = (document.all && !document.getElementById) ?
document.all["username"] : document.getElementById("username");
if (aUserName.value == "") { 
	alert("Please enter your email username and click again.");
}
else {
	document.location.href  = "SendPassword.aspx?u=" + aUserName.value;
}
return(true);
}

function copytext(s) {
	window.clipboardData.setData("Text", s);
}

function newfolder(msg){
	var folder=prompt(msg,"");
	if ((folder!="") && (folder!=null))
	{
		document.listform.action="fileman.asp?a=newfolder&newfolder=" + escape(folder);
		document.listform.submit();
	}
}

function viewlog(msg,f){
	var findstr=prompt(msg,"");
	if (findstr!=null)
	{
		document.listform.action="fileman.asp?a=findtext&f="+ escape(f) + "&findstr="+escape(findstr);
		document.listform.submit();
	}
}

function findtext(msg){
for (var f, n=0, DL=document.listform, i=0; i<DL.elements.length; i++) {if ((DL.elements[i].name.indexOf('f')> -1)) {if (DL.elements[i].checked){n=n+1; }}}
if (n>0){
	var findstr=prompt(msg,"");
	if (findstr!=null)
	{
		document.listform.action="fileman.asp?a=findtext&findstr="+escape(findstr);
		document.listform.submit();
	}}
else {
	alert(sel_item_msg)
}}

function attribs(msg){
for (var f, n=0, DL=document.listform, i=0; i<DL.elements.length; i++) {if ((DL.elements[i].name.indexOf('f')> -1)) {if (DL.elements[i].checked){n=n+1; }}}
if (n>0) {
	var attr=prompt(msg,"");
	if ((attr!="") && (attr!=null))
	{
		document.listform.action="fileman.asp?a=attribs&attr="+escape(attr);
		document.listform.submit();
	}}
else {
	alert(sel_item_msg)
}}

function GetFromHistory(){
		document.listform.action="fileman.asp?a=list";
		document.listform.submit();
}

function zip_dl(){
for (var f, n=0, DL=document.listform, i=0; i<DL.elements.length; i++) {if ((DL.elements[i].name.indexOf('f')> -1)) {if (DL.elements[i].checked){n=n+1; }}}
if (n>0) {
		document.listform.action="fileman.asp?a=zip_dl";
		document.listform.submit();
	}
else {
	alert(sel_item_msg)
}}

function zip(msg){
for (var f, n=0, DL=document.listform, i=0; i<DL.elements.length; i++) {if ((DL.elements[i].name.indexOf('f')> -1)) {if (DL.elements[i].checked){f=DL.elements[i].value.toLowerCase();n=n+1; }}}
if (n>0) {
	if(f.indexOf("\\")!=-1){ var L=(f.length-1),S;
	 while(f.charAt(L)=="\\"){f=f.substring(0,L);L--;}
	S=f.split("\\"); f=S[(S.length-1)]; }
	var p=f.lastIndexOf(".");
	if (p!=-1) {f=f.substring(0,p);}
	var target=prompt(msg,f + ".zip");
	if ((target!="") && (target!=null)) {
		document.listform.action="fileman.asp?a=zip&target="+escape(target);
		document.listform.submit();
	}}
else {
	alert(sel_item_msg)
}}

function unzip(msg){
for (var f, n=0, DL=document.listform, i=0; i<DL.elements.length; i++) {if ((DL.elements[i].name.indexOf('f')> -1)) {if (DL.elements[i].checked){n=n+1; }}}
if (n>0) {
	if(confirm(msg)){
		document.listform.action="fileman.asp?a=unzip";
		document.listform.submit();}}
else {
	alert(sel_item_msg)
}}

function submitform(action){
for (var f, n=0, DL=document.listform, i=0; i<DL.elements.length; i++) {if ((DL.elements[i].name.indexOf('f')> -1)) {if (DL.elements[i].checked){n=n+1; }}}
if (n>0 || action == "paste") {
		document.listform.action="fileman.asp?a="+action;
		document.listform.submit();}
else {
	alert(sel_item_msg)
}}

function del(msg){
for (var f, n=0, DL=document.listform, i=0; i<DL.elements.length; i++) {if ((DL.elements[i].name.indexOf('f')> -1)) {if (DL.elements[i].checked){n=n+1; }}}
if (n>0) {
	if(confirm(msg+"?")){
		document.listform.action="fileman.asp?a=del";
		document.listform.submit();}}
else {
	alert(sel_item_msg)
}}

function rename(curtemplate,msg1,msg2){
for (var f, n=0, DL=document.listform, i=0; i<DL.elements.length; i++) {if ((DL.elements[i].name.indexOf('f')> -1)) {if (DL.elements[i].checked){f=DL.elements[i].value;n=n+1; }}}
if (n>0) {
	if (n==1) {
		if(f.indexOf("\\")!=-1){ var L=(f.length-1),S;
		 while(f.charAt(L)=="\\"){f=f.substring(0,L);L--;}
		S=f.split("\\"); f=S[(S.length-1)]; }
		msg=msg1;}
	else {
		f=curtemplate;
		msg=msg2;
	}
	var newname=prompt(msg,f);
	if ((newname!="") && (newname!=null)){
		document.listform.action="fileman.asp?a=rename&newname="+escape(newname);
		document.listform.submit();
		}
	}
else {
	alert(sel_item_msg)
}}

function CheckAll(){
	for (var i=0;i<document.listform.elements.length;i++) {
		var e=document.listform.elements[i];
		if (e.name !='allbox'){
			e.checked=document.listform.allbox.checked;
		}
	}
}

function ButtonOver(item) {
	item.className = "Button_sel";
	if (item.alt !=null) {
		window.status=item.alt;
	}
}

function ButtonOver1(item) {
	item.className = "3DLook1";
	if (item.alt !=null) {
		window.status=item.alt;
	}
}

function ButtonOff1(item) {
	item.className = "3DLook";
	window.status='GeoTMSWeb';
}

function ButtonOff(item) {
	item.className = "Button_unsel";
	window.status='GeoTMSWeb';
}


function confirmSQL(msg){
	var SQL=document.sqlform.SQL.value;
	if ((SQL!="") & (SQL.toUpperCase().indexOf('SELECT')<0)){
		if(confirm(msg))
			document.sqlform.submit();
		}
	else
			document.sqlform.submit();
	}

function CheckAllZips(){
	for (var i=0;i<document.unzip.elements.length;i++) {
		var e=document.unzip.elements[i];
		if (e.name !='allbox'){
			e.checked=document.unzip.allbox.checked;
		}
	}
}

function unzipitems(msg){
	if(confirm(msg+"?")){
		document.unzip.action="fileman.asp?a=unzipitems";
		document.unzip.submit();
	}
}

function Wrap(){
var f=document.editform;
 if(f.wrap.checked){
	f.body.wrap= 'off';
	}
 else{
	f.body.wrap= 'soft';
 }
}

//tak 1/12/04 Added some generic functions for form validation.
//-------------------------------------------------------------------
// isDigit(value)
//   Returns true if value is a 1-character digit
//-------------------------------------------------------------------
function isDigit(num) {
	if (num.length>1){return false;}
	var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
	}

//-------------------------------------------------------------------
// isInteger(value)
//   Returns true if value contains all digits
//-------------------------------------------------------------------
function isInteger(val){
	if (isBlank(val)){return false;}
	for(var i=0;i<val.length;i++){
		if(!isDigit(val.charAt(i))){return false;}
		}
	return true;
	}

function isChecked(oRadioGrp) {
var numItems;

numItems = oRadioGrp.length;
//tak 11/21/2007 There aren't any permits to apply for online currently, so, can't do anything
	if (typeof oRadioGrp == "undefined")
	{
	return false;
	}
    if (typeof oRadioGrp.length == "undefined") 
    { 
        // get value for single radio button 
        if (oRadioGrp.checked) 
			return true;
    } 
    else 
    { 
        // get value for group of radio buttons 
        for (var i=numItems-1; i>=0; i--) {
                if (oRadioGrp[i].checked) {
					return true; 
				}
        }
    } 
return false;
}

//-------------------------------------------------------------------
// isBlank(value)
//   Returns true if value only contains spaces
//-------------------------------------------------------------------
function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
	}