// general
function homeOver(){document.getElementById('home').innerHTML='<img src="design/icons/home.png" alt="Home" />'}function homeOut(){document.getElementById('home').innerHTML=''}function optView(){document.getElementById('searchopt').style.display='block'}function optHide(){document.getElementById('searchopt').style.display='none'}function showCountry(){var list=document.getElementById("cty_list");if(list.style.display=='none'){slowOp("cty_list",100);list.style.display='block'}else{list.style.display='none'}}function overCountry(){var country=document.getElementById("cty_select");country.style.background='#0065b7 url(design/a_down.gif) 5px 50% no-repeat';country.style.border='1px solid #0065b7';country.style.color='#fff'}function outCountry(){var country=document.getElementById("cty_select");country.style.background='#fff url(design/a_down_blue.gif) 5px 50% no-repeat';country.style.border='1px solid #dedede';country.style.color='#0065b7'}

// bbcode
var isMozilla=(navigator.userAgent.toLowerCase().indexOf('gecko')!=-1)?true:false;var regexp=new RegExp("[\r]","gi");function storeCaret(id,selec){if(isMozilla){oField=document.getElementById('textarea_'+id);objectValue=oField.value;deb=oField.selectionStart;fin=oField.selectionEnd;objectValueDeb=objectValue.substring(0,oField.selectionStart);objectValueFin=objectValue.substring(oField.selectionEnd,oField.textLength);objectSelected=objectValue.substring(oField.selectionStart,oField.selectionEnd);oField.value=objectValueDeb+"["+selec+"]"+objectSelected+"[/"+selec+"]"+objectValueFin;oField.selectionStart=strlen(objectValueDeb);oField.selectionEnd=strlen(objectValueDeb+"["+selec+"]"+objectSelected+"[/"+selec+"]");oField.focus();oField.setSelectionRange(objectValueDeb.length+selec.length+2,objectValueDeb.length+selec.length+2)}else{oField=document.getElementById('textarea_'+id);var str=document.selection.createRange().text;if(str.length>0){var sel=document.selection.createRange();sel.text="["+selec+"]"+str+"[/"+selec+"]";sel.collapse();sel.select()}else{oField.focus(oField.caretPos);oField.focus(oField.value.length);oField.caretPos=document.selection.createRange().duplicate();var bidon="%~%";var orig=oField.value;oField.caretPos.text=bidon;var i=oField.value.search(bidon);oField.value=orig.substr(0,i)+"["+selec+"][/"+selec+"]"+orig.substr(i,oField.value.length);var r=0;for(n=0;n<i;n++){if(regexp.test(oField.value.substr(n,2))==true){r++}};pos=i+2+selec.length-r;var r=oField.createTextRange();r.moveStart('character',pos);r.collapse();r.select()}}}

// print
function print(titre){var header='<html><head><title>'+titre+'</title><link rel="stylesheet" href="style/style.css" type="text/css"  /><style>#sub_title { margin-bottom: 5px; }</style></head><body onload="window.print();window.close()" style="width: 670px;">';var footer="</body></html>";var zi="<img src=\"design/sp_logo.gif\" alt=\"Shared Parking\" /><br /><br />"+document.getElementById("zone").innerHTML;var f=window.open("","","height=720,width=710,toolbar=0,menubar=0,scrollbars=1,resizable=0,status=0,location=0,left=10,top=10");f.document.write(header+zi+footer);f.document.close();return}

// slowopacity
function slowOp(id,level){var oActuel=1;var oFinal=level;var element=document.getElementById(id);var opacity;var oft=function(){oActuel+=2;element.filter='alpha(opacity='+oActuel+')';element.style.mozOpacity=oActuel/100;element.style.opacity=oActuel/100;if(oActuel>oFinal){clearInterval(opacity)}};oft();opacity=setInterval(oft,10)}

// textarealimit
function restrictinput(e,theform,maxlength){if(theform.value.length>=maxlength){var pressedkey=/[a-zA-Z0-9\.\,\/]/;if(pressedkey.test(String.fromCharCode(e.keyCode))){if(e.preventDefault){e.preventDefault()}e.returnValue=false;return false}}}function countlimit(e,theform,maxlength,text,text2){var lengthleft=maxlength-theform.value.length;theform.value=theform.value.substring(0,maxlength);if(lengthleft<=1){caractere=text}else{caractere=text2}document.getElementById("limite").innerHTML='<strong>'+lengthleft+'</strong> '+caractere}function displaylimit(theid,thelimit,text,text2){var theform=document.getElementById(theid);var limit_text='<span id="limite"><strong>'+thelimit+'</strong> '+text2+'</span>';document.write(limit_text);if(theform.addEventListener){theform.addEventListener('keypress',function(e){var that=this;restrictinput(e,that,thelimit)},true);theform.addEventListener('keyup',function(e){var that=this;countlimit(e,that,thelimit,text,text2)},true)}else{theform.onkeypress=function(e){e=e||window.event;var that=this;return restrictinput(e,that,thelimit)};theform.onkeyup=function(e){e=e||window.event;var that=this;countlimit(e,that,thelimit,text,text2)}}}

// commentspagination
function getPage(ad,page,type){document.getElementById('loading').style.display='block';if(window.XMLHttpRequest){xhr_object=new XMLHttpRequest()}else if(window.ActiveXObject){xhr_object=new ActiveXObject("Microsoft.XMLHTTP")}else{document.getElementById('comments').innerHTML="AJAX error.<br /><br />"}xhr_object.open("GET","../../comments.inc?ad="+ad+"&page="+page+"&type="+type,false);xhr_object.send(null);if(xhr_object.readyState==4){function display(){document.getElementById('comments').innerHTML=xhr_object.responseText;document.getElementById('loading').style.display='none'}window.setTimeout(display,500)}else{document.getElementById('comments').innerHTML="AJAX error.<br /><br />"}}

// description field
function desc(champ,hide){if(hide==false){if(document.all){document.getElementById(champ).display='inline';slowOp(champ,100)}else{document.getElementById(champ).style.display='table-cell';slowOp(champ,100)}}else{document.getElementById(champ).style.display='none'}}
	
// captcha refresh
function captchaRefresh(){document.getElementById("captcha").src="captcha/captcha?"+Math.floor(Math.random()*1000)}

// redirection
function ch_page(value,page_link, sc){location.href=page_link+((sc == true)?'&page='+value:'-'+value+'.html')}