var url = String(document.location);
var dev = false ;
if(url.indexOf("z6creation.net") >=0 ){
	var dev = true;
}

/* TRADIFORT ************************************************************************************/
function getOptions_tradifort6m(id, type) {
	
	if ((id!="width") ){
		value_width = Field.getValue("width");
		array_width = value_width.split("-");
		width = array_width[0];
	}

	url = "";
	//if(dev){ url = "/www.easybuilding.eu"; }
	url += "/tradifort/tradifort-6m/options.php?type="+type+"&unit="+id;


	if (id=="width") { 
		if ($("width")) $("width").disable();
		if ($("height")) $("height").disable();
		if ($("element")) $("element").disable();
		if ($("submit")) $("submit").hide();
	}
	if (id=="height") { 
		if ($("height")) $("height").disable();
		if ($("element")) $("element").disable();
		if ($("submit")) $("submit").hide();
		
		if ((Field.getValue("width")=="---") || (Field.getValue("long")=="0")) return false;
		url = url+"&width="+encodeURIComponent(width); 
	}
	if (id=="element") {
		if ($("element")) $("element").disable();
		if ($("submit")) $("submit").hide();
		
		if (Field.getValue("width")=="---") return false;
		if (Field.getValue("height")=="---") return false;
		url = url+"&width="+encodeURIComponent(width);
		url = url+"&height="+encodeURIComponent(Field.getValue("height"));
	}
	if (id=="cheneaux") {
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
		
		if (Field.getValue("width")=="---") return false;
		if (Field.getValue("height")=="---") return false;
		if (Field.getValue("element")=="---") return false;
		url = url+"&width="+encodeURIComponent(width);
		url = url+"&height="+encodeURIComponent(Field.getValue("height"));
		url = url+"&element="+encodeURIComponent(Field.getValue("element"));
	}
	new Ajax.Request(url, { method: 'get',
		onSuccess: function(transport) {
			if (!transport.responseText.empty()) {
				if (id!="width" || (Field.getValue("width")=="---") || Field.getValue("width")==null) $(id).update(transport.responseText).enable();
				if (id=="width" && (Field.getValue("width")!="---") && (Field.getValue("width")!=null)) {
					$("width").enable();
					$("long").enable();
					if (Field.getValue("long")!="---") getOptions_tradifort6m("height", type); 
				}
				else if (id=="height" && (Field.getValue("height")!="---")) getOptions_tradifort6m("element", type);
				else if (id=="element" && (Field.getValue("element")!="---")) getOptions_tradifort6m("cheneaux", type);
			}
		}
	});
}
function showSubmit_tradifort6m() {
	if ((Field.getValue("width")=="---") || (Field.getValue("height")=="---") || (Field.getValue("element")=="---") || (Field.getValue("cheneaux")=="---")) {
		$("submit").hide();
	}else{
		$("submit").show();
		//Effect.ScrollTo('submit');
	} 
}

function getOptions_tradifort5m(id, type) {
	
	if ((id!="width") ){
		value_width = Field.getValue("width");
		array_width = value_width.split("-");
		width = array_width[0];
	}
	
	url = "";
	//if(dev){ url = "/www.easybuilding.eu"; }
	url += "/tradifort/tradifort-5m/options.php?type="+type+"&unit="+id;


	if (id=="width") { 
		if ($("width")) $("width").disable();
		if ($("height")) $("height").disable();
		if ($("element")) $("element").disable();
		if ($("submit")) $("submit").hide();
	}
	if (id=="height") { 
		if ($("height")) $("height").disable();
		if ($("element")) $("element").disable();
		if ($("submit")) $("submit").hide();
		
		if ((Field.getValue("width")=="---") || (Field.getValue("long")=="0")) return false;
		url = url+"&width="+encodeURIComponent(width); 
	}
	if (id=="element") {
		if ($("element")) $("element").disable();
		if ($("submit")) $("submit").hide();
		
		if (Field.getValue("width")=="---") return false;
		if (Field.getValue("height")=="---") return false;
		url = url+"&width="+encodeURIComponent(width);
		url = url+"&height="+encodeURIComponent(Field.getValue("height"));
	}
	if (id=="cheneaux") {
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
		
		if (Field.getValue("width")=="---") return false;
		if (Field.getValue("height")=="---") return false;
		if (Field.getValue("element")=="---") return false;
		url = url+"&width="+encodeURIComponent(width);
		url = url+"&height="+encodeURIComponent(Field.getValue("height"));
		url = url+"&element="+encodeURIComponent(Field.getValue("element"));
	}
	
	new Ajax.Request(url, { method: 'get',
		onSuccess: function(transport) {
			if (!transport.responseText.empty()) {
				if (id!="width" || (Field.getValue("width")=="---") || Field.getValue("width")==null) $(id).update(transport.responseText).enable();
				if (id=="width" && (Field.getValue("width")!="---") && (Field.getValue("width")!=null)) {
					$("width").enable();
					$("long").enable();
					if (Field.getValue("long")!="---") getOptions_tradifort5m("height", type); 
				}
				else if (id=="height" && (Field.getValue("height")!="---")) getOptions_tradifort5m("element", type);
				else if (id=="element" && (Field.getValue("element")!="---")) getOptions_tradifort5m("cheneaux", type);
			}
		}
	});
	
}
function showSubmit_tradifort5m() {
	if ((Field.getValue("width")=="---") || (Field.getValue("height")=="---") || (Field.getValue("element")=="---") || (Field.getValue("cheneaux")=="---")) {
		$("submit").hide();
	}else{
		$("submit").show();
		//Effect.ScrollTo('submit');
	} 
}

/* TRADIFORT ************************************************************************************/

/* GALVAFORT ************************************************************************************/0
function getOptions_galvafort(id, type) {
	
	if ((id!="width") ){
		value_width = Field.getValue("width")
		array_width = value_width.split("-");
		width = array_width[0];
	}
	
	url = "";
	if(dev){url = "/www.easybuilding.eu"; }
	url += "/galvafort/options.php?type="+type+"&unit="+id;

	if (id=="width") { 
		if ($("width")) $("width").disable();
		if ($("height")) $("height").disable();
		if ($("element")) $("element").disable();
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
	}
	if (id=="height") { 
		if ($("height")) $("height").disable();
		if ($("element")) $("element").disable();
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
		
		if ((Field.getValue("width")=="---") || (Field.getValue("long")=="0")) return false;
		url = url+"&width="+encodeURIComponent(width); 
	}
	if (id=="element") {
		if ($("element")) $("element").disable();
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
		
		if (Field.getValue("width")=="---") return false;
		if (Field.getValue("height")=="---") return false;
		url = url+"&width="+encodeURIComponent(width);
		url = url+"&height="+encodeURIComponent(Field.getValue("height"));
	}
	
	if (id=="cheneaux") {
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
		
		if (Field.getValue("width")=="---") return false;
		if (Field.getValue("height")=="---") return false;
		if (Field.getValue("element")=="---") return false;
		url = url+"&width="+encodeURIComponent(width);
		url = url+"&height="+encodeURIComponent(Field.getValue("height"));
		url = url+"&element="+encodeURIComponent(Field.getValue("element"));
		
	}
	new Ajax.Request(url, { method: 'get',
		onSuccess: function(transport) {
			if (!transport.responseText.empty()) {
				if (id!="width" || (Field.getValue("width")=="---") || Field.getValue("width")==null) $(id).update(transport.responseText).enable();
				if (id=="width" && (Field.getValue("width")!="---") && (Field.getValue("width")!=null)) {
					$("width").enable();
					$("long").enable();
					if (Field.getValue("long")!="---") getOptions_galvafort("height", type); 
				}
				else if (id=="height" && (Field.getValue("height")!="---")) getOptions_galvafort("element", type);
				
				if(id =="element"){
					//si le type de couverture est seulement tole laqué on affiche seulement l'image tole
					response = transport.responseText ;
					if(response.indexOf("fibr") != -1){
			
					}else{
						var init_source = $('img_info_couverture').src;
						$('img_info_couverture').src=init_source.replace("info_picto_couverture2.jpg" , "info_picto_couverture3.jpg");
					}
				}
			}
		}
	});
}
function showSubmit_galvafort() {
	if ((Field.getValue("width")=="---") || (Field.getValue("height")=="---") || (Field.getValue("element")=="---") /*|| (Field.getValue("cheneaux")=="---")*/ ) {
		$("submit").hide();
	}else{
		$("submit").show();
	} 
}

/* GALVAFORT ************************************************************************************/

/* GALVABAT  ************************************************************************************/

function getOptions_galvabat(id, type) {

	if ((id!="width") ){
		value_width = Field.getValue("width")
		array_width = value_width.split("-");
		width = array_width[0];
	}
	
	url = "";
	if(dev){url = "/www.easybuilding.eu"; }
	url += "/galvabat/options.php?type="+type+"&unit="+id;

	if (id=="width") { 
		if ($("width")) $("width").disable();
		if ($("height")) $("height").disable();
		if ($("element")) $("element").disable();
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
	}
	if (id=="height") { 
		if ($("height")) $("height").disable();
		if ($("element")) $("element").disable();
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
		
		if ((Field.getValue("width")=="---") || (Field.getValue("long")=="0")) return false;
		url = url+"&width="+encodeURIComponent(width); 
	}
	if (id=="element") {
		if ($("element")) $("element").disable();
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
		
		if (Field.getValue("width")=="---") return false;
		if (Field.getValue("height")=="---") return false;
		url = url+"&width="+encodeURIComponent(width);
		url = url+"&height="+encodeURIComponent(Field.getValue("height"));
	}
	if (id=="cheneaux") {
		if ($("cheneaux")) $("cheneaux").disable();
		if ($("submit")) $("submit").hide();
		
		if (Field.getValue("width")=="---") return false;
		if (Field.getValue("height")=="---") return false;
		if (Field.getValue("element")=="---") return false;
		url = url+"&width="+encodeURIComponent(width);
		url = url+"&height="+encodeURIComponent(Field.getValue("height"));
		url = url+"&element="+encodeURIComponent(Field.getValue("element"));
	}
	new Ajax.Request(url, { method: 'get',
		onSuccess: function(transport) {
			if (!transport.responseText.empty()) {
				if (id!="width" || (Field.getValue("width")=="---") || Field.getValue("width")==null) $(id).update(transport.responseText).enable();
				if (id=="width" && (Field.getValue("width")!="---") && (Field.getValue("width")!=null)) {
					$("width").enable();
					$("long").enable();
					if (Field.getValue("long")!="---") getOptions_galvabat("height", type); 
				}
				else if (id=="height" && (Field.getValue("height")!="---")) getOptions_galvabat("element", type);
				
				if(id =="element"){
					//si le type de couverture est seulement tole laqué on affiche seulement l'image tole
					response = transport.responseText ;
					if(response.indexOf("fibr") != -1){
			
					}else{
						var init_source = $('img_info_couverture').src;
						$('img_info_couverture').src=init_source.replace("info_picto_couverture2.jpg" , "info_picto_couverture3.jpg");
					}
				}
			}
		}
	});
}
function showSubmit_galvabat() {
	if ((Field.getValue("width")=="---") || (Field.getValue("height")=="---") || (Field.getValue("element")=="---") /*|| (Field.getValue("cheneaux")=="---")*/) {
		$("submit").hide();
	}else{
		$("submit").show();
	} 
}

/* GALVABAT ************************************************************************************/
