/*
 * JavaScript Code for support purpose
 *
 * $Id: support.js,v 1.2 2007-04-05 17:51:00 rafi Exp $
 */

function Client_getName() {
	return this.name;
}

function Client_getVersion() {
	return this.version;
}

function Client_getType() {
	switch (this.type) {
		case this.IE:
			return this.IE;
		case this.OPERA:
			return this.OPERA;
		case this.MOZILLA:
			return this.MOZILLA;
		default:
			return this.UNKNOWN;
	}
}

function Client_hasDOM() {
	return this.DOM;
}

function Client_hasDHTML() {
	return this.DHTML;
}

function Client_toString() {
	return new String(this.name + " " + this.version); 
}

 
/*
 * An object for determining the client type, i.e. the browser.
 */
function Client() {
	/* Browser types */
 	this.IE = 0;
 	this.OPERA = 1;
 	this.MOZILLA = 2;
 	this.UNKNOWN = -1;
 	
 	this.getName = Client_getName;
 	this.getVersion = Client_getVersion;
 	this.getType = Client_getType;
 	this.hasDOM = Client_hasDOM;
 	this.hasDHTML = Client_hasDHTML;
 	this.toString = Client_toString;
 	
 	this.name = "";
	this.version = "";
	this.type = this.UNKNOWN;
	this.DHTML = false;
	this.DOM = false;
 	 
 	/* The Code is initialy borrowed from
 	 * http://www.selfhtml.de and has been
 	 * enhanced by Rafael Ostertag.
 	 */ 
	if (window.opera) {
     	this.type = this.OPERA;
 	}
 	
	if(document.getElementById) {
		this.DHTML = true;
   		this.DOM = true;
 	}
	if(document.all && this.type!=this.OPERA) {
   		this.DHTML = true;
   		this.type = this.IE;
 	}
	if(navigator.appName=="Netscape" && this.type!=this.OPERA) {
   		DHTML = true;
   		this.type = this.MOZILLA;
 	}
 	
 	switch (this.type) {
 		case this.IE:
			this.name = navigator.appName;
			this.version = navigator.appVersion; 		
 			break;
 		case this.OPERA:
 			this.name = navigator.appName;
 			this.version = navigator.appVersion;
 			break;
 		case this.MOZILLA:
			this.name = navigator.appName;
 			this.version = navigator.appVersion;
 			break;
 		default:
 			this.name = undefined;
 			this.version = undefined;
 	}
}

function opennew(anelem, winname) {
	if (anelem==null) {
		return true;
	}
	
	var href;
	if (anelem.href) {
		href=anelem.href;
	} else {
		return true;
	}
	
	if(winname=="" || winname==undefined) {
		winname = "opennew";
	}
	
	if(window.open) {
		var nw = window.open(href, winname);
		return false;
	}
	
	return true;

}

/**
 * @brief Function for changing the up link image in the navigator.
 *
 * Changes the up link image in the navigator. You can use it for
 * onmouseover and onmouseout events. It alternates between the files
 * uparrow.png and uparrowinv.png.
 *
 * The images are expected to be in the /images/navigator folder.
 */
function changenavuplinkimg() {
	var imgs = document.images;
	for (var n=0; n<imgs.length; n++) {
		if (imgs[n].id === "navuplinkimg") {
			var path = imgs[n].src;
			var comps = path.split("/");
			if (comps[comps.length-1] === "uparrow.png")
				document.images[n].src = "/images/navigator/uparrowinv.png";
			else
				document.images[n].src = "/images/navigator/uparrow.png";
			return;
		}
	}
}

