
   
  

$(document).ready(function() {
	Galleria.loadTheme('/medias/classic/galleria.classic.js');
	$('#galleria').galleria({
		height:523,
		width:760
	})
	
	showPanel(1);
	//showPanel(1);
});


function showPanel(id) {

	$('.panel').hide();
	$('#panel_'+id).show();
	$('.panel_title').css('font-weight','lighter');
	
	
	$('#title_'+id).css('font-weight','bold');
	if(id==2) {
		
		initGal();
	}
}


function initGal() {
	t=$('#ta').val().split(',');
	
	i=0;
	s='';
	while(t[i]) {
		if(t[i]!='') {
			s+="<a href='/photos/big/"+t[i]+"'><img src='photos/thumbs/"+t[i]+"'  /></a>";	
		}
		i++;
	}
	
	
	$('#galleria').html(s);
	//Galleria.loadTheme('/medias/classic/galleria.classic.js');
	$('#galleria').galleria({
		height:523,
		width:760
	});
	
}

function showForm(blocId) {
	
	$j.get("ajaxrequest.php",{'todo':'showForm','blocId':blocId},function(data) {
		
		$('#'+blocId).css('display',data);
	});

}




function checkTheFields1() {
	if(document.f_shortcontactform.email.value=="" || document.f_shortcontactform.lastname.value=="" || document.f_shortcontactform.firstname.value=="" || document.f_shortcontactform.tel.value=="") {
	alert("Vous n'avez pas remplis tous les champs obligatoires");
	}
	else {
	document.f_shortcontactform.submit();
	}
}





function checkTheFields2() {
	if(document.f_expcontactform.email.value=="" || document.f_expcontactform.lastname.value=="" || document.f_expcontactform.firstname.value=="" || document.f_expcontactform.tel.value=="") {
	alert("Vous n'avez pas remplis tous les champs obligatoires");
	}
	else {
	document.f_expcontactform.submit();
	}
}



function checkTheFields3() {
	bloc_types_array=Array();
	for(i=0;i<document.f_longcontactform.bloc_types.length;i++) {
		if(document.f_longcontactform.bloc_types[i].selected) {
			bloc_types_array.push(document.f_longcontactform.bloc_types[i].value);
		}
	}
	
	flat_types_array=Array();
	for(i=0;i<document.f_longcontactform.flat_types.length;i++) {
		if(document.f_longcontactform.flat_types[i].selected) {
			flat_types_array.push(document.f_longcontactform.flat_types[i].value);
		}
	}
	house_types_array=Array();
	for(i=0;i<document.f_longcontactform.house_types.length;i++) {
		if(document.f_longcontactform.house_types[i].selected) {
			house_types_array.push(document.f_longcontactform.house_types[i].value);
		}
	}
	area_types_array=Array();
	for(i=0;i<document.f_longcontactform.area_types.length;i++) {
		if(document.f_longcontactform.area_types[i].selected) {
			area_types_array.push(document.f_longcontactform.area_types[i].value);
		}
	}
	document.f_longcontactform.bloc_values.value=bloc_types_array.join(',');
	document.f_longcontactform.flat_values.value=flat_types_array.join(',');
	document.f_longcontactform.house_values.value=house_types_array.join(',');
	document.f_longcontactform.area_values.value=area_types_array.join(',');
	if(document.f_longcontactform.email.value=="" || document.f_longcontactform.lastname.value=="" || document.f_longcontactform.firstname.value=="" || document.f_longcontactform.tel.value=="") {
	alert("Vous n'avez pas remplis tous les champs obligatoires");
	}
	else {
	document.f_longcontactform.submit();
	}
}



// JavaScript Document
function switchSearchFor(type) {
	
	document.searchForm.submit();
	
}

function listResult() {
	if(document.searchForm.searchfor.value=='sale') {
		document.searchForm.chap.value=1;
		document.searchForm.action='index.php';
		document.searchForm.submit();
	}
	else if(document.searchForm.searchfor.value=='rent') {
		document.searchForm.chap.value=2;
		document.searchForm.action='index.php';
		document.searchForm.submit();
	}
	if(document.searchForm.searchfor[0].checked) {
		document.searchForm.chap.value=1;
		document.searchForm.action='index.php';
	}
	else {
		document.searchForm.chap.value=2;
		document.searchForm.action='index.php';
	}
	document.searchForm.submit();
	
}

function showMap(zip) {
	window.open('map.php?zip='+zip,'map','width=600, height=400');
}

/*
	function showForm(blocId) {
		var myAjax = new Ajax.Request(
			"ajaxrequest.php",
			{
				method:'get',
				parameters:'todo=showForm&blocId='+blocId,
				asynchronous:true,
				onComplete: function(request) {
					var val = request.responseText;
					document.getElementById(blocId).style.display=val;
				}
			});
	}
	*/


	function getValues(stage) {
		var myAjax = new Ajax.Request(
			"ajaxrequest.php",
			{
				method:'get',
				parameters:'todo=getValues&stage=' + stage + '&offer_type=' + document.getElementById('offrer_type').value + '&item_type=' + document.getElementById('item_type').value + '&price_slice=' + document.getElementById('price_slice').value + '&geozone=' + document.getElementById('geozone').value + '&nb_rooms=' + document.getElementById('nb_rooms').value,
				asynchronous:true,
				onLoading: function(request) {
					document.getElementById('ajaxstatus').style.backgroundColor='#ff9933';
					document.getElementById('ajaxstatus').style.borderColor='#000000';
				},
				onComplete: function(request) {

					var val = request.responseText;
					var arr = val.split('\n');
					var outval='';

					for(i=0;i<arr.length ;i++ ){
						arr2 = arr[i].split('|');

					}



					//var veh = {car: {}, truck: {}};
					//veh['car']["Ford" + "models"] = ['Fiesta', 'Mondeo', 'Galcon'];
					//var models = veh.car.Fordmodels;
					//for (i = 0; i < models.length; i += 1) {
					//	alert("The model: " + models[i]);
					//}

					
					document.getElementById('ajaxstatus').style.backgroundColor='#ffffff';
					document.getElementById('ajaxstatus').style.borderColor='#000000';
				}
			});
	}









function switchPict(pictName,pictId,size) {
	document.big.src='photos/'+pictName+pictId+'.jpg';
	sizeArray=size.split('x');
	thewidth=sizeArray[0];
	theheight=sizeArray[1];
	document.big.width=thewidth;
	
}
function getBudget(kind) {
	document.theForm.budget.options.length=0;
	if(kind=='rent') {
	budgets=Array("2","4","6");
	}
	else {
	budgets=Array("400","700","1.000","1.500");
	}
	document.theForm.budget.options[0]=new Option("moins de "+budgets[0]+".000 €", "moins de "+budgets[0]+".000", false, false);
	for(i=1;i<budgets.length;i++) {
	document.theForm.budget.options[i]=new Option("entre "+budgets[i-1]+" et "+budgets[i]+".000 €", "entre "+budgets[i-1]+" et "+budgets[i]+".000", false, false);
	}
	document.theForm.budget.options[i-1]=new Option("plus de "+budgets[i-1]+".000 €", "plus de "+budgets[i-1]+".000", false, false);
}

function getBudget2(kind,theform) {
	document.forms[theform].budget.options.length=0;
	if(kind=='rent') {
	budgets=Array("2","4","6");
	}
	else {
	budgets=Array("400","700","1.000","1.500");
	}
	document.forms[theform].budget.options[0]=new Option("moins de "+budgets[0]+".000 �", "moins de "+budgets[0]+".000", false, false);
	for(i=1;i<budgets.length;i++) {
	document.forms[theform].budget.options[i]=new Option("entre "+budgets[i-1]+" et "+budgets[i]+".000 �", "entre "+budgets[i-1]+" et "+budgets[i]+".000", false, false);
	}
	document.forms[theform].budget.options[i-1]=new Option("plus de "+budgets[i-1]+".000 �", "plus de "+budgets[i-1]+".000", false, false);
}


function listResult() {
	if(document.searchForm.searchfor.value=='sale') {
		document.searchForm.chap.value=1;
		document.searchForm.action='index.php';
		document.searchForm.submit();
	}
	else if(document.searchForm.searchfor.value=='rent') {
		document.searchForm.chap.value=2;
		document.searchForm.action='index.php';
		document.searchForm.submit();
	}
	if(document.searchForm.searchfor[0].checked) {
		document.searchForm.chap.value=1;
		document.searchForm.action='index.php';
	}
	else {
		document.searchForm.chap.value=2;
		document.searchForm.action='index.php';
	}
	document.searchForm.submit();
	
}

function menutop_mouseover(id,bool,lang) {
//alert(id.src);
	tarray=id.src.split('/');
	imgsrc=tarray[tarray.length-1];
	tarray=imgsrc.split('.');
	
	if(bool==1) {
		imgsrc=tarray[0]+"_on.png";
		//alert(tarray[0]+"_on.gif");
	}
	else {
		tarray=tarray[0].split('_');
		imgsrc=tarray[0]+".png";
	}

	//alert(tarray[0]+"////"+imgsrc);
	id.src="http://web1003.optinet-isp.net/~mexxinternational.com/www/medias/"+lang+"/"+imgsrc;
}







function translate(language) {
	//alert(language);
	//alert(document.getElementById("origLang").value);
     //var text = document.getElementById("text").innerHTML;
	  var text=document.getElementById("origLang").value;
	//  alert(text);
	  text=text.substr(0,1200);
      google.language.detect(text, function(result) {
        if (!result.error && result.language) {
          google.language.translate(text, result.language, language,
                                    function(result) {
            var translated = document.getElementById("text");
            if (result.translation) {
              translated.innerHTML = result.translation;
		//	  alert(result.translation);
            }
          });
        }
      });
    }



