/*#### Popup Fenster ####*/
function openWindow(AGB)
	{
  NewWindow = window.open(AGB, "Zweitfenster","width=500,height=500,scrollbars=yes");
  NewWindow.focus();
	}
	
function openPay(Bezahlen)
	{
  NewWindow = window.open(Bezahlen, "Zweitfenster","width=800,height=600,scrollbars=yes");
  NewWindow.focus();
	}
	
/*#### Browser aktualisierung ####*/
var $buoop = {} 
$buoop.ol = window.onload; 
window.onload=function(){ 
	if ($buoop.ol) $buoop.ol(); 
	var e = document.createElement("script"); 
	e.setAttribute("type", "text/javascript"); 
	e.setAttribute("src", "http://browser-update.org/update.js"); 
	document.body.appendChild(e); 
	}

/*#### Sicherheitsabfragen ####*/

function checkDelete(){
	var text = unescape("Wollen Sie den Eintrag wirklich l%F6schen?");
	var agree = confirm(text);
	if(agree){
		return true;
		}else{
			return false;
			}
	}

function checkAktiv(){
	var text = unescape("Wollen Sie das Objekt wirklich aktivieren?");
	var agree = confirm(text);
	if(agree){
		return true;
		}else{
			return false;
			}
	}
	
function checkDeaktiv(){
	var text = unescape("Wollen Sie das Objekt wirklich deaktivieren?");
	var agree = confirm(text);
	if(agree){
		return true;
		}else{
			return false;
			}
	}

/*#### Objektbewertung ####*/
function bw(bild){
	document.getElementById('pic').src = bild;
	}
	

/*##### Preisausgaben beim Eintragen des Objektes ####*/

// Privat 9oder gewerblich
function setPricePoG(id,price){
	window.document.getElementById(id).value = price;
	}

// Kategoriepreise
function setPriceKat(id,kat){
	for(var i = 0;i < katArray.length; i++){
		if(katArray[i][0] == kat){
			window.document.getElementById(id).value = katArray[i][1];
			}
		}
	}


// Ausstattung
function setPrice(checkId,id,price,on){
	var temp, temp2;

	if(on == 1){
		window.document.getElementById(id).value = price;
		temp = price.replace(',','.');
		temp2 = window.document.getElementById(checkId).value;
		if(temp2 == "0"){temp2 = parseInt(temp2);}
		window.document.getElementById(checkId).value = eval(temp2) + eval(temp);
		}else{
			temp = price.replace(',','.');
			window.document.getElementById(checkId).value = eval(window.document.getElementById(checkId).value) - eval(temp);
			
			if(window.document.getElementById(checkId).value == 0){
				window.document.getElementById(id).value = "0,00";
				}
			
			}
	}


// Luxus
function setPriceLuxus(id,price,on,id2){
	var luxusAll = new Array();
	luxusAll[0] = "userObPaytv1";
	luxusAll[1] = "userObWlan1";
	luxusAll[2] = "userObPC1";
	luxusAll[3] = "userObPrinter1";
	luxusAll[4] = "userObPool1";
	luxusAll[5] = "userObSauna1";
	luxusAll[6] = "userObWirl1";
		
	var countCheck = 0;
	
	for(var i = 0;i < luxusAll.length;i++){
		
		if(window.document.getElementById(luxusAll[i]).checked == true){ 
			countCheck++;
			if(countCheck == luxusAll.length){
				window.document.getElementById(id).value = "0,00";
				}
			}else{
				window.document.getElementById(id).value = price;
				}
		}
	}


// Umgebung
function setPriceUmg(id,price,id2,id3){
	var counArray;
	countArray = parseInt(window.document.getElementById(id3).value);
	var newId = "";
	var countOn = 0;

	for(var i = 0;i < countArray;i++){
		newId = id2 + i;

		if(window.document.getElementById(newId).checked == true){
			window.document.getElementById(id).value = price;
			countOn++;
			}
		}
	
	if(countOn == 0){
		window.document.getElementById(id).value = "0,00";
		}
	}


// Extras
function setPriceExtras(id,price,on,id2){
	var extrasAll = new Array();
	extrasAll[0] = "userObStrom1";
	extrasAll[1] = "userObWasser1";
	extrasAll[2] = "userObParkplatz1";
	extrasAll[3] = "userObService1";
	extrasAll[4] = "userObService21";
	extrasAll[5] = "userObReinigung1";
	extrasAll[6] = "userObBuegel1";
	extrasAll[7] = "userObKey1";
		
	var countCheck = 0;
	
	for(var i = 0;i < extrasAll.length;i++){
		
		if(window.document.getElementById(extrasAll[i]).checked == true){ 
			countCheck++;
			if(countCheck == extrasAll.length){
				window.document.getElementById(id).value = "0,00";
				}
			}else{
				window.document.getElementById(id).value = price;
				}
		}
	}
	
// Verpflegung
function setPriceVerpfl(id,price,on,id2){
	var verpflAll = new Array();
	verpflAll[0] = "userObFrueh1";
	verpflAll[1] = "userObMittag1";
	verpflAll[2] = "userObAbend1";
	verpflAll[3] = "userObKaffee1";
		
	var countCheck = 0;
	
	for(var i = 0;i < verpflAll.length;i++){
		
		if(window.document.getElementById(verpflAll[i]).checked == true){ 
			countCheck++;
			if(countCheck == verpflAll.length){
				window.document.getElementById(id).value = "0,00";
				}
			}else{
				window.document.getElementById(id).value = price;
				}
		}
	}


// Zusatz
function checkArea(id,price,id2){
	var temp = window.document.getElementById(id).value;

	if(temp.length > 0){
		window.document.getElementById(id2).value = price;
		}else{
			window.document.getElementById(id2).value = "0,00";
			}
	}


// Mediapreise
function checkFile(id,countPic,price,id2,id3){
	var newId,z; z=0;
	
	for(var i = 1;i < 6;i++){
		newId = id + i;
		
		if(window.document.getElementById(newId).value != ""){
			window.document.getElementById(id2).value = price;
			z++;
			}
			
		}
		
		if(z < 2){
			
			if(window.document.getElementById(id3).value == ""){
				window.document.getElementById(id2).value = "0,00";
				}
			}
	}
	
function checkArea(fremdId,fremdCount,id,price,id2){
	var temp = window.document.getElementById(id).value;

	if(temp.length > 0){
		window.document.getElementById(id2).value = price;
		}else{
			window.document.getElementById(id2).value = "0,00";
			
			checkFile(fremdId,fremdCount,price,id2);
			}
	}
