// JavaScript Document

function show_props(obj, nomObj) {
	var resultat = "";
	for (var i in obj) {
	    resultat += nomObj + "." + i + " = " + obj[i] + "\n";
	}
    return resultat;
}

function getLeft(imgElem) {
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}

function getTop(imgElem) {
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

function goomapframe(){
	document.write('<iframe width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.fr/maps?f=l&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=sll=43.866205,-0.109862&amp;sspn=0.120048,0.215607&amp;ie=UTF8&amp;near=78550+HOUDAN&amp;cd=1&amp;ei=Vd7USemBO4Xw2wLr0aCmCw&amp;cid=14595185584525211108&amp;ll=48.799175,1.585979&amp;spn=0.022615,0.042057&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe>');
}

// initialisation
$(document).ready(function(){
	
	// navigation
	$(".extlink").attr("target","_blank");
	$(".extilink").attr("target","_blank");
	$(".retourtop").click(function (){scrollTo(0,0);})

	
	// layoutHeader
	$("#dialog").dialog({
		bgiframe: true,
		modal: true,
		buttons: { 
			Ok: function() { $(this).dialog('close'); }
		}
	});

	$("#hautpage").hover(function (){
		$(".smenu").slideUp("fast");
		$(this).stopTime();
	});
	
	$("#content").hover(function (){
		$(".smenu").slideUp("fast");
		$(this).stopTime();
	});
		
	$(".imenulink").click(
		function (){
			var m=this.nextSibling;
			m.style.left=getLeft(this)+'px';
			$(m).slideDown("slow");
		}
	);

	$("#accrocheService dt").click(function (){
		if ( $(this).hasClass("on") ){
			var n=this.id.charAt(0);
			$("#accrocheService dt").filter(function (){ return $(this).attr("id").charAt(0) == n; }).removeClass("on");
			$("#accrocheService dd").filter(function (){ return $(this).attr("id").charAt(1) == n; }).removeClass("on");
		}
	});
	
	$("#accrocheService dt").hover(function (){ {
			var n=this.id.charAt(0);
			var d="#d"+this.id;
			$("#accrocheService dt").filter(function (){ return $(this).attr("id").charAt(0) == n; }).removeClass("on");
			$("#accrocheService dd").filter(function (){ return $(this).attr("id").charAt(1) == n; }).removeClass("on");
			$(this).addClass("on");
			$(d).addClass("on");
		}
	});
	
	/*$('#autopromo').cycle({
		fx:     'fade', 
	    speed:   500, 
	    timeout: 15000, 
	    next:   '#autopromo', 
	    pause:   1
	});*/
	
	// index et chapitres
	$("#accrocheMultiple li").click(function (){
		if ( !$(this).hasClass("on") ){
			var n=this.id.charAt(1);
			var d="#d"+this.id;
			$("#accrocheMultiple li").filter(function (){ return $(this).attr("id").charAt(1) == n; }).removeClass("on");
			$("#accrocheMultiple div").filter(function (){ return $(this).attr("id").charAt(2) == n; }).removeClass("on");
			$(this).addClass("on");
			$(d).addClass("on");
		}
	});
	
	$("#accrocheMultiplerech li").click(function (){
		if ( !$(this).hasClass("on") ){
			var n=this.id.charAt(1);
			var d="#d"+this.id;
			$("#accrocheMultiplerech li").filter(function (){ return $(this).attr("id").charAt(1) == n; }).removeClass("on");
			$("#accrocheMultiplerech div").filter(function (){ return $(this).attr("id").charAt(2) == n; }).removeClass("on");
			$(this).addClass("on");
			$(d).addClass("on");
		}
	});
	
});

