function ChangeInputType(oldElm,iType,iValue,noFocus) {
	if(!oldElm || !oldElm.parentNode || (iType.length<4) || !document.getElementById || !document.createElement) 
		return;	
	var newElm = document.createElement('input');
	newElm.type = iType;
	if(oldElm.name) 
		newElm.name = oldElm.name;
	if(oldElm.id) 
		newElm.id = oldElm.id;
	if(oldElm.className)
		newElm.className = oldElm.className;
	if (oldElm.style)
		newElm.style.width = oldElm.style.width; 
		newElm.style.height = oldElm.style.height; 
		newElm.style.float = oldElm.style.float; 
		newElm.style.margin = oldElm.style.margin; 
		newElm.style.padding = oldElm.style.padding;
		
	newElm.onfocus = function() 
	{
		if(this.hasFocus) 
			return;
		var newElm = ChangeInputType(this,'password', (this.value=='Password')?'':this.value);
		if(newElm) 
			newElm.hasFocus=true;
	}
	newElm.onblur = function() 
	{
		if(this.hasFocus)
		if(this.value=='' || this.value=='Password') 
		{
			ChangeInputType(this,'text','Password',true);
		}
	}
	newElm.onkeydown = function(e)
	{
		if (BrowserDetect.browser == 'Explorer')
		{
			if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) 
			{
				remember();
				document.Form1.submit();
			}
		}
		else
		{
			if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) 
			{
				remember();
				document.Form1.submit();
			}
		}
	}
	// hasFocus is to prevent a loop where onfocus is triggered over and over again
	newElm.hasFocus=false;
	oldElm.parentNode.replaceChild(newElm,oldElm);
	if(iValue) 
		newElm.value = iValue;
	if(!noFocus || typeof(noFocus)=='undefined') 
	{
		window.tempElm = newElm;
		setTimeout("tempElm.hasFocus=true;tempElm.focus();",2);
	}
	return newElm;
}

function Load(){
	window.onload = function() {
		var ua = navigator.userAgent.toLowerCase();
  		if(!((ua.indexOf('konqueror')!=-1) && (document.all || (ua.indexOf('khtml/3.4')!=-1))) && !(((ua.indexOf('safari')!=-1) && !window.print) || (document.defaultCharset && !window.print)))
		{
			if(document.Form1.remeber.checked)
			{
				ChangeInputType(document.forms[0].password,'password',document.forms[0].password.value,true);	
			}
			else
			{
				ChangeInputType(document.forms[0].password,'text','Password',true);	
			}
			
		}
      	
	}
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function WaterMarkPassword(){
	document.getElementById('password').initialValue = document.getElementById('password').value;
	document.getElementById('password').onfocus = function ()
	{
		if (this.value == this.initialValue)
		{
			this.value = "";
			document.getElementById('password').type = "password";
		}
	}

	document.getElementById('password').onblur = function ()
	{
		if (this.value == "")
		{
			document.getElementById('password').type = "text";
			this.value = this.initialValue;
		}
	}
	
//	document.getElementById('password').onkeydown = function()
//	{
//		if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
//		{
//			remember();
//			document.Form1.submit();
//		}
//	}

}

function WaterMarkAccount(){
	document.getElementById('account').initialValue = document.getElementById('account').value;
	document.getElementById('account').onfocus = function ()
	{
		if (this.value == this.initialValue)
		this.value = "";
	}

	document.getElementById('account').onblur = function ()
	{
		if (this.value == "")
		this.value = this.initialValue;
	}
}

function RememberCookies(){
var ca=GetCookie("usrinfo");
var ps=GetCookie("passinfo");
var rm=GetCookie("reminfo");

if ((ca!=null)&&(ps!=null)){
	document.Form1.account.value = ca;
	document.Form1.password.value=ps;
	document.Form1.password.style.display='inline';
	document.Form1.remeber.checked=rm
}
else{
	document.Form1.account.value = "Account #";
	document.Form1.password.value="";
	document.Form1.remeber.checked=false;
  }
}

// Get Cookie Value function
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1) endstr = document.cookie.length;
return unescape (document.cookie.substring(offset, endstr));
}

// Get Cookie function
function GetCookie(name) {
var arg = name+"=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
  i = document.cookie.indexOf(" ", i) + 1;
  if (i == 0) break;
}
return null;
}

function remember() 
{
	var expires = new Date ();
	//alert(document.Form1.remeber.checked);
	if(document.Form1.remeber.checked)
	{
		expires.setTime (expires.getTime() + (1000 * 60 * 60 * 24 * 31));
		document.cookie = "usrinfo="+document.Form1.account.value+"; expires=" + expires.toGMTString() +"; path=/";
		document.cookie = "passinfo="+document.Form1.password.value+"; expires=" + expires.toGMTString() +"; path=/";
		document.cookie = "reminfo="+document.Form1.remeber.checked+"; expires=" + expires.toGMTString() +"; path=/";
	}
	else
	{
		delete_cookie("usrinfo","/");
		delete_cookie("passinfo","/");
		delete_cookie("reminfo","/");
	}
	/*document.Form1.submit;*/
}

function delete_cookie (name, path)
{
// Build expiration date string:
var expiration_date = new Date ();
expiration_date . setYear (expiration_date . getYear () - 1);
expiration_date = expiration_date . toGMTString ();

// Build set-cookie string:
var cookie_string = escape (name) + "=; expires=" + expiration_date;
if (path != null)
	cookie_string += "; path=" + path;

// Delete the cookie:
document . cookie = cookie_string;
}

function Submit1_onclick() {
/*createCookie(loginname,document.Form1.account.value+"#"+document.Form1.password.value,365);*/
}

