// JavaScript Document

// ------------------------------------- Sous-menu ------------------------------------------*


function montre(id) {
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
	if (d) {d.style.display='block';}
}


//-------------------------------------Menu------------------------------------------------------


function showmenu(elmnt) {
	document.getElementById(elmnt).style.visibility="visible"
}
function hidemenu(elmnt) {
	document.getElementById(elmnt).style.visibility="hidden"
}


//----------------------------- popup photo annonces --------------------------------------------

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function adjust_popup()
{
        var w, h, fixedW, fixedH, diffW, diffH;
        if (document.documentElement && document.body.clientHeight==0) {     // Catches IE6 and FF in DOCMODE
                fixedW = document.documentElement.clientWidth;
                fixedH = document.documentElement.clientHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - document.documentElement.clientWidth;
                diffH = fixedH - document.documentElement.clientHeight;
                w = fixedW + diffW + 16; // Vert Scrollbar Always On in DOCMODE.
                h = fixedH + diffH;
                if (w >= screen.availWidth) h += 16;
        } else if (document.all) {
                fixedW = document.body.clientWidth;
                fixedH = document.body.clientHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - document.body.clientWidth;
                diffH = fixedH - document.body.clientHeight;
                w = fixedW + diffW;
                h = fixedH + diffH;
                if (h >= screen.availHeight) w += 16;
                if (w >= screen.availWidth)  h += 16;
        } else {
                fixedW = window.innerWidth;
                fixedH = window.innerHeight;
                window.resizeTo(fixedW, fixedH);
                diffW = fixedW - window.innerWidth;
                diffH = fixedH - window.innerHeight;
                w = fixedW + diffW;
                h = fixedH + diffH;
                if (w >= screen.availWidth)  h += 16;
                if (h >= screen.availHeight) w += 16;
        }
        w = Math.min(w,screen.availWidth);
        h = Math.min(h,screen.availHeight);
        window.resizeTo(w,h);
        window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}

// ---------------------------- Détail ------------------------------------
$(function() {
	$("#resume").click(function () {
	  $("#detail").slideToggle("slow");
	});
});

// --------------------------- BBCode -------------------------------------

function insertTag(_aa,tag,_ac){
	var _ad=((_ac)?"</"+tag+">":"");
	var Tag="<"+tag+">";
	var _af=eval(_aa);
	if(navigator.appName == "Microsoft Internet Explorer"){
		var str=document.selection.createRange().text;
		_af.focus();
		var sel=document.selection.createRange();
		sel.text=Tag+str+_ad;
		return;
	}
	else {
		oldPos=_af.scrollTop;
		oldHght=_af.scrollHeight;
		pos=_af.selectionEnd+Tag.length+_ad.length;
		_af.value=_af.value.substr(0,_af.selectionStart)+Tag+_af.value.substr(_af.selectionStart,_af.selectionEnd-_af.selectionStart)+_ad+_af.value.substr(_af.selectionEnd);
		_af.selectionStart=pos;
		_af.selectionEnd=pos;
		newHght=_af.scrollHeight-oldHght;
		_af.scrollTop=oldPos+newHght;
	}
	_af.focus();
}
