////////////////////////////////////////////////
// Configuration:
///////////////////////////////////////////////
//window.onerror = error
window.onload = init




////////////////////////////////////////////////
// Functions:
///////////////////////////////////////////////

////////////////////////////////////////////////
// Description: Supresses any error messages
///////////////////////////////////////////////
function error() {
	return true
}

////////////////////////////////////////////////
// Description: XHTML standard way of rendering links for external targets.  Use 
//	syntax - <a href="" rel="external">Link</a> and call on the onload statement
///////////////////////////////////////////////
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
////////////////////////////////////////////////
// Description: Opens a window with the specified url, width and height
///////////////////////////////////////////////
function WinOpeninternet(url, width, height) {
	remote = window.open(url,"","toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,status=no,width=" + width + ",height=" + height);
	if (remote.opener == null) remote.opener = window; 
	remote.opener.name = "opener";

}

////////////////////////////////////////////////
// Description: Opens a window with the specified url, width and height centered on the screen
///////////////////////////////////////////////
function OpenCenteredWindow(url, width, height) {
	var remote = window.open(url,'New_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=Yes,resizable=no,copyhistory=no,width='+width+',height='+height);
	remote.moveTo(screen.availWidth/2-(width/2),screen.availHeight/2-(height/2));
	remote.focus();
	if (remote.opener == null) remote.opener = window; 
	remote.opener.name = "opener";
}

////////////////////////////////////////////////
// Description: Overwrite our css for netscape
///////////////////////////////////////////////
function css() {

	// BROWSER CHECK
	var browser = navigator.appName;
	var appVer = parseInt(navigator.appVersion);
	var ie = "Microsoft Internet Explorer";
	var ns = "Netscape";
	if (navigator.appVersion.indexOf("Macintosh") != -1) {
		isMac = true;
	} else {
		isMac = false;
	}


	if (!isMac && browser == ns && appVer < 5)  {
		//document.styleSheets[0].disabled = true
		document.writeln('<link rel="stylesheet" type="text/css" media="screen" href="/css/basic_NN4.css">')	
	}

}
////////////////////////////////////////////////
// Description: Initializes a few things when the window loads
///////////////////////////////////////////////
function init() {
	externalLinks()

	// tracking
	if (GetScreenWidth() != '') 		setCookie("width", GetScreenWidth());
	if (GetScreenHeight() != '') 		setCookie("height", GetScreenHeight());
	if (GetColorDepth() != '') 			setCookie("colors", GetColorDepth());
	
}
////////////////////////////////////////////////
// Description: Returns a cookie
///////////////////////////////////////////////
  function getCookie(name) { // use: getCookie("name");
    var bikky = document.cookie
    var index = bikky.indexOf(name + "=");
    if (index == -1) return null;
    index = bikky.indexOf("=", index) + 1;
    var endstr = bikky.indexOf(";", index);
    if (endstr == -1) endstr = bikky.length;
    return unescape(bikky.substring(index, endstr));
  }
////////////////////////////////////////////////
// Description: Sets a session cookie
///////////////////////////////////////////////
function setCookie(key, value) {
	document.cookie = key + "=" + value + ";path=/"
}

////////////////////////////////////////////////
// Description: Sets a permanent cookie
///////////////////////////////////////////////
function setPermCookie(key, value) {
	var when = new Date()
	when.setMonth(when.getMonth()+12)
	var dt = when.toGMTString().toString()
	document.cookie = key + "=" + value + "; expires=" + dt + ";path=/;"
}
////////////////////////////////////////////////
// Description: Deletes a cookie
///////////////////////////////////////////////
function delete_cookie(name){
	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
////////////////////////////////////////////////
// Description: Deletes a cookie
///////////////////////////////////////////////
function delCookie (NameOfCookie) {
	document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

////////////////////////////////////////////////
// Description: Returns a cookie
///////////////////////////////////////////////
function find_cookiename(name) {
	var str = document.cookie
	var part = str.split(";")
	var part1 = part[0].split("=")
	var arg = part1[0]
	//alert(arg)
if (name == arg) {
	return(true)
}else {
	return(false)
}
}

////////////////////////////////////////////////
// Description: Returns true if the browser if version 4 and above
///////////////////////////////////////////////
function Is4() {
         if (parseInt(navigator.appVersion) >= 4) {
             return(true)
         } else {
             return(false)
         }
}

////////////////////////////////////////////////
// Description: Returns screen width
///////////////////////////////////////////////
function GetScreenWidth() {
         if (Is4()) {
             return(screen.width)
         } else {
             return("")
         }
}
////////////////////////////////////////////////
// Description: Returns screen height
///////////////////////////////////////////////
function GetScreenHeight() {
         if (Is4()) {
             return(screen.height)
         } else {
             return("")
         }
}
////////////////////////////////////////////////
// Description: Returns color depth
///////////////////////////////////////////////
function GetColorDepth() {
	// 256 - 8
	// 16 bit - 14
	// 24
         if (Is4()) {
             return(screen.colorDepth)
         } else {
             return("")
         }
}

////////////////////////////////////////////////
// Description: Returns connection type
///////////////////////////////////////////////
function GetConnectionType() {
    var ret = ""
    if (navigator.appName == "Microsoft Internet Explorer") {
        ret = oClientCaps.connectionType
    }

    if (ret == "") {
        ret = ""
    }
    return(ret)
}

////////////////////////////////////////////////
// Description: Returns date time stamp
///////////////////////////////////////////////
function GetDateTimeStamp() {
	var dt = new Date()
	var adjYear = dt.getYear()
	if(dt.getYear().toString().length == 3) { adjYear = dt.getYear() + 1900 }
	//alert(adjYear)
	var rtrn = dt.getMonth()+1  +"/"+ dt.getDate() +"/"+ adjYear +" " //+ dt.getHours() +":"+ dt.getMinutes() +":"+  dt.getSeconds()
	if (dt.getHours() > 12) {
		rtrn += dt.getHours()-12 +":"+ dt.getMinutes() +":"+  dt.getSeconds() + " PM"
	} else {
		rtrn += dt.getHours() +":"+ dt.getMinutes() +":"+  dt.getSeconds() + " AM"
	}
	//alert(rtrn)
	return(escape(rtrn))

}





