function resetAdvancedSerch(){for(y=0;y<document.forms.advancedSearchSoftwares.length;y++){document.forms.advancedSearchSoftwares[y].checked=false}for(y=0;y<document.forms.advancedSearchActivities.length;y++){document.forms.advancedSearchActivities[y].checked=false}document.getElementById("advancedLocation").value="";document.getElementById("advancedLocationMaxDistance").value="";hiddeAdvancedSearch()}function hiddeAdvancedSearch(){$("#divAdvancedSerachGeneral").animate({height:0},500,function(){document.getElementById("recherchePoint").removeAttribute("readonly");document.getElementById("divBtnAdvancedSearch").onclick=function(){showAdvancedSearch()};document.getElementById("flecheAdvancedSearch").src=serveur+"img/site/flecheAdvancedSearch"+colorAdvancedSerachFleche+".png";$("#divAdvancedSerachGeneral")[0].style.display="none";advancedSearch=false});$("#btnSearchStudio, #divChpRecherche").animate({opacity:1},500,function(){})}function showAdvancedSearch(){$("#divAdvancedSerachGeneral")[0].style.display="block";var a=document.getElementById("recherchePoint").value;document.getElementById("recherchePoint").value="";document.getElementById("recherchePoint").setAttribute("readonly",false);if(a!=""){$.ajax({url:serveur+"ajax/cleanAdvancedSearchString.php",type:"POST",data:{str:a},dataType:"xml",success:function(a){geocoderUser=new GClientGeocoder;geocoderUser.reset();str=a.getElementsByTagName("value")[0].firstChild.data;geocoderUser.getLocations(str,function(a){if(a.Status.code!=200){document.getElementById("advancedLocation").value=""}else{var b=a.Placemark[0];var c=b.address;document.getElementById("advancedLocation").value=c}})}})}else{document.getElementById("advancedLocation").value=""}$("#divAdvancedSerachGeneral").animate({height:146},500,function(){document.getElementById("divBtnAdvancedSearch").onclick=function(){hiddeAdvancedSearch()};document.getElementById("flecheAdvancedSearch").src=serveur+"img/site/flecheAdvancedSearch"+colorAdvancedSerachFleche+"Up.png";advancedSearch=true});$("#btnSearchStudio, #divChpRecherche").animate({opacity:0},500,function(){})}function drawCircle(a,b){var c=GPolygon.Circle(a,b*1e3,"#000000",2,.3,"#000000",.1);map.addOverlay(c);return c}function userCountryResult(a){var b=a.getElementsByTagName("idPays")[0].firstChild.data;var c=a.getElementsByTagName("nomPays")[0].firstChild.data;var d=a.getElementsByTagName("codeTelPays")[0].firstChild.data;var e=document.createElement("option");e.text=c;e.value=b;insertOptionBefore(e,document.getElementById("fCountry"));document.getElementById("fCountry").insertBefore(e,document.getElementById("fCountry").firstChild);document.getElementById("fCountry").selectedIndex=0;var f=document.createElement("option");f.text=d;insertOptionBefore(f,document.getElementById("fPrefixPhone"));document.getElementById("fPrefixPhone").insertBefore(f,document.getElementById("fPrefixPhone").firstChild);document.getElementById("fPrefixPhone").selectedIndex=0;$(".InputOpacite").removeClass("InputOpacite")}function formatAdressUser(a){adresse=a;geocoderUser=new GClientGeocoder;if(geocoderUser){geocoderUser.reset();geocoderUser.getLocations(a,function(b){if(b.Status.code!=200){alert(a+" is unavailable");document.getElementById("fAddress").value="";document.getElementById("fCity").value="";document.getElementById("fAAN").value="";document.getElementById("fZip").value=""}else{var c=b.Placemark[0];requete("ajax/getCountrySpec.php","?codePays="+c.AddressDetails.Country.CountryNameCode,userCountryResult);var d=new Array;var e=b.Placemark[0];function f(a,b){if(typeof a=="string"){d[""+a.toString()+""]=b}}function g(a,b){for(i in a){if(typeof a[i]=="object"){g(a[i],b)}else{b.apply(this,[i,a[i]])}}}g(e,f);var h="";var j="";var k="";var l="";if(d["ThoroughfareName"]){j=d["ThoroughfareName"]}if(d["LocalityName"]){h=d["LocalityName"]}if(d["AdministrativeAreaName"]){l=d["AdministrativeAreaName"]}if(d["PostalCodeNumber"]){k=d["PostalCodeNumber"]}document.getElementById("fAddress").value=j.replace(/(^\s*)|(\s*$)/g,"");document.getElementById("fCity").value=h.replace(/(^\s*)|(\s*$)/g,"");document.getElementById("fAAN").value=l.replace(/(^\s*)|(\s*$)/g,"");document.getElementById("fZip").value=k.replace(/(^\s*)|(\s*$)/g,"")}})}}function forceHttp(){var a=document.getElementById("siteStudio").value;if(a.substring(0,7)=="http://"){}else{document.getElementById("siteStudio").value="http://"+a}}function allStudios(){firstLoad=true;requete("ajax/listStudioMap.php","?recherche=",placerPoint)}function resetOldSearches(){resetHistorique();var a=document.getElementById("recherchePoint").value;document.getElementById("txtPermalink").value="";if(a!=""){recherchePointBdd()}}function resetHistorique(){supprPoints();recherche1=null;recherche2=null;lastTableauPermalink=new Array;totalTableauPermalink=new Array;totalPermalinkNom=new Array;indexHistoriqueNom=0;document.getElementById("txtPermalink").value="";document.getElementById("recherchePoint").value="";firstLoad=true;requete("ajax/listStudioMap.php","?recherche=",placerPoint)}function historiqueRecherche(a,b){if(a.getElementsByTagName("marker").length>0){placerPoint(a,AIcon,b);document.getElementById("ajaxLoaderLocal").style.visibility="hidden"}else{document.getElementById("spanCompteurRequete").innerHTML=" No studio found";supprPoints();document.getElementById("ajaxLoaderLocal").style.visibility="hidden"}}function drawAdvancedSearch(a,b,c,d,e,f,g){advancedLatLng="&lat="+escape(a)+"&lng="+escape(b)+"&maxDistance="+d;var h=new GLatLng(a,b);if(d>1e3){d=1e3;document.getElementById("advancedLocationMaxDistance").value=1e3}var i={strRecherche:c,advancedSearchLocation:h,maxDistance:d,strActivities:e,strSoftwares:f};requete("ajax/listStudioMap.php","?recherche="+e+f+advancedLatLng+"&city="+g,historiqueRecherche,i)}function traitementAdvancedSearch(a){var b="&activities=";var c=0;for(y=0;y<document.forms.advancedSearchActivities.length;y++){if(document.forms.advancedSearchActivities[y].checked==true){if(c!=0){b+="--"+document.forms.advancedSearchActivities[y].value}else{b+=document.forms.advancedSearchActivities[y].value}c++}}var d="&softwares=";var c=0;for(y=0;y<document.forms.advancedSearchSoftwares.length;y++){if(document.forms.advancedSearchSoftwares[y].checked==true){if(c!=0){d+="--"+document.forms.advancedSearchSoftwares[y].value}else{d+=document.forms.advancedSearchSoftwares[y].value}c++}}if(b=="&activities="){b=""}if(d=="&softwares="){d=""}var e=document.getElementById("advancedLocation").value;var f=document.getElementById("advancedLocationMaxDistance").value;if(f==0||f==""){f="null"}else{f=f.replace(",",".")}var g="";if(e!=""){if(is_numeric(f)){document.getElementById("advancedLocationMaxDistance").style.borderColor="#cccccc";geocoderUser=new GClientGeocoder;geocoderUser.reset();geocoderUser.getLatLng(e,function(c){if(c==null){requete("ajax/listStudioMap.php","?recherche="+b+d+"&city="+e,historiqueRecherche,a);alert("Location : '"+a+"' is unavailable")}else{var g=c.lat();var h=c.lng();drawAdvancedSearch(g,h,a,f,b,d,e)}})}else{if(f=="null"){requete("ajax/listStudioMap.php","?recherche="+a+b+d+"&city="+e,historiqueRecherche,a)}else{alert("This is not a number!");document.getElementById("ajaxLoaderLocal").style.visibility="hidden";document.getElementById("advancedLocationMaxDistance").style.borderColor="red"}}}else{requete("ajax/listStudioMap.php","?recherche="+a+b+d,historiqueRecherche,a)}}function recherchePointBdd(a){if(a){var b="";document.getElementById("ajaxLoaderLocal").style.visibility="visible";requete("ajax/listStudioMap.php","?recherche="+b,historiqueRecherche)}else{if(document.getElementById("recherchePoint").value!=""||advancedSearch==true){document.getElementById("ajaxLoaderLocal").style.visibility="visible";var b="";if(document.getElementById("recherchePoint").value!="Ex : VFX London"&&document.getElementById("recherchePoint").value!=""){b=escape(document.getElementById("recherchePoint").value)}if(advancedSearch==true){b=document.getElementById("advancedLocation").value;traitementAdvancedSearch(b)}else{requete("ajax/listStudioMap.php","?recherche="+b,historiqueRecherche,b)}document.getElementById("aDirectory").href=serveur+"cg-studios-list/q/"+b}else{var b="";document.getElementById("ajaxLoaderLocal").style.visibility="visible";document.getElementById("aDirectory").href=serveur+"cg-studios-list";requete("ajax/listStudioMap.php","?recherche="+b,historiqueRecherche)}}}function supprPoints(){for(var a in tableauPoint){map.removeOverlay(tableauPoint[a]["marker"])}if(markerCluster!=null){markerCluster.clearMarkers()}}function navTo(a){var b=new GLatLngBounds;var c=a.split("|");for(z=0;z<c.length;z++){var d=c[z].split(",");var e=d[0];var f=d[1];if(e!=undefined&&f!=undefined){b.extend(new GLatLng(e,f,false))}}map.setCenter(b.getCenter());map.setZoom(map.getBoundsZoomLevel(b))}function bulleInfoStudio(a){var b=a.getElementsByTagName("marker");var c="";for(i=0;i<b.length;i++){tableauPoint[b.item(i).getAttribute("id")]["name"]=stripslashes(b.item(i).getElementsByTagName("name")[0].firstChild.data);var d=tableauPoint[b.item(i).getAttribute("id")]["name"];c+="<div class='infoBulleInt'>CGStudio's name :<br /><div class='infoBulleStudioName'>"+d+"</div>";c+="<a class='lienInfoBulle' href='"+serveur+"id-card/"+tableauPoint[b.item(i).getAttribute("id")]["id"]+"/"+urlencode(d)+"' target='_blank'><div class='seeMoreMap'>See <strong>"+d+"</strong>'s mini ID Card</div></a>";c+="</div><div class='sB'></div>"}markerBulle.openInfoWindowHtml(c.substring(0,c.length-22))}function urlencode(a){a=escape(a);a=a.replace("+","-");a=a.replace("%20","-");a=a.replace("*","-");a=a.replace("/","-");a=a.replace("\\","-");a=a.replace("@","-");return a}function getInfoStudio(a,b,c){requete("ajax/getStudioMapInfos.php","?idStudio="+a+"&lat="+b+"&lng="+c,bulleInfoStudio)}function placerPoint(a,b,c){if(markerBulle){markerBulle.closeInfoWindow()}arrayMarker=new Array;if(markerCluster!=null&&markerCluster){markerCluster.clearMarkers();map.clearOverlays()}if(b){var d={icon:b}}else{var d=iconDefaut}var e=new GLatLngBounds;var f=a.getElementsByTagName("marker");var g=a.getElementsByTagName("total")[0].firstChild.data;document.getElementById("spanCompteurRequete").innerHTML="<span id='nbrResultMap'>"+g+"</span> studios found";for(i=0;i<f.length;i++){if(tableauPoint[f.item(i).getAttribute("id")]){map.removeOverlay(tableauPoint[f.item(i).getAttribute("id")]["marker"]);delete tableauPoint[f.item(i).getAttribute("id")]}var h=new GLatLng(f.item(i).getElementsByTagName("lat")[0].firstChild.data,f.item(i).getElementsByTagName("lng")[0].firstChild.data,false);e.extend(h);var j=new GMarker(h,d);j.value=f.item(i).getAttribute("id");tableauPoint[f.item(i).getAttribute("id")]=new Array;tableauPoint[f.item(i).getAttribute("id")]["id"]=f.item(i).getAttribute("id");tableauPoint[f.item(i).getAttribute("id")]["marker"]=j;tableauPoint[f.item(i).getAttribute("id")]["point"]=h;GEvent.addListener(j,"click",function(){markerBulle=this;getInfoStudio(tableauPoint[this.value]["id"],this.getLatLng().lat(),this.getLatLng().lng())});arrayMarker.push(j)}markerCluster=new MarkerClusterer(map,arrayMarker,{maxZoom:12,gridSize:40});indexHistoriqueNom++;if(f.length==1){if(d.icon==AIcon){map.setCenter(h);map.setZoom(15)}else if(d.icon==BIcon){}else{map.setCenter(h);map.setZoom(15)}}else if(f.length>1){if(d.icon==AIcon){map.setCenter(e.getCenter());var k;if(map.getBoundsZoomLevel(e)<6){k=map.getBoundsZoomLevel(e)-1}else{k=map.getBoundsZoomLevel(e)}map.setZoom(k)}else if(d.icon==BIcon){}else{map.setCenter(e.getCenter());map.setZoom(2)}}if(firstLoad==true){map.setCenter(new GLatLng("18.6230470","15.9328550"));map.setZoom(2);firstLoad=false}if(c&&c.advancedSearchLocation&&c.maxDistance){var l=drawCircle(c.advancedSearchLocation,c.maxDistance);k=map.getBoundsZoomLevel(l.getBounds());map.setZoom(k);var m=new GMarker(c["advancedSearchLocation"],{draggable:true,icon:zoneMarker});GEvent.addListener(m,"dragstart",function(){map.closeInfoWindow()});GEvent.addListener(m,"dragend",function(){var a=m.getLatLng();var b=c.strRecherche;c.advancedSearchLocation=a;drawAdvancedSearch(a.lat(),a.lng(),b,c.maxDistance,c.strActivities,c.strSoftwares)});map.addOverlay(m)}if(c&&c.strRecherche){perma=serveur+"home/q/"+c["strRecherche"];document.getElementById("txtPermalink").value=perma}return true}function positionPoint(a){document.getElementById("adresseStudio").value=adresse;document.getElementById("divAjoutInfo").style.display="block";$("#divAjout").animate({height:hauteurDivAjoutPointDeuxiemeEtape},800,function(){});$("#divAjoutInfo").animate({opacity:1},800,function(){})}function recupAdresse(a){place=a.Placemark[0];point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);map.setCenter(point,13);marker=new GMarker(point);map.addOverlay(marker);marker.openInfoWindowHtml(place.address)}function addStudioCountryResult(a){var b=a.getElementsByTagName("idPays")[0].firstChild.data;var c=a.getElementsByTagName("nomPays")[0].firstChild.data;var d=a.getElementsByTagName("codeTelPays")[0].firstChild.data;var e=document.createElement("option");e.text=c;e.value=b;insertOptionBefore(e,document.getElementById("paysStudio"));document.getElementById("paysStudio").insertBefore(e,document.getElementById("paysStudio").firstChild);document.getElementById("paysStudio").selectedIndex=0;var f=document.createElement("option");f.text=d;insertOptionBefore(f,document.getElementById("prefixPhone"));document.getElementById("prefixPhone").insertBefore(f,document.getElementById("prefixPhone").firstChild);document.getElementById("prefixPhone").selectedIndex=0}function insertOptionBefore(a,b){if(b.selectedIndex>=0){var c=b.options[b.selectedIndex];try{b.add(a,c)}catch(d){b.add(a,b.selectedIndex)}}}function afficherAdresse(a){adresse=a;if(geocoderAjout){geocoderAjout.reset();mapAjoutStudio.clearOverlays();document.getElementById("ajaxLoaderAdresse").style.display="block";geocoderAjout.getLocations(a,function(b){if(b.Status.code!=200){alert(a+" is unavailable");document.getElementById("ajaxLoaderAdresse").style.display="none";document.getElementById("adresseStudio").value="";document.getElementById("cityStudio").value="";document.getElementById("administrativeAreaNameStudio").value="";document.getElementById("zipStudio").value=""}else{var c=b.Placemark[0];var d=c.Point.coordinates;point=new GLatLng(d[1],d[0]);mapAjoutStudio.setCenter(point,13);markerRecherche=new GMarker(new GLatLng(d[1],d[0]),{draggable:true});GEvent.addListener(markerRecherche,"dragstart",function(){mapAjoutStudio.closeInfoWindow();var a=markerRecherche.getLatLng();document.getElementById("lat").value=a.lat();document.getElementById("lng").value=a.lng()});GEvent.addListener(markerRecherche,"dragend",function(){var a=markerRecherche.getLatLng();document.getElementById("lat").value=a.lat();document.getElementById("lng").value=a.lng()});var e=markerRecherche.getLatLng();document.getElementById("lat").value=e.lat();document.getElementById("lng").value=e.lng();mapAjoutStudio.addOverlay(markerRecherche);document.getElementById("ajaxLoaderAdresse").style.display="none";var f=new Array;var g=b.Placemark[0];function h(a,b){if(typeof a=="string"){f[""+a.toString()+""]=b}}function j(a,b){for(i in a){if(typeof a[i]=="object"){j(a[i],b)}else{b.apply(this,[i,a[i]])}}}j(g,h);var k="";var l="";var m="";var n="";if(f["ThoroughfareName"]){l=f["ThoroughfareName"]}if(f["LocalityName"]){k=f["LocalityName"]}if(f["AdministrativeAreaName"]){n=f["AdministrativeAreaName"]}if(f["PostalCodeNumber"]){m=f["PostalCodeNumber"]}requete("ajax/getCountrySpec.php","?codePays="+f["CountryNameCode"],addStudioCountryResult);document.getElementById("adresseStudio").value=l.replace(/(^\s*)|(\s*$)/g,"");document.getElementById("cityStudio").value=k.replace(/(^\s*)|(\s*$)/g,"");document.getElementById("administrativeAreaNameStudio").value=n.replace(/(^\s*)|(\s*$)/g,"");document.getElementById("zipStudio").value=m.replace(/(^\s*)|(\s*$)/g,"")}})}}function requete(a,b,c,d){xhr=getXhr();xhr.onreadystatechange=function(){if(xhr.readyState==4){if(xhr.status==200){if(xhr.responseXML){if(d){c.call(this,xhr.responseXML,d)}else{c.call(this,xhr.responseXML)}}}else{alert("Error code : "+xhr.status)}}};xhr.open("GET",serveur+a+b,true);xhr.setRequestHeader("Content-Type","text/html; charset=UTF-8");xhr.send(null)}function load(){if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("map"));geocoder=new GClientGeocoder;map.setUIToDefault();firstLoad=true;GEvent.addListener(map,"click",function(a,b){if(b){};})}if(getVar("q")!=""){requete("ajax/listStudioMap.php","?recherche="+escape(getVar("q")),historiqueRecherche,escape(getVar("q")))}else{requete("ajax/listStudioMap.php","?recherche=",placerPoint)}}function getVar(a){var b=String(document.location);var c=b.indexOf("/"+a+"/","3");if(c!=-1){b=b.substr(c+a.length+2,b.length-c);return_value=b}else{return_value=""}return unescape(return_value)}function lockSubmit(a,b){var c;if(window.event)c=window.event.keyCode;else if(a)c=a.which;else return true;if(c==13){b.blur();return false}}function submitenter(a,b,c,d){var e;if(window.event)e=window.event.keyCode;else if(b)e=b.which;else return true;if(e==13){if(d!=""){c.call(this,d);submitEnterTimer=false}else{c.call(this,null);submitEnterTimer=false}}else{return true}}function stripslashes(a){return(a+"").replace(/\\(.?)/g,function(a,b){switch(b){case"\\":return"\\";case"0":return"";case"":return"";default:return b}})}function addslashes(a){return(a+"").replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0")}function is_numeric(a){return(typeof a==="number"||typeof a==="string")&&a!==""&&!isNaN(a)}var advancedSearch=false;var newPoint=new Array;var map=null;var geocoder=null;var markerRecherche;var adresse;var tableauPoint=new Array;var lastTableauPermalink=new Array;var totalTableauPermalink=new Array;var totalPermalinkNom=new Array;var indexHistoriqueNom=0;var markerCluster;var markerBulle=null;var recherche1;var recherche2;var AIcon;letter="A";AIcon=new GIcon(G_DEFAULT_ICON);AIcon.image=serveur+"img/site/markerMap.png";var BIcon;letter2="B";BIcon=new GIcon(G_DEFAULT_ICON);BIcon.image=serveur+"img/site/markerMap.png";var zoneMarker;zoneMarker=new GIcon(G_DEFAULT_ICON);zoneMarker.image=serveur+"img/markers/flecheArea.png";zoneMarker.iconSize=new GSize(34,33);zoneMarker.shadow=serveur+"img/markers/shadowArea.png";zoneMarker.shadowSize=new GSize(48,37);zoneMarker.iconAnchor=new GPoint(17,16);zoneMarker.imageMap=[0,0,34,0,34,33,0,33];var iconDefaut=new GIcon(G_DEFAULT_ICON);iconDefaut.image=serveur+"img/site/markerMap.png";var historiquestringRecherche=""
