	var popupStatus = 0;
	var popupname;
	var db = [];
	//loading popup with jQuery magic!
	function loadPopup(popupname1) {
	    popupname = popupname1;		if(popupStatus==0){
			$("#backgroundPopup").css({
				"opacity": "0.8",
				"height": "1000px"
			});
			$("#backgroundPopup").fadeIn("slow");
			$('#'+popupname1).fadeIn("slow");
			popupStatus = 1;
			$("#videoDiv").css({
				"visibility": "hidden"
			});
		}
	}
	//disabling popup with jQuery magic!

	function disablePopup(popupname1) {
		if(popupStatus==1){
			$("#backgroundPopup").fadeOut("slow");
			$('#popupContact1').fadeOut("slow");
			$('#partListingsDiv').fadeOut("slow");
			$('#'+ popupname).fadeOut("slow");
			popupStatus = 0;
			$("#videoDiv").css({
				"visibility": "visible"
			});
			$('#'+ popupname).remove();
			/*$("#searchDiv").css({
				"visibility": "visible"
			});*/
			//$('#searchDiv').fadeIn("slow");
		}
	}
	
	//centering popup
	function centerPopup(popupname) {
		//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $('#'+popupname).height();
		var popupWidth = $('#'+popupname).width();
		
		$('#'+popupname).css({
			"position": "absolute",
			"top": 0,
			"left": windowWidth/2-popupWidth/2
		});
		window.scrollTo(0, 0);
		/*$('#'+popupname).css({
			"position": "absolute",
			"top": windowHeight/2-popupHeight/2,
			"left": windowWidth/2-popupWidth/2 + 50
		});
		window.scrollTo(0, (windowHeight / 2 - popupHeight / 2));*/
		//only need force for IE6
		var windowHeight1 = document.body.clientHeight;
		$("#backgroundPopup").css({
			"height": windowHeight1
		});
	}
	
	//CONTROLLING EVENTS IN jQuery
	$(document).ready(function(){
		//LOADING POPUP
		//Click the button event!
		$("#button").click(function(){
		//centering with css
			centerPopup(popupname);
			//load popup
			loadPopup();
		});
		//CLOSING POPUP
		//Click the x event!
		$("#popupContactClose").click(function() {
			disablePopup(popupname);
		});
		//Click out event!
		$("#backgroundPopup").click(function() {
		disablePopup(popupname);
		});
		//Press Escape event!
		$(document).keypress(function(e){
		if (e.keyCode == 27 && popupStatus == 1) {
		    disablePopup(popupname);
		}
		});
	});
	var content = null;
	var pclass = "";
	var typeTxt = "";

	function update_values(v1, v2, v3, v2txt, v3txt) {
		category = v1 ; type = v2 ; ville = v3;typeTxt = v2txt;
		var url = "./index.php?pclass%5B%5D="+v1;
		if (v1 == 11){pclass = "residentiel";url = url +"&residentiel="+v2txt+"&balneaire=&professionel=&"+v3txt+"&action=searchresults";}
		if (v1 == 12){pclass = "balneaire";url = url +"&residentiel=&balneaire="+v2txt+"&professionel=&"+v3txt+"&action=searchresults";}
		if (v1 == 13){pclass = "professionel";url = url +"&residentiel=&balneaire=&professionel="+v2txt+"&"+v3txt+"&action=searchresults";}
		var icons = document.getElementsByName("icon");
		//debugger;
		for(var i = 0; i<icons.length; i++){
			var id = icons[i].getAttribute("id");
			if(id == v1+"__" || id == v1+"_"+v2+"_" || id == v1+"_"+v2+"_"+v3){
				document.getElementById("span_"+id).innerHTML = '<img name="icon" id="'+id+'" column="'+ $("#"+id).attr("column") + '" src="'+templatePath+'/'+ $("#"+id).attr("column") + 'arrow_gold.gif" style="cursor:pointer;vertical-align:center;margin-bottom:20px;" border="0" onclick="javascript:update_values(\''+$("#"+id).attr("cat")+'\',\''+$("#"+id).attr("type")+'\',\''+$("#"+id).attr("ville")+'\',\''+$("#"+id).attr("typetxt")+'\',\''+$("#"+id).attr("villetxt")+'\');" cat="'+$("#"+id).attr("cat")+'"  type="'+$("#"+id).attr("type")+'" ville="'+$("#"+id).attr("ville")+'"  typetxt="'+$("#"+id).attr("typetxt")+'"  villetxt="'+$("#"+id).attr("villetxt")+'"/>';
			}
			else{
				document.getElementById("span_"+id).innerHTML = '<img name="icon" id="'+id+'" column="'+ $("#"+id).attr("column") + '" src="'+templatePath+'/'+ $("#"+id).attr("column") + 'arrow.gif" style="cursor:pointer;vertical-align:center;margin-bottom:20px;" border="0" onclick="javascript:update_values(\''+$("#"+id).attr("cat")+'\',\''+$("#"+id).attr("type")+'\',\''+$("#"+id).attr("ville")+'\',\''+$("#"+id).attr("typetxt")+'\',\''+$("#"+id).attr("villetxt")+'\');" onmouseover="this.src=\''+templatePath+$("#"+id).attr("column") +'arrow_gold.gif\'" onmouseout="this.src=\''+templatePath+$("#"+id).attr("column") +'arrow.gif\'" cat="'+$("#"+id).attr("cat")+'"  type="'+$("#"+id).attr("type")+'" ville="'+$("#"+id).attr("ville")+'"  typetxt="'+$("#"+id).attr("typetxt")+'"  villetxt="'+$("#"+id).attr("villetxt")+'"/>';
			}
		}
		if (v1 != "" && v2 == "" && v3 == "") { $("#priv_part").hide();$("#searchResults").hide();$("#featuredListings").hide(); /*$("#featuredListings").fadeIn(3000);*/$("#column4").hide(); $("#videoDiv").hide(); $("#contentDiv").hide(); /*$("#searchDiv").fadeIn(3000);*/ $("#column2").fadeIn(10); $("#column3").fadeIn(10); $("#211").hide(); $("#212").hide(); $("#213").hide(); $("#3111").hide(); $("#3112").hide(); $("#3113").hide(); $("#3114").hide(); $("#3115").hide(); $("#3121").hide(); $("#3122").hide(); $("#3123").hide(); $("#3124").hide(); $("#3125").hide(); $("#3131").hide(); $("#3132").hide(); $("#3133").hide(); $("#3134").hide(); $("#3135").hide(); }
		if (v1 != "" && v2 != "" && v3 == "") { $("#priv_part").hide();$("#searchResults").hide();$("#featuredListings").hide(); /*$("#featuredListings").fadeIn(3000);*/$("#column4").hide(); $("#3111").hide(); $("#3112").hide(); $("#3113").hide(); $("#3114").hide(); $("#3115").hide(); $("#3121").hide(); $("#3122").hide(); $("#3123").hide(); $("#3124").hide(); $("#3125").hide(); $("#3131").hide(); $("#3132").hide(); $("#3133").hide(); $("#3134").hide(); $("#3135").hide(); }
		if(v1 != "" && v2 != "" && v3 != ""){
			document.getElementById("column4").innerHTML = "<div style='width:100%;text-align:center'>... chargement ...</div>";
			jQuery.get(url, "", function(data) { $("#priv_part").hide();$("#searchResults").hide();$("#featuredListings").hide(); document.getElementById("column4").innerHTML = data; $("#column4").fadeIn(3000); });
		}
		if(v1 != "") $("#2"+v1).fadeIn(3000);
		if(v2 != "") $("#3"+v1+""+v2).fadeIn(3000);
	}

	function update_search(value,id,sb){
		if(value == "" && sb == undefined){
			document.getElementById("typeAll"+id).innerHTML = '<select name="residentiel"> <option value=""/> <option value="Appartement">Appartement</option> <option value="Villa">Villa</option> <option value="Terrain">Terrain</option> <option value="Ryad">Ryad</option> <option value="Divers">Divers</option> <option value="Balneaire">Baln&eacute;aire</option> <option value="Resorts">Resorts-Golf</option> <option value="Hotel">H&ocirc;tels</option> <option value="Spa">Cure-Spa</option> <option value="Bureau">Bureaux</option> <option value="Usine">Usine</option> <option value="Depot">D&eacute;pots-Hangars</option> <option value="Magasin">Magasin</option> <option value="Commerce">Fond de commerce</option> </select>';
		}
		if(value == "" && sb != undefined){
			document.getElementById("prixmin"+id).innerHTML = '<select id="prixminSelect'+id+'"/>';
			document.getElementById("prixmax"+id).innerHTML = '<select id="prixmaxSelect'+id+'"/>';			
		}
		if(value == "11"){
			document.getElementById("typeAll"+id).innerHTML = "<select id='typeSelect"+id+"' name='residentiel'> <option value=''/> <option value='Appartement'>Appartement</option> <option value='Villa'>Villa</option> <option value='Terrain'>Terrain</option> <option value='Ryad'>Ryad</option> <option value='Divers'>Divers</option> </select>";
		}
		if(value == "12"){
			document.getElementById("typeAll"+id).innerHTML = '<select id="typeSelect'+id+'" name="balneaire"> <option value=""/>  <option value="Balneaire">Baln&eacute;aire</option> <option value="Resorts">Resorts-Golf</option> <option value="Hotel">H&ocirc;tels</option> <option value="Spa">Cure-Spa</option> </select>';
		}
		if(value == "13"){
			document.getElementById("typeAll"+id).innerHTML = '<select id="typeSelect'+id+'"  name="professionel"> <option value=""/> <option value="Bureau">Bureaux</option> <option value="Usine">Usine</option> <option value="Depot">D&eacute;pots-Hangars</option> <option value="Magasin">Magasin</option> <option value="Commerce">Fond de commerce</option> </select>';
		}
		if(value == "Vente-Achat"){
			document.getElementById("prixmin"+id).innerHTML = '<select id="prixminSelect'+id+'"> <option value="200000">200000 DH</option> <option value="300000">300000DH</option> <option value="400000">400000DH</option> <option value="500000">500000 DH</option> <option value="1000000">1000000 DH</option> <option value="1500000">1500000 DH</option> <option value="2000000">2000000 DH</option> </select>';
			document.getElementById("prixmax"+id).innerHTML = '<select id="prixmaxSelect'+id+'"> <option value="300000">300000 DH</option> <option value="400000">400000DH</option> <option value="600000">600000DH</option> <option value="1000000">1000000 DH</option> <option value="2500000">2500000 DH</option> <option value="3000000">3000000 DH</option> <option value="9999999999">5000000 DH et Plus</option> </select>';
		}	
		if(value == "Location-Vide"){
			document.getElementById("prixmin"+id).innerHTML = '<select id="prixminSelect'+id+'"> <option value="3000">3000 DH</option> <option value="5000">5000 DH</option> <option value="7000">7000 DH</option> <option value="10000">10000</option> <option value="20000">20000 DH</option> <option value="30000">30000 DH</option> <option value="50000">50000 DH</option> </select>';
			document.getElementById("prixmax"+id).innerHTML = '<select id="prixmaxSelect'+id+'"> <option value="5000">5000 DH</option> <option value="8000">8000 DH</option> <option value="15000">15000 DH</option> <option value="25000">25000</option> <option value="35000">35000 DH</option> <option value="50000">50000 DH</option> <option value="9999999999">60000 DH et Plus</option> </select>';
		}
		if(value == "Location-meublee"){
			document.getElementById("prixmin"+id).innerHTML = '<select id="prixminSelect'+id+'"> <option value="5000">5000 DH</option> <option value="8000">8000 DH</option> <option value="15000">15000 DH</option> <option value="17500">17500 DH</option> <option value="20000">20000 DH</option> <option value="25000">25000 DH</option> <option value="30000">30000 DH</option> </select>';
			document.getElementById("prixmax"+id).innerHTML = '<select id="prixmaxSelect'+id+'"> <option value="8000">8000 DH</option> <option value="14000">14000 DH</option> <option value="18000">18000 DH</option> <option value="25000">25000 DH</option> <option value="35000">35000 DH</option> <option value="50000">50000 DH</option> <option value="9999999999">60000 DH et plus</option> </select>';
		}		
	}

function search_results(id) {
	$("#featuredListings").hide();
	var cat = document.getElementById("categorySelect"+id).value;
	var type = document.getElementById("typeSelect"+id).value;
	var transaction = document.getElementById("transactionSelect"+id).value;	
	var ville =  document.getElementById("villeSelect"+id).value;	
	var prixmin = document.getElementById("prixminSelect"+id).value;	
	var prixmax = document.getElementById("prixmaxSelect"+id).value;				
	var url = "./index.php?action=searchresults&pclass%5B%5D="+cat;
	if(cat == '')	url += "&residentiel=&balneaire=&professionel=";			
	if(cat == '11')	url += "&residentiel="+type+"&balneaire=&professionel=";
	if(cat == '12')	url += "&residentiel=&balneaire="+type+"&professionel=";
	if(cat == '13')	url += "&residentiel=&balneaire=&professionel="+type;
	url += "&city="+ville+"&price-min="+prixmin+"&price-max="+prixmax+"&transaction="+transaction;
	
	document.getElementById("searchResults").style.width = "60%";
	document.getElementById("searchResults").innerHTML = "Chargement en cours ...";

	jQuery.get( url,"",function(data){$("#priv_part").hide();$("#videoDiv").hide();$("#contentDiv").hide();/*$("#searchDiv").fadeIn(3000);*/$("#column2").hide();$("#column3").hide();$("#column4").hide();$("#211").hide();$("#212").hide();$("#213").hide();$("#3111").hide();$("#3112").hide();$("#3113").hide();$("#3114").hide();$("#3115").hide();$("#3121").hide();$("#3122").hide();$("#3123").hide();$("#3124").hide();$("#3125").hide();$("#3131").hide();$("#3132").hide();$("#3133").hide();$("#3134").hide();$("#3135").hide();document.getElementById("searchResults").innerHTML = data;$("#searchResults").fadeIn(3000);});
}

function view_favorites(url) {
	
	document.getElementById("searchResults").style.width = "60%";
	document.getElementById("searchResults").innerHTML = "Chargement en cours ...";

	jQuery.get( url,"",function(data){$("#priv_part").hide();$("#featuredListings").hide();$("#videoDiv").hide();$("#contentDiv").hide();/*$("#searchDiv").fadeIn(3000);*/$("#column2").hide();$("#column3").hide();$("#column4").hide();$("#211").hide();$("#212").hide();$("#213").hide();$("#3111").hide();$("#3112").hide();$("#3113").hide();$("#3114").hide();$("#3115").hide();$("#3121").hide();$("#3122").hide();$("#3123").hide();$("#3124").hide();$("#3125").hide();$("#3131").hide();$("#3132").hide();$("#3133").hide();$("#3134").hide();$("#3135").hide();document.getElementById("searchResults").innerHTML = data;$("#searchResults").fadeIn(3000);});
}

function map_search(ville) {
    disablePopup('popupContact1');
    document.body.style.cursor = '';
    var url = './?action=searchresults&pclass[]=' + category + '&city=' + ville;
    if (category == '11') url += "&residentiel=" + typeTxt + "&balneaire=&professionel=";
    if (category == '12') url += "&residentiel=&balneaire=" + typeTxt + "&professionel=";
    if (category == '13') url += "&residentiel=&balneaire=&professionel=" + typeTxt;
    jQuery.get(url, "",function(data) {document.getElementById("column4").innerHTML = data; $("#column4").fadeIn(3000); });
}

function savedSearch(url) {
	jQuery.get( url,"",function(data){$("#videoDiv").hide();$("#contentDiv").hide();/*$("#searchDiv").fadeIn(3000);*/$("#column2").hide();$("#column3").hide();$("#column4").hide();$("#211").hide();$("#212").hide();$("#213").hide();$("#3111").hide();$("#3112").hide();$("#3113").hide();$("#3114").hide();$("#3115").hide();$("#3121").hide();$("#3122").hide();$("#3123").hide();$("#3124").hide();$("#3125").hide();$("#3131").hide();$("#3132").hide();$("#3133").hide();$("#3134").hide();$("#3135").hide();$("#featuredListings").hide();document.getElementById("searchResults").innerHTML = data;$("#searchResults").fadeIn(3000);});
}

function get_pub(pclass){
	jQuery.get('./?action=searchresults&projetpub=oui&pclass[]=' + pclass, '',function(data) {document.getElementById("divpub"+pclass).innerHTML = data; });
}

function displayPubVideo(){
	document.getElementById("pub").style.display="none"; 
	$("#videoDiv").fadeIn("slow");
}
	
function get_part(pclass){
	jQuery.get('./?action=searchresults&projetpub=oui&sortby=position&pclass[]=' + pclass, '',function(data) {document.getElementById("divpartners").innerHTML = data; });
}	
	
function search_partners(id, title, image) {
	hideProjectsPartners();
	hideVideoPartners();
	document.getElementById("partListingsDivT").innerHTML = "<div style='cursor:pointer;' onclick='disablePopup(\"partListingsDiv\")'><img style='vertical-align:middle;' src='template/css/images/close.jpg'/>Fermer</div> <div class='textMenu' style='font-size:25px; width:100%; height:50px; text-align:center'><!--span class='textMenu'>"+title+"</span--><br/><img width='170px' height='100px' class='borderSilver' src='"+image+"'/></div>";
    var	url = "./?action=searchresults&pclass[]_or[]=11&pclass[]_or[]=12&pclass[]_or[]=13&promoteur="+id;
	jQuery.get( url,"",function(data) {document.getElementById("partListingsDivL").innerHTML = data;$("#partListingsDiv").fadeIn(3000);});
}	

function putVideoPartners(vid,title,description,id,prix,quartier,adresse,ville,pays) {
	document.getElementById("partListingsDivR").innerHTML = "<div id='partners_" + vid + "' name='contactPopup1' style='color:#cecece;border-right: #cecece 2px solid; padding-right: 12px; border-top: #cecece 2px solid; padding-left: 12px; font-size: 13px; z-index: 2; background: black; padding-bottom: 12px; border-left: #cecece 2px solid; width: 700px; padding-top: 40px; border-bottom: #cecece 2px solid; _position: fixed; position: relative; top: -10px;text-align:center;color: #EAB347'><a id='popupContactClose'><img style='cursor: hand' onclick='hideVideoPartners();' src='template/css/images/close.jpg'></img></a><strong>"+title+"</strong><br/><iframe src='http://www.giroptic.com/client/embed_nologo/frame.php?xid=" + vid + "' width='560' height='395' frameborder='0' marginwidth='0' marginheight='0' scrolling='no'></iframe><BR/><table><tr><td width='30%'><br/>Prix (Dh):"+prix+"<br/>Quartier:"+quartier+"<br/>Adresse:"+adresse+"<br/>Ville:"+ville+"<br/>Pays:"+pays+"</td><td width='70%' style='padding-left:10px'><br/><p style='color:#ffffff;'>"+description+"</p></td></tr></table></div>"; 	
}

function hideProjectsPartners() {
	document.getElementById("partListingsDivL").innerHTML = ''; 	
}	

function hideVideoPartners() {
	document.getElementById("partListingsDivR").innerHTML = ''; 	
}	


function get_featured_listings(pclass){
	jQuery.get('./?action=searchresults&pclass[]_or[]=11&pclass[]_or[]=12&pclass[]_or[]=13&featuredOnly=yes', '',function(data) {document.getElementById("pubspace").innerHTML = data; $('ul.spy').simpleSpy(1,8000);});
}

function get_pubspace(pclass){
	jQuery.get('./?action=searchresults&pclass[]=' + pclass + '&sortby=position&featuredOnly=yes', '',function(data) {document.getElementById("featuredListings").innerHTML = data; $('ul.spypub').simpleSpy(6,8000);});
}
function display_pub(video, title, image) {
	hideProjectsPartners();
	hideVideoPartners();
	document.getElementById("partListingsDivT").innerHTML = "<div style='cursor:pointer;' onclick='disablePopup(\"partListingsDiv\")'><img style='vertical-align:middle;' src='template/css/images/close.jpg'/>Fermer</div> <div class='textMenu' style='font-size:25px; width:100%; height:50px; text-align:center'><span class='textMenu'>"+title+"</span><br/><img width='400px' height='90px' class='borderSilver' src='"+image+"'/></div>";
	document.getElementById("partListingsDivR").innerHTML = '<div id="partners_' + video + '" name="contactPopup1" style="color:#cecece;border-right: #cecece 2px solid; padding-right: 12px; border-top: #cecece 2px solid; padding-left: 12px; font-size: 13px; z-index: 2; background: black; padding-bottom: 12px; border-left: #cecece 2px solid; width: 700px; padding-top: 40px; border-bottom: #cecece 2px solid; _position: fixed; height: 500px; position: relative; top: 40px;text-align:center;color: #EAB347"><a id="popupContactClose"><img style="cursor: hand" onclick="hideVideoPartners();" src="template/css/images/close.jpg"></img></a><strong>'+title+'</strong><br/><iframe src="http://www.giroptic.com/client/embed_nologo/frame.php?xid=' + video + '" width="560" height="395" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><BR/><p style="color:#ffffff;"></p></div>'; 	
    
}
function hide_progress(){
	setTimeout("$('#progressbar').hide();",120000);
}

function putPubVideo(vid,title,description,quartier,adresse,ville,pays,photo) {
	document.getElementById("searchDivCenter").style.visibility = "hidden";
	document.getElementById("searchDiv").style.visibility = "hidden";
	var html = "<div id='fetured_" + vid + "' name='contactPopup1' style='color:#cecece;border-right: #cecece 2px solid; padding-right: 12px; border-top: #cecece 2px solid; padding-left: 12px; font-size: 13px;left:500px; z-index: 2; background: black; padding-bottom: 12px; border-left: #cecece 2px solid; width: 700px; padding-top: 40px; border-bottom: #cecece 2px solid; _position: fixed; position: absolute; top: 40px; display: none; text-align:center;color: #EAB347'><div id='popupGallery'><a onclick='$(\"#videodiv"+vid+"\").show();$(\"#photosdiv"+vid+"\").hide();'>Visite viruelle</a>  |  <a onclick='$(\"#videodiv"+vid+"\").hide();$(\"#photosdiv"+vid+"\").show();'>Photos</a></div><a id='popupContactClose'><img style='cursor: hand' onclick='disablePopup(\"fetured_" + vid + "\")' src='template/css/images/close.jpg'></img></a><strong>"+title+"</strong><br/><div id='videodiv"+vid+"'><iframe src='http://www.giroptic.com/client/embed_nologo/frame.php?xid=" + vid + "' width='560' height='395' frameborder='0' marginwidth='0' marginheight='0' scrolling='no'></iframe></div><div style='display:none;' id='photosdiv"+vid+"'>";
	html += '<embed type="application/x-shockwave-flash" src="https://picasaweb.google.com/s/c/bin/slideshow.swf" width="560" height="395" flashvars="host=picasaweb.google.com&hl=fr&feat=flashalbum&RGB=0x000000&feed='+photo+'" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';//photo;
	html += "</div><BR/><table><tr><td width='30%'><br/>Quartier:"+quartier+"<br/>Adresse:"+adresse+"<br/>Ville:"+ville+"<br/>Pays:"+pays+"</td><td width='70%' style='padding-left:10px'><br/><p style='color:#ffffff;'>"+description+"</p></td></tr></table></div>"; 
	document.getElementById("featuredDiv").innerHTML = html;
	loadPopup('fetured_'+vid); 
	centerPopup('fetured_'+vid);
};

function putVideo(vid,title,description,id,prix,quartier,adresse,ville,pays) {
		  document.getElementById("searchDivCenter").style.visibility = "hidden";
		  document.getElementById("searchDiv").style.visibility = "hidden";
	      document.getElementById("featuredDiv").innerHTML = "<div id='fetured_" + vid + "' name='contactPopup1' style='color:#cecece;border-right: #cecece 2px solid; padding-right: 12px; border-top: #cecece 2px solid; padding-left: 12px; font-size: 13px;left:500px; z-index: 2; background: black; padding-bottom: 12px; border-left: #cecece 2px solid; width: 700px; padding-top: 40px; border-bottom: #cecece 2px solid; _position: fixed; position: absolute; top: 40px; display: none; text-align:center;color: #EAB347'><a id='popupContactClose'><img style='cursor: hand' onclick='disablePopup(\"fetured_" + vid + "\")' src='template/css/images/close.jpg'></img></a><strong>"+title+"</strong><br/><iframe src='http://www.giroptic.com/client/embed_nologo/frame.php?xid=" + vid + "' width='560' height='395' frameborder='0' marginwidth='0' marginheight='0' scrolling='no'></iframe><BR/><table><tr><td width='30%'><br/>Prix (Dh):"+prix+"<br/>Quartier:"+quartier+"<br/>Adresse:"+adresse+"<br/>Ville:"+ville+"<br/>Pays:"+pays+"</td><td width='70%' style='padding-left:10px'><br/><p style='color:#ffffff;'>"+description+"</p></td></tr></table><!--p style='width:100%; text-align:center;'>{check_member}<a href='index.php?action=addtofavorites&amp;listingID="+id+"'>{lang_add_favorites_link}</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='index.php?action=delete_favorites&amp;listingID="+id+"' onclick='return confirmDelete()'>{lang_delete_from_favorites}</a>{/check_member}</p--></div>"; 
      };

function putVidPhotos(vid,title,description,id,prix,quartier,adresse,ville,pays,photo) {
		  document.getElementById("searchDivCenter").style.visibility = "hidden";
		  document.getElementById("searchDiv").style.visibility = "hidden";
	      var html = "<div id='fetured_" + vid + "' name='contactPopup1' style='color:#cecece;border-right: #cecece 2px solid; padding-right: 12px; border-top: #cecece 2px solid; padding-left: 12px; font-size: 13px;left:500px; z-index: 2; background: black; padding-bottom: 12px; border-left: #cecece 2px solid; width: 700px; padding-top: 40px; border-bottom: #cecece 2px solid; _position: fixed; position: absolute; top: 40px; display: none; text-align:center;color: #EAB347'><div id='popupGallery'><a onclick='$(\"#videodiv"+id+"\").show();$(\"#photosdiv"+id+"\").hide();'>Visite viruelle</a>  |  <a onclick='$(\"#videodiv"+id+"\").hide();$(\"#photosdiv"+id+"\").show();'>Photos</a></div><a id='popupContactClose'><img style='cursor: hand' onclick='disablePopup(\"fetured_" + vid + "\")' src='template/css/images/close.jpg'></img></a><strong>"+title+"</strong> <br/><div id='videodiv"+id+"'><iframe src='http://www.giroptic.com/client/embed_nologo/frame.php?xid=" + vid + "' width='560' height='395' frameborder='0' marginwidth='0' marginheight='0' scrolling='no'></iframe></div><div style='display:none;' id='photosdiv"+id+"'>";
		  html += '<embed type="application/x-shockwave-flash" src="https://picasaweb.google.com/s/c/bin/slideshow.swf" width="560" height="395" flashvars="host=picasaweb.google.com&hl=fr&feat=flashalbum&RGB=0x000000&feed='+photo+'" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';//photo;
		  //html += photo;
		  html += "</div><BR/><table><tr><td width='30%'><br/>Prix (Dh):"+prix+"<br/>Quartier:"+quartier+"<br/>Adresse:"+adresse+"<br/>Ville:"+ville+"<br/>Pays:"+pays+"</td><td width='70%' style='padding-left:10px'><br/><p style='color:#ffffff;'>"+description+"</p></td></tr></table><!--p style='width:100%; text-align:center;'>{check_member}<a href='index.php?action=addtofavorites&amp;listingID="+id+"'>{lang_add_favorites_link}</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='index.php?action=delete_favorites&amp;listingID="+id+"' onclick='return confirmDelete()'>{lang_delete_from_favorites}</a>{/check_member}</p--></div>"; 
		  document.getElementById("featuredDiv").innerHTML = html;
      };
/******************************************************************************************************************************/
$(document).ready(function() {
  // Handler for .ready() called.
  get_pubspace(16);get_featured_listings();
});
(function ($) {
    
$.fn.simpleSpy = function (limit, interval) {
    limit = limit || 6;
    interval = interval || 8000;
    
    return this.each(function () {
        // 1. setup
            // capture a cache of all the list items
            // chomp the list down to limit li elements
        var $list = $(this),
            items = [], // uninitialised
            currentItem = limit,
            total = 0, // initialise later on
            height = $list.find('> li:first').height();
            
        // capture the cache
        $list.find('> li').each(function () {
            items.push('<li>' + $(this).html() + '</li>');
        });
        
        total = items.length;
        
        $list.wrap('<div class="spyWrapper" />').parent().css({ height : height * limit });
        
        $list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();
 
        // 2. effect        
        function spy() {
            // insert a new item with opacity and height of zero
            var $insert = $(items[currentItem]).css({
                height : 0,
                opacity : 0,
                display : 'none'
            }).prependTo($list);
                        
            // fade the LAST item out
            $list.find('> li:last').animate({ opacity : 0}, 1000, function () {
                // increase the height of the NEW first item
                $insert.animate({ height : height }, 1000).animate({ opacity : 1 }, 1000);
                
                // AND at the same time - decrease the height of the LAST item
                // $(this).animate({ height : 0 }, 1000, function () {
                    // finally fade the first item in (and we can remove the last)
                    $(this).remove();
                // });
            });
            
            currentItem++;
            if (currentItem >= total) {
                currentItem = 0;
            }
            
            setTimeout(spy, interval)
        }
        
        spy();
    });
};
    
})(jQuery);
