function toggleLayer( layerName ) {
	var elem, vis;
	if( document.getElementById ) // this is the way the standards work
		elem = document.getElementById( layerName );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[layerName];
	else if( document.layers ) // this is the way nn4 works
		elem = document.layers[layerName];
	vis = elem.style;
	// if the style.display value is blank we try to figure it out here
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
	}

function getWindowHeight_withoutScroll() {
	var v=0,d=document,w=window;
	if((!d.compatMode || d.compatMode == 'CSS1Compat') && !(w.opera && (!w.opera.version || parseFloat(w.opera.version()) < 9.5)) && d.documentElement && d.documentElement.clientHeight)
		{v=d.documentElement.clientHeight;}
	else if(d.body && d.body.clientHeight)
		{v=d.body.clientHeight;}
	else if(xDef(w.innerWidth,w.innerHeight,d.width)) {
		v=w.innerHeight;
		if(d.width>w.innerWidth) v-=16;
		}
	return v;
	}

/***************************************************************************************************
 *** resize scrolling pane for correct scrolling
 ***************************************************************************************************/
function resizeScroller()	{
	var frame = document.getElementById("contentScroller");
	winH = window.innerHeight;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winH = window.innerHeight;
			}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winH = document.body.offsetHeight;
			}
		}
	winH = getWindowHeight_withoutScroll();
	newHeight = winH - 171;  //179;
	frame.style.height = newHeight + "px";
	}

function checkBrowserName(name){
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf(name.toLowerCase())>-1) {
		return true;
		}
	return false;
	}

function getCSSRule(ruleName)	{
	
	//tmpConcat = "";
	
	ruleName=ruleName.toLowerCase();
	if (document.styleSheets) {
		i = 0;
		max = document.styleSheets.length - 1;
		if (checkBrowserName('opera'))	{
			i = 0;
		//	max = 1;
			}
		for (i; i <= max; i++) {
			styleSheet = document.styleSheets[i];
			if (styleSheet)	{
				var theRules = new Array();
				if (styleSheet.rules) {
					theRules = styleSheet.rules;
					}
				else {
					if (styleSheet.cssRules) {
						theRules = styleSheet.cssRules;
						}
					else	{
						return false;
						}
					}
				if (theRules) {
					for (ii = 0; ii < theRules.length; ii++){
						tmp = theRules[ii].selectorText.toLowerCase();
						
						//if (tmp.substring(0, 1) == "#") {
						//	tmpConcat = tmpConcat + tmp + "\n";
						//	}
						if(theRules[ii].selectorText.toLowerCase()==ruleName){
							return theRules[ii];
					  	}
					  }
					}
				}
			}
		}
	//alert(tmpConcat);
	return false;
	}


/***************************************************************************************************
 *** Function growshrink
 ***************************************************************************************************/
function growshrink() {
	var rightBar = getCSSRule("#chirurgie-schaffhausen-rightbar");
	var lContent  = getCSSRule("#lContent");
	var pic = getCSSRule("arrow");
	
	//alert("lContent: " + lContent);
	
	if (rightBar.style.display == 'none')	{
		numOfColsBefore = 2;
		setCookie("numOfColumns", 3, 1, "www.stadtpraxis.ch");
		}
	else	{
		numOfColsBefore = 3;
		setCookie("numOfColumns", 2, 1, "www.stadtpraxis.ch");
		}
	
	/***************************************************************************************************
	 *** changing from 3 to 2 cols
	 ***************************************************************************************************/
	if (numOfColsBefore == 3)	{
		rightBar.style.display = 'none';
		rightBar.style.width = '0px';
		//lContent.style.width = '100%';
		lContent.style.marginRight = '7px';
		//window.document.images['showHideArrow'].src = "pictures/left.png";
		document.showHideArrow.src = "/fileadmin/chirurgie/schaffhausen/chirurgen/templates/pictures/left.png";
		document.showHideArrow.title = "Klicken Sie hier, um diese Anzeigefläche wieder zu verkleinern und die verborgenen Spalten einzublenden";
		}

	/***************************************************************************************************
	 *** changing from 2 to 3 cols
	 ***************************************************************************************************/
	if (numOfColsBefore == 2)	{
		lContent.style.marginRight = '219px';
		rightBar.style.display = '';
		rightBar.style.width = '205px';
		document.showHideArrow.src = "/fileadmin/chirurgie/schaffhausen/chirurgen/templates/pictures/right.png";
		document.showHideArrow.title = "Klicken Sie hier, um diese Anzeigefläche zu vergrössern";
		}
  }
function setUserStyle() {
	numOfColums = getCookie("numOfColumns");
	if (numOfColums.length) {
		
		}
	else {
		numOfColums =3;
		}
	alert();
	}

/********************************************
Cookie functions
*********************************************/
function setCookie (cookieName, cookieValue, daysValid, domainName)	{
	var domain_string = domainName ? ("; domain=" + domainName) : '' ;
	document.cookie = cookieName + "=" + encodeURIComponent(cookieValue) + "; " +
					"max-age=" + 60 * 60 * 24 * daysValid + "; " +
					"path=/" + domain_string;
	cookieName = "dummy";
	document.cookie = cookieName + "=" + encodeURIComponent(cookieValue) + "; " +
					"max-age=" + 60 * 60 * 24 * daysValid + "; " +
					"path=/" + domain_string;
	}
function getCookie(cookieName)	{
	cookieString = document.cookie;
	if (cookieString.length != 0) {
		cookieStart = document.cookie.indexOf(cookieName + "=");
		if (cookieStart != -1)	{
			cookieStart = cookieStart + cookieName.length + 1;
			cookieEnd   = document.cookie.indexOf(";", cookieStart);
			if (cookieEnd == -1) cookieEnd = document.cookie.length;
			return unescape(document.cookie.substring(cookieStart, cookieEnd));
			}
		}
	return "";
	}

