function openElem(elem, w, h){

		this.elem = document.getElementById(elem);
		this.elem.className = 'dyncontainer';
		this.elemWidth = w+40;
		this.elemHeight = h+40;	
		this.offPosX = this.elemWidth / 2;
		this.offPosY = this.elemHeight / 2 + 100;
		
		try {
			fillerdiv = document.createElement('div'); 
			fillerdiv.className = 'filler';
			fillerdiv.setAttribute('id', elem + 'pagefiller');	
			document.body.insertBefore(fillerdiv,document.body.firstChild);
			document.getElementById(elem + "pagefiller").onclick=function() {
				closeElem(elem);
			}	
			
		} catch(e) { }	
		
		var scrOfY = 0;
		var leftpos = 0;
		var Ypos = 0;
		
 			if( typeof( window.pageYOffset ) == 'number' ) {
   				 scrOfY = window.pageYOffset;
  			} else if( document.body && document.body.scrollTop ) {
   				 scrOfY = document.body.scrollTop;
 			 } else if( document.documentElement && document.documentElement.scrollTop ) {
    			scrOfY = document.documentElement.scrollTop;
  			}

 		var windowWidth, windowHeight;
		if (self.innerHeight) {
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth;
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		
		Ypos = windowHeight / 2 - this.offPosY + scrOfY;
		leftpos = windowWidth / 2 - this.offPosX;
				
		this.elem.style.top=Ypos+'px';
 		this.elem.style.left=leftpos+'px';
 		
		this.elem.style.height = this.elemHeight + 'px';
		this.elem.style.width = this.elemWidth + 'px';
		
		this.elem.style.display='';
		
			try {
			var containerdiv;
			containerdiv = document.createElement('div');
			containerdiv2 = document.createElement('div');
			containerdiv.className = 'dyncontainer_header';
			containerdiv.setAttribute('id',elem + 'containerheader');		
			containerdiv.appendChild(containerdiv2);
			this.elem.insertBefore(containerdiv,this.elem.firstChild);
			
			document.getElementById(elem + "containerheader").onclick=function(){
				closeElem(elem);
			}	 
			
			} catch(e) { }

}


function closeElem(elem) {	
	this.elem = document.getElementById(elem);
	this.filler = document.getElementById(elem + 'pagefiller');	
	this.closer = document.getElementById(elem + 'containerheader');	
	this.elem.style.display='none';
	try {
			document.body.removeChild(this.filler);
			this.elem.removeChild(this.closer); 
			
	} catch(e) { }
}

function setTextZoom() {
	var styleused = getActiveStyleSheet();
	if(styleused=='zoom') { setActiveStyleSheet(''); }
	else { setActiveStyleSheet('zoom'); }
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



