/**
  * STERN fontSize Functions
*/

function getFontSize() { 
  var font = "";
  if (document.cookie) {
    var start = document.cookie.indexOf("=") + 1;
    var end = document.cookie.indexOf(";");
    if (end == -1) {
      end = document.cookie.length;
    } 
    font = document.cookie.substring(start,end);
  }
  fontSize(font);
}

function setFontSize(f) { 
  var a = new Date();
  a = new Date(a.getTime() +1000*60*60*24*365);
  document.cookie = 'fontsize='+f+'; expires='+a.toGMTString()+';'; 
}

function fontSize(f) {
  divname='';
  if (document.getElementById('content')) {
  divname='content';
  }
  else if (document.getElementById('content-gabel')) { 
  divname='content-gabel';  
  }
  if (divname!='') {
    if (!document.getElementById(divname).style.fontSize) {
      document.getElementById(divname).style.fontSize=1+'em';
      document.getElementById(divname).style.lineHeight = '1em';
    }
    g=parseFloat(document.getElementById(divname).style.fontSize.replace('em',''));
    g+=f;
    if(g>0.5&&g<10){
      document.getElementById(divname).style.fontSize=g.toFixed(1)+'em';
      document.getElementById(divname).style.lineHeight=g.toFixed(1)+'em';
    }
  }
  setFontSize(f);
}

// oeffnet Popup wird für popup-Modul benötigt
function openPopup(URL,popname,W,H,scroll,rezisable,X,Y) {
	var URL,popname,W,H,scroll,rezisable,X,Y;
	if (!popname) { popname='popup'; }
	if (!W) { W=520; }
	if (!H) { H=460; }
	if (!scroll) { scroll=0; }
	if (!rezisable) { rezisable=0; }
	if (!X) { X=screen.width/2-(W/2); }
	if (!Y) { Y=screen.height/2-(H/2)-20; }
	properties = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scroll+",resizable="+rezisable+",";
	properties += "width="+W+",height="+H+",left="+X+",top="+Y;
	popwin=window.open(URL,popname,properties);
	popwin.focus();
}

// Sitemap
function loadPage(url) {
window.opener.location.href=url;
}


// zeigt Flash direkt an
function showFlash(src, width, height, quality, menu, bgcolor, flashvars) {
	closeTags = "</" + "embed></" + "object>";
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" title=""><param name="movie" value="' + src + flashvars + '"><param name="quality" value="' + quality + '"><param name="bgcolor" value="' + bgcolor + '" /><param name="wmode" value="transparent"><param name="menu" value="' + menu + '"><param name="play" value="true"><embed src="' + src + flashvars + '" quality="' + quality + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="' + bgcolor + '" width="' + width + '" height="' + height + '" menu="' + menu + '" play="true" wmode="transparent">'+closeTags);
    //##	alert("showFlash() flashvars="+flashvars + " => " + src);
}


function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}


function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}


function hideLayer (setDiv) {
	MM_changeProp(setDiv,'','style.display','none','DIV');
}


function showLayer (setDiv) {
	MM_changeProp(setDiv,'','style.display','block','DIV');
}


function changeImg (id,setThumb,setDiv,count) {
    // alle Zoombilder hide
    for (var i = 1; i <= count; i++) {
        divname='zoom'+id+'-'+i;
        hideLayer (divname);
    }
    // alle Hi Thumbs hide
    // alle Lo Thumbs show
    for (var i = 1; i <= count; i++) {
        divnamehi='thumb'+id+'-'+i+'_hi';
        hideLayer (divnamehi);
        divnamelo='thumb'+id+'-'+i+'_lo';
        showLayer (divnamelo);
    }
    // hide Thumbnail lo
    setThumblo=setThumb+'_lo';
    hideLayer (setThumblo);
    // show Thumbnail hi
    setThumbhi=setThumb+'_hi';
    showLayer (setThumbhi);
    // show Zoombild
    layernamezoom='zoom'+id;
    document.getElementById(layernamezoom).innerHTML = document.getElementById(setDiv).innerHTML;
    //showLayer (setDiv);
}

function setEmptyField(field,ignorestring) {
    if (document.getElementById(field).value==ignorestring) {
    document.getElementById(field).value='';
    document.getElementById(field).focus();
    }
}

function checkSearchString(ignorestring,lang) {
    searchstring=document.getElementById("search").value;
    if ((searchstring.length<3) || (searchstring==ignorestring)) {
      if (lang=='de') {
        alert('Bitte Suchbegriff mit mindestens 3 Buchstaben eingeben.');
      }
      else {
        alert('3 Characters minimum.');
      }
      return false;
    }
    else {
    return true;
    }
}


