
function execScript(divid)
{ var liste = $(divid).getElementsByTagName("script"); for (var j=0; j<liste.length; j++)
{ eval(liste[j].innerHTML);}
}
function changeCSSProperty(classe, propriete, valeur)
{ if (!document.styleSheets)
return; var cssRules = 'cssRules'; if (document.all)
cssRules = 'rules'; for (var sSheet=0; sSheet < document.styleSheets.length; sSheet++)
{ for (var rule=0; rule < document.styleSheets[sSheet][cssRules].length; rule++)
{ var currentClass = new String(document.styleSheets[sSheet][cssRules][rule].selectorText); currentClass = currentClass.toLowerCase(); if (currentClass == classe.toLowerCase())
{ document.styleSheets[sSheet][cssRules][rule].style[propriete] = valeur;}
}
}
}
function recupValeurCSS(classe,propriete)
{ if (!document.styleSheets)
return ""; var cssRules = 'cssRules'; if (document.all)
cssRules = 'rules'; for (var sSheet=0; sSheet < document.styleSheets.length; sSheet++)
{ for (var rule=0; rule < document.styleSheets[sSheet][cssRules].length; rule++)
{ var currentClass = document.styleSheets[sSheet][cssRules][rule].selectorText.substring(1); if (currentClass == classe)
{ return(document.styleSheets[sSheet][cssRules][rule].style[propriete])
}
}
}
}
function ajouter(select1, select2)
{ var usersGroups = document.getElementById(select1); var users = document.getElementById(select2); var compteselect=0; for (yo=0; yo<users.length ; yo++)
if (users.options[yo].selected)
compteselect++; if (compteselect==0)
{ return;}
for (yo=0; yo<users.length;yo++)
{ if (users.options[yo].selected)
{ nouvel_element = new Option(users.options[yo].text,users.options[yo].value,false,false); usersGroups.options[usersGroups.length] = nouvel_element; users.options[yo] = null;}
}
ajouter(select1,select2);}
function setHeight(ladiv1,ladiv2)
{ taille = $(ladiv1).offsetHeight; $(ladiv2).style.height = $(ladiv2).offsetHeight + taille;}
function getValues(idForm)
{ var chValue = ""; var formulaire = $(idForm)
var liste = formulaire.getElementsByTagName("input"); for (var k=0; k<liste.length; k++)
{ if ((liste[k].type=="radio")||(liste[k].type=="checkbox"))
{ if ((liste[k].checked)&&(liste[k].name!=""))
chValue = chValue + liste[k].name +"="+(liste[k].value)+"&";}
else
if (liste[k].name!="")
chValue = chValue + liste[k].name +"="+(liste[k].value)+"&";}
liste = formulaire.getElementsByTagName("select"); for (var k=0; k<liste.length; k++)
chValue = chValue + liste[k].name +"="+(liste[k].value)+"&"; if ((chValue.substr(((chValue.length)-1), 1)) == "&")
chValue = chValue.substr(0,((chValue.length)-1)); return(chValue);}
function imprime_zone(commande, obj)
{ var zi = document.getElementById(obj).innerHTML; var f = window.open("/common/vierge.asp", "ZoneImpr", "height=500, width=600,	toolbar=0, menubar=0, scrollbars=1, resizable=1, status=0, location=0, left=10, top=10"); alert(f); f.document.getElementsByTagName("body")[0].innerHTML += "	" + zi + "	"; f.window.print(); f.window.close(); return true;}
var ns4 = (document.layers)? true:false; var ie4 = (document.all)? true:false; var dom = (document.getElementById)? true:false; var PreloadFlag = false; function getWindowSize()
{ var MySize = new Array(); if (window.innerWidth)
MySize[0] = window.innerWidth; else
MySize[0] = document.body.clientWidth; if (window.innerHeight)
MySize[1] = window.innerHeight; else
MySize[1] = document.body.clientHeight; return MySize;}
function getLeft(MyObject)
{ if (dom || ie4)
{ if (MyObject.offsetParent)
return (MyObject.offsetLeft + getLeft(MyObject.offsetParent)); else
return (MyObject.offsetLeft);}
if (ns4)
{ return (MyObject.x);}
}
function getTop(MyObject)
{ if (dom || ie4)
{ if (MyObject.offsetParent)
return (MyObject.offsetTop + getTop(MyObject.offsetParent)); else
return (MyObject.offsetTop);}
if (ns4)
{ return (MyObject.y);}
}
function getHeight(DivId)
{ if (dom)
return (document.getElementById(DivId).offsetHeight); if (ie4)
return (document.all[DivId].clientHeight); if (ns4)
return (document.layers[DivId].clip.height);}
function getWidth(DivId)
{ if (dom)
return (document.getElementById(DivId).offsetWidth); if (ie4)
return (document.all[DivId].clientWidth); if (ns4)
return (document.layers[DivId].clip.width);}
function ExtractClip(MyString)
{ var MyClip = new Array(); if (MyString == "")
{ MyClip[0] = 0; MyClip[1] = 0; MyClip[2] = 0; MyClip[3] = 0;}
else
{ MyClip = MyString.split("rect(")[1].split(" "); for (var i=0;i<MyClip.length;i++)
{ MyClip[i] = parseInt(MyClip[i]);}
}
return MyClip;}
function getClip(DivId)
{ var MyClip = new Array(); var MyString = ""; if (dom)
{ MyString = document.getElementById(DivId).style.clip; MyClip = ExtractClip(MyString);}
else if (ie4)
{ MyString = document.all[DivId].style.clip; MyClip = ExtractClip(MyString);}
else if (ns4)
{ MyClip[0] = document.layers[DivId].clip.top; MyClip[1] = document.layers[DivId].clip.right; MyClip[2] = document.layers[DivId].clip.bottom; MyClip[3] = document.layers[DivId].clip.left;}
var MyVal = ""
for (var i=0;i<MyClip.length;i++)
{ MyVal = MyVal + " " + MyClip[i];}
return MyClip;}
function SetToXY(DivId,Coordinates)
{ if (dom)
{ document.getElementById(DivId).style.left = Coordinates[0]; document.getElementById(DivId).style.top = Coordinates[1];}
if (ie4)
{ document.all[DivId].style.posLeft = Coordinates[0]; document.all[DivId].style.posTop = Coordinates[1];}
if (ns4)
{ document.layers[DivId].pageX = Coordinates[0]; document.layers[DivId].pageY = Coordinates[1];}
}
function SetToAnchor(AnchorId,AnchorName,DivId)
{ var MyCoordinates = new Array(); var MyAnchor; if (dom)
{ MyAnchor = document.getElementById(AnchorId);}
else if (ie4)
{ MyAnchor = document.all[AnchorId];}
else if (ns4)
{ MyAnchor = document.anchors[AnchorName];}
MyCoordinates[0] = getLeft(MyAnchor); MyCoordinates[1] = getTop(MyAnchor); SetToXY(DivId,MyCoordinates); return MyCoordinates;}
function SetClip(DivId,MyClip)
{ if (dom)
{ document.getElementById(DivId).style.clip = "rect("+MyClip[0]+"px "+ MyClip[1]+"px "+ MyClip[2]+"px "+ MyClip[3]+"px)";}
else if (ie4)
{ document.all[DivId].style.clip = "rect("+MyClip[0]+"px "+ MyClip[1]+"px "+ MyClip[2]+"px "+ MyClip[3]+"px)";}
else if (ns4)
{ document.layers[DivId].clip.top = MyClip[0]; document.layers[DivId].clip.right = MyClip[1]; document.layers[DivId].clip.bottom = MyClip[2]; document.layers[DivId].clip.left = MyClip[3];}
}
function Show(DivId)
{ if (dom)
{ document.getElementById(DivId).style.visibility = "visible";}
else if (ie4)
{ document.all[DivId].style.visibility = "visible";}
else if (ns4)
{ document.layers[DivId].visibility = "show";}
}
function Hide(DivId)
{ if (dom)
{ document.getElementById(DivId).style.visibility = "hidden";}
else if (ie4)
{ document.all[DivId].style.visibility = "hidden";}
else if (ns4)
{ document.layers[DivId].visibility = "hide";}
}
function PreloadImages()
{ var MyArguments = PreloadImages.arguments; var MyImages = new Array(); if (document.images)
{ for(var i=0; i<MyArguments.length; i++)
{ MyImages[i]= new Image(); MyImages[i].src = MyArguments[i];}
PreloadFlag = true;}
}
function ChangeImages()
{ var MyArguments = ChangeImages.arguments; var ImgName; for(var i=0; i<MyArguments.length; i+=2)
{ ImgName = MyArguments[i]; document.images[ImgName].src = MyArguments[i+1];}
}
Array.prototype.inArray = function(val)
{ for(var a2 = 0; a2 < this.length; ++a2)
{ if(this[ a2] == val)
return true;}
return false;}
document.getElementsByClassName = function(className)
{ var elts = document.getElementsByTagName('*'); var classArray = new Array(); for (var j = 0; j < elts.length; ++j)
{ if (elts[j].getAttribute('class') && elts[j].getAttribute('class').split(' ').inArray(className))
{ classArray.push(elts[j]);}
}
return classArray;}


function selectAll(idSelect)
{
	var theSelect=$(idSelect);
	for (var i=0; i<theSelect.options.length; i++)
		theSelect.options[i].selected = true;
}



function goURL(url)
{
	document.location.href = url;
}





function help(action)
{
	if (action=="open")
		window.open("/help/default.htm");
	if (action=="download")
		window.open("/help/Colortech.chm");
	if (action=="mail")
		document.location.href="mailto:support@spralac.com";
		
}

function redirectAfterLogin()
{
	var page="";
	if (document.getElementById('page'))
		page = document.getElementById('page').value;
	if (page != "") {
		while(page.search(":::")!=-1)
			page=page.replace(":::","&")
		//window.location.replace(urlDoc+page);
		try{
			window.top.location.replace(urlDoc+page)
		}
		catch(e){
			//alert("Erreur dans redirectAfterLogin : "+e.message)
		}
	}
	else
		window.top.location.href="/formules/default.asp";
}




function deconnexion()
{
	var xmlDeconnect = XHR("post", "/common/traite_login_xml.asp", "");
	//DomXSL("divLogin","/common/login_xml.asp", "/common/login_light.xsl","post","");
	goURL("/common/login.asp?deconnect=1");
}


function deconnexionLight()
{
	var xmlDeconnect = XHR("post", "/common/traite_login_xml.asp", "");
	DomXSL("divLogin","/common/login_xml.asp", "/common/login_light.xsl","post","");
	try {
		aMenuBar.clearAll();
		var chParam = "/common/genere_sousMenu.asp?langue="+langue+"&idMenu="+idMenuColortechEmpty+"&tmp="+(new Date).valueOf();
		aMenuBar.loadXML(chParam);
	}catch(e) {}
}



function position(e) {
	xx = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
	yy = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
}





function verifLogin(login,mdp,light)
{
	if (document.getElementById('div_JustLogOf'))
		document.getElementById('div_JustLogOf').style.display='none';
		
	var xhr_object = null;
	if(window.XMLHttpRequest)
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject)
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else return;

	xhr_object.open("POST", "/common/traite_login_xml.asp", true);
	xhr_object.onreadystatechange = function() {
		if(xhr_object.readyState == 4) {
			var xmlDoc = xhr_object.responseXML;
			var colorLogin = document.getElementById('colorLogin');
			
			try {
				var acces = xmlDoc.getElementsByTagName("Acces")[0].firstChild.data;
				if (acces==0) {
					if (!light) {
						colorLogin.style.height = "50px";
						colorLogin.style.color = "white";
						colorLogin.style.zIndex = "4000";
						colorLogin.style.backgroundImage = "url(/common/img/login_error.gif)"
						colorLogin.style.backgroundRepeat = "no-repeat"
					}
					colorLogin.innerHTML = "<br>"+erreurLogin+"<br>";
				}
				else {
					if (!light) {
						colorLogin.style.height = "50px";
						colorLogin.style.color = "red";
						colorLogin.style.zIndex = "4000";
						colorLogin.style.backgroundImage = "url(/common/img/login_ok.gif)"
						colorLogin.style.backgroundRepeat = "no-repeat"
						colorLogin.innerHTML = "<br>"+loginOK+"<br>";
					}
					
					if (!light)
						setTimeout("redirectAfterLogin()",800);
					else {
						DomXSL("divLogin","/common/login_xml.asp", "/common/login_light.xsl","post","");
						try {
							aMenuBar.clearAll();
							var chParam = "/common/genere_sousMenu.asp?langue="+langue+"&idMenu="+idMenuColortech+"&tmp="+(new Date).valueOf();
							aMenuBar.loadXML(chParam);
						}catch(e) {alert(e.message)}
					}
				}
			}
			catch(e){
				if (!light) {
					colorLogin.style.height = "50px";
					colorLogin.style.color = "white";
					colorLogin.style.zIndex = "4000";
					colorLogin.style.backgroundImage = "url(/common/img/login_error.gif)"
					colorLogin.style.backgroundRepeat = "no-repeat"
				}
				colorLogin.innerHTML = "<br>"+erreurLogin+"<br>";
			}
		}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_object.send("login="+login+"&password="+mdp);
}


function trace(page) {
	var t = XHR("POST", "/trace.php", "page="+page);
}
