function defaultValueInput(focus,inputValue){if(focus){if(document.search.query.value==inputValue){document.search.query.value="";}}else{if(document.search.query.value==""){document.search.query.value=inputValue;}}}function validateEmail(strCourriel){var reg=/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/;return reg.test(strCourriel);}function isUndefined(v){var undef;return v===undef;}function raw_popup(url,target,w,h,features,framed){if(isUndefined(w)){w=_POPUP_W;}if(isUndefined(h)){h=_POPUP_H;}if(isUndefined(features)){features=_POPUP_FEATURES;}if(isUndefined(target)){target="_blank";}if(isUndefined(framed)){framed=true;}var wleft=(screen.availWidth-w-10)/2;var wtop=(screen.availHeight-h-90)/2;if(eval(framed)){var theWindow=window.open("",target,"width="+w+",height="+h+",left="+wleft+",top="+wtop+","+features);theWindow.document.open();theWindow.document.write(frameset);theWindow.document.close();theWindow.frames[0].location=frameheader+"?"+url;theWindow.frames[1].location=url;}else{var theWindow=window.open(url,target,"width="+w+",height="+h+",left="+wleft+",top="+wtop+","+features);}theWindow.focus();return theWindow;}function link_popup(src,inframe,w,h,features){var target="sherbrookeAmi";var href=src;if(isUndefined(inframe)){inframe=true;var n=urlvalide.length;for(var i=0;i<n;i++){if(href.indexOf(urlvalide[i])!=-1){inframe=false;break;}}}return raw_popup(href,target||"_blank",w,h,features,inframe);}function printPage(){var param="?";var txt="print=1";var lien=(window.location+"").split("#")[0];if(lien.indexOf("?")>0){param="&";}if(lien.indexOf("print")<0){window.location.href=lien+param+txt;}}function sendLink(){var link="/webconcepteur/web/VilledeSherbrooke/"+document.getElementById("user-language").value+"/sendlink.prt?link="+escape(document.getElementById("full-path").value);link_popup(link,"false",530,375,"location=0,statusbar=0,menubar=0,scrollbars=0,resizable=0");}function navigDropDownMenu(mySelect){if(mySelect.options[mySelect.selectedIndex].value!=0){var myIndex=mySelect.selectedIndex;mySelect.selectedIndex=0;location.href=mySelect.options[myIndex].value;}}function displayFavorites(){if(document.getElementById("favorites-content")){var favHTML="";if(sherbrookeFavoritesJSON.favorites.length>0){favHTML+="<ul>";}for(i=0;i<sherbrookeFavoritesJSON.favorites.length;i++){favHTML+='<li><a href="'+sherbrookeFavoritesJSON.favorites[i].url+'">'+sherbrookeFavoritesJSON.favorites[i].title+"</a>&nbsp;";favHTML+='<a href="#" onclick="removeFavorite('+i+'); return false;" class="remove">'+removeFavText+"</a></li>";}if(sherbrookeFavoritesJSON.favorites.length>0){favHTML+="</ul>";}document.getElementById("favorites-content").innerHTML=favHTML;}}function saveAndDisplay(){var myJSONText=JSON.stringify(sherbrookeFavoritesJSON);store.set("SherbrookeFavorites",myJSONText);displayFavorites();}function getData(){if(store!=null){store.get("SherbrookeFavorites",function(ok,val){if(ok){if(val==null){sherbrookeFavoritesJSON={favorites:[]};}else{sherbrookeFavoritesJSON=JSON.parse(val);}}else{sherbrookeFavoritesJSON={favorites:[]};}});}else{sherbrookeFavoritesJSON={favorites:[]};}}function addCurrentPageToFavorite(){var title=document.title;var url=document.location.href;if(title.indexOf(" -")>=0){title=title.substring(0,title.indexOf(" -"));}addFavorite(title,url);}function addFavorite(a_title,a_url){var i=0;var favFound=false;if(sherbrookeFavoritesJSON.favorites.length>0){while(i<sherbrookeFavoritesJSON.favorites.length&&!favFound){if(sherbrookeFavoritesJSON.favorites[i].url==a_url){favFound=true;}else{i++;}}}var maximumReached=false;if(maxFavorites<=sherbrookeFavoritesJSON.favorites.length){maximumReached=true;}if(!favFound){if(!maximumReached){sherbrookeFavoritesJSON.favorites.push({title:a_title,url:a_url});if(jQuery("body").attr("class")=="fr"){jQuery("#fav-msg").text("La page est ajouté ŕ vos favoris");}else{jQuery("#fav-msg").text("This page is added to your favorites");}jQuery("#fav-msg").fadeIn(500).delay(1500).fadeOut(500);saveAndDisplay();}else{alert(maxFavReachedText);}}else{jQuery("#fav-msg").text(favAlreadyInlistText);jQuery("#fav-msg").fadeIn(500).delay(1500).fadeOut(500);}}function removeFavorite(a_index){sherbrookeFavoritesJSON.favorites.splice(a_index,1);saveAndDisplay();}
