function gereH(){
	hmain = dojo.byId("main").offsetHeight;
	if(hmain>550){
		dojo.byId("footer").style.marginTop = (hmain-550)+"px";
		dojo.byId("leftOmbreCoin").style.marginTop = (hmain-565)+"px";
		dojo.byId("rightOmbreCoin").style.marginTop = (hmain-565)+"px";
		dojo.byId("rightMain").style.height = 558+hmain+"px";
		dojo.byId("rightShadow").style.height = 452+hmain+"px";
	}
}

function switchRight(){
	if(dojo.byId("rightHidden").value == "0"){
	element = "rightMain";
	width= dojo.byId(element).offsetWidth;
	marg = dojo.byId(element).style.marginLeft;
	if(width==53&&marg=="0px"){
		dojo.animateProperty({
			node:element,
			duration: 300,
			easing: dojo.fx.easing.expoOut,
			properties: {
				width: {end: 252, unit:"px"},
				marginLeft: {end: -199, unit:"px"}
			}
		}).play();
	}else if(width==252){
		dojo.animateProperty({
			node:element,
			duration: 300,
			easing: dojo.fx.easing.expoOut,
			properties: {
				width: {end: 53, unit:"px"},
				marginLeft: {end: 0, unit:"px"}
			}
		}).play();
	}}
}

function hidden(num){
	dojo.byId("rightHidden").value = num;
}

function blockRight(){
	element = "rightMain";
	dojo.animateProperty({
		node:element,
		duration: 300,
		easing: dojo.fx.easing.expoOut,
		properties: {
			width: {end: 253, unit:"px"},
			marginLeft: {end: -214, unit:"px"}
		}
	}).play();
}

function closeRight(){
	element = "rightMain";
	dojo.animateProperty({
		node:element,
		duration: 300,
		easing: dojo.fx.easing.expoOut,
		properties: {
			width: {end: 53, unit:"px"},
			marginLeft: {end: 0, unit:"px"}
		}
	}).play();
}

function switchFleche(page){
	if(page==0){
		page = 1;
	}
	element = "navigFleche";
	if(dojo.byId(element).style.display="none"){
		dojo.byId(element).style.display="block";
	}
	newtop = ((page-1)*35)-4;
	dojo.animateProperty({
		node:element,
		duration: 300,
		easing: dojo.fx.easing.expoOut,
		properties: {
			marginTop: {end: newtop, unit:"px"}
		}
	}).play();	
}

function rangeNavig(){
	for(i=1;i<=8;i++){
		element = "navigMove"+i;
		dojo.byId(element).style.marginLeft = "-150px";
	}
}

function switchNavig2(page){
	element = "navigMove"+page;
	newtop = (page-1)*35;	
		if(dojo.byId("ssNavigHidden").value>0){
			element2 = "navigMove"+dojo.byId("ssNavigHidden").value;
			dojo.animateProperty({
				node:element2,
				duration: 300,
				easing: dojo.fx.easing.expoOut,
				properties: {
					marginLeft: {end: -150, unit:"px"}
				}
			}).play;
			dojo.byId("ssNavigHidden").value = 0;
		}
	
	dojo.animateProperty({
		node:element,
		duration: 300,
		easing: dojo.fx.easing.expoOut,
		properties: {
			marginLeft: {end: -150, unit:"px"}
		},
		onEnd: function(){
			dojo.byId(element).style.marginTop = newtop+"px";
			dojo.byId(element).style.display = "block";
			dojo.byId("sousNavig"+page).style.display = "block";
			dojo.byId("ssNavigHidden").value = page;
			dojo.xhrPost({
			url: "/index/ajax/",
			content:{
				page_id: page
			},			
			load: function(data){
				dojo.byId("navigMove"+page).innerHTML = data;
				dojo.animateProperty({
					node:element,
					duration: 300,
					easing: dojo.fx.easing.expoOut,
					properties: {
						marginLeft: {end: 0, unit:"px"}
					}				
				}).play();			 
		}})}
}).play();
}

function switchNavig3(page){
	
	for(i=1;i<=8;i++){
		check = "ssNavigOpen"+i;
		checkO = dojo.byId(check).value;
			if(checkO == 1){
			element2 = "navigMove"+i;
			dojo.animateProperty({
				node:element2,
				duration: 300,
				easing: dojo.fx.easing.expoOut,
				properties: {
					marginLeft: {end: -150, unit:"px"}
				}				
			}).play();
			check0 = 0;
			dojo.byId(element2).style.display="none";
			elementB = "sousNavig"+i;
			dojo.byId(elementB).style.display="none";
		}
	}
	
	element = "navigMove"+page;
	elementB = "sousNavig"+page;
	dojo.animateProperty({
		node:element,
		duration: 300,
		easing: dojo.fx.easing.expoOut,
		properties: {
			marginLeft: {end: -150, unit:"px"}
		},
		onEnd: function(){
				dojo.byId(element).style.display="block";
				dojo.byId(elementB).style.display="block";
				check = "ssNavigOpen"+page;
				dojo.byId(check).value = 1;
				dojo.animateProperty({
					node:element,
					duration: 300,
					easing: dojo.fx.easing.expoOut,
					properties: {
						marginLeft: {end: 0, unit:"px"}
					}				
				}).play();		
		}
}).play();
}

function switchNavig(page){
	element = "navigMove";
	newtop = (page-1)*35;
	dojo.animateProperty({
		node:element,
		duration: 300,
		easing: dojo.fx.easing.expoOut,
		properties: {
			marginLeft: {end: -150, unit:"px"}
		},
		onEnd: function(){
			dojo.byId(element).style.marginTop = newtop+"px";
			dojo.xhrPost({
			url: "/index/ajax/",
			content:{
				page_id: page
			},			
			load: function(data){
				dojo.byId("navigMove").innerHTML = data;
				dojo.animateProperty({
					node:element,
					duration: 300,
					easing: dojo.fx.easing.expoOut,
					properties: {
						marginLeft: {end: 0, unit:"px"}
					}				
				}).play();			 
		}})}
}).play();
}

function openSousNavig(id,nb){
	var i = 1;
	for(i=1;i<=nb;i++){
		elem = id.substring(0,1)+"-"+i;
		closeSousNavig(elem);
	}
	hidden = "sousSousNavigHidden"+id;
	lheight = dojo.byId(hidden).offsetHeight-5;
	element = "sousSousNavig"+id;
	dojo.animateProperty({
		node:element,
		duration: 600,
		easing: dojo.fx.easing.expoOut,
		properties: {
			height: {end: lheight, unit:"px"}
		}
	}).play();
}

function closeSousNavig(id){
	element = "sousSousNavig"+id;
	dojo.animateProperty({
		node:element,
		duration: 600,
		easing: dojo.fx.easing.expoOut,
		properties: {
			height: {end: 0, unit:"px"}
		}
	}).play();
}

function bzzzRight(){
	element = "rightMain";
	width = dojo.byId(element).offsetWidth;
	thewidth = width+2;
	dojo.animateProperty({
			node:element,
			duration: 100,
			easing: dojo.fx.easing.expoOut,
			properties: {
				width: {end: thewidth, unit:"px"}
			},
			onEnd: function(){
				dojo.animateProperty({
					node:element,
					duration: 100,
					easing: dojo.fx.easing.expoOut,
					properties: {
						width: {end: width, unit:"px"}
					}
				}).play();				 
			}
	}).play();
}

function str_replace(a, b, str) {
    return str_replace2(str, a, b);
}

function str_replace2(SRs, SRt, SRu) {
	  /*
	  **  Replace a token in a string
	  **    s  string to be processed
	  **    t  token to be found and removed
	  **    u  token to be inserted
	  **  returns new String
	  */
	  SRRi = SRs.indexOf(SRt);
	  SRRr = '';
	  if (SRRi == -1) return SRs;
	  SRRr += SRs.substring(0,SRRi) + SRu;
	  if ( SRRi + SRt.length < SRs.length)
	    SRRr += str_replace2(SRs.substring(SRRi + SRt.length, SRs.length), SRt, SRu);
	  return SRRr;
}


