// Modifié le 2006-02-08
var pwisIE4 = (typeof(document.all) != 'undefined' && parseInt(navigator.appVersion) >= 4 && typeof(window.opera) == 'undefined')? 1 : 0;

function pwSetVisibility(obj,visible)
{
	if( document.getElementById(obj) )
	{
		if(visible) document.getElementById(obj).style.visibility='inherit';
		else document.getElementById(obj).style.visibility='hidden';
	}
}

function pwShowObject(obj,disp,is_noadjust)
{
	el=document.getElementById(obj);
	if( el ){
		if(!disp)disp='block';
        if(navigator.appName.indexOf("Microsoft") == -1){
            switch(el.tagName.toUpperCase())
            {
                case 'TR':
                    disp = 'table-row';
                break;
                case 'TD':
                    disp = 'table-cell';
                break;
            }
        }
        el.style.display=disp;
        if( !is_noadjust ) pwAdjustIFrame();
    }
}
function pwHideObject(obj, is_noadjust)
{
	el=document.getElementById(obj);
	if( el )
	{
		el.style.display="none";
		if( !is_noadjust ) pwAdjustIFrame();
	}
}

function pwToggleDisplay(obj)
{
	var whichEl = document.getElementById(obj);
	if( whichEl )
	{
        if( whichEl.style.display == 'none' || whichEl.style.display == 'block' ){
		    if (whichEl.style.display == 'none') {
			    whichEl.style.display = 'block';
		    } else {
			    whichEl.style.display = 'none';
		    }
        }else{

		    if (whichEl.style.visibility == 'hidden') {
			    whichEl.style.visibility = 'visible';
		    } else {
			    whichEl.style.visibility = 'hidden';
		    }
        }
	}
}

function pwCheckAll(theForm, cName, check)
{
for(i=0,n=theForm.elements.length;i < n;i++)
{
if (theForm.elements[i].className.indexOf(cName) !=-1)
{
theForm.elements[i].checked = check;
}
}
}

function pwCheckCount(theForm, cName, check)
{
var nb=0;
for(i=0,n=theForm.elements.length;i < n;i++)
{
if (theForm.elements[i].className.indexOf(cName) !=-1)
{
if( theForm.elements[i].checked == check ) nb++;
}
}
return nb;
}

function pwGetFirstCheckValue(theForm, cName)
{
for(i=0,n=theForm.elements.length;i < n;i++)
{
if(theForm.elements[i].className.indexOf(cName) !=-1 && theForm.elements[i].checked == true )
{
	return theForm.elements[i].value;
}
}
return false;
}

function pwOpenDetail(filename,targetname,w,h)
{
window.open(filename,targetname,'status=no,location=no,scrollbars=yes,resize=no,directories=no,toolbar=no,menubar=no,copyhistory=yes,width='+w+',height='+h);
return false;
}

function pwOpenWindow(url,targetname,x,y,w,h,is_resize)
{
	var s='';
	if(y!='')s=s+'top='+y+',';
	if(x!='')s=s+'left='+x+',';
	if(w!='')s=s+'width='+w+',';
	if(h!='')s=s+'height='+h+',';
	s=s+'status=no,location=no,scrollbars=yes,resize=';
	if(is_resize=1) s=s+'yes';
	else s=s+'no';
	s=s+',directories=no,toolbar=no,menubar=no,copyhistory=no';
	window.open(url,targetname,s);
}

function pwOpenHelp(url)
{
	pwOpenWindow(url,'_blank',screen.width-450-30,10,450,450,1);
}

function pwChangeLocation(myfield,target)
{
var formindex=myfield.selectedIndex;
if(myfield.value != ""){
target.location=myfield.options[formindex].value;
return true;
}
return (false);
}

function pwDisplayOnCheck(chk,targetid,display)
{
if( document.getElementById(targetid) ){
obj = document.getElementById(targetid);
if( chk.checked ){
	if(!display)display='block';
	obj.style.display = display;
}
else{
	obj.style.display = 'none';
}
}
pwAdjustIFrame();
}

function pwHideOnCheck(chk,targetid,display)
{
if( document.getElementById(targetid) ){
obj = document.getElementById(targetid);
if( chk.checked ){
	obj.style.display = 'none';
}
else{
	if(!display)display='block';
	obj.style.display = display;
}
}
}

function pwAddHTML(idname,html)
{
el = document.getElementById(idname);
el.innerHTML = el.innerHTML + html;
}

var getFFVersion=navigator.userAgent.indexOf("Firefox");
function pwAdjustIFrame()
{
	try {
	myiframe = window.frameElement;
	if(myiframe && !window.opera)
	{
		myiframe.style.display="block";
		if(myiframe.contentDocument && myiframe.contentDocument.body.offsetHeight) //ns6 syntax
			myiframe.height = myiframe.contentDocument.body.offsetHeight+30;
		else if(myiframe.Document && myiframe.Document.body.scrollHeight) //ie5+ syntax
			myiframe.height = myiframe.Document.body.scrollHeight+20;

		if( parent && parent.frameElement )
		{
			parent.pwAdjustIFrame();
		}
	}
	}
	catch(er){}
}

function pwSetCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function pwGetCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function pwDeleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

window.document.getElement = function(id)
{
    if( id )
    {
        try{
            var el = document.getElementById(id);
            if( !el ) throw "L'objet '"+id+"' n'est pas contenu dans le document courant.";
        }catch(err){
            if( DEBUG_ALERT_MESSAGE == true ) alert("Javascript DEBUG ERROR : " + err);
        }
        if( el )
            return el;
        else
        {
            var el = new Object();
            return false;
        }
    }
};

function pwFormSubmit(theForm,action)
{
    theForm.action=action;
    theForm.submitform.value=theForm.submitcode.value;
}
