/*
	main.js
	06/01/2005 - CH - added init() to handle functions to be called onload.
	04/25/2005 - CH - copied rollover.js fcns to this file.
	04/25/2005 - CH - created popWin() and re-wrote legacy fcns to use it.
	
	usage of this file deprecates:
		rollover.js
		popup.js
		popup-legacy.js
*/


/* init */
window.origInit = window.init;
if( window.origInit == null ) window.origInit = function(){}
init = function( fcn ){
	if( ! window.initFunctions )
		window.initFunctions = new Array();
	if( typeof(fcn) == "string")
		window.initFunctions[ window.initFunctions.length ] = fcn;
	else{
		origInit();
		for( var i=0; i<window.initFunctions.length; i++ ){
			eval(window.initFunctions[i]);
		}
	}
}
onload=init


/* rollover */
function RollOverOn(target) {
	if (document.images) {
		if (typeof (target) == "string") {
			if (typeof (eval(document[target])) == "object") document[target].src = this.OnImage.src;
		} else if (typeof (target) == "object") {
			target.src = this.OnImage.src;
		}
	}
	this.State = "ON";
}
function RollOverOff(target) {
	if (document.images) {
		if (typeof (target) == "string") {
			if (typeof (eval(document[target])) == "object") document[target].src = this.OffImage.src;
		} else if (typeof (target) == "object") {
			target.src = this.OffImage.src;
		}
	}
	this.State = "OFF";
}
function RollOverToggle(target) {
	if (this.State == "OFF") this.On(target)
	else this.Off(target);
}
function RollOver(OffSrc, OnSrc) {
	if (document.images) {
		this.OffImage = new Image();
		this.OffImage.src = OffSrc;
		this.OnImage = new Image();
		this.OnImage.src = OnSrc;
	}
	this.State = "OFF";
	this.Off = RollOverOff;
	this.On = RollOverOn;
	this.Toggle = RollOverToggle;
}


/* popup windows */
function popWin( url, name, width, height, extra ){
	if( !name ) name = "popWin";
	if( !width ) width = 400;
	if( !height ) height = 300;
	if( !extra ) extra = "";
	var left = (screen.availWidth - width) /2;
	var top = (screen.availHeight - height) /2;
	var params = "width="+ width + ", height=" + height + ", " + "top="+ top + ", left=" + left + ", " + extra;
	var popupWindow = window.open( url, name, params );
	popupWindow.focus();
}
/* begin legacy popup fcns */
function popupWindow(theURL){ popWin( theURL, '_blank', 695, 550, 'scrollbars=1, resizable=1, status=1' ); return false; }
function pu( url, width, height, left, top ){ if(width==null) width=450; if(height==null) height=600; popWin( url, 'pu_window', width, height, 'directories=0, location=0, menubar=0, resizable=yes, scrollbars=1, status=0, toolbar=1' ); }
function popup(){ var popupWin; self.name = "parent"; if (! popupWin || popupWin.closed){ popWin( "", "new_win", 450, 450, "directories=0, location=0, menubar=1, resizable=1, scrollbars=1, status=0, toolbar=0" ); } document.email2friend.submit(); }
/* end legacy popup fcns */


/* cookies */
function getCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1){
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else{
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1){
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/* browser sniffer */
function Is(){
	var appName = navigator.appName;
	var version = navigator.appVersion;
	
	this.ns = ( appName == "Netscape" );
	this.ns4 = this.ns && version.indexOf("4.")!=-1;
	this.ns5 = this.ns && version.indexOf("5.")==0;
	this.ns6 = ( this.ns5 || (this.ns && version.indexOf("6.")!=-1) );

	this.ie = ( appName == "Microsoft Internet Explorer" );
	this.ie4 = this.ie && version.indexOf("MSIE 4.")!=-1;
	this.ie5 = this.ie && version.indexOf("MSIE 5.")!=-1;
	this.ie6 = this.ie && version.indexOf("MSIE 6.")!=-1;
	
	var userAgent = navigator.userAgent.toLowerCase()
	this.mac = ( userAgent.indexOf( "mac" ) != -1 )
	this.win = ( userAgent.indexOf( "windows" ) != -1 )
	this.linux = ( userAgent.indexOf( "linux" ) != -1 )
}
Is.prototype.toString = function(){
	var s = ''
	for( var i in this ){
		s += i + ': ' + this[i] + '\n'
	}
	return s;
}
var is = new Is();