
function IsIE8Browser() {  
    var rv = -1;    
    var ua = navigator.userAgent;    
    var re = new RegExp("Trident\/([0-9]{1,}[\.0-9]{0,})");    if (re.exec(ua) != null) {        rv = parseFloat(RegExp.$1);    }    return (rv == 4);
}

var ie8 = IsIE8Browser();


function setFontButtons() 
{
    var imgInc = document.getElementById("imgIncreaseFont");
    var imgDec = document.getElementById("imgDecreaseFont");

    imgInc.src = "grafik/icons/ico_schrift_vergroessern_off.gif";
    imgInc.setAttribute("onmouseover", "this.src='grafik/icons/ico_schrift_vergroessern_on.gif'");
    imgInc.setAttribute("onmouseout", "this.src='grafik/icons/ico_schrift_vergroessern_off.gif'");

    imgDec.src = "grafik/icons/ico_schrift_verkleinern_off.gif";
    imgDec.setAttribute("onmouseover", "this.src='grafik/icons/ico_schrift_verkleinern_on.gif'");
    imgDec.setAttribute("onmouseout", "this.src='grafik/icons/ico_schrift_verkleinern_off.gif'");

    if (iCounter == 2) 
    {
        imgInc.src = "grafik/icons/ico_schrift_vergroessern_inaktiv.gif";
        imgInc.setAttribute("onmouseover", "");
        imgInc.setAttribute("onmouseout", "");
    }
    if (iCounter == 0) 
    {
        imgDec.src = "grafik/icons/ico_schrift_verkleinern_inaktiv.gif";
        imgDec.setAttribute("onmouseover", "");
        imgDec.setAttribute("onmouseout", "");
    }
}

function showMPA() 
{
    var imgPfeil = document.getElementById("imgPfeil");
    
    if (imgPfeil.src.indexOf("schliessen") > -1) 
    {
        jQuery(".divMPA a").css("border-bottom", "0px");
        jQuery(".divMPA_Team").hide();
        jQuery(".divTeam").css("height", jQuery(".divMembers").height() + 30);        
        imgPfeil.src = "grafik/icons/bt_pfeil.png";
    }
    else 
    {
        jQuery(".divMPA a").css("border-bottom", "1px solid #BABABA");
        jQuery(".divMPA_Team").show();
        jQuery(".divTeam").css("height", jQuery(".divMembers").height() + jQuery(".divMPA_Team").height() + 30);                
        imgPfeil.src = "grafik/icons/bt_pfeil_schliessen.png";
    }
}

function popup(querystring,x,y)
{
	var nwl = (screen.width-x)/2;
	var nwh = (screen.height-y)/2;		
	var popup=window.open('popup.aspx?id='+querystring, 'Lageplan', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+x+',height='+y+',left='+nwl+',top='+nwh+'');
}

function catchEnter(evt, buttonid) {
   
    if (evt.key == 'enter') {
        evt.returnValue = false;
        evt.cancel = true;
        var button = $(buttonid);

        if (button != null) {
            button.click();
        }
     
        return false;
    }

    return true;
}

function resizeFont(pSize)
{
    var content = document.getElementById('content');
    
    //alert(content.style.fontSize);
    
    content.style.fontSize = 20 + "px";
    
    //alert(content.style.fontSize);
    
}



        
/***********************************************************/
/* ------------------------------------------------------- */
/***********************************************************/

var gAutoPrint = false; 
var gSpecialPrint = null;

/*******************/
/* print functions */
/*******************/
var lastwindow = null;

function replaceAll( str, from, to ) 
{
    var idx = str.indexOf(from);
    var i = 0;
    while (idx > -1 && i<100) {
        i++;
        str = str.replace(from, to); 
        idx = str.indexOf(from);
    }
    return str;
}


function printscreen(divid,fid)
{

	var printdiv = $(divid);
	
    if(gSpecialPrint != null)
        printdiv = $(gSpecialPrint);
		
	popupAndWrite(fid);

}

function popupAndWrite(fid)
{
   
    if(lastwindow != null)
        lastwindow.close();
       
       printTipp(fid);

}

function berechneBMI() 
{
   var iBMI;  
   var iGewicht = document.getElementById('ctl00_cpContent_repEntries_ctl00_txtGewicht').value;
   var iGroesse = document.getElementById('ctl00_cpContent_repEntries_ctl00_txtGroesse').value;
   var strResultat;
   
   var divResultat = document.getElementById("divResultat");

   if (iGewicht < 10 || iGewicht > 200) { strResultat = "Falsches Gewicht.<br/>Bitte Daten erneut eingeben."; divResultat.style.color = "red"; }
   if (iGroesse < 50 || iGroesse > 250)   { strResultat = "Falsche Gr&ouml;sse.<br/>Bitte Daten erneut eingeben."; divResultat.style.color = "red"; }
   
   if ((iGewicht < 10 || iGewicht > 200) || (iGroesse < 50 || iGroesse > 250))
   { /* Keine Aktion notwendig. */ }
   else
   {
       iBMI = Math.round(iGewicht / (Math.pow((iGroesse/100),2)));
       
       strResultat = "Ihr BMI betr&auml;gt <b>" + iBMI + "</b>.<br/>";
         
       if (iBMI < 18)                   { strResultat += "Sie haben starkes Untergewicht."; }
       if (iBMI == 18)                  { strResultat += "Sie haben deutliches Untergewicht."; }
       if (iBMI == 19)                  { strResultat += "Sie haben leichtes Untergewicht."; }
       if (iBMI >= 20 && iBMI <= 24)    { strResultat += "Dies liegt im idealen Bereich."; }
       if (iBMI >= 25 && iBMI <= 29)    { strResultat += "Sie haben leichtes bis mässiges Übergewicht."; }
       if (iBMI >= 30 && iBMI <= 39)    { strResultat += "Sie haben deutliches Übergewicht."; }
       if (iBMI >= 40)                  { strResultat += "Sie haben sehr starkes Übergewicht."; }
       
       divResultat.style.color = "#58595b";
   }
   
   divResultat.innerHTML = strResultat;
}

function printTipp(fid) {

    var myLayer = $('content');

      today = new Date();

      var strDateTime = today.getDate() + "." + (today.getMonth()+1) + "." + today.getFullYear() + ", " + today.toLocaleTimeString() + " Uhr";
      var parameter = "menubar=yes,toolbar=yes,scrollbars=yes,statusbar=no,location=no,resizable=yes,width=750px,height=760px";
      var printWin = window.open("","printSpecial_"+replaceAll(replaceAll(replaceAll(replaceAll(strDateTime,".","_"),":","_")," ","_"),",",""),parameter);

      var text = "";
      text += "<table width=\"100%\" style=\"border-bottom:1px solid #58595b;margin-bottom:25px;\"><tr><td class=\"printheader\" style=\"padding-bottom:4px;\" valign=\"bottom\">";
      
      text += "<img width=\"186px\" height=\"182px\" src=\"./grafik/logo/img_logo.png\" />";

      var content = myLayer.innerHTML.replace(/<SCRIPT/gi, "<!-- ").replace(/<\/SCRIPT>/gi, "//--> ")
      
      if(content.indexOf("<STYLE>") > -1)
      {
        content = content.substr(0, content.indexOf("<STYLE>")) + content.substr((content.indexOf("</STYLE>")+8), content.length - (content.indexOf("</STYLE>")+8))
      }

      text += "</td><td valign=\"bottom\" align=\"right\" style=\"padding-bottom:6px;font-size:10px;font-family:Verdana;\">Im Bretscha 7 | 9494 Schaan | Tel. +423 235 08 08 | Fax +423 235 08 00</td></table>"; // + $('ctl00_lblStatus').innerHTML + "<br><br>";
      text += content;
      
      printWin.document.open();    
      printWin.document.write("<html><head><link href='./css/print.css' rel='stylesheet' type='text/css'></link></head><style> body {background-color:white;text-align:left;} div {overflow:visible;} .scroll{overflow:visible;} .highlight{color:black;background-color:white;}</style><body><div class='text'><form onsubmit='return false;'>" + text + "</form></div></body></html>");
      printWin.document.close();
      printWin.print();

  }

