// browser detection
var browserNew = (document.getElementById)? true:false;
// var ns4 = (document.layers)? true:false;
var ie = (document.all)? true:false;
var Macintosh = navigator.userAgent.indexOf('Mac')>0;
var DHTML = (document.getElementById || document.all || document.layers);
var seth;
var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
// var ns4 = ((navigator.appName.indexOf("etscap")>0) && (navigator.appVersion.indexOf("4")>0))? true:false;
var ie4 = (document.all && !dom) ? true : false;

		

var pgLoaded;
wndo = new Array();	// "window" for scrollable content

		
		// which site ?
	        var sw = 0;	
	        function setSwStatus() {
		var myhref = this.location.href;
		var re = '.php';
		var helper = myhref.split(re);
		var help = helper[0].substring(helper[0].length-3,helper[0].length);
		if (help == "ome") { sw = 0;
		} else if (help == "unt") { sw = 1;
		} else if (help == "pro") { sw = 2;
		} else if (help == "phi") { sw = 3;
		} else if (help == "job") { sw = 4;
		} else if (help == "kon") { sw = 5;
		} 

		} // end of swstatus
		
// splash show
var timerID = null
var timerRunning = false
var splashid = 1;
var splashTime = 2000;

function splashMe() {
	stopwatching();
	startwatching();    
}

function stopwatching() { 
	if(timerRunning) {
		clearTimeout(timerID);
	} 
	timerRunning = false;
} 

function startwatching() {
	swapImage('document.pic', 'document.pic','/img/splash/splash_pic_' + splashid + '.jpg');
	splashid++;
	if (splashid == "7") { 
		splashid = 1; 
	}	
	timerID = setTimeout("splashMe()",splashTime);
	timerRunning = true;
}

// end of splash

// open window routine
var winheight=100;
var winwidth=100;

function openmywin(imgwidth,imgheight) {
 // if (window.mywin&&window.mywin.closed==false) mywin.close();
 if (!document.layers&&!document.all&&!document.getElementById)
  {
   paramstp="height="+imgheight+",width="+imgwidth+",top=6"+
   ",left=6,scrollbars=yes,location=no"+
   ",directories=no,status=no,menubar=no,toolbar=no,resizable=no"
   mywin = window.open("","extern",paramstp);
   mywin.self.focus();
   return;
  }
 
 if (document.layers)
  {
   LeftPosition=(screen.width)?(screen.width-imgwidth)/2:100;
   TopPosition=(screen.height)?(screen.height-imgheight)/2:100;
   paramstp="height="+imgheight+",width="+imgwidth+",top="+TopPosition+
   ",left="+LeftPosition+",scrollbars=yes,location=no"+
   ",directories=no,status=no,menubar=no,toolbar=no,resizable=no"}
 else
  {
  LeftPosition=(screen.width)?(screen.width-imgwidth)/2:100;
  TopPosition=(screen.height)?(screen.height-imgheight)/2:100;
  paramstp="height="+imgheight+",width="+imgwidth+",top="+TopPosition+
  ",left="+LeftPosition+",scrollbars=yes,location=no"+
  ",directories=no,status=no,menubar=no,toolbar=no,resizable=no"}
  
  mywin = window.open("","extern",paramstp);
  mywin.self.focus();
  return;
}

// end of window open	
// main navigation

                // array of swap images
		var sar = new Array();
		sar[0] = "home";
		sar[1] = "unt";
		sar[2] = "pro";
		sar[3] = "phi";
		sar[4] = "job";
		sar[5] = "kon";

		var s = new Array();
		s[0] = "img/gen/nav_home_on.gif";
		s[1] = "img/gen/nav_unt_on.gif";
		s[2] = "img/gen/nav_pro_on.gif";
		s[3] = "img/gen/nav_phi_on.gif";
		s[4] = "img/gen/nav_job_on.gif";
		s[5] = "img/gen/nav_kon_on.gif";
		
		var sr = new Array();
		sr[0] = "img/gen/nav_home.gif";
		sr[1] = "img/gen/nav_unt.gif";
		sr[2] = "img/gen/nav_pro.gif";
		sr[3] = "img/gen/nav_phi.gif";
		sr[4] = "img/gen/nav_job.gif";
		sr[5] = "img/gen/nav_kon.gif";

		// mouseUp
		function mu(i) {
		if (i!=sw) {
		swapImage('document.' + sar[i],'document.' + sar[i], s[i], 'swapImage' + i);
		}
		}	
		
		// mouseDown
		function md(i) {
		if (i!=sw) {
		swapImage('document.' + sar[i],'document.' + sar[i], sr[i], 'swapImage' + i);
		}
		}	
		
		// mouseClick
		function redirect(i) {
		
				self.location.href="index_" + sar[i] + ".php";
		
		}


		// switch images
		function swapImage() { 
  		var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.swapImgData;
  		for (i=0; i < (swapImage.arguments.length-2); i+=3) {
    			objStr = swapImage.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) {
      			swapArray[j++] = obj;
      			swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj) ? obj.src : oldArray[j];
   		   	obj.src = swapImage.arguments[i+2];
  		} }
  		document.swapImgData = swapArray; //used for restore
		}
		
		// preload images
		function preloadImages() { 
  			if (document.images) {
    			var imgFiles = preloadImages.arguments;
    			var preloadArray = new Array();
    				for (var i=0; i<imgFiles.length; i++) {
      					preloadArray[i] = new Image;
      					preloadArray[i].src = imgFiles[i];
    				}
  			}
		}
		
		// things to do after the page loads
		function initPage() {
			setSwStatus(); 
			preloadImages('../img/gen/nav_home_on.gif');
			preloadImages('../img/gen/nav_unt_on.gif');
			preloadImages('../img/gen/nav_pro_on.gif');
			preloadImages('../img/gen/nav_phi_on.gif');
			preloadImages('../img/gen/nav_job_on.gif');
			preloadImages('../img/gen/nav_kon_on.gif');
			prepLyr();if (parent.erin) parent.erin('layerscroll');
		}
			
		// initializes
		window.onload = initPage;

// main navigation ends

// layer scroll routines

var clipTop = 0;
var clipWidth = 570;
var clipBottom = 302;
if (ns4) { 
	var topper = 225;
} else { 
	var topper = 0;
}
var lyrheight = 0;
var diffb = 0; // some kind of init > amount
var time,amount,theTime,theHeight;

function prepLyr()
{
	if (!DHTML) return;
	
	if (sw == 1) {
	var x = new getObj('faklyr');
	var y = new getObj('reflyr');
	var z = new getObj('stalyr');
	} else if (sw == 2) {
	var x = new getObj('porlyr');
	var y = new getObj('entlyr');
	var z = new getObj('ipolyr');
	} else if (sw == 4) {
	var x = new getObj('poslyr');
	clipBottom = 200;
		if (ns4) {
		topper = 305;
		}
	} else if (sw == 5) {
	var x = new getObj('imprlyr');
	clipBottom = 130;
		if (ns4) {
		topper = 400;
		}
	} else return;
	
	if (document.layers)
	{
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
		if (!y) return;
		y.style.clip.top = clipTop;
		y.style.clip.left = 0;
		y.style.clip.right = clipWidth;
		y.style.clip.bottom = clipBottom;
		if (!z) return;
		z.style.clip.top = clipTop;
		z.style.clip.left = 0;
		z.style.clip.right = clipWidth;
		z.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
		x.style.clip = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)'
		if (!y) return;
		lyrheight = y.obj.offsetHeight;
		y.style.clip = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)'
		if (!z) return;
		lyrheight = z.obj.offsetHeight;
		z.style.clip = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)'
	}
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

function realscroll()
{
	
	if (!DHTML) return;
	if (seth == 'ref') { 
		lyrheight = 460; 
	} else if (seth == 'sta') {
		lyrheight = 1380;
	} else if (seth == 'ipo') {
		lyrheight = 2395;
	} else if (seth == 'impr') {
		lyrheight = 260;
	}	

	diffb = lyrheight - clipBottom;
	if (diffb < amount) { amount = diffb; }
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper;
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function vis(lname,val)
{
	if (!DHTML) return;
	if (!lname) return;
	var f = new getObj(lname);
	f.style.visibility = val;
}

function getObj(name)
{
  if (!name) return;
  if (document.getElementById)
  {
    this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
    this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

// set active layer var
function sethigh(sethigh) {
	seth = sethigh;
}


// wrap scrolling
function scrollup() {
	var lid = getactivelayer();
	if (!lid) return;
	if (lid == 'faklyr') return;
	if (lid == 'entlyr') return;
	if (lid == 'porlyr') return;
	if (lid == 'reflyr') return;
	// inchUp(0,4);
	scrollayer(lid,-8,20)
}

function scrolldown() {
	var lid = getactivelayer();
	if (!lid) return;
	if (lid == 'faklyr') return;
	if (lid == 'entlyr') return;
	if (lid == 'porlyr') return;
	if (lid == 'reflyr') return;
	// inchDown(0,4);
	scrollayer(lid,8,20)
}

function getactivelayer() {
	if (!seth) return;
	var rc = seth + 'lyr';
	return rc;
}

//wrap page up||down
function pageup() {
	var lid = getactivelayer();
	if (!lid) return;
	if (lid == 'faklyr') return;
	if (lid == 'entlyr') return;
	if (lid == 'porlyr') return;
	if (lid == 'reflyr') return;
	if (clipTop < 302) {
		scrollayer(lid,-clipTop,10);
	} else {
	scrollayer(lid,-302,10);
}
	stopScroll();
}

function pagedown() {
	var lid = getactivelayer();
	if (!lid) return;
	if (lid == 'faklyr') return;
	if (lid == 'entlyr') return;
	if (lid == 'porlyr') return;
	if (lid == 'reflyr') return;
	scrollayer(lid,302,10);
	stopScroll();
}


// page/scroll sidebar switches 
var switchMe = 0;

function setswitch(swflag) {
	switchMe = swflag;
	if (swflag == 1) {
	swapImage('document.scroll_up','document.scroll_up', '/img/gen/scroll_up.gif');
	swapImage('document.scroll_down','document.scroll_down', '/img/gen/scroll_down.gif');
	swapImage('document.page_up','document.page_up','/img/gen/page_up.gif');
	swapImage('document.page_down','document.page_down', '/img/gen/page_down.gif');
	} else {
	swapImage('document.scroll_up','document.scroll_up', '/img/gen/scroll_up_off.gif');
	swapImage('document.scroll_down','document.scroll_down', '/img/gen/scroll_down_off.gif');
	swapImage('document.page_up','document.page_up','/img/gen/page_up_off.gif');
	swapImage('document.page_down','document.page_down', '/img/gen/page_down_off.gif');
	}
}

function switchMeIn(toSwitch) {
	if (switchMe == '1') {
		swapImage('document.' + toSwitch,'document.' + toSwitch, '/img/gen/' + toSwitch + '.gif');
	}
}

function switchMeOut(toSwitch) {
	if (switchMe == '1') {
		swapImage('document.' + toSwitch,'document.' + toSwitch, '/img/gen/' + toSwitch + '_off.gif');
	}	
}



//tests 

function dw_shiftTo(x,y) {
	if (ns4) { this.css.moveTo(x,y); } 
	else { this.css.left=x+"px"; this.css.top=y+"px"; }
}

function dw_shiftBy(x,y) {
	if (ns4) { this.css.moveBy(x,y); }
	else { 
		this.css.left = parseInt(this.css.left)+x+"px";
		this.css.top = parseInt(this.css.top)+y+"px";
	}
}
function dw_show() {	this.css.visibility = "visible"; }
function dw_hide() { this.css.visibility = "hidden"; }

////////////////////////////////////////////////////////////////////
//  Constructor function used for creating scrollable content areas.
//	Used to create both wndo and content objects.
//  Argument for creating wndo objects:	id of wndo div.
//	Arguments for creating content (done in loadScrLyr function):
//	id of content div, id of html element that contains content. 
//	NOTE: Netscape 6 needs that html container and its id 
//	in order to get width for horizontal scrolling.
//	If only using vertical scrolling, that extra container
//	is not necessary.
////////////////////////////////////////////////////////////////////
function dw_lyrObj(obj,id) {
	this.el = (ns4)? getLyrRef(obj,document): (ie4)? document.all[obj]: (ie5||ns5)? document.getElementById(obj): null;
	this.css = (ns4)? this.el: (ie4||ie5||ns5)? this.el.style: null;
	this.height = (ns4)? this.el.clip.height: (ie4||ie5)? this.el.clientHeight: (ns5)? this.el.offsetHeight: 0;
	this.width = (ns4)? this.el.clip.width: (ie4||ie5)? this.el.clientWidth: (ns5)? (id)? document.getElementById(id).offsetWidth: this.el.offsetWidth: 0;
}


/////////////////////////////////////////////////////////////////////
// loadScrLyr function: loads scrollable content div(s)
//	arg's: wndo array number, id of scrollable div,
//	and id of table or other html element that contains div content. 
//	NOTE: Netscape 6 needs that html container and its id 
//	in order to get width for horizontal scrolling.
//	If only using vertical scrolling, that extra container
//	is not necessary.
/////////////////////////////////////////////////////////////////////
function loadScrLyr(num,lyr,id) {
	if (!pgLoaded) return; // avoid not loaded errors
	if (typeof wndo[num].cnt != "undefined") wndo[num].cnt.hide();
	wndo[num].cnt = new dw_lyrObj(lyr,id);
	wndo[num].cnt.show();
	wndo[num].cnt.shiftTo(0,0);	// restore top/left to 0 
	wndo[num].maxX = wndo[num].cnt.width - wndo[num].width;
	wndo[num].maxY = wndo[num].cnt.height - wndo[num].height
} 

dw_lyrObj.prototype.shiftBy=dw_shiftBy;
dw_lyrObj.prototype.shiftTo=dw_shiftTo;
dw_lyrObj.prototype.show=dw_show; 
dw_lyrObj.prototype.hide=dw_hide;

// get reference to nested layer for ns4
// from dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (ns4) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}