var Ind       = 0;


//**********************************************************************
/*function ResetErgebnis()
{
   window.document.FormEB.Edit_Liter.value = "";
   window.document.FormEB.Edit_Geld.value  = "";
   window.document.FormEB.Edit_CO2.value   = "";
}
*/
//**********************************************************************
function SetUalt()
{
   Ind  = document.forms['energie'].LB_UwAlt.selectedIndex;
   document.forms['energie'].Edit_U.value = document.forms['energie'].LB_UwAlt.options[Ind].value;
   //ResetErgebnis();
}

//**********************************************************************
/*function SetUNeu()
{
   Ind     = document.FormEB.LB_UwNeu.selectedIndex;
   document.FormEB.Edit_UNeu.value = document.FormEB.LB_UwNeu.options[Ind].value;;
   ResetErgebnis ();
}*/

//**********************************************************************
function SetHeizwerte()
{
   Ind  = document.forms['energie'].LB_Energieart.selectedIndex;
   var i = document.forms['energie'].LB_Energieart.options[Ind].value;
   if (i == 1) // &#x00d6;l
   {
	   document.forms['energie'].Edit_Preis.value= 60;
   }
   
   if (i == 2) // Erdgas
   {
	   document.forms['energie'].Edit_Preis.value= 65;
   }
   
   if (i == 3) // Fl&#x00fc;ssiggas
   {
	   document.forms['energie'].Edit_Preis.value= 60;
   }
}


function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+'.'+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + ',' + cents);
}


//**********************************************************************
function BerechneErgebnis()
{
 // die Funktion geht nicht
 //if (window.document.FormEB.RB_Glas[0].Checked == true) UN = 5.8
 //  else
 //if (window.document.FormEB.RB_Glas[1].Checked == true) UN = 3.0;
  //SetHeizwerte (); 
  v=location.search.substring(1, location.search.length).split('&');
  getVars = new Array();
  for (var i=0;i<v.length;i++){
	  var temp = v[i].split('=');
	  getVars[temp[0]] = temp[1];
  }
  
  //Ind       = document.FormEB.LB_Energieart.selectedIndex;
  var ETyp  = getVars['LB_Ort'];

  //Ind       = document.FormEB.LB_Ort.selectedIndex;
  var G     = getVars['LB_Ort'];
  var F     = getVars['Edit_F'];
  var UN    = getVars['LB_UwNeu'];
  UA        = getVars['Edit_U'];
  var W     = getVars['Edit_W'];
  var CO2Faktor = 0;
  var H         = 0;
  
  var lb_Energieart = getVars['LB_Energieart'];    
   if (lb_Energieart == '1') // &#x00d6;l
   {
		H = 9.92;
		CO2Faktor = 2.7; // kg/l
   }
   if (lb_Energieart == '2') // Erdgas
   {
		H = 10.0;
		CO2Faktor = 2.22; // kg/m3
   }
   if (lb_Energieart == '3') // Fl&#x00fc;ssiggas
   {
	   H = 12.87;
	   CO2Faktor = 3.08; // kg/kg
   }
  
  
  //alert(UA);
  //alert(UN);
  //alert(F);
  //alert(G);
  //alert(H);
  //alert(W);
  var Einheit = Math.round(((UA-UN)*F*G*24) /(10*H*W));
  var Geld  = Einheit * getVars['Edit_Preis'] / 100;
  var CO2   = Math.round(Einheit * CO2Faktor );
  document.forms['energie'].Edit_Liter.value = formatCurrency(Einheit);
  document.forms['energie'].Edit_Geld.value  = formatCurrency(Geld);
  document.forms['energie'].Edit_CO2.value   = formatCurrency(CO2);
}

//**********************************************************************
/*function UWertInfo()
{
  alert("Fenster mit Isolierglas ohne Beschichtung\n\n" + 
        "2.80 W/m&#x00b2; K  - Kunststoff- und Holzfenster\n" +
        "2.90 W/m&#x00b2; K  - Aluminiumfenster\n" +
        "3.20 W/m&#x00b2; K  - sonstige Fenster, z.B. Stahl oder Beton\n\n" +
        "\n\n" + 
        "Fenster mit Einfachglas\n\n" +
        "4.80 W/m&#x00b2; K  - Kunststoff- und Holzfenster\n" +
        "5.00 W/m&#x00b2; K  - Aluminiumfenster\n" +
        "5.00 W/m&#x00b2; K  - sonstige Fenster, z.B. Stahl oder Beton");
        }
*/
//**********************************************************************

function PruefenInt(Element,ElementWert)
 { 
 z = (1==1);
 z=iCheck(ElementWert);
 if(!z)
   {
   Element.focus();
   alert('Dies ist kein g&#x00fc;ltiger Wert!');
   return false;
   }
  return true;
 }

//**********************************************************************

function PruefenFloat(Element,ElementWert)
 { 
 z = (1==1);
 z=fCheck(ElementWert);
 if(!z)
   {
   Element.focus();
   alert('Dies ist kein g&#x00fc;ltiger Wert!');
   return false;
   }
  return true;
 }

//**********************************************************************

function fCheck(s)
 {
 n='.1234567890';
 for(var i=0;i<s.length;i++)
  if((n.indexOf(s.charAt(i))==-1))return false;
 return true;
 }

//**********************************************************************

function iCheck(s)
 {
 n='1234567890';
 for(var i=0;i<s.length;i++)
  if((n.indexOf(s.charAt(i))==-1))return false;
 return true;
 }

//**********************************************************************
/*function UWertInfo() 
{ 
  alert("Fenster mit Isolierglas ohne Beschichtung\n\n" + "2.80 W/m&#x00b2; K - Kunststoff- und Holzfenster\n" + "2.90 W/m&#x00b2; K - Aluminiumfenster\n" + "3.20 W/m&#x00b2; K - sonstige Fenster, z.B. Stahl oder Beton\n\n" + "\n\n" + "Fenster mit Einfachglas\n\n" + "4.80 W/m&#x00b2; K - Kunststoff- und Holzfenster\n" + "5.00 W/m&#x00b2; K - Aluminiumfenster\n" + "5.00 W/m&#x00b2; K - sonstige Fenster, z.B. Stahl oder Beton"); 
}*/


//**********************************************************************
function SetProfileOptions()
{
	Ind  = document.forms['energie'].LB_UwNeu.selectedIndex;
	if(document.forms['energie'].LB_UwNeu.options[Ind].value == '0.8') {
		document.forms['energie'].LB_System.options[1] = null;
		document.forms['energie'].LB_System.options[1] = null;
		document.forms['energie'].LB_System.options[1] = null;
		document.forms['energie'].LB_System.options[1] = null;
		document.forms['energie'].LB_System.options[1] = null;
	}
	else {
		document.forms['energie'].LB_System.options[1] = new Option('TOPLINE 70 AD','toplinead.htm');
		document.forms['energie'].LB_System.options[2] = new Option('SOFTLINE 70 AD','softline70ad.htm');
		document.forms['energie'].LB_System.options[3] = new Option('SWINGLINE','swinglinead.htm');
		document.forms['energie'].LB_System.options[4] = new Option('TOPLINE MD','toplinemd.htm');
		document.forms['energie'].LB_System.options[5] = new Option('SOFTLINE 70 MD','softline70md.htm');
		document.forms['energie'].LB_System.options[2].selected = true;
	}
	if((document.forms['energie'].LB_UwNeu.options[Ind].value == '0.8') || (document.forms['energie'].LB_UwNeu.options[Ind].value == '0.9')){
		document.forms['energie'].LB_System.options[0].selected = true;
	}
}
//**********************************************************************
function neu(name,features) {
	Ind  = document.forms['energie'].LB_System.selectedIndex;
	url= "http://www.veka.de/homepage/divers/de/" + document.forms['energie'].LB_System.options[Ind].value; 
  	window.open(url,name,features);
}
//**********************************************************************

function showassi(h,w ){
	document.getElementById('derframe').height=h;
	document.getElementById('derframe').width=w;
	document.getElementById('derframe').style.display = 'block';
}

function showassihelp( ){
	document.getElementById('derframe').src="assi/help.htm";
	showassi(230,200 );
}

function hideframe(){
    document.getElementById('derframe').style.display = 'none';
}
//**********************************************************************

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function displayClose() {
	if (BrowserDetect.browser=="Explorer") document.getElementById('beend').style.display = 'block';
}


function print_de() {
	javascript:alert('Ein optimales Druckergebnis erhalten Sie, wenn sie im nachfolgenden Druckdialog die Ausrichtung \'Querformat\' ausw&#x00e4;hlen.');
	window.print()
}
