/*
 * Autocomplete - jQuery plugin 1.0.2
 *
 * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.autocomplete.js 5747 2008-06-25 18:30:55Z joern.zaefferer $
 *
 */;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){v=words.slice(0,words.length-1).join(options.multipleSeparator)+options.multipleSeparator+v;}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value){return[""];}var words=value.split(options.multipleSeparator);var result=[];$.each(words,function(i,value){if($.trim(value))result[i]=$.trim(value);});return result;}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$.Autocompleter.Selection(input,previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else
$input.val("");}});}if(wasVisible)$.Autocompleter.Selection(input,input.value.length,input.value.length);};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}setTimeout(populate,25);function flush(){data={};length=0;}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else
if(data[q]){return data[q];}else
if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.Autocompleter.Selection=function(field,start,end){if(field.createTextRange){var selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}else if(field.setSelectionRange){field.setSelectionRange(start,end);}else{if(field.selectionStart){field.selectionStart=start;field.selectionEnd=end;}}field.focus();};})(jQuery);


/*
 * Thickbox 3 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
var tb_pathToImage = "images/loadingAnimation.gif";
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$(o).2S(9(){1u(\'a.18, 3n.18, 3i.18\');1w=1p 1t();1w.L=2H});9 1u(b){$(b).s(9(){6 t=X.Q||X.1v||M;6 a=X.u||X.23;6 g=X.1N||P;19(t,a,g);X.2E();H P})}9 19(d,f,g){3m{3(2t o.v.J.2i==="2g"){$("v","11").r({A:"28%",z:"28%"});$("11").r("22","2Z");3(o.1Y("1F")===M){$("v").q("<U 5=\'1F\'></U><4 5=\'B\'></4><4 5=\'8\'></4>");$("#B").s(G)}}n{3(o.1Y("B")===M){$("v").q("<4 5=\'B\'></4><4 5=\'8\'></4>");$("#B").s(G)}}3(1K()){$("#B").1J("2B")}n{$("#B").1J("2z")}3(d===M){d=""}$("v").q("<4 5=\'K\'><1I L=\'"+1w.L+"\' /></4>");$(\'#K\').2y();6 h;3(f.O("?")!==-1){h=f.3l(0,f.O("?"))}n{h=f}6 i=/\\.2s$|\\.2q$|\\.2m$|\\.2l$|\\.2k$/;6 j=h.1C().2h(i);3(j==\'.2s\'||j==\'.2q\'||j==\'.2m\'||j==\'.2l\'||j==\'.2k\'){1D="";1G="";14="";1z="";1x="";R="";1n="";1r=P;3(g){E=$("a[@1N="+g+"]").36();25(D=0;((D<E.1c)&&(R===""));D++){6 k=E[D].u.1C().2h(i);3(!(E[D].u==f)){3(1r){1z=E[D].Q;1x=E[D].u;R="<1e 5=\'1X\'>&1d;&1d;<a u=\'#\'>2T &2R;</a></1e>"}n{1D=E[D].Q;1G=E[D].u;14="<1e 5=\'1U\'>&1d;&1d;<a u=\'#\'>&2O; 2N</a></1e>"}}n{1r=1b;1n="1t "+(D+1)+" 2L "+(E.1c)}}}S=1p 1t();S.1g=9(){S.1g=M;6 a=2x();6 x=a[0]-1M;6 y=a[1]-1M;6 b=S.z;6 c=S.A;3(b>x){c=c*(x/b);b=x;3(c>y){b=b*(y/c);c=y}}n 3(c>y){b=b*(y/c);c=y;3(b>x){c=c*(x/b);b=x}}13=b+30;1a=c+2G;$("#8").q("<a u=\'\' 5=\'1L\' Q=\'1o\'><1I 5=\'2F\' L=\'"+f+"\' z=\'"+b+"\' A=\'"+c+"\' 23=\'"+d+"\'/></a>"+"<4 5=\'2D\'>"+d+"<4 5=\'2C\'>"+1n+14+R+"</4></4><4 5=\'2A\'><a u=\'#\' 5=\'Z\' Q=\'1o\'>1l</a> 1k 1j 1s</4>");$("#Z").s(G);3(!(14==="")){9 12(){3($(o).N("s",12)){$(o).N("s",12)}$("#8").C();$("v").q("<4 5=\'8\'></4>");19(1D,1G,g);H P}$("#1U").s(12)}3(!(R==="")){9 1i(){$("#8").C();$("v").q("<4 5=\'8\'></4>");19(1z,1x,g);H P}$("#1X").s(1i)}o.1h=9(e){3(e==M){I=2w.2v}n{I=e.2u}3(I==27){G()}n 3(I==3k){3(!(R=="")){o.1h="";1i()}}n 3(I==3j){3(!(14=="")){o.1h="";12()}}};16();$("#K").C();$("#1L").s(G);$("#8").r({Y:"T"})};S.L=f}n{6 l=f.2r(/^[^\\?]+\\??/,\'\');6 m=2p(l);13=(m[\'z\']*1)+30||3h;1a=(m[\'A\']*1)+3g||3f;W=13-30;V=1a-3e;3(f.O(\'2j\')!=-1){1E=f.1B(\'3d\');$("#15").C();3(m[\'1A\']!="1b"){$("#8").q("<4 5=\'2f\'><4 5=\'1H\'>"+d+"</4><4 5=\'2e\'><a u=\'#\' 5=\'Z\' Q=\'1o\'>1l</a> 1k 1j 1s</4></4><U 1W=\'0\' 2d=\'0\' L=\'"+1E[0]+"\' 5=\'15\' 1v=\'15"+1f.2c(1f.1y()*2b)+"\' 1g=\'1m()\' J=\'z:"+(W+29)+"p;A:"+(V+17)+"p;\' > </U>")}n{$("#B").N();$("#8").q("<U 1W=\'0\' 2d=\'0\' L=\'"+1E[0]+"\' 5=\'15\' 1v=\'15"+1f.2c(1f.1y()*2b)+"\' 1g=\'1m()\' J=\'z:"+(W+29)+"p;A:"+(V+17)+"p;\'> </U>")}}n{3($("#8").r("Y")!="T"){3(m[\'1A\']!="1b"){$("#8").q("<4 5=\'2f\'><4 5=\'1H\'>"+d+"</4><4 5=\'2e\'><a u=\'#\' 5=\'Z\'>1l</a> 1k 1j 1s</4></4><4 5=\'F\' J=\'z:"+W+"p;A:"+V+"p\'></4>")}n{$("#B").N();$("#8").q("<4 5=\'F\' 3c=\'3b\' J=\'z:"+W+"p;A:"+V+"p;\'></4>")}}n{$("#F")[0].J.z=W+"p";$("#F")[0].J.A=V+"p";$("#F")[0].3a=0;$("#1H").11(d)}}$("#Z").s(G);3(f.O(\'37\')!=-1){$("#F").q($(\'#\'+m[\'26\']).1T());$("#8").24(9(){$(\'#\'+m[\'26\']).q($("#F").1T())});16();$("#K").C();$("#8").r({Y:"T"})}n 3(f.O(\'2j\')!=-1){16();3($.1q.35){$("#K").C();$("#8").r({Y:"T"})}}n{$("#F").34(f+="&1y="+(1p 33().32()),9(){16();$("#K").C();1u("#F a.18");$("#8").r({Y:"T"})})}}3(!m[\'1A\']){o.21=9(e){3(e==M){I=2w.2v}n{I=e.2u}3(I==27){G()}}}}31(e){}}9 1m(){$("#K").C();$("#8").r({Y:"T"})}9 G(){$("#2Y").N("s");$("#Z").N("s");$("#8").2X("2W",9(){$(\'#8,#B,#1F\').2V("24").N().C()});$("#K").C();3(2t o.v.J.2i=="2g"){$("v","11").r({A:"1Z",z:"1Z"});$("11").r("22","")}o.1h="";o.21="";H P}9 16(){$("#8").r({2U:\'-\'+20((13/2),10)+\'p\',z:13+\'p\'});3(!(1V.1q.2Q&&1V.1q.2P<7)){$("#8").r({38:\'-\'+20((1a/2),10)+\'p\'})}}9 2p(a){6 b={};3(!a){H b}6 c=a.1B(/[;&]/);25(6 i=0;i<c.1c;i++){6 d=c[i].1B(\'=\');3(!d||d.1c!=2){39}6 e=2a(d[0]);6 f=2a(d[1]);f=f.2r(/\\+/g,\' \');b[e]=f}H b}9 2x(){6 a=o.2M;6 w=1S.2o||1R.2o||(a&&a.1Q)||o.v.1Q;6 h=1S.1P||1R.1P||(a&&a.2n)||o.v.2n;1O=[w,h];H 1O}9 1K(){6 a=2K.2J.1C();3(a.O(\'2I\')!=-1&&a.O(\'3o\')!=-1){H 1b}}',62,211,'|||if|div|id|var||TB_window|function||||||||||||||else|document|px|append|css|click||href|body||||width|height|TB_overlay|remove|TB_Counter|TB_TempArray|TB_ajaxContent|tb_remove|return|keycode|style|TB_load|src|null|unbind|indexOf|false|title|TB_NextHTML|imgPreloader|block|iframe|ajaxContentH|ajaxContentW|this|display|TB_closeWindowButton||html|goPrev|TB_WIDTH|TB_PrevHTML|TB_iframeContent|tb_position||thickbox|tb_show|TB_HEIGHT|true|length|nbsp|span|Math|onload|onkeydown|goNext|&nbsp;|&nbsp;|fermer|tb_showIframe|TB_imageCount|Close|new|browser|TB_FoundURL|&nbsp;|Image|tb_init|name|imgLoader|TB_NextURL|random|TB_NextCaption|modal|split|toLowerCase|TB_PrevCaption|urlNoQuery|TB_HideSelect|TB_PrevURL|TB_ajaxWindowTitle|img|addClass|tb_detectMacXFF|TB_ImageOff|150|rel|arrayPageSize|innerHeight|clientWidth|self|window|children|TB_prev|jQuery|frameborder|TB_next|getElementById|auto|parseInt|onkeyup|overflow|alt|unload|for|inlineId||100||unescape|1000|round|hspace|TB_closeAjaxWindow|TB_title|undefined|match|maxHeight|TB_iframe|bmp|gif|png|clientHeight|innerWidth|tb_parseQuery|jpeg|replace|jpg|typeof|which|keyCode|event|tb_getPageSize|show|TB_overlayBG|TB_closeWindow|TB_overlayMacFFBGHack|TB_secondLine|TB_caption|blur|TB_Image|60|tb_pathToImage|mac|userAgent|navigator|of|documentElement|Prev|lt|version|msie|gt|ready|Next|marginLeft|trigger|fast|fadeOut|TB_imageOff|hidden||catch|getTime|Date|load|safari|get|TB_inline|marginTop|continue|scrollTop|TB_modal|class|TB_|45|440|40|630|input|188|190|substr|try|area|firefox'.split('|'),0,{}));

listingLocked = false;

if ((navigator.appName == "Netscape")&&(navigator.appVersion.substring(0,4)>=4)){
	
	isNav="net";
} 
if (navigator.appName == "Microsoft Internet Explorer"){
	
	isNav="ie";
}

var root_path = "/module/carto";

// the value of the div_hotel_pop_layer
var div_content_arr = new Array();

// type 1
var arr_id_type_1 = new Array();
arr_id_type_1[0] = 1;
arr_id_type_1[1] = 2;
arr_id_type_1[2] = 3;
arr_id_type_1[3] = 4;

var search_engine_is_blocked = false;
var sto1 = 0;

function eval_js_contenu(ch){
	
    var tab_ch = ch.split("<script");
    for (var i=1; i<tab_ch.length; i++){
    	
		var code_js = tab_ch[i];
		code_js = code_js.substring(code_js.indexOf(">")+1, code_js.indexOf("</"+"script>"));
		eval(code_js);
    }
}

function traite_chaine_inv(ch) {
	
	ch = ch.replace(new RegExp("&#039;", "gi"), "'");
	ch = ch.replace(new RegExp("&#034;", "gi"), "\"");
	
	return ch;
}

function cbox_check_it(label, ind){
	
	var obj_group = eval("document.form_carto_search."+label);
	
	if (obj_group) {
		if (obj_group[ind]) var obj_group_final = obj_group[ind];
		else var obj_group_final = obj_group;
		
		if (obj_group_final.checked) var checked = false;
		else var checked = true;
		
		// on (de)selectionne le checkbox
		obj_group_final.checked = checked;
		
		// update img src if obj img exists
		var obj_img = document.getElementById(label+"_"+ind);
		if (obj_img) {
			/*
			var img_src_final = false;
			var img_src = obj_img.src;
			if (checked) {
				var pos_ext = img_src.lastIndexOf(".");
				if (pos_ext>-1) {
					
					var img_src_without_ext = img_src.substring(0, pos_ext);
					var ext = img_src.substring(pos_ext);
					
					var img_src_final = img_src_without_ext+"_checked"+ext;
				} 
			}
			else {
				img_src_final = img_src.replace(new RegExp("_checked"), "");
			}
			if (img_src_final!=false) obj_img.src = img_src_final;
			*/
			if (checked) obj_img.className = "img_check";
			else obj_img.className = "img_normal";
		}
	}
}

function radio_check_it(label, ind) {
	
	var obj_group = eval("document.form_carto_search."+label);
	if (obj_group && obj_group[ind]) {
		
		// on check le radio
		if (obj_group[ind].checked) var checked = false;
		else var checked = true;
		
		// on (de)selectionne le radio
		obj_group[ind].checked = checked;
		
		// update img src if obj img exists
		for (var i=0; i<obj_group.length; i++) {
			var obj_img = document.getElementById(label+"_"+i);
			if (obj_img) {
				
				/*
				var img_src_final = false;
				var img_src = obj_img.src;
				if (obj_group[i].checked) {
					var pos_ext = img_src.lastIndexOf(".");
					if (pos_ext>-1) {
						
						var img_src_without_ext = img_src.substring(0, pos_ext);
						var ext = img_src.substring(pos_ext);
						
						var img_src_final = img_src_without_ext+"_checked"+ext;
					} 
				}
				else {
					img_src_final = img_src.replace(new RegExp("_checked"), "");
				}
				if (img_src_final!=false && obj_img!=img_src_final) obj_img.src = img_src_final;
				*/
				if (obj_group[i].checked) obj_img.className = "img_check";
				else obj_img.className = "img_normal";
			}
		}
	}
}

function AJAXRequest(page,retfonc,methode,data,async,callback){
	
	if (!async) async = false;
	var xhr_object = null;
	if(window.XMLHttpRequest){ // Firefox
		
		xhr_object = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){ // Internet Explorer
		
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{ // XMLHttpRequest non supporte par le navigateur
		
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		return;
	}
	
	if (data=="") data=null;
	
	if(methode == "GET" && data != null){
		
		url = page+"?"+data; 
		data = null; 
	}
	else {
		url = page; 
	}
	xhr_object.open(methode, url, !async);
	xhr_object.onreadystatechange = function(){
		
		if(xhr_object.readyState == 4){
			
			var RetAjax=xhr_object.responseText;
			eval(retfonc+'(RetAjax);');
			
			if(url.match(/display_list_result/g) && listingLocked==false) {
				change_carto_tab(1);
				change_state_button_search(1);
			}
			
			if(typeof callback == 'function'){callback();}
			
			globalDataForm = {};
		}		
	}	
	if(methode == "POST") xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_object.send(data);
}

function interface_replace_data(ch) {

	var regStart = /<!---- [^/]\w+ ---->/g;
	var regEnd = /<!---- [/]\w+ ---->/g;
	var aryStartComment = new Array();
	var aryContent = new Array();
	aryStartComment = ch.match(regStart);
	aryContent = ch.split(regStart);
	if(aryStartComment && aryContent && aryStartComment.length == aryContent.length) {
		
		for(var i = 0 ; i < aryContent.length ; i++){
			
			var divId = aryStartComment[i].replace("<!---- ","").replace(" ---->","");
			var divContent = aryContent[i].replace(regEnd,"");
			var oDiv = document.getElementById(divId);
			if (oDiv) {
				
				oDiv.innerHTML = divContent;
				/*
				if (divContent.replace(/ /gi,"").length>0) {
					
					oDiv.style.display="block";
				}
				else {
					
					oDiv.style.display="none";
				}
				*/
			}
		}
	}
	else{
		for(var i = 0 ; i < aryContent.length-1 ; i++){
			
			var divId = aryStartComment[i].replace("<!---- ","").replace(" ---->","");
			var divContent = aryContent[i+1].replace(regEnd,"");	
			var oDiv = document.getElementById(divId);
			if (oDiv) {
				
				oDiv.innerHTML = divContent;
				/*
				if (divContent.replace(/ /gi,"").length>0) {
					
					oDiv.style.display="block";
				}
				else {
					
					oDiv.style.display="none";
				}
				*/	
			}
		}	
	}
	eval_js_contenu(ch);
}

function change_state_button_search(state) {
	
	var f = document.form_carto_search;
	if (!f) return false;
	
	var obj_submit_button = document.getElementById("carto_submit_button");
	if (!obj_submit_button) return false;
	
	var div_cover_1 = document.getElementById("div_cover_1");
	var div_cover_2 = document.getElementById("div_cover_2");
	
	if (!state) {
		
		obj_submit_button.src = obj_submit_button.src.replace("_actif", "_inactif");
		
		div_cover_1.style.display = "block";
		div_cover_2.style.display = "block";
		
		search_engine_is_blocked = true;
	}
	else {
		
		obj_submit_button.src = obj_submit_button.src.replace("_inactif", "_actif");
		
		div_cover_1.style.display = "none";
		div_cover_2.style.display = "none";
		
		search_engine_is_blocked = false;
	}
}

function generateArrProduct(){
	
	var arr_product = "";
	
	//get select id
	var f = document.form_carto_search;
	if (!f) return false;
	
	var obj_all = f.getElementsByTagName("*");
	
	for (var i=0; i<obj_all.length; i++) {
	
		var obj_form = obj_all[i];
		var tag_name = obj_form.tagName;
		if (tag_name=="INPUT" || tag_name=="TEXTAREA" || tag_name=="OPTION" ) {
			
			if(tag_name=="OPTION"){
				
				if (obj_form.id) {
				
					if(obj_form.selected == true){
						
						if (obj_select.name && obj_form.value.length>0) arr_product += "&"+obj_form.id+"="+escape(obj_form.value);
					}
				}
				else {
					
					var obj_select = obj_form.parentNode;
					if (obj_select) {
						
						if(obj_form.selected == true){
							
							if (obj_select.name && obj_form.value.length>0) arr_product += "&"+obj_select.name+"="+escape(obj_form.value);
						}
					}
				}
			}
			else{
				
				if(obj_form.type == "radio" || obj_form.type == "checkbox"){
					
					if(obj_form.checked == true){
						
						if (obj_form.name && obj_form.value.length>0) arr_product += "&"+obj_form.name+"="+escape(obj_form.value);
					}
				}
				else{
					
					if(obj_form.value != "" || obj_form.value != null){
						
						if (obj_form.name && obj_form.value.length>0) arr_product += "&"+obj_form.name+"="+escape(obj_form.value);
					}
				}
			}
		}
	}
	return arr_product;
}

function generateXml(callback){
	
	arr_product = generateArrProduct();
	
	if (search_engine_is_blocked) {
		
		if (sto1) clearTimeout(sto1);
		sto1 = setTimeout("change_state_button_search(1)", 10000);
		return false;
	}
	else {
		
		generateResult(arr_product,0,"",callback);
	}
	
	change_state_button_search(0);
}

function generateResultByZipcode_old(zipcode){
	
	arr_product = generateArrProduct();
	
	if (search_engine_is_blocked) {
		
		if (sto1) clearTimeout(sto1);
		sto1 = setTimeout("change_state_button_search(1)", 10000);
		return false;
	}
	else {
		
		generateResult(arr_product,0,zipcode,callback);
	}
	
	change_state_button_search(0);
}

function generateResultByZipcode(zipcode){
	
	var post = {}
	var fields = $("form[name=form_carto_search] *:input").serializeArray();
	$.each(fields, function(i, field){
        post[(field.name)] = field.value;
    });		
	post['regroup'] = zipcode;
	
	$.ajax({
		type : "POST",
		url : "ajax/display_list_result.php",
   		data : post,
   		cache: false,
   		dataType: "html",
		success: function(msg){
			$('#div_result_list').empty();
     		$('#div_result_list').html(msg);
     		change_div_tab_result_onclick(); 
     		change_carto_tab(2);
     		$('#div_cover_1,#div_cover_2').hide();
   		},
		beforeSend : function() {		
			$('#div_cover_1,#div_cover_2').show();		
		},
		error : function() {
			$('#div_cover_1,#div_cover_2').hide();
		}	
	});
}

function orderBy_select(zipcode){
	
    var orderBy = document.getElementById("orderBy").value;
    
    if(orderBy > 0){
    	
	    arr_product = generateArrProduct();
		
		
		if (search_engine_is_blocked) {
		
			if (sto1) clearTimeout(sto1);
			sto1 = setTimeout("change_state_button_search(1)", 10000);
			return false;
		}
		else {
			
			generateResult(arr_product,orderBy,zipcode);
		}
		
		change_state_button_search(0);
	}
}

function update_orderBy_select(j){
	
    var orderBy_select = document.getElementById("order"+j);
    orderBy_select.selected = "selected";
}

function generateResult(arr_product,orderBy,zipcode,callback){
	
	var zoom_class_value = document.getElementById("hidden_zoom_class").value;
	
	AJAXRequest(root_path + "/ajax/display_list_result.php?zoomClass="+zoom_class_value+"&orderBy="+orderBy+"&zipcode="+zipcode,"interface_replace_data","POST","action=generateResult"+arr_product,null,callback);
}

function generateFiche(product_id,cat,title){
	
	$('#div_cover_1').css('display','block');
  	$('#div_cover_2').css('display','block');
  	
  	if(title) {  		
	  	var sel = $('#divnavigation');
	  	if(!sel.data('defaut')) {
	  		sel.data('defaut',$('#divnavigation p').html());
	  	}
	  	
	  	$('#divnavigation p').html(sel.data('defaut')+' &gt; '+title); 
	}	
  	
  
  if(cat){cat='&cat='+cat}
  else{var cat='';}
  
	AJAXRequest(root_path + "/ajax/display_product.php?product_id="+product_id+cat,"interface_replace_data","POST","action=display_product");  	
}

// select type 1
function select_type_1(id){
	
	for (var i = 0; i<arr_id_type_1.length; i++) {
		
		var id_tmp = arr_id_type_1[i];
		
		var label_span = "span_type_"+id_tmp;
		var obj_span = document.getElementById(label_span);
		if (obj_span) {
			
			if (id==id_tmp){
				
				var label_class = "class_type_1_select";
			}
			else {
				
				var label_class = "class_type_1_normal";
			}
			obj_span.className = label_class;
		}
	}
}

function click_picto_hebergement(type_select_id, query, callback){	
	click_picto_all('hebergement', type_select_id, query, callback);
}

function click_picto_restauration(type_select_id, query, callback){	
	click_picto_all('restauration', type_select_id, query, callback);
}

function click_picto_manifestation(type_select_id, query, callback){	
	click_picto_all('manifestation', type_select_id, query, callback);
}

function click_picto_loisir(type_select_id, query, callback){	
	click_picto_all('loisir', type_select_id, query, callback);
}

function click_picto_weekend(type_select_id, query, callback){	
	click_picto_all('weekend', type_select_id, query, callback);
}

function click_picto_rando(type_select_id, query, callback){	
	click_picto_all('rando', type_select_id, query, callback);
}

function click_picto_ete(type_select_id, query, callback){
	
	click_picto_all('ete', type_select_id, query, callback);
}

function fillForm(callback) {
	callbackFinal = function() {
	
		//second click on radio input
		
		$('input[type=radio]').unbind('click').click(function(e){		
			var name = $(this).attr('name');			
			var input = $('input[name='+name+']');
			var last = '';
			
			if(input.eq(0).data('last') == $(this).val()) {
				input.removeAttr('checked');
				last = '';
			}
			else {			
				last = $(this).val();
			}	
			input.eq(0).data('last', last);			
		});
		
		
		var val = '';
		for(var z in globalDataForm) {
			val = globalDataForm[z];
			if(val) {
				$('*[name='+z+']').val(val);
			}
		}
		
		var field = $('input[name=product_city]');
		if(field.val()) {
			field.trigger('keyup');
			
			if($('input[name=distance]').val()) {
				$('#commune_value').trigger('keyup');
			}
		}
		
		if(typeof callback == 'function') {
			callback();
		}		
	}
	
	return callbackFinal;
}


function click_picto_all(what, type_select_id, query, callback) {
	
	formSaving();
	callbackFinal = fillForm(callback);
	
	query = (!query) ? '' : query;
	if (!type_select_id) { 
		type_select_id = null; 
		ch_type_select_id = "";
	}
	else {
		ch_type_select_id = "&type_select_id="+type_select_id;
	}
	//select_type_1(4);
	
	AJAXRequest(root_path + "/generate_form.php","interface_replace_data","POST","action=click_picto_"+what+query,'', callbackFinal);
	
	$('#type_menu span[id^=span_type_]').removeClass('class_type_1_select').addClass('class_type_1_normal');
	
	var id = 1; 
	switch(what) {
		case 'restauration':
			id = 2;
		break;
		case 'manifestation':
			id = 3;
		break;
		case 'loisir':
			id = 4;
		break;
	}
	
	$('#type_menu span[id=span_type_'+id+']').removeClass('class_type_1_normal').addClass('class_type_1_select');
	
}


function type_select(){
	
	formSaving();
	callbackFinal = fillForm();
	
    var tpey_select_id = document.getElementById("type1").value;
    AJAXRequest(root_path + "/generate_form.php?type_select_id="+tpey_select_id,"interface_replace_data","POST","action=type_select", '', callbackFinal);
}

function type2_select(){
	
	formSaving();
	callbackFinal = fillForm();
	
    var tpey_select_id = document.getElementById("type2").value;
    AJAXRequest(root_path + "/generate_form.php?type_select_id="+tpey_select_id,"interface_replace_data","POST","action=type2_select", '', callbackFinal);
}

var is_popup = 0; // Specifies whether the carto is a popup or not

function generate_validate(action, type_select, is_popup, query, callback){
	
	var div_search_engine = document.getElementById('div_search_engine');
	var div_result_layer = document.getElementById('div_result_layer');
	var div_carnet_layer = document.getElementById('div_carnet_layer');
	
	if(!div_search_engine){
		
		generate_search_engine_layer(action, type_select, is_popup, query, callback);
		generate_result_layer(is_popup);
	}
	else{
		var div_workspace_carto_popup = document.getElementById("workspace_carto_popup");
		if(div_search_engine.style.display == "block"){
			
			div_search_engine.style.display = "none";
			div_result_layer.style.display = "none";
			div_workspace_carto_popup.style.display = "none";
			div_carnet_layer.style.display = "none";
			
			$('#div_search_engine_table').hide();
			$('#idfr_carto_table').hide();
		}
		else{
			
			div_search_engine.style.display = "block";
			div_result_layer.style.display = "block";
			div_workspace_carto_popup.style.display = "block";
			if(div_carnet_layer){div_carnet_layer.style.display = "none";}
			
			$('#div_search_engine_table').show();
			$('#idfr_carto_table').show();
		}
	}

improve = new Scroller();
}

function close_search_layer(){
	
	var div_workspace_carto_popup = document.getElementById("workspace_carto_popup");
	var div_search_engine = document.getElementById('div_search_engine');
	var div_result_layer = document.getElementById('div_result_layer');
	var div_carnet_layer = document.getElementById('div_carnet_layer');
	
	div_search_engine.style.display = "none";
	div_result_layer.style.display = "none";
	if(div_carnet_layer){div_carnet_layer.style.display = "none";}
	div_workspace_carto_popup.style.display = "none";
	
	$('#div_search_engine_table').hide();
	$('#idfr_carto_table').hide();	
	
	viewports['x']='-1';
	viewports['y']='-1';
}

function generate_search_engine_layer(action, type_select_id, is_popup, query, callback){
	if (!action) action = "hebergement";
	if (!is_popup) is_popup = 0;
	if (!type_select_id) type_select_id = null;
	var ch_class_hebergement = "class_type_1_normal";
	var ch_class_restauration = "class_type_1_normal";
	var ch_class_manifestation = "class_type_1_normal";
	var ch_class_loisir = "class_type_1_normal";
	var ch_class_weekend = "class_type_1_normal";
	var ch_class_rando = "class_type_1_normal";
	
	var display_categories = "display:block";
	
	switch (action) {
		
		case "restauration":
			ch_class_restauration = "class_type_1_select";
			break;
		
		case "manifestation":
			ch_class_manifestation = "class_type_1_select";
			break;
		
		case "loisir":
			ch_class_loisir = "class_type_1_select";
			break;
			
		case "loisir":
			ch_class_weekend = "class_type_1_select";
			break;
			
		case "rando":
			ch_class_rando = "class_type_1_select";
			break;
		
		default:
			ch_class_hebergement = "class_type_1_select";
			break;
		
	}
	
	var search_e = document.createElement('div');
	search_e.id = 'div_search_engine';
	search_e.className = 'div_search_engine';
	search_e.style.display = "block";
	var divc = "<div id='div_box'>";
	divc += "<div id='header' style=\"background-image:url('" + root_path + "/images/onglet_recherche.png');\" class=\"notfix\">";
	if(is_popup == 1){
		divc += "<div id='div_result_close_window' class='div_result_close_window' onclick='close_search_layer();'>\n";
		divc += "<img src=\"" + root_path + "/images/fermer_blanc.png\" align=\"absmiddle\" border=0>\n";
		divc += "</div>\n";
	}
	divc += "</div>";
	
	if(is_popup=='other_activity'){
		divc += "<div id='type_menu' class='div_type_menu' >";
		divc += "<table width=\"90%\">";
		divc += "<tr>";
    divc += "<td><a onclick='click_picto_manifestation();' style=\"cursor:pointer;\"><img onclick='click_picto_manifestation();' hspace=\"3\" vspace=\"3\" align=\"absmiddle\" src='" + root_path + "/images/picto/type_1/visite.gif'/><span id=\"span_type_3\" class=\""+ch_class_manifestation+"\">Sortir et se divertir</a></td>";
		divc += "</tr>";
		divc += "<tr>";
		divc += "<td><a onclick='click_picto_restauration();' style=\"cursor:pointer;\"><img onclick='click_picto_restauration();' hspace=\"3\" vspace=\"3\" align=\"absmiddle\" src='" + root_path + "/images/picto/type_1/gastronomie.gif'/><span id=\"span_type_2\" class=\""+ch_class_restauration+"\">Se sentir gastronome</span></a></td>";
		divc += "</tr>";
		divc += "<tr>";
    divc += "<td><a onclick='click_picto_loisir();' style=\"cursor:pointer;\"><img onclick='click_picto_loisir();' hspace=\"3\" vspace=\"3\" align=\"absmiddle\" src='" + root_path + "/images/picto/type_1/loisir.gif'/><span id=\"span_type_4\" class=\""+ch_class_loisir+"\">Se dépenser, se cultiver</span></a></td>";
		divc += "</tr>";
		divc += "</table>";
		divc += "</div>";
	}
	
	else if(is_popup){
		divc += "<div id='type_menu' class='div_type_menu' >";
		divc += "<table width=\"100%\" cellspacing=\"0\">";
		divc += "<tr>";
		divc += "<td><a onclick='click_picto_hebergement(null, null, "+callback+");' style=\"cursor:pointer;\"><img onclick='click_picto_hebergement(null, null, "+callback+");' hspace=\"3\" vspace=\"3\" align=\"absmiddle\" src='" + root_path + "/images/picto/type_1/seloger.gif'/><span id=\"span_type_1\" class=\""+ch_class_hebergement+"\"> Se loger</span></a></td>";
		divc += "</tr>";
		divc += "<tr>";
    divc += "<td><a onclick='click_picto_manifestation(null, null, "+callback+");' style=\"cursor:pointer;\"><img onclick='click_picto_manifestation(null, null, "+callback+");' hspace=\"3\" vspace=\"3\" align=\"absmiddle\" src='" + root_path + "/images/picto/type_1/visite.gif'/><span id=\"span_type_3\" class=\""+ch_class_manifestation+"\"> Sortir et se divertir</a></td>";
		divc += "</tr>";
		divc += "<tr>";
		divc += "<td><a onclick='click_picto_restauration(null, null, "+callback+");' style=\"cursor:pointer;\"><img onclick='click_picto_restauration(null, null, "+callback+");' hspace=\"3\" vspace=\"3\" align=\"absmiddle\" src='" + root_path + "/images/picto/type_1/gastronomie.gif'/><span id=\"span_type_2\" class=\""+ch_class_restauration+"\"> Se sentir gastronome</span></a></td>";
		divc += "</tr>";
		divc += "<tr>";
    divc += "<td><a onclick='click_picto_loisir(null, null, "+callback+");' style=\"cursor:pointer;\"><img onclick='click_picto_loisir(null, null, "+callback+");' hspace=\"3\" vspace=\"3\" align=\"absmiddle\" src='" + root_path + "/images/picto/type_1/loisir.gif'/><span id=\"span_type_4\" class=\""+ch_class_loisir+"\"> Se dépenser, se cultiver</span></a></td>";
		divc += "</tr>";
		divc += "</table>";
		divc += "</div>";
	}
	
	divc += "<form style=\"margin:0px; padding:0px;\" name=\"form_carto_search\" onsubmit=\"return false;\" method=\"post\" action=\"javascript:return false;\">";
    	divc += "<div id='type' class='div_type'>";
		divc += "</div>";
		divc += "<div id='type_content' class='div_type_content'>";
		divc += "</div>";
		divc += "<input id='hidden_zoom_class' type='hidden' value='1'>";
	divc += "</form>";
	divc += "</div>";
	divc += "<div id='div_cover_2' class='div_cover' style='width:210px;display:none;height:558px'><div id='div_cover_content_img_2' class='div_cover_content_img_2'></div></div>";
	
	search_e.innerHTML = divc;	
	
	if (is_popup == 1) var obj_pere = document.getElementById("workspace_carto_popup_table");
	else var obj_pere = document.getElementById("workspace_carto");	
	
	if (obj_pere) obj_pere.insertBefore(search_e, obj_pere.firstChild);
	else document.body.insertBefore(search_e, document.body.firstChild);
	
	if(is_popup == 1) {
		$('#div_search_engine').replaceWith('<div id="div_search_engine_table"><table cellspacing="0"><tr><td class="boxy b50"></td><td class="b50"></td><td class="boxy b50"></td></tr><tr><td class="b50"></td><td width="210"><div id="div_search_engine" class="div_search_engine">' + $('#div_search_engine').html() + '</div></td><td class="b50"></td></tr><tr><td class="boxy b50"></td><td class="b50"></td><td class="boxy b50"></td></tr></table></div>');
	}
	
	//eval("click_picto_"+action+"('"+type_select_id+"',\""+query+"\")");
	
	click_picto_all(action, type_select_id, query);
}

var map_width_base = 734;
var map_height_base = 570;

var map_window_width = 570;
var map_window_height = 570;

var map_content_left = -(map_width_base - map_window_width)/2;
var map_content_top = -(map_height_base - map_window_height)/2;

var map_window_left = 113;
//var map_window_left = 258;
var map_window_top = 38;

function generate_result_layer(is_popup){
	if (!is_popup) is_popup = 0;
	var result_l = document.createElement('div');
	result_l.id = 'div_result_layer'; 
	result_l.className = 'div_result_layer';
	result_l.style.display = "block";
	
	var divc = "\n<div id='div_result_menu' class='div_result_menu'>\n";
		divc += 	"<div id='div_tab_carto' class='div_tab_carto' style=\"cursor:pointer\" onclick='change_carto_tab(1);'></div>\n";
		divc += 	"<div id='div_tab_result' class='div_tab_result' style=\"cursor:pointer\"></div>\n";
		divc += 	"<div id='div_tab_fiche' class='div_tab_fiche' style=\"cursor:pointer\"></div>\n";
		divc += 	"<div id='div_tab_carnet' class='div_tab_carnet' style=\"cursor:pointer;\" onclick='change_carto_tab(4);carnet_display_result();'></div>\n";
		divc += "</div>\n";
		
		divc += 	"<div id='div_result_map_zoom' class='div_result_map_zoom'>\n";
		divc += 		"<img src=\""+ root_path + "/images/map/legende_zoom_fond_haut.png\" class='notfix' style=\"width: 53px; height: 2px\" ><br />\n";
		divc += 		"<div class='div_result_map_zoom_p' style=\"background-image: url('"+ root_path + "/images/map/legende_zoom_fond_centre.png'); margin:0px;padding:0px;padding-left:8px;padding-right:10px; padding-bottom:5px; line-height:15px;\">\n";
		divc += 			"<div style=\"text-align:left;padding-bottom:5px;\"><b>Zoom</b></div>\n";
		divc += 			"<img id='map_zoom_out_img' src='" + root_path + "/images/map/legende_boutonmoins.png' border=0 class='notfix' ><br>\n";
		divc += 			"<img id='line_img' src='" + root_path + "/images/map/legende_fondcentre.png' width='30px' border=0 class='notfix'><br>\n";
		divc += 			"<img id='map_zoom_in_img' onclick='map_zoom(2,\"in\",event);' src='" + root_path + "/images/map/legende_boutonsplusactif.png' border=0 class='notfix'><br>\n";
		divc += 			"<img id='line_img' src='" + root_path + "/images/map/legende_fondhaut.png' width='30px' border=0 class='notfix'><br>\n";
		divc += 			"<img id='map_zoom_class_img' src='" + root_path + "/images/map/legende_boutonzoom1.png' border=0 class='notfix'><br>\n";
		divc += 		"</div>\n";
		divc += 		"<img src=\""+ root_path + "/images/map/legende_zoom_fond_bas.png\" class='notfix'><br />\n";
		divc += 	"</div>\n";
		divc += 	"<div id='div_result_map_legend' class='div_result_map_legend'>\n";
		divc += 		"<img src=\""+ root_path + "/images/map/legende_fondhaut.png\" class=\"notfix\"><br />\n";
		divc += 		"<div style=\"background-image: url('"+ root_path + "/images/map/legende_fondcentre.png'); padding-left:8px;padding-right:10px; line-height:15px;\" class='notfix'>\n";
		divc += 			"<div style=\"text-align:left;padding-bottom:5px;\"><b>L&eacute;gende</b></div>\n";
		divc += 			"<b>Routes</b></td><td align='center'> <img style=\"cursor:pointer;\" align=\"absmiddle\" id='legend_routes' src='" + root_path + "/images/map/legende_checkbox.png' onclick='change_legend_image(\"div_carto_routes\",\"legend_routes\");' border=0 class='notfix'><br />\n";
		divc += 			"<b>Villes</b></td><td align='center'> <img style=\"cursor:pointer;\" align=\"absmiddle\" id='legend_villes' src='" + root_path + "/images/map/legende_checkboxchekcked.png' onclick='change_legend_image(\"div_carto_villes\",\"legend_villes\");' border=0  class='notfix'><br />\n";
		divc += 			"<b>Gares</b></td><td align='center'> <img style=\"cursor:pointer;\" align=\"absmiddle\" id='legend_gares' src='" + root_path + "/images/map/legende_checkbox.png' onclick='change_legend_image(\"div_carto_gares\",\"legend_gares\");' border=0  class='notfix'><br />\n";
		divc += 		"<br /></div>\n";
		divc += 		"<img src=\""+ root_path + "/images/map/legende_fondbas.png\" class='notfix'><br />\n";
		divc += 	"</div>\n";
		
		divc += "<div id='div_result_map' class='div_result_map'>\n";
		divc += 	"<div id='div_result_map_content' style='background-color:#FFFFFF;top:" + map_content_top + "px;left:" + map_content_left + "px;width:" + map_width_base + "px;height:" + map_height_base + "px;z-index:301;'>\n";
		divc += 		"<div id='div_carto_map' class='div_carto_map_img' style='background-image:url(" + root_path + "/images/map/zoom1/Carte_Zoom_1.jpg);display:block;'></div>\n";
		divc += 		"<div id='div_carto_routes' class='div_carto_map_img' style='background-image:url(" + root_path + "/images/map/zoom1/routes.png);display:none;'></div>\n";
		divc += 		"<div id='div_carto_gares' class='div_carto_map_img' style='background-image:url(" + root_path + "/images/map/zoom1/gares.png);display:none;'></div>\n";
		divc += 		"<div id='div_carto_villes' class='div_carto_map_img' style='background-image:url(" + root_path + "/images/map/zoom1/villes.png);display:block;'></div>\n";
		divc += 		"<div id='div_carto_pictos_hotel' class='div_carto_pictos_hotel' ondblclick='map_zoom(2,\"in\",event);'></div>\n";
		divc += 	"</div>\n";
		divc += "</div>\n";
		divc += "<div id='div_hotel_pop_layer' class='div_hotel_pop_layer' style='top:0px;left:0px;display:none;' onmouseout=\"hidelayer_with_timeout();\" onmouseover=\"hidelayer_stop_timeout();\"></div>";
		divc += "<div id='div_big_hotel_pop_layer' class='div_big_hotel_pop_layer' style='top:0px;left:0px;display:none' onmouseout=\"hidelayer2_with_timeout();\" onmouseover=\"hidelayer2_stop_timeout();\"></div>";
		divc += "<div id='div_result_list' class='div_result_list' style='display:none;'></div>\n";
		divc += "<div id='div_result_selection' class='div_result_selection' style='display:none;'></div>\n";
		divc += "<div id='div_result_carnet' class='div_result_carnet' style='display:none;'></div>\n";
		divc += "<div id='div_cover_1' class='div_cover' style='width:525px;display:none;top:0;height:558px'>"
				+"<div id='div_cover_content_img' class='div_cover_content_img'>"
				+"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"200\" height=\"200\" title=\"chargement\">"
				+"<param name=\"movie\" value=\""+ root_path + "/images/mire.swf\">"
				+"<param name=\"wmode\" value=\"transparent\">"
				+"<param name=\"quality\" value=\"high\">"
				+"<embed src=\""+ root_path + "/images/mire.swf\" wmode=\"transparent\" width=\"200\" height=\"200\" quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"></embed>"
				+"</object></div></div>";
	result_l.innerHTML = divc;
	
	if (is_popup==1) var obj_pere = document.getElementById("workspace_carto_popup_table");
	else var obj_pere = document.getElementById("workspace_carto");
	if (obj_pere) obj_pere.insertBefore(result_l, obj_pere.firstChild);
	else document.body.insertBefore(result_l, document.body.firstChild);
}


function generate_carnet_layer(){
	
	var strCookie = document.cookie;
	var arrCookie = strCookie.split("; ");
	var cdt44_cookie = "";
	for(var i = 0;i<arrCookie.length;i++){
		
		var arr_cdt44_cookie = arrCookie[i].split("=");
		if(arr_cdt44_cookie[0] == "sessioncarnetid"){
			cdt44_cookie = arr_cdt44_cookie[1];
			break;
		}
	}
	
	var carnet_l = document.createElement('div');
	carnet_l.id = 'div_carnet_layer'; 
	carnet_l.className = 'div_carnet_layer';
	carnet_l.style.display = "none";
	
	var div_carnet_print_style = "none";
	
	if(cdt44_cookie != ""){
			
		div_carnet_print_style = "block";
	}
	
	var divc = "\n<div id='div_result_menu' class='div_result_menu'>\n";
		divc += 	"<div id='div_tab_carnet' class='div_tab_carto' style=\"cursor:pointer\"><p class='div_tab_text'>Carnet</p></div>\n";
		divc += "</div>\n";
		divc += "<div id='div_carnet_result_list' class='div_result_list' style='display:block;'></div>\n";
		divc += "<div id='div_show_result_list' class='div_show_result_list' onclick='show_carto_result_list();'>\n";
		divc += "Retour &agrave; la recherche  &nbsp;\n";
		divc += "</div>\n";
		divc += "<div id='div_carnet_print' class='div_carnet_print' style='display:" + div_carnet_print_style + ";' onclick='carnet_print();'>\n";
		divc += "&nbsp;<img src=\"" + root_path + "/images/pdf.png\" align=\"absmiddle\" border=0>&nbsp;\n";
		divc += "</div>\n";
		divc += "<div id='div_show_carnet_login' class='div_show_carnet_login' onclick='carnet_auth_form();'>\n";
		divc += "&nbsp;<img src=\"" + root_path + "/images/acceder_panier.png\" align=\"absmiddle\" border=0>&nbsp;\n";
		divc += "</div>\n";
	carnet_l.innerHTML = divc;
	
	var obj_pere = document.getElementById("workspace_carto");
	if (obj_pere) obj_pere.insertBefore(carnet_l, obj_pere.firstChild);
	else document.body.insertBefore(carnet_l, document.body.firstChild);
}

function change_carto_tab(i){
	
	var div_result_map = document.getElementById('div_result_map');
	var div_result_list = document.getElementById('div_result_list');
	var div_result_selection = document.getElementById('div_result_selection');
	var div_result_carnet = document.getElementById('div_result_carnet');
	
	var div_tab_carto = document.getElementById('div_tab_carto');
	var div_tab_result = document.getElementById('div_tab_result');
	var div_tab_fiche = document.getElementById('div_tab_fiche');
	var div_tab_carnet = document.getElementById('div_tab_carnet');
	
	var sel = $('#divnavigation');
	if(!sel.data('defaut')) {
	  	sel.data('defaut',$('#divnavigation p').html());
	}
	
	switch(i) {
		
		case 2:
			div_result_map.style.display = "none";
			div_result_list.style.display = "block";
			div_result_selection.style.display = "none";
			div_result_carnet.style.display = "none";
			
			$('#div_result_map_zoom').css('display','none');
	    	$('#div_result_map_legend').css('display','none');
			
					
			div_tab_carto.style.backgroundImage = "url(" + root_path + "/images/onglet_carte.png)";
			div_tab_result.style.backgroundImage = "url(" + root_path + "/images/onglet_liste_over.png)";
			div_tab_fiche.style.backgroundImage = "url(" + root_path + "/images/onglet_fiche.png)";
			//#modif adv - a voir
			div_tab_carnet.style.backgroundImage = "url(" + root_path + "/images/onglet_cdr.png)";
			
			document.getElementById('div_hotel_pop_layer').style.display = "none";
			document.getElementById('div_big_hotel_pop_layer').style.display = "none";
			
			$('#divnavigation p').html(sel.data('defaut')+' &gt; Liste des offres');
			
			break;
	
		case 3:
			div_result_map.style.display = "none";
			div_result_list.style.display = "none";
			div_result_selection.style.display = "block";
			div_result_carnet.style.display = "none";
			$('#div_result_map_zoom').css('display','none');
	    	$('#div_result_map_legend').css('display','none');
			
			div_tab_carto.style.backgroundImage = "url(" + root_path + "/images/onglet_carte.png)";
			div_tab_result.style.backgroundImage = "url(" + root_path + "/images/onglet_liste.png)";
			div_tab_fiche.style.backgroundImage = "url(" + root_path + "/images/onglet_fiche_over.png)";
			//#modif adv - a voir
			div_tab_carnet.style.backgroundImage = "url(" + root_path + "/images/onglet_cdr.png)";
			
			div_tab_fiche.onclick = function() {change_carto_tab(3);};
			
			document.getElementById('div_hotel_pop_layer').style.display = "none";
			document.getElementById('div_big_hotel_pop_layer').style.display = "none";
			break;
			
		case 4:
			div_result_map.style.display = "none";
			div_result_list.style.display = "none";
			div_result_selection.style.display = "none";
			div_result_carnet.style.display = "block";
			$('#div_result_map_zoom').css('display','none');
			$('#div_result_map_legend').css('display','none');
			
			div_tab_carto.style.backgroundImage = "url(" + root_path + "/images/onglet_carte.png)";
			div_tab_result.style.backgroundImage = "url(" + root_path + "/images/onglet_liste.png)";
			div_tab_fiche.style.backgroundImage = "url(" + root_path + "/images/onglet_fiche.png)";
			//#modif adv - a voir
			div_tab_carnet.style.backgroundImage = "url(" + root_path + "/images/onglet_cdr_over.png)";
			
			document.getElementById('div_hotel_pop_layer').style.display = "none";
			document.getElementById('div_big_hotel_pop_layer').style.display = "none";
			
			$('#divnavigation p').html(sel.data('defaut')+' &gt; Carnet');
			
			break;
	
		case 1:
		default:
			div_result_map.style.display = "block";
			div_result_list.style.display = "none";
			div_result_selection.style.display = "none";
			div_result_carnet.style.display = "none";
			$('#div_result_map_zoom').css('display','block');
	    	$('#div_result_map_legend').css('display','block');
			
			div_tab_carto.style.backgroundImage = "url(" + root_path + "/images/onglet_carte_over.png)";
			div_tab_result.style.backgroundImage = "url(" + root_path + "/images/onglet_liste.png)";
			div_tab_fiche.style.backgroundImage = "url(" + root_path + "/images/onglet_fiche.png)";
			//#modif adv - a voir
			div_tab_carnet.style.backgroundImage = "url(" + root_path + "/images/onglet_cdr.png)";
			
			document.getElementById('div_hotel_pop_layer').style.display = "none";
			document.getElementById('div_big_hotel_pop_layer').style.display = "none";
			
			$('#divnavigation p').html(sel.data('defaut')+' &gt; Carte'); 
	}
	
	
	  	
	
}

function change_div_tab_result_onclick(){
	
	document.getElementById('div_tab_result').onclick = function() {change_carto_tab(2);};
}

// suggest for field commune
function cache_tous_div_suggest_product_city(){
	
	cache_div_suggest_product_city("product_city");
}

function affiche_div_suggest_product_city(nom_champ_text){
	
	nom_div = "div_suggest_"+nom_champ_text;
	
	var f = document.form_carto_search;
	var obj_div = document.getElementById(nom_div);
	if (!obj_div) return false;
	
	/*
	var obj_div_commune = eval("f.cp_commune");
	if (obj_div_commune)
	{
		obj_div_commune.style.visibility = "hidden";
	}
	*/
	obj_div.style.visibility = "visible";
	
	if (document.body.addEventListener) {//Gecko
		document.body.addEventListener('onclick', cache_tous_div_suggest_product_city, false);
	} else if (document.body.attachEvent) {//IE
		document.body.attachEvent('onclick', cache_tous_div_suggest_product_city);
	}
}

function cache_div_suggest_product_city(nom_champ_text){
	
	nom_div = "div_suggest_"+nom_champ_text;
	
	var f = document.form_carto_search;
	var obj_div = document.getElementById(nom_div);
	if (!obj_div) return false;
	
	//var obj_div_commune = eval("f.cp_commune");
	
	
	obj_div.style.visibility = "hidden";
	/*
	if (obj_div_commune)
	{
		obj_div_commune.style.visibility = "visible";
	}
	*/
}

function affect_suggest_commune(nom_champ_text, val){
	
	nom_div = "div_suggest_"+nom_champ_text;
	
	var f = document.form_carto_search;
	
	var obj_commune = eval("f."+nom_champ_text);
	var obj_div = document.getElementById(nom_div);
	
	obj_commune.value = val;
	cache_div_suggest_product_city(nom_champ_text);
	obj_div.innerHTML = "";
}

function maj_champ_div_suggest_product_city(nom_champ_text, val){
	
	nom_div = "div_suggest_"+nom_champ_text;
	var obj_div = document.getElementById(nom_div);
	
	if(window.ActiveXObject) // Internet Explorer
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest) // Firefox
	      xhr_object = new XMLHttpRequest();
	else  { // XMLHttpRequest non support  par le navigateur
	      return;
	}
	
	xhr_object.open("POST", "../../module/carto/maj_select/maj_suggest_commune.php", true);
		
	xhr_object.onreadystatechange = function() {
      if(xhr_object.readyState == 4)
      {
	      	
		  var code_html = xhr_object.responseText;
		  if (code_html.replace(/ /g, "").length>0) {
		  	
			  obj_div.innerHTML = code_html;
			  affiche_div_suggest_product_city(nom_champ_text);
		  }
		  else {
		  	
		  	cache_div_suggest_product_city(nom_champ_text);
			obj_div.innerHTML = "";
		  }
		}
	}
	
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "nom_champ_text="+nom_champ_text+"&product_city="+escape(val);
	xhr_object.send(data);
}

var t_suggest_commune = -1;
function show_div_suggest_product_city(nom_champ_text, force){
	
	nom_div = "div_suggest_"+nom_champ_text;
	
	if (t_suggest_commune) clearTimeout(t_suggest_commune);
	if (!force) {
		
		t_suggest_commune = setTimeout("show_div_suggest_product_city(\""+nom_champ_text+"\", 1)", 100);
		return false;
	}
	
	var f = document.form_carto_search;
	if (!f) return false;
	
	var obj_commune = eval("f."+nom_champ_text);
	if (!obj_commune) return false;
	var valeur_champ_commune = obj_commune.value;
	if (valeur_champ_commune.replace(/ /g, "").length>1) {
		
		var obj_div = document.getElementById(nom_div);
		
		if (!obj_div) return false;
		maj_champ_div_suggest_product_city(nom_champ_text, valeur_champ_commune);
	}
	else cache_div_suggest_product_city(nom_champ_text);

}

//page navigation
function navigation_display_div(id, nb_num_page) {

	for (var ind=id-nb_num_page; ind<=id+nb_num_page; ind++) {
	
		var obj_div = document.getElementById("div_result_workspace_"+ind);
		if (obj_div) {
		
			if (ind==id) obj_div.style.display = "block";
			else obj_div.style.display = "none";
		}
	}
$('.result_page').scrollTop(0);
}

function explid_carto_display_product(id_product) {
	generate_validate();
	generateFiche(id_product,'', '');
}

function mkpicto(what) {
	 if($('#'+what).attr('checked')==true) {
	   
	   $('#'+what).attr('checked',false);
	   $('#'+what+'_picto').css({'border':'0px','padding':'2px'});
	   
     }
	 else {
	 
	   $('#'+what).attr('checked','checked');
	   $('#'+what+'_picto').css({'border':'2px solid black','padding':'0'});
	   
     }	   
}

function mklevel() {
  var val=$('#chaine')[0].options[$('#chaine')[0].selectedIndex].value;
  
  if(val==5) {
    $('#type4_content').css('display','block');
    $('#type5_content').css('display','none');
  }
  else if(val==6) {
    $('#type4_content').css('display','none');
    $('#type5_content').css('display','block');    
  }
  else {
    $('#type4_content').css('display','none');
    $('#type5_content').css('display','none');
    
  } 
$('#type5_content input,#type4_content input').attr('checked',false);
$('#type5_content img,#type4_content img').css({'border':'0px','padding':'2px'}); 
}

function mkradiopicto(what,pdiv) {

$('#'+pdiv+' input').each(function(){
  
	if(what.match(/star/g)) {
		if($(this).attr('id')!=what || ($(this).attr('id')==what && $(this).attr('checked')==true)) {    
			var id = $(this).attr('id').replace('star','');
			$('#'+$(this).attr('id')+'_picto').attr('src',"/module/carto/images/picto/etoiles/etoiles"+id+".png");
			$(this).attr('checked',false);
		}
		else {
			var id = what.replace('star','');
			$('#'+what+'_picto').attr('src',"/module/carto/images/picto/etoiles/etoiles"+id+"_select.png");
			$(this).attr('checked','checked');
		}
	}
	else {
		if($(this).attr('id')!=what || ($(this).attr('id')==what && $(this).attr('checked')==true)) {    
			$('#'+$(this).attr('id')+'_picto').css({'border':'0px','padding':'2px'});
			$(this).attr('checked',false);
		}
		else {
			$('#'+what+'_picto').css({'border':'2px solid black','padding':'0'});
			$(this).attr('checked','checked');
		}
	}
  
  });	   
}

function mkcheckboxpicto(what,pdiv) {
	$('#'+pdiv+' input').each(function(){
		if($(this).attr('id')==what) {
			var id = $(this).attr('id').replace('star','');
			if($(this).attr('checked')==true){
				$(this).attr('checked',false);
				$('#'+$(this).attr('id')+'_picto').attr('src',"/module/carto/images/picto/etoiles/etoiles"+id+".png");
				if(what=='star5'){
					$(".class_autres_div").hide();
				}
			}else{
				$(this).attr('checked',true);
				$('#'+what+'_picto').attr('src',"/module/carto/images/picto/etoiles/etoiles"+id+"_select.png");
				if(what=='star5'){
					$(".class_autres_div").show();
				}
			}
		}
	});
}

function label_autres_check(what) {
	$('.class_autres_div div').each(function(){
		if($(this).attr('id')==what) {
			var id = $(this).attr('id').replace('label_','');
			if($('#'+id).attr('checked')==true){
				$('#'+id).attr('checked',false);
				$(this).removeClass('class_autres_div_label_checked');
			}else{
				$('#'+id).attr('checked',true);
				$(this).addClass('class_autres_div_label_checked');
			}
		}
	});
	$('#star5_picto').attr('src',"/module/carto/images/picto/etoiles/etoiles5.png");
	$('#star5').attr('checked',false);
	$(".class_autres_div").hide();
}

function onlyInt(elem) {
	
	$(elem).unbind('keydown').keydown(function(e){	
		var num = $(elem).val().length;
		var charCode = e.keyCode;
		
		if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 96 || charCode > 105) && charCode != 37 && charCode != 39  && charCode != 46 || ((charCode == 96 || charCode == 48) && num == 0)) {
            e.preventDefault();
        }		
	
	});
}

function formSaving() {
	var tmp = $('form[name=form_carto_search]').serializeArray();
	var data = {};
	for(var x in tmp) {
		data = tmp[x];
		globalDataForm[data.name] = data.value;
	}
}

$(document).ready(function(){

    $('#date,#mois').live('click',function(){
    
        if($(this).attr('id')=='mois'){            
            $('.mois').attr('checked',true);            
            }
        else{            
            $('.date').attr('checked',true);
            }
    
        });
        
    $('#conf_bop_picto').live('click',function(){

        if($(this).css('padding')=='2px 2px 2px 2px'){
        
            $('#type1').attr('disabled',false);
            $('#type2').attr('disabled',false);
            $('#product_city').attr('disabled',false);
            
            }
        else{
        
            $('#type1').attr('disabled',true);
            $('#type2').attr('disabled',true);
            $('#product_city').attr('disabled',true);
        
            }
    
        });

});

var globalDataForm = {};