// Check Browser Version Andreas Bauer
function browserVersion(path) {
	this.path = (path) ? path : '../../code/style/';
	this.isDynamic = (!window.navigator.appVersion.indexOf('4.') || !window.navigator.appVersion.indexOf('5.'));
	var version = navigator.appVersion
	var v = parseInt(version)
	var agent = navigator.userAgent.toLowerCase();
	this.isMac = (agent.indexOf('mac') >= 0);
	this.isLinux = (agent.indexOf('inux') >= 0);
	this.isOpera = (agent.indexOf('opera') >= 0);
	this.name = window.navigator.appName;
	this.isIE = (this.name == "Microsoft Internet Explorer");	
	this.isNS = (this.name =="Netscape");	
	this.isNS5 = ((this.name=="Netscape" || this.name=="Mozilla" ) && v==5);
	this.css = '<LINK REL="stylesheet" HREF="' + this.path;
	if(this.isMac)	this.css += 'Mac';
	if(this.isLinux) this.css += 'Linux';
	if(this.isIE)	this.css += 'IEStyle';
	else if (this.isNS) this.css += 'NSStyle';
	else this.css += 'IEStyle';
	this.css += (this.css == '' ? '' : '.css" TYPE="text/css">');	
}

function screenInfo() {
	if(b.isDynamic)	{	
		if(b.isIE) {
			this.width = document.body.clientWidth;
			this.height = document.body.clientHeight;
		}
		else if (b.isNS)  {
			this.width = window.innerWidth;	
			this.height = window.innerHeight; 		
		}
	}	
}

function frameLoader(frameset) {
	if(top==self) { 
		this.frameset = (frameset) ? frameset : "../index.htm";
		this.currURL = unescape(window.location.pathname);
		this.newURL = this.frameset + "?" + this.currURL;
		if (b.isDynamic)
			this.redirect = 'location.replace('+this.newURL +')';
		else
			this.redirect = 'location.href ='+ this.newURL;
	}
	else this.redirect = "";
}

function getLayerHandle(id, nestref) {
	var hObj;
	// = (parent.frames.length > 0) frames
	if(b.isIE) hObj = document.all[id].style;
	if(b.isOpera) hObj = document.getElementById(id).style;
	if(b.isNS && !b.isOpera) {
		if(b.isNS5) hObj = document.getElementById(id).style;
		else hObj = (nestref)? eval(nestref+'.document.'+id) : document.layers[id];		
	}
	return hObj;
}
// function which position and show or hide layers - Andreas Bauer
function handleLayer(layername, pixelx, pixely, view, nestref) {
	if(b.isDynamic)	{
		var obj = getLayerHandle(layername,  nestref);
		if(b.isIE || b.isOpera) { 
			obj.pixelLeft = pixelx;
			obj.pixelTop = pixely;
		}
		else {
			obj.left = pixelx;
			obj.top = pixely;
		}
		showLayer(layername,view, nestref);
	}	
}

function moveBy(layername, pixelx, pixely, nestref) {
	if(b.isDynamic){
		var obj = getLayerHandle(layername, nestref);	
		if(b.isNS5)	{
			obj.left = parseInt(obj.left) + pixelx;
			obj.top = parseInt(obj.top) + pixely;
		}
		if (b.isNS && !b.isNS5) {
			obj.moveBy(pixelx,pixely);						
		}
		if(b.isIE) {
			obj.pixelLeft += pixelx;
			obj.pixelTop += pixely;				
		}
	}
}

function isLayerVisible(layername, nestref) {
	var bVisible = false;
	if(b.isDynamic)	{
		var obj = getLayerHandle(layername, nestref);
		 bVisible = (b.isNS) ? ( obj.visibility == "show") : (obj.visibility == "visible");		
	}
	return bVisible;
}

function showLayer(layername,view, nestref) {
	if(b.isDynamic)	{
		var obj = getLayerHandle(layername, nestref);
		if(view) obj.visibility = (b.isNS && !b.isNS5 && !b.isOpera) ? "show" : "visible";
		else obj.visibility = (b.isNS && !b.isNS5 && !b.isOpera) ? "hide" : "hidden";
	}			
}

function writeToLayer(layername,txt, nestref) {
	var hObj;
	if(b.isDynamic) {
		if(b.isIE) document.all[layername].innerHTML = txt;
		else if(b.isOpera) alert("write don't work with Opera");
		else if(b.isNS) {
			if(b.isNS5) document.getElementById(layername).innerHTML = txt;
			else {
				hObj = (nestref)? eval("document."+nestref+".document."+layername+".document") : document.layers[layername].document;  // nestref todo
				with(hObj) {open();	write(txt);	close();}
			}
		}				
	}	
}

function getLayerId(index,nestref) {
	if(b.isIE) returnHtml = document.all.tags("DIV").item(index).id;
	if(b.isNS5) returnHtml = document.getElementsByTagName("DIV").item(index).id;
	if(b.isNS && !b.isNS5) returnHtml = (nestref) ? eval(nestref+'.document.layers["'+index+'"].id') : document.layers[index].id;
	return returnHtml;
}

function getLayerCount(nestref) {
	var nLayers = 0; 
	if(b.isIE) nLayers = document.all.tags("DIV").length; 
	if(b.isNS5) nLayers = document.getElementsByTagName("DIV").length;
	if(b.isNS && !b.isNS5) nLayers = (nestref) ? eval(nestref+".document.layers.length") : document.layers.length; 	
	return nLayers;
}

function resizeIt() {
	if(b.isIE) start();
	else document.location = document.location;
}

// Window functions
function newWindow(url,name,width,height) {
	var hWindow;
	hWindow = window.open(url,name, "dependent=yes,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width +",height="+height+"\"");
	hWindow.focus();
}

// Rollover functions
// old functions
function switchImgRestore() { 
  if (document.SwitchImgData != null)
    for (var i=0; i<(document.SwitchImgData.length-1); i+=2)
      document.SwitchImgData[i].src = document.SwitchImgData[i+1];
}

function preloadImages() { 
  if (document.images) {
    var imgFiles = preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function switchImage() { 
  var i,j=0,objStr,obj,SwitchArray=new Array,oldArray=document.SwitchImgData;
  for (i=0; i < (switchImage.arguments.length-2); i+=3) {
    objStr = switchImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      SwitchArray[j++] = obj;
      SwitchArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = switchImage.arguments[i+2];
  } }
  document.SwitchImgData = SwitchArray; 
}
// End Rollover functions


