
/* - general.js - */
// http://www.lachampagne-ardenne-cabourg.com/portal_javascripts/general.js?original=1
function openPopup(url,largeur,hauteur){if(!largeur)
largeur=750;if(!hauteur)
hauteur=500;var aw=screen.width;var ah=screen.height;var l=(aw-largeur)/2;var t=(ah-hauteur)/2;window.open(url,'Popup','width='+largeur+',height='+hauteur+',left='+l+',top='+t);return false}
function searchForAttr(node,attr){var regex=new RegExp('.+\\\\s'+attr+'="(\\\\S+)".+','mg');var match=node.innerHTML.replace(regex,'$1');if(match){return match}
return ''}
function initWrapper(wrapper,w,h,url){wrapper.style.backgroundPosition='top center';wrapper.style.backgroundRepeat='no-repeat';var child_id=wrapper.id+"_transition";if(wrapper.hasChildNodes()&&wrapper.firstChild.id!=child_id){wrapper.style.backgroundImage='url('+searchForAttr(wrapper,'src')+')';while(wrapper.hasChildNodes()){wrapper.removeChild(wrapper.firstChild)}
wrapper.innerHTML=''}
if(!wrapper.hasChildNodes()){try{var newNode=document.createElementNS('http://www.w3.org/1999/xhtml','span')}
catch(e){var newNode=document.createElement('span')}
newNode.id=child_id;newNode.style.display='block';newNode.style.backgroundPosition='top center';newNode.style.backgroundRepeat='no-repeat';wrapper.appendChild(newNode)}
var wrapper_child=wrapper.firstChild;wrapper.style.width=w+'px';wrapper.style.height=h+'px';wrapper_child.style.backgroundImage='url('+url+')';wrapper_child.style.width=w+'px';wrapper_child.style.height=h+'px'}
function transition(wrapper_child,callback_counter){try{wrapper_child.filters.alpha.opacity=(callback_counter*100)} catch(e){wrapper_child.style.KhtmlOpacity=callback_counter;if(callback_counter>=1){wrapper_child.style.MozOpacity=0.9999999;wrapper_child.style.opacity=0.9999999} else{wrapper_child.style.MozOpacity=callback_counter;wrapper_child.style.opacity=callback_counter}}}
function changeDiaporama(){var wrapper=document.getElementById('diaporama-wrapper');initWrapper(wrapper,diaporama[index].width,diaporama[index].height,diaporama[index].src);transition(wrapper.firstChild,callback_counter);var wrapper2=document.getElementById('diaporama-wrapper2');if(wrapper2){initWrapper(wrapper2,diaporamaBIG[index].width,diaporamaBIG[index].height,diaporamaBIG[index].src);transition(wrapper2.firstChild,callback_counter)}
if(callback_counter>=1){wrapper.style.backgroundImage='url('+diaporama[index].src+')';if(wrapper2){wrapper2.style.backgroundImage='url('+diaporamaBIG[index].src+')'}
callback_counter=0;if(start){setTimeout("loop()",6000)}
return}
callback_counter+=.10;setTimeout("changeDiaporama()",100)}
function loop(){if(start){index=(index+1)%diaporama.length;var wrapper2=document.getElementById('diaporama-wrapper2');if(wrapper2){if(index>0){$('#TB_prev')[0].style.display="inline"}
if(index+1==diaporamaBIG.length){$('#TB_next')[0].style.display="none"}
if(index==0){$('#TB_prev')[0].style.display="none"}
if(index+1<diaporamaBIG.length){$('#TB_next')[0].style.display="inline"}
$("#compteur")[0].innerHTML="Image "+(index+1)+" sur "+(diaporamaBIG.length)}
changeDiaporama()}}

