/*
scroll.js (modified)

This code is from Dynamic Web Coding 
www.dyn-web.com 
Copyright 2001 by Sharon Paine 
Permission granted to use this code as long as this 
entire notice is included.
*/

dom = (document.getElementById) ? true : false;
ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
ns4 = (document.layers && !dom) ? true : false;
ie4 = (document.all && !dom) ? true : false;
nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

var scrTimer = 40;
var scrTmId=0;
var pgLoaded;
var oeTags;
var hasFlash;
wndo = new Array();

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"; }
	
function inchDown(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.top);
	if (y>-wndo[num].maxY) { 
		wndo[num].cnt.shiftBy(0,-inc);
		scrTmId = setTimeout("inchDown("+num+","+inc+")",scrTimer);
		MM_swapImage('scroll_u','','pics/u.gif',1)
	} else{
		MM_swapImage('scroll_d','','pics/d_.gif',1)
    }
}

function inchUp(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
		wndo[num].cnt.shiftBy(0,inc);
		scrTmId = setTimeout("inchUp("+num+","+inc+")",scrTimer);
		MM_swapImage('scroll_d','','pics/d.gif',1)
    }else{
		MM_swapImage('scroll_u','','pics/u_.gif',1)
    }
}

function inchRight(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.left);	
	if (y>-wndo[num].maxX+15) { 
		wndo[num].cnt.shiftBy(-inc,0);
		scrTmId = setTimeout("inchRight("+num+","+inc+")",scrTimer);
		MM_swapImage('scroll_l','','pics/l.gif',1)
    }else{
		MM_swapImage('scroll_r','','pics/r_.gif',1)
    }
}

function inchLeft(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.left);
	if (y<0) { 
		wndo[num].cnt.shiftBy(inc,0);
		scrTmId = setTimeout("inchLeft("+num+","+inc+")",scrTimer);
		MM_swapImage('scroll_r','','pics/r.gif',1)	
    }else{
		MM_swapImage('scroll_l','','pics/l_.gif',1)
    }
}

function stopScroll() {
	clearTimeout(scrTmId);
}

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;
}

function loadScrLyr(num,lyr,id) {
	if (!pgLoaded) return;
	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);
	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;
  }
}

var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

window.onload = initScrLyr; 

function initScrLyr() {
    MM_preloadImages('pics/h1_.gif','pics/h2_.gif','pics/h3_.gif','pics/h4_.gif','pics/h5_.gif','pics/h6_.gif','pics/h7_.gif','pics/h8_.gif','pics/h9_.gif','pics/v1_.gif','pics/v2_.gif','pics/v3_.gif','pics/v4_.gif','pics/v5_.gif','pics/v6_.gif','pics/v7_.gif','pics/u.gif','pics/d_.gif','pics/l.gif','pics/r_.gif');
    MM_reloadPage(true);
    pgLoaded=true;	
    wndo[0] = new dw_lyrObj('wn1');	
    loadScrLyr(0,'w1c1');	
    if (parseInt(wndo[0].cnt.css.top)>wndo[0].maxY) {
        MM_swapImage('scroll_d','','pics/d_.gif',1)
    }
    if(document.title!='home'){
        wndo[1] = new dw_lyrObj('wn2');		
	loadScrLyr(1,'w2c1');
        if (parseInt(wndo[1].cnt.css.left)>=wndo[1].maxX) {
  	    MM_swapImage('scroll_r','','pics/r_.gif',1)
	}
        MM_swapImage(document.title,'','pics/'+document.title+'_.gif',1);
	MM_swapImage('titel','','pics/title_'+document.title+'.gif',1);
    }
}

// Dreamweaver scripts

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  MM_swapImage(document.title,'','pics/'+document.title+'_.gif',1);
  MM_swapImage('titel','','pics/title_'+document.title+'.gif',1)
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

// Custom functions

function macMask() {
  if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") != -1 ) { 
    oeTags = '<div id="macmask">'
    + '<img src="pics/macmask.gif" width="819" height="100">'
    + '</div>'
    document.write(oeTags);
  }
}