//sniff - ADAPTED FROM NETSCAPE WITH PERMISSION
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_nav5   = (is_nav && (is_major == 5));
var is_nav5up = (is_nav && (is_major >= 5));
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);

var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3 = (is_ie && (is_major < 4));
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up = (is_ie  && (is_major >= 4));
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up = (is_ie  && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

var is_aol   = (agt.indexOf("aol") != -1);
var is_aol4  = (is_aol && is_ie4);

var is_opera = (agt.indexOf("opera") != -1);
var is_webtv = (agt.indexOf("webtv") != -1);

var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac = (agt.indexOf("mac")!=-1);

var nscp4 = is_nav4
var ie4   = is_ie4
var dom1  = (is_nav6up || is_ie5up)

if (is_mac && is_ie5){dom1 = false}

var hardCode = 0;


origWidth = is_ie ? screen.width : window.outerWidth;
origHeight =  is_ie ? screen.height : window.outerHeight;
function resizeHandler() {
	if (!nscp4 || window.outerWidth == origWidth && window.outerHeight == origHeight){return;}
	location.reload();
}
window.onresize = resizeHandler;


//open window - no scrollbars, resizable
function opiWin(url, x, y){
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;
	
    var xOffset = (xMax - x)/2, yOffset = (yMax - y)/2;
    window.open(url,'genWin','width=' +x+ ',height=' +y+ ',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',resizable=yes,status=no,scrollbars=no');
}

//open window - resizable=yes,status=yes,scrollbars=yes
function opAdminWin(url, x, y, winName){
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;
	
    var xOffset = (xMax - x)/2, yOffset = (yMax - y)/2;
	if(!winName){winName = 'adminWin';}
    launch(url,winName,'width=' +x+ ',height=' +y+ ',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',resizable=yes,status=yes,scrollbars=yes', "parentWin");
}

//open window - resizable=yes,status=yes,scrollbars=yes
function opPrintWin(url, x, y){
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;
	
    var xOffset = (xMax - x)/2, yOffset = (yMax - y)/2;
    launch(url,'printWin','width=' +x+ ',height=' +y+ ',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',resizable=yes,status=yes,scrollbars=yes,menubar=yes,toolbar=yes', "parentWin");
}

function launch(newURL, newName, newFeatures, orgName) {
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}


//Verify is integer
//usage:  onkeyup="intCheck(this);"
var acceptableIntChars = "0123456789.";
//var acceptableIntChars = "0123456789.,$-%";
function intCheck(field){
	var iValue = parseInt(field.value);
	lastChar = field.value.charAt(field.value.length-1);
	if (acceptableIntChars.indexOf(lastChar) == -1){
	 	alert("This field only accepts numbers");
		if (field.value.length == 1){field.value = 0;}
		else{field.value = parseFloat(field.value.substring(0, (field.value.length - 1)));}		
		field.focus();
	}
}
//Limit length of text area
//usage: <textarea onKeyDown="textAreaLimit(this,1024);" onKeyUp="textAreaLimit(this,1024);">blah</textarea>
function textAreaLimit(field, maxlimit){
    if (field.value.length > maxlimit){
        field.value = field.value.substring(0, maxlimit);
        alert("You have exceeded the maximum limit of " + maxlimit +" characters.");    
    }
}
