// JavaScript Document

/*function heightModif(nr){
	if (nr==1){
		document.getElementById("tempDevide").style.height = "30px";
	}
	else if (nr==2){
		document.getElementById("tempDevide").style.height = "86px";
	}
	else if (nr==3){
		document.getElementById("tempDevide").style.height = "44px";
	}
	else if (nr==4){
		document.getElementById("tempDevide").style.height = "44px";
	}
	else if (nr==5){
		document.getElementById("tempDevide").style.height = "114px";
	}
	else if (nr==6){
		document.getElementById("tempDevide").style.height = "128px";
	}
}
function heightModifEN(nr){
	if (nr==1){
		document.getElementById("tempDevide").style.height = "30px";
	}
	else if (nr==2){
		document.getElementById("tempDevide").style.height = "86px";
	}
	else if (nr==3){
		document.getElementById("tempDevide").style.height = "44px";
	}
	else if (nr==4){
		document.getElementById("tempDevide").style.height = "44px";
	}
	else if (nr==5){
		document.getElementById("tempDevide").style.height = "114px";
	}
	else if (nr==6){
		document.getElementById("tempDevide").style.height = "128px";
	}
}
function heightModif2(){
	document.getElementById("tempDevide2").style.height = "1px";
}*/

function showSpan(nr){
	var d = document;
	if (document.getElementById('currentSpan').value != '0') eval("d.getElementById('span"+document.getElementById('currentSpan').value+"').style.display = 'none'");
	eval("d.getElementById('span"+nr+"').style.display = 'block'");
	document.getElementById('currentSpan').value = nr;
}
function showSpanEN(nr){//4 en pages
	var d = document;
	if (document.getElementById('currentSpan').value != '0') eval("d.getElementById('span"+document.getElementById('currentSpan').value+"').style.display = 'none'");
	eval("d.getElementById('span"+nr+"').style.display = 'block'");
	document.getElementById('currentSpan').value = nr;
}
function showSpan2(nr){
	var d = document;
	if (document.getElementById('currentSpan').value != '0') eval("d.getElementById('span"+document.getElementById('currentSpan').value+"').style.display = 'none'");
	eval("d.getElementById('span"+nr+"').style.display = 'block'");
	document.getElementById('currentSpan').value = nr;
	heightModif2();	
}

function detParam(){
	
	var idx = document.URL.indexOf('?');
	var params = new Array();
	
	if (idx != -1){
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++) {
        	nameVal = pairs[i].split('=');
        	params[nameVal[0]] = nameVal[1];
        }
		show2(params["next"],'1');
    }
	else{
		document.getElementById('currentSpan').value = '0';
	}  	
}


function showStep(current, next){
	var d = document;
	if (current == 0) 	eval("d.getElementById('step"+next+"').style.display = 'block'");
	else {
		eval("d.getElementById('step"+current+"').style.display = 'none'");
		eval("d.getElementById('step"+next+"').style.display = 'block'");
	}
}

function showText(next){
	if (next == 1){
		document.getElementById("nfoArea").innerHTML = "Un catalog al caselor construite de compania noastra.<br />Click pentru detalii.";
		document.getElementById("nfoArea").style.color = "#333";
	}
	else if (next == "2"){
		document.getElementById("nfoArea").innerHTML = "Un formular de comanda, prin intermediul caruia, pute-ti solicita o oferta de pret pentru casa dumneavoastra.<br />Click pentru detalii.";
		document.getElementById("nfoArea").style.color = "#333";
	}
	else if (next == "0"){
		document.getElementById("nfoArea").innerHTML = "Pentru detalii,<br />click pe link-urile de mai sus.";
		document.getElementById("nfoArea").style.color = "#999";
	}
}

function showProject(prjNR){
	
	var temp = document.getElementById("currentPG").value;
	
	eval("document.getElementById('pg"+temp+"').style.display = 'none'");
	eval("document.getElementById('pg"+prjNR+"').style.display = 'block'");
	document.getElementById("currentPG").value = prjNR;
}

function detPg(){
	
	var idx = document.URL.indexOf('?');
	var params = new Array();
	
	if (idx != -1){
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++) {
        	nameVal = pairs[i].split('=');
        	params[nameVal[0]] = nameVal[1];
        }
		document.getElementById("currentPG").value = "0";
		showProject(params["next"]);
    }
	else{
		document.getElementById("currentPG").value = "0";
		document.getElementById("pg0").style.display = "block";
	}  	
}

// form scripts

function resetRadioGrp(obj){
	
	for (var i in obj){
		if (obj[i].checked) {obj[i].checked = false;}	
	}
	
}

function radioGrpStatus(obj){
	
	var l = obj;
	
	for (var i = 0; i < l.length; i++){
		
		if (obj[i].checked) {return true;}	
	}
	
	return false;
	
}

function verifythis(theForm){
		
		if (theForm.nume.value == ''){
			alert("Va rugam sa introduceti numele dumneavoastra.");
			return false;
		}
		/*if (theForm.adresa.value == ''){
			alert("Va rugam sa introduceti adresa dumneavoastra.");
			return false;
		}*/
		if (theForm.telfax.value == ''){
			alert("Va rugam sa introduceti un numar de telefon si/sau fax, la care pute-ti fi contactat.");
			return false;
		}
		with (theForm.email.value)
		{
			apos=theForm.email.value.indexOf("@");
			dotpos=theForm.email.value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2) {
				alert("Va rugam sa introduceti o adresa de email valida la care puteti fi contact.");
				return false;
			}
		}
		
		
		if ( !radioGrpStatus(theForm.tipCasaR) && theForm.tipCasaT.value == ''){
			alert("Va rugam sa selectati sau sa descrieti tipul de casa pe care-l doriti.");
			return false;
		}
		
		
		if ( !radioGrpStatus(theForm.tiglaR) && theForm.tiglaT.value == ''){
			alert("Va rugam sa selectati sau sa descrieti tipul de invelitoare pentru acoperis pe care-l doriti.");
			return false;
		}
		if ( !radioGrpStatus(theForm.stablatR) && theForm.stablatT.value == ''){
			alert("Va rugam sa selectati sau sa descrieti tipul de stablat(finisajul stresinei) pe care-l doriti.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajextR) && theForm.finisajextT.value == ''){
			alert("Va rugam sa selectati sau sa descrieti tipul de finisaj exterior pe care-l doriti.");
			return false;
		}	
		if ( !radioGrpStatus(theForm.tamplarieR) && theForm.tamplarieT.value == ''){
			alert("Va rugam sa selectati sau sa descrieti tipul de tamplarie exterioara pe care-l doriti.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajintR) && theForm.finisajintT.value == ''){
			alert("Va rugam sa selectati sau sa descrieti tipul de finisaj interior pe care-l doriti.");
			return false;
		}
		if ( !radioGrpStatus(theForm.izolatieR) && theForm.izolatieT.value == ''){
			alert("Va rugam sa selectati sau sa descrieti ce tip de izolatie doriti sa fie folosit.");
			return false;
		}
		if (theForm.filename.value == ''){
			alert("Va rugam sa atasati planurile sau schita casei pentru care doriti oferta.");
			return false;
		}
		
			
		
	}
	
function verifythisEN(theForm){
		
		if (theForm.nume.value == ''){
			alert("Please add your name.");
			return false;
		}
		/*if (theForm.adresa.value == ''){
			alert("Va rugam sa introduceti adresa dumneavoastra.");
			return false;
		}*/
		if (theForm.telfax.value == ''){
			alert("Please add your telephone and/or fax number.");
			return false;
		}
		with (theForm.email.value)
		{
			apos=theForm.email.value.indexOf("@");
			dotpos=theForm.email.value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2) {
				alert("Please add a valid e-mail address.");
				return false;
			}
		}
		
		
		if ( !radioGrpStatus(theForm.tipCasaR) && theForm.tipCasaT.value == ''){
			alert("Please add the type of house you want.");
			return false;
		}
		
		
		if ( !radioGrpStatus(theForm.tiglaR) && theForm.tiglaT.value == ''){
			alert("Please select or describe the type of roof covering you want.");
			return false;
		}
		if ( !radioGrpStatus(theForm.stablatR) && theForm.stablatT.value == ''){
			alert("Please select or describe the type of eaves finishing you want.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajextR) && theForm.finisajextT.value == ''){
			alert("Please select or describe the type of exterior finishing you want.");
			return false;
		}	
		if ( !radioGrpStatus(theForm.tamplarieR) && theForm.tamplarieT.value == ''){
			alert("Please select or describe the type of exterior joinery you want.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajintR) && theForm.finisajintT.value == ''){
			alert("Please select or describe the type of interior finishing you want.");
			return false;
		}
		if ( !radioGrpStatus(theForm.izolatieR) && theForm.izolatieT.value == ''){
			alert("Please select or describe the type of insulation you want.");
			return false;
		}
		if (theForm.filename.value == ''){
			alert("Please attach the plans or preliminary projects of the house for which you want the offer.");
			return false;
		}
		
			
		
	}

function verifythisENcatalog(theForm){
	
		if (theForm.nume.value == ''){
			alert("Please add your name.");
			return false;
		}
		/*if (theForm.adresa.value == ''){
			alert("Va rugam sa introduceti adresa dumneavoastra.");
			return false;
		}*/
		if (theForm.telfax.value == ''){
			alert("Please add your telephone and/or fax number.");
			return false;
		}
		with (theForm.email.value)
		{
			apos=theForm.email.value.indexOf("@");
			dotpos=theForm.email.value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2) {
				alert("Please add a valid e-mail address.");
				return false;
			}
		}
		
		if ( !radioGrpStatus(theForm.tipCasaR) && theForm.tipCasaT.value == ''){
			alert("Please add the type of house you want.");
			return false;
		}
		
		if ( !radioGrpStatus(theForm.tiglaR) && theForm.tiglaT.value == ''){
			alert("Please select or describe the type of roof covering you want.");
			return false;
		}
		if ( !radioGrpStatus(theForm.stablatR) && theForm.stablatT.value == ''){
			alert("Please select or describe the type of eaves finishing you want.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajextR) && theForm.finisajextT.value == ''){
			alert("Please select or describe the type of exterior finishing you want.");
			return false;
		}	
		if ( !radioGrpStatus(theForm.tamplarieR) && theForm.tamplarieT.value == ''){
			alert("Please select or describe the type of exterior joinery you want.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajintR) && theForm.finisajintT.value == ''){
			alert("Please select or describe the type of interior finishing you want.");
			return false;
		}
		if ( !radioGrpStatus(theForm.izolatieR) && theForm.izolatieT.value == ''){
			alert("Please select or describe the type of insulation you want.");
			return false;
		}
		
}



function verifythisFR(theForm){
		
		if (theForm.nume.value == ''){
			alert("Veuillez introduire votre nom.");
			return false;
		}
		/*if (theForm.adresa.value == ''){
			alert("Va rugam sa introduceti adresa dumneavoastra.");
			return false;
		}*/
		if (theForm.telfax.value == ''){
			alert("Veuillez introduire un numéro de téléphone et/ou de fax.");
			return false;
		}
		with (theForm.email.value)
		{
			apos=theForm.email.value.indexOf("@");
			dotpos=theForm.email.value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2) {
				alert("Veuillez introduire une adresse de courriel valide.");
				return false;
			}
		}
		
		
		if ( !radioGrpStatus(theForm.tipCasaR) && theForm.tipCasaT.value == ''){
			alert("Veuillez introduire le type de maison que vous désirez.");
			return false;
		}
		
		
		if ( !radioGrpStatus(theForm.tiglaR) && theForm.tiglaT.value == ''){
			alert("Veuillez sélectez ou décrire le type de couverture pour le toit que vous désirez.");
			return false;
		}
		if ( !radioGrpStatus(theForm.stablatR) && theForm.stablatT.value == ''){
			alert("Veuillez sélectez ou décrire le type de finition de l’avant-toit que vous désirez.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajextR) && theForm.finisajextT.value == ''){
			alert("Veuillez sélectez ou décrire le type de finition extérieur que vous désirez.");
			return false;
		}	
		if ( !radioGrpStatus(theForm.tamplarieR) && theForm.tamplarieT.value == ''){
			alert("Veuillez sélectez ou décrire le type de menuiserie extérieure que vous désirez.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajintR) && theForm.finisajintT.value == ''){
			alert("Veuillez sélectez ou décrire le type de finition intérieure que vous désirez.");
			return false;
		}
		if ( !radioGrpStatus(theForm.izolatieR) && theForm.izolatieT.value == ''){
			alert("Veuillez sélectez ou décrire le type d’isolation que vous désirez.");
			return false;
		}
		if (theForm.filename.value == ''){
			alert("Veuillez joindre les plans ou les avant-projets de la maison pour laquelle vous désirez l’offre.");
			return false;
		}
		
			
		
	}

function verifythisFRcatalog(theForm){
		
		if (theForm.nume.value == ''){
			alert("Veuillez introduire votre nom.");
			return false;
		}
		/*if (theForm.adresa.value == ''){
			alert("Va rugam sa introduceti adresa dumneavoastra.");
			return false;
		}*/
		if (theForm.telfax.value == ''){
			alert("Veuillez introduire un numéro de téléphone et/ou de fax.");
			return false;
		}
		with (theForm.email.value)
		{
			apos=theForm.email.value.indexOf("@");
			dotpos=theForm.email.value.lastIndexOf(".");
			if (apos<1||dotpos-apos<2) {
				alert("Veuillez introduire une adresse de courriel valide.");
				return false;
			}
		}
		
		
		if ( !radioGrpStatus(theForm.tipCasaR) && theForm.tipCasaT.value == ''){
			alert("Veuillez introduire le type de maison que vous désirez.");
			return false;
		}
		
		
		if ( !radioGrpStatus(theForm.tiglaR) && theForm.tiglaT.value == ''){
			alert("Veuillez sélectez ou décrire le type de couverture pour le toit que vous désirez.");
			return false;
		}
		if ( !radioGrpStatus(theForm.stablatR) && theForm.stablatT.value == ''){
			alert("Veuillez sélectez ou décrire le type de finition de l’avant-toit que vous désirez.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajextR) && theForm.finisajextT.value == ''){
			alert("Veuillez sélectez ou décrire le type de finition extérieur que vous désirez.");
			return false;
		}	
		if ( !radioGrpStatus(theForm.tamplarieR) && theForm.tamplarieT.value == ''){
			alert("Veuillez sélectez ou décrire le type de menuiserie extérieure que vous désirez.");
			return false;
		}
		if ( !radioGrpStatus(theForm.finisajintR) && theForm.finisajintT.value == ''){
			alert("Veuillez sélectez ou décrire le type de finition intérieure que vous désirez.");
			return false;
		}
		if ( !radioGrpStatus(theForm.izolatieR) && theForm.izolatieT.value == ''){
			alert("Veuillez sélectez ou décrire le type d’isolation que vous désirez.");
			return false;
		}
}


	
	
	function setValue(theForm, obj){
		
		var ceva = eval("this."+obj+".value;");
		alert(ceva);
		
	}
	
		
	function showDetails (next, prev){
	
		var d = document;
		d.getElementById("right_panel").innerHTML="";
		
		d.getElementById('right_panel').innerHTML=d.getElementById('det'+next).innerHTML;
		d.getElementById("details").value = next;
	
	}
	
	function deselectRadioGrp(obj){
		for (var i = 0; i < obj.lenght; i++){
		if (obj[i].checked) {obj[i].checked = false;}	
	}	
	}

function showHouse(nr){
	var d = document;
	var currentPG = d.getElementById("catalogPG").value;
	eval("d.getElementById('no"+currentPG+"').style.display = 'none'");
	eval("d.getElementById('no"+nr+"').style.display = 'block'");
	d.getElementById("catalogPG").value = nr;
	if (nr == 0){d.getElementById("backButton").style.display = 'none';}
	else{d.getElementById("backButton").style.display = 'block';}
}

function changeBG(no,target){

	var d = document;
	var obj = eval("d.getElementById('"+target+"')");
	if (target == "no1") obj.style.background = "url(/images/vrt_catalog_v1_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no2") obj.style.background = "url(/images/vrt_catalog_v2_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no3") obj.style.background = "url(/images/vrt_catalog_v3_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no4") obj.style.background = "url(/images/vrt_catalog_v4_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no5") obj.style.background = "url(/images/vrt_catalog_v5_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no6") obj.style.background = "url(/images/vrt_catalog_v6_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no7") obj.style.background = "url(/images/vrt_catalog_v7_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no8") obj.style.background = "url(/images/vrt_catalog_v8_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no10") obj.style.background = "url(/images/vrt_catalog_v10_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no11") obj.style.background = "url(/images/vrt_catalog_v11_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no12") obj.style.background = "url(/images/vrt_catalog_v12_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no13") obj.style.background = "url(/images/vrt_catalog_v13_ro_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no14") obj.style.background = "url(/images/vrt_catalog_v14_ro_bg"+no+".jpg) no-repeat 50% 0%";
	
	//alert(obj.style.background);
}

function changeBGen(no,target){

	var d = document;
	var obj = eval("d.getElementById('"+target+"')");
	
	if (target == "no1") obj.style.background = "url(/images/vrt_catalog_v1_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no2") obj.style.background = "url(/images/vrt_catalog_v2_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no3") obj.style.background = "url(/images/vrt_catalog_v3_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no4") obj.style.background = "url(/images/vrt_catalog_v4_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no5") obj.style.background = "url(/images/vrt_catalog_v5_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no6") obj.style.background = "url(/images/vrt_catalog_v6_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no7") obj.style.background = "url(/images/vrt_catalog_v7_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no8") obj.style.background = "url(/images/vrt_catalog_v8_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no10") obj.style.background = "url(/images/vrt_catalog_v10_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no11") obj.style.background = "url(/images/vrt_catalog_v11_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no12") obj.style.background = "url(/images/vrt_catalog_v12_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no13") obj.style.background = "url(/images/vrt_catalog_v13_en_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no14") obj.style.background = "url(/images/vrt_catalog_v14_en_bg"+no+".jpg) no-repeat 50% 0%";
	
	//alert(obj.style.background);
}

function changeBGfr(no,target){

	var d = document;
	var obj = eval("d.getElementById('"+target+"')");
	
	if (target == "no1") obj.style.background = "url(/images/vrt_catalog_v1_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no2") obj.style.background = "url(/images/vrt_catalog_v2_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no3") obj.style.background = "url(/images/vrt_catalog_v3_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no4") obj.style.background = "url(/images/vrt_catalog_v4_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no5") obj.style.background = "url(/images/vrt_catalog_v5_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no6") obj.style.background = "url(/images/vrt_catalog_v6_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no7") obj.style.background = "url(/images/vrt_catalog_v7_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no8") obj.style.background = "url(/images/vrt_catalog_v8_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no9") obj.style.background = "url(/images/vrt_catalog_v9_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no10") obj.style.background = "url(/images/vrt_catalog_v10_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no11") obj.style.background = "url(/images/vrt_catalog_v11_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no12") obj.style.background = "url(/images/vrt_catalog_v12_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no13") obj.style.background = "url(/images/vrt_catalog_v13_fr_bg"+no+".jpg) no-repeat 50% 0%";
	else if (target == "no14") obj.style.background = "url(/images/vrt_catalog_v14_fr_bg"+no+".jpg) no-repeat 50% 0%";
	
	//alert(obj.style.background);
}


function writeV(){
	
	document.getElementById("scriptError").style.display = "none";
	
	
	var idx = document.URL.indexOf('?');
	var params = new Array();
	
	if (idx != -1){
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++) {
        	nameVal = pairs[i].split('=');
        	params[nameVal[0]] = nameVal[1];
        }
		document.getElementById("houseId").innerHTML= params["next"]+".<br><br>";
		document.getElementById("houseV").value = params["next"];
    }
	else{
		document.getElementById("houseId").innerHTML = "...";
		document.getElementById("scriptError").style.display = "block";
	}  	

}

function redoit(){

	var idx = document.URL.indexOf('?');
	var params = new Array();
	
	if (idx != -1){
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++) {
        	nameVal = pairs[i].split('=');
        	params[nameVal[0]] = nameVal[1];
        }
		return params["next"];
    }
	else{
		document.getElementById("houseId").innerHTML = "<strong>Script Error!! Please reload the page</strong>";
	}

}