/******************************* Object Url *****************************/
function UrlParameter(name,value){
	this.name = name;
	this.value = value;
}

function Url(href){
	this.href = href;
	
	var arSplitNumMark = this.href.split("#");
	this.anchor = "";
	if (arSplitNumMark.length > 1)
		this.anchor = arSplitNumMark[1];
	
	var arSplitQuestionMark = arSplitNumMark[0].split("?");
	this.fullpathname = arSplitQuestionMark[0];
	
	this.search = "";
	if (arSplitQuestionMark.length > 1)
		this.search = arSplitQuestionMark[1];
	this.initArrayParameters();
}

Url.prototype.toString = function(){
	return "href: " + this.href + " fullpathname: " + this.fullpathname + " search: " + this.search + " anchor:" + this.anchor;
}

Url.prototype.initHRef = function(){
	this.href = this.fullpathname;
	if (this.arParameters.length > 0)
		this.href += "?";
	for (var i=0;i<this.arParameters.length; i++) {
		this.href += this.arParameters[i].name + "=" + this.arParameters[i].value;
		if (i <this.arParameters.length - 1)
			this.href += "&";
	}
	if (this.anchor.length > 0)
		this.href += "#" + this.anchor;
//	alert(this.toString());
}

Url.prototype.initArrayParameters = function(){
	this.arParameters = new Array();
	if (this.search.length > 0){
		var arParam = this.search.split("&");
		for (var i=0; i< arParam.length; i++){
			var arCurParam = arParam[i].split("=");
			this.arParameters[i] = new UrlParameter(arCurParam[0],arCurParam[1]);
		}
	}
}

Url.prototype.setParamValue = function(paramName,paramValue){
	var bFound = false;
	for (var i=0; (i< this.arParameters.length) && !bFound; i++){
		if (this.arParameters[i].name == paramName){
			this.arParameters[i].value = paramValue;
			bFound = true;
			break;
		}
	}
	if (!bFound)
		this.arParameters[this.arParameters.length] = new UrlParameter(paramName,paramValue);
	this.initHRef();
}
/*************************** Fin Object Url ******************************/

/******************************* Toise **********************************/
function toise_clic(age)
{
	var url = new Url(this.location.href);
	url.setParamValue("curage",age);
	this.location.href = url.href;
	tag_toise(age);
}
/*************************** Fin Toise **********************************/

/***************************** Page Imprimer ****************************/
function imprime(){	
	if (window.print){
		window.print()
	}
	else{
		if(navigator.appVersion.indexOf("Mac")<0){
		WebBrowser1.focus()
		PrintFaPage()
		}
		else{
			alert('Utilisez le menu "fichier/imprimer"\nmerci')
		}
	}
}
/************************* Fin Page Imprimer ****************************/

/**************** Formulaire Posez vos questions ************************/

//pour voir le detail des questions de la semaine ou l'historique
function GoToDetail(url,age)
{
		this.location.href="questiondetail.php?docid="+url;
}
/**************** Fin Formulaire Posez vos questions ********************/

/******************************* Popup **********************************/
function openPop(url)
{
	var LocalPop = window.open("", "Bledina","toolbar=no,scrollbars=no,directories=no,menubar=no,status=no,resizable=no,width=421,height=496");
	LocalPop.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>Chargement en cours...</title><style type="text/css">body{margin:0;padding:0;}div#content{width:421px;height:496px;} #loading{width:32px;height:32px;margin:auto;margin-top:230px;display:block;}</style></head><body><div id="content"><p id="loading"><img src="/fr/img/ajax-loader.gif" alt="Chargement en cours..."/></p></div></body></html>');
	LocalPop.location = url;
	LocalPop.focus();
 
//	} else {
//		LocalPop.close();
//		openPop(url);
//	}
	
//	
//	// pour ?viter d'ouvrir plusieurs fen?tres simultan?es 
//	pop = open(url,"Bledina","toolbar=no,scrollbars=no,directories=no,menubar=no,status=no,resizable=no,width=421,height=496");
//   	if (pop && !pop.closed) pop.close();
//   	// ouvre la fen?tre 
//   	pop = open(url,"Bledina","toolbar=no,scrollbars=no,directories=no,menubar=no,status=no,resizable=no,width=421,height=496");
//   	if (!pop.opener) pop.opener = self;
} 
/****************************** Fin Popup *******************************/

function openPopup(url, name, width, height,scroll){
	window.open(url, name, "width="+width+",height="+height+",scrollbars=" + scroll);
}

function popupcentree(furl,largeur,hauteur,options){
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;
    window.open(furl,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
/*********************************FIXE PNG ***************************************/
function fixPNG(idImg, context) {
    if (document.body.filters && (document.all && !window.opera) && !window.XMLHTTPRequest) {
        var img = document.getElementById(idImg);
        var src = img.src;
        img.src = context+'img/dot.gif';
        img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',sizingMethod='image')";  
    }
}

function FixPNGAllImg(chemin){
		if(document.body.filters && (document.all && !window.opera) && !window.XMLHTTPRequest){			
			var oImage = document.getElementsByTagName('img');
			if(!oImage) return;			
			for(var i = 0;i<oImage.length;i++){
				if(oImage[i].className == 'png'){
                    oImage[i].style.background = 'none';
		            oImage[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + oImage[i].src + "',sizingMethod='image')";                        
					oImage[i].src = chemin+'img/dot.gif';
				}
			}			
		}
	}

function rollNav(ImgNme){
	obj=(document.images)? document.images[ImgNme]:0; ClicNme=(document.clicImg)? document.clicImg.name:""; 
	if (!obj && document.layers) {
		for (i=0; i<document.layers.length; i++) { 
			ObjLyr=document.layers[i].document;
			if (ObjLyr.images && ObjLyr.images[ImgNme]) obj=ObjLyr.images[ImgNme];
		}
	}       
    if (ClicNme!=ImgNme)obj.src=(obj.src.lastIndexOf('_on')!=-1)?obj.src.replace(/_on/gi,"_off"):obj.src.replace(/_off/gi,"_on");
    document.OnImg=obj;
    //alert(obj.src);
}