//Thomas Vie copyright 2000
//DHTML functions
// ----------------- BROWSER CHECK -----------------

var version = parseInt(navigator.appVersion);
var isNS4 = false
var isIE4 = false
var isMAC = false
var initialize = 0
var Ex, Ey, topColor, subColor, ContentInfo,ie,ns;





if (navigator.appName.substring(0,8) == "Netscape" && version >= 4) {
	var isNS4 = true;
	ns=true;
	doc = "document";
	sty = "";
	cache = "hide";
	Ex = "e.pageX"
	Ey = "e.pageY"
	window.captureEvents(Event.MOUSEMOVE)
	window.onmousemove=overhere

	topColor = "#FFCC33"
	subColor = "#FFFFFF"
}
	//alert ("OK");
if (navigator.appName.substring(0,9) == "Microsoft" &&  version >= 4 ) {
	Ex = "event.x"
	Ey = "event.y"
	ie=true;
	topColor = "#FFCC33"
	subColor = "#FFFFFF"
	isIE4 = true;
	doc = "document.all";
	sty = ".style";
	cache = "hidden";
}

if (navigator.userAgent.indexOf('Mac') != -1) { isMAC = true;}




function mouseIn(layer)  {
	layerText = doc + "[\""+layer+"\"]" + sty;
	layerObj = eval(layerText);
	layerObj.visibility = "visible";
}

function mouseOut(layer)  {
        //alert(layerText);
	layerText = doc + "[\""+layer+"\"]" + sty;
	layerObj = eval(layerText);
	layerObj.visibility = cache;
}

function mouseInPos(layer)  {
	if(isIE4){
		Ex = "event.x"
		Ey = "event.y"
	}

	if(isNS4){
		Ex = "e.pageX"
		Ey = "e.pageY"
		window.captureEvents(Event.MOUSEMOVE)
		window.onmousemove=overhere
	}


	layerText = doc + "[\""+layer+"\"]" + sty;
	layerObj = eval(layerText);
	myWidth=283;
	layerObj.left=eval(Ex)-myWidth;
	layerObj.top=eval(Ey);
	layerObj.visibility = "visible";
}


function mouseOut(layer)  {
        //alert(layerText);
	layerText = doc + "[\""+layer+"\"]" + sty;
	layerObj = eval(layerText);
	layerObj.visibility = cache;
}

function mouseInFrame(frame,layer)  {
	layertext='window.top.frames.'+frame+'.'+layer+'.style';
	layerObj=eval(layertext);
	layerObj.top=20;
	layerObj.left=2;
	layerObj.visibility="visible";
	//window.top.frames.menu_b_gauche.boton1.style.visibility
}

function mouseOutFrame(frame,layer)  {
	layertext='window.top.frames.'+frame+'.'+layer+'.style';
	layerObj=eval(layertext);
	layerObj.visibility=cache;

}


function changeimage(towhat,name){
	if (document.images){
		var result = "document.images."+name;
		obj=eval(result);
		obj.src=towhat.src;
	}
}


function posIn(layer, x,y, delta)  {
	layerText = doc + "[\""+layer+"\"]" + sty;
	layerObj = eval(layerText);
	if(is.ns4) {
		y=y+delta;
	}
	layerObj.left = x;
    layerObj.top = y;
	layerObj.visibility = "visible";
}

function nada()  {
	var y;
	y=y+1;
}

function changeFrame(document,frame)  {
	var todo = "parent."+frame+".location=\""+document+"\"";
	doc_charge = new String(eval("parent."+frame+".location"));
	if(doc_charge.indexOf(document)==-1) {
		eval(todo);
	}
}

function clearForm(form) {
        var element;
        for (var i = 0; i < form.elements.length; i++) {
                element = form.elements[i];
                if (element.type == "text" || element.type == "password" || element.type == "textarea") element.value = '';
                else if (element.type.indexOf("select") != -1) element.selectedIndex = -1;
                else if (element.type == "checkbox" && element.checked) element.checked = false;
                else if (element.type == "radio" && element.checked == true) element.checked = false;
        }

}


// -------------------- OPENWINDOW --------------------

var variation
var variationbis
var zoom



if (isNS4 && !isMAC) variation = 40
if (isIE4 && !isMAC) variation = 35
if (isNS4 && isMAC) variation = 1
if (isIE4 && isMAC) variation = -25
function openw(url,nom,dimx,dimy)
		{
		dimy = dimy - variation;
		featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+ dimx + ",height=" + dimy;
        zoom = window.open(url,nom,featur)
		zoom.focus();
		}
function openw2(url,nom,dimx,dimy)
		{
		dimy = dimy - variation;
		featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+ dimx + ",height=" + dimy;
        zoom = window.open(url,nom,featur)
		zoom.focus();
		}



	
// ---------------------- SWIFT ----------------------

var processing
var nmenu = 0
var nsmenu = 0
var menuonoff = 0
var smof
var stop = 0

function menu(sm) {
	nmenu++
	this.id = 'menu['+nmenu+']'
	this.calque = (isIE4)? eval("document.all.Xmenu"+nmenu+".style") : eval("document.Xmenu"+nmenu)
	this.dir = 0;
	this.pos = parseInt(this.calque.top);
	this.onoff = 0;
	this.numero = nmenu
	
	this.swift = f_swift
	this.menumove = f_menumove
	
	if (sm) {
		this.sm = sm
		smenu[nmenu] = new smenu()
	}

}

function smenu() {
	nsmenu++
	this.id = "smenu["+nsmenu+"]"
	this.mynumero=nsmenu;
	this.calque = (isIE4)? eval("document.all.smenu"+nsmenu+".style") : eval("document.smenu"+nsmenu)
	this.limite = (isIE4)? eval('document.all.smenu'+nsmenu+'.scrollHeight') : this.calque.document.height
	this.pos = parseInt(this.calque.top);
	this.yclip = 0
	this.onoff = 0
		
	this.getclip = f_getclip
	this.clipclip = f_clipclip
	this.clipup = f_clipup
	this.clipdown = f_clipdown
	this.setclip = f_setclip
	this.showhide = f_showhide
	if (isIE4) this.getclip()
	//alert ("limite : "+this.limite);
}

function f_getclip() {
			this.clipval = this.calque.clip.split('px ')
			this.clipval[1] = parseInt(this.clipval[1])
			this.clipval[0] = this.clipval[0].substring(5);
			this.clipval[3] = parseInt(this.clipval[3]);
}

function f_clipclip() {
	if (isIE4 && isMAC) {
		this.showhide()
		return
	}
	if (!this.onoff) {
			this.onoff = 1
			this.clipdown();
		} else {
			this.onoff = 0
			this.clipup()
		}
}

function f_clipdown() {
	if (this.yclip < (this.limite)) {
		this.yclip += 4;
		this.setclip()
		setTimeout (this.id+".clipdown()",10);
	}
}

function f_clipup() {
	if (this.yclip > 0) {
		this.yclip -= 4;
		this.setclip()
		setTimeout (this.id+".clipup()",10);
	}
}

function f_setclip() {
	if (isNS4) this.calque.clip.bottom = this.yclip; 
	if (isIE4) this.calque.clip = 'rect(' + this.clipval[0] + ' ' + this.clipval[1] + ' ' + this.yclip + ' ' + this.clipval[3] + ')';
}

function clipison() {
	if (isIE4 && isMAC) {
		return
	} else {
		for (i=1 ; i<=nsmenu ; i++) {
			smenu[i].yclip = 0
			smenu[i].setclip()
			smenu[i].calque.visibility = "visible"
		}
	}
}

function f_showhide() {
		if (this.calque.visibility != cache) {
			this.calque.visibility = "hidden"
		}
		else {
			this.calque.visibility = "visible"
		}
}

function f_swift() {
	if (!processing) {
		processing = 1;
		if (this.sm) {
			smon = smenu[this.numero]
		}
		if (this.sm && menuonoff) smof = smenu[menuonoff]
		if (isIE4 && isMAC && smof) smof.showhide()
		if (this.numero > menuonoff) {
				for (i=1;i<=menuonoff;i++) {
					menu[i].dir = 0
				}
				for (i=menuonoff+1;i<=this.numero;i++) {
					menu[i].dir = -1
				}
				for (i=this.numero+1;i<=nmenu;i++) {
					menu[i].dir = 0
				}
		}
		if (this.numero < menuonoff) {
				for (i=1;i<=this.numero;i++) {
					menu[i].dir = 0
				}
				for (i=this.numero+1;i<=menuonoff;i++) {
					menu[i].dir = 1
				}
				for (i=menuonoff+1;i<=nmenu;i++) {
					menu[i].dir = 0
				}
		}
		if (!menuonoff || this.numero==menuonoff) {
			for (i=1;i<=nmenu;i++) {
				if (i<this.numero+1) {
					menu[i].dir = 0
				} else {
					(this.onoff)? menu[i].dir = -1 : menu[i].dir = 1
				}
			}
			smof = 0
		}
		ct = 1
//				menu[this.numero].calque.visibility = "hidden"
		this.menumove()
		if (this.numero==menuonoff && this.onoff) {
			menu[menuonoff].onoff
			menuonoff = 0;
		} else {
			if (menuonoff) menu[menuonoff].onoff = 0
			menuonoff = this.numero;
		}
		this.onoff = !this.onoff
	}
}

function f_menumove() {
	ct++;
	var lim=26;
	if (ct <= lim) {
		for (i=1;i<=nmenu;i++) {
			mp = menu[i]
			mp.pos = mp.pos + mp.dir * 4;
			mp.calque.top = mp.pos;
			if (mp.sm) {
				smp = smenu[i]
				smp.pos = smp.pos + mp.dir * 4;
				smp.calque.top = smp.pos;
			}
		}
	if (this.sm) {
			if (smof) {		
				smof.yclip = smof.yclip-4
				smof.setclip()
				smof.onoff = 0
			} 
			smon.yclip = (smon.onoff)? smon.yclip-4 : smon.yclip+4
			smon.setclip()
		}
		setTimeout(this.id+".menumove()", 10);
	} else {
		if (isIE4 && isMAC) {
			if(!smof && !smon.onoff) smon.calque.visibility="visible"
			if(smof && !smon.onoff) smon.calque.visibility="visible"
		}
		processing = 0
		smof = 0
		smon.onoff = !smon.onoff
	}
}

		
/*function changeFrame(document,frame)  {
	var todo;
	todo = "parent."+frame+".location=\""+document+"\"";
	eval(todo);
}*/


////////////////////////////////// new functions  /////////////////////////////////////////



function MoveToolTip(layerName, FromTop, FromLeft, e){
	if(ie){eval(doc + "." + layerName + sty + ".top = "  + (eval(FromTop) + document.body.scrollTop-30))}
	if(ns){eval(doc + "." + layerName + sty + ".top = "  +  eval(FromTop))}
	eval(doc + "." + layerName + sty + ".left = " + (eval(FromLeft) + 15))
}






function ReplaceContent(layerName){
	if(ie){document.all[layerName].innerHTML = ContentInfo}


	if(ns){
		with(document.layers[layerName].document) 
		{ 
		   open(); 
		   write(ContentInfo); 
		   close(); 
		}

	}

}



function Activate(){initialize=1}
function deActivate(){initialize=0}


function overhere(e){
	//alert(doc + "." + "ToolTip" + sty + ".visibility");

	if(initialize){
		MoveToolTip("ToolTip", Ey, Ex, e)
		eval(doc + "." + "ToolTip" + sty + ".visibility = 'visible'")
	}

	else{
		MoveToolTip("ToolTip", 0, 0)
		eval(doc + "." + "ToolTip" + sty + ".visibility = 'hidden'")
	}

}









function EnterContent(layerName, TTitle, TContent){

ContentInfo = '<table border="0" width="120" cellspacing="0" cellpadding="0">'+
'<tr><td width="100%" bgcolor="#000000" align="center">'+

'<table border="0" width="100%" cellspacing="1" cellpadding="0" align="center">'+
'<tr><td width="100%" bgcolor=#CEEEFF align="center">'+

'<table border="0" width="100%" cellspacing="0" cellpadding="0" align="center">'+
'<tr><td width="100%" align="center">'+

'<font class="tooltiptitle">&nbsp;'+TTitle+'</font>'+

'</td></tr>'+
'</table>'+

'</td></tr>'+

'<tr><td width="100%" bgcolor='+subColor+'>'+

'<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">'+

'<tr><td width="100%" align="center">'+

'<font class="tooltipcontent">'+TContent+'</font>'+

'</td></tr>'+
'</table>'+

'</td></tr>'+
'</table>'+

'</td></tr>'+
'</table>';


ReplaceContent(layerName)
}

///////////////////////// new functions v2

function openIT(windowTIT,theurl,Path) {
	//theurl="../program-xmail/step_list.php?step=0"

	wname ="CHROMELESSWIN";
	//W=579;
	//H=349;
	W=572;
	H=430;
	windowCERRARa 		= "images/closed.gif"
	windowCERRARd 		= "images/closed.gif"
	windowCERRARo 		= "images/closed.gif"
	windowBORDERCOLOR   	= "#000000"
	windowBORDERCOLORsel	= "#FFFFFF"
	windowTITBGCOLOR    	= "#e0e0e0"
	windowTITBGCOLORsel 	= "#a0a0a0"
	openchromeless(theurl, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel,Path)
}

function openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel,Path) {
	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4) isie=true
	else											     isie=false

	if (isie) { H=H+20+2; W=W+2; }

	s = ",width="+W+",height="+H;
/*
	if (isie) {
		var parameters = escape( theURL+"|"+windowCERRARa+"|"+windowCERRARd+"|"+windowCERRARo+"|"+windowTIT+"|"+windowBORDERCOLOR+"|"+windowBORDERCOLORsel+"|"+windowTITBGCOLOR+"|"+windowTITBGCOLORsel)

		splashWin = window.open( "" , wname, "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0"+s)

		splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) )
		splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) )

		splashWin.document.open("text/html", "replace");
		splashWin.document.write("<html><style type='text/css'>\n");
		splashWin.document.write("body                  { border: 1px solid #000000; overflow: hidden; margin: 0pt;}");
		splashWin.document.write("#stillloadingDiv 	{ position: absolute; left: 0px; top: 0px; width: 100%px; height: 19px; z-index: 1; background-color: #C0C0C0; layer-background-color: #C0C0C0; clip:rect(0,100%,19,0);}");
		splashWin.document.write("</style>\n");
		splashWin.document.write("<body onload=\"top.document.location.replace('"+Path+"chromeless.html?"+parameters+"')\" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll='no'>");
		splashWin.document.write("<div id=stillloadingDiv><table width=100% height=22 cellspacing=0 cellpadding=0><tr><td align=left valign=middle width=100%><FONT size=1 face=verdana color=#000000>&nbsp;&nbsp;c o n t a c t i n g . . .</font></td></tr></table></div>");
		splashWin.document.write("</body></html>");
		splashWin.document.close();

	}
	else 
	*/
	   var splashWin = window.open(theURL, '', "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1"+s, true)
	splashWin.title=windowTIT;
	splashWin.focus();
}

//////////////////////////////////////////////////////////////// CHROMELESS OPEN WINDOW //////
// Se genera una variable global con el nombre del wname... el nuevo objeto creado es eval(wname)
function openwinnowin(theurl, wname, W, H) {
	if (is.ie) r = ",resizable=0"
	else       r = ",resizable=1"
	s = ",width="+W+",height="+H;

	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	var splashWin = window.open("", wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0"+r+s)

	splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) )
	splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) )

	splashWin.document.open("text/html", "replace");
	splashWin.document.write("<html><style type='text/css'>\n");
	splashWin.document.write("#lineLDiv 		{ position: absolute; left:         0px; top:                  0px; width:     1px; height: "+H+"px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,1,"+H+",0);}");
	splashWin.document.write("#lineRDiv		{ position: absolute; left: "+(W-1)+"px; top:                  0px; width:     1px; height: "+H+"px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,1,"+H+",0);}");
	splashWin.document.write("#lineBDiv 		{ position: absolute; left:         0px; top: "+         (H-1)+"px; width: "+W+"px; height:     1px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,"+W+",1,0);}");
	splashWin.document.write("#lineTDiv 		{ position: absolute; left:         0px; top:                  0px; width: "+W+"px; height:     1px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,"+W+",1,0);}");
	splashWin.document.write("#stillloadingDiv 	{ position: absolute; left:         0px; top: "+Math.ceil(H/2)+"px; width: "+W+"px; height: "+H+"px; z-index: 1; background-color: #C0C0C0; layer-background-color: #C0C0C0; clip:rect(0,"+W+",19,0);}");
	splashWin.document.write("</style>\n");
	splashWin.document.write("<body onload=\"self.document.location.href='"+theurl+"'\" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll='no' style='border: 0px; overflow: hidden; margin: 0pt;'>");
	splashWin.document.write("<div id='lineLDiv'></div>");
	splashWin.document.write("<div id='lineRDiv'></div>");
	splashWin.document.write("<div id='lineBDiv'></div>");
	splashWin.document.write("<div id='lineTDiv'></div>");
	splashWin.document.write("<div id=stillloadingDiv><table width=100% height=22 cellspacing=0 cellpadding=0><tr><td align=left valign=middle width=100%><FONT size=1 face=verdana color=#000000>&nbsp;&nbsp;c o n t a c t i n g . . .</font></td></tr></table></div>");
	splashWin.document.write("</body></html>");
	splashWin.document.close();

	splashWin.focus();

	eval(wname+"=splashWin")
}

function volver() {
if(window.frames.length>0) {
  window.parent.frames[2].history.go(-3);
}else{
  window.history.go(-1);
}
}

function CheckAll(chk,ml,which)
{
 	var what = chk.checked;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
			if(e.name.indexOf(which)!=-1  && e.type=='checkbox') {
					//alert(e.type);
					e.checked = what;
			}
			//alert(e.name+'<BR>');
			/*
	    if (e.name == "Mid") {
		Check(e);
	    }
			*/
	}
	//ml.toggleAll.checked = what;
}

