/*******************************************************************************
Creado el 08/09/2006

Script que contiene las funciones asociadas al arrastre de capas y de creación 
de los hints. 

********************************************************************************/
		//////////////////////////////////////////
		////CODIGO PARA MOSTRAR EL HINT  /////////
		//////////////////////////////////////////
			var ToolTip = 
			{
			fade      : 150,							// Efecto de fundido del hint
			opacity   : 0,							//Opacidad del Hint	
			timer     : 1000, 						// Tiempo de aparición del hint en ms
			bcolor    : "#FFFFE1", 					// color de fondo
			id        : "Hint" , 					// id de la capa Hint
			element   : null,    					// Elemento contenedor del hint
			tip       : null,    					// objeto que referencia a la capa hint
			isShowing : false,						// Boleano que indica si está o no mostrándose el hint
			fontsize  : 12,							// Size de la fuente
			idTimer   : 0,							// Id del temporizador de espera para mostrase el hint
			ClassCss  : "",							// Clase que se aplica a la capa
			/*
				Función que analiza el browser sobre la que se ejecutar esté script
				return browser
			*/
			browser: function ()
			{
					var ua, s, i;
					ua = navigator.userAgent;
					s = "MSIE";
					if ((i = ua.indexOf(s)) >= 0) 
						return "IE";
					s = "Netscape6/";
					if ((i = ua.indexOf(s)) >= 0) 
						return "Netscape";
					s = "Gecko";
					if ((i = ua.indexOf(s)) >= 0)
						return "Other";
					return null;
			},
			   
			/*
				Muestra el hint
			*/
			ShowTooltip: function (msg) 
			{
					var el =document.createElement ("DIV");
					el.id = this.id;
					el.style.zIndex="1000";
					el.style.display="none" ;
					document.body.appendChild (el);
					el.style.backgroundColor= this.bcolor;
					el.style.fontSize = this.fontsize;
					el.className = this.ClassCss;
					el.style.position="absolute";
					el.style.border= "#000000 1px solid";
					el.innerHTML=msg;
					this.tip = el;
					this.RegisterEvents();
					// Temporizador de espera a que aparezca el hint
					this.idTimer =setTimeout ("this.idTimer=setInterval('ToolTip.Show()',"+(this.fade/5)+")", this.timer)
			},
			Show: function()
			{
			    if(this.tip)
			    {
				    if (this.browser () == "IE")
						this.tip.style.filter="alpha(opacity="+(this.opacity+=20)+");"
					else
						this.tip.style.opacity =(this.opacity+=20/100);
					ToolTip.tip.style.display='inline'
					if (this.opacity >=100)
					{
						clearInterval(this.idTimer);
						this.isShowing=true;
						return;
					}
				}
			},
			/*
				Actualiza la posición del hint;
			*/
			Update : function (e)
			{
					if (this.tip)
					{
						if (!this.isShowing)
						{		
							clearTimeout(this.idTimer);
							this.idTimer= setTimeout ("ToolTip.idTimer=setInterval('ToolTip.Show()',"+(this.fade/5)+")", this.timer)
						}
						if (this.browser () == "IE")
						{
							this.tip.style.left=  e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft + 15;
							this.tip.style.top= e.clientY  +  document.documentElement.scrollTop + document.body.scrollTop + 15;
						}
						else
						{
							this.tip.style.top = e.pageY  + 15;
							this.tip.style.left = e.pageX + 15;
						}
				    
					}
				},	
			/*
					Registra los eventos asociados al hint
			*/
			RegisterEvents: function ()
			{
					if (this.tip)
					{
						if (this.browser() == "IE" ) 
						{
							this.tip.style.left = window.event.clientX;
							this.tip.style.top = window.event.clientY;
							document.attachEvent("onmousemove", Update);
							window.event.cancelBubble = true;
							window.event.returnValue = false;
						}
						else 
							document.addEventListener("mousemove", Update,   true);
					}
			},
			/*
					Elimina los eventos asociados al hint
			*/
			UnregisterEvents: function () 
			{
					if (this.browser() == "IE") 
						document.detachEvent("onmousemove", Update);
					else
						document.removeEventListener("mousemove", Update,   true);
			},
			/*
					Oculta el Hint;
			*/
			Hide : function ()
			{
					if (this.tip)
					{
						document.body.removeChild(this.tip);
						this.tip= null;
						this.element= null;
						this.opacity =0;
						if (!this.isShowing) 
							clearTimeout (this.idTimer);
						else
							this.isShowing = false;
						this.UnregisterEvents();
					}
			}
			}; 
			function CreateToolTipForElement (id,msg,css)
			{
				ToolTip.element = id;
				ToolTip.ClassCss = css;
				ToolTip.ShowTooltip (msg);    
			}
			function doToolTip(id,msg,css)
			{
				if (ToolTip.element != null)
					return;
				CreateToolTipForElement(id,msg,css);
			}
			function Update(event)
			{
				ToolTip.Update(event);
			}
			function removeToolTip()
			{
				ToolTip.Hide();
			}

			
		//////////////////////////////////////////
		////CODIGO PARA ARRASTRAR VENTANA  ///////
		//////////////////////////////////////////

		// Determinamos Navegador y version
		function Browser() {
		var ua, s, i;
		this.isIE    = false;
		this.isNS    = false;
		this.version = null;
		ua = navigator.userAgent;
		s = "MSIE";
		if ((i = ua.indexOf(s)) >= 0) {
			this.isIE = true;
			this.version = parseFloat(ua.substr(i + s.length));
			return;
		}
		s = "Netscape6/";
		if ((i = ua.indexOf(s)) >= 0) {
			this.isNS = true;
			this.version = parseFloat(ua.substr(i + s.length));
			return;
		}
		// Treat any other "Gecko" browser as NS 6.1.
		s = "Gecko";
		if ((i = ua.indexOf(s)) >= 0) {
			this.isNS = true;
			this.version = 6.1;
			return;
		}
		}
		var browser = new Browser();
		// Objeto global para guardar la información del drag.
		var dragObj = new Object();
		dragObj.zIndex = 500;

		function dragStart(event, id) 
		{
			var el;
  			var x, y;
  			// Si nos dan elemento id, lo buscamos, sino usamos el elemento en el que 
  			// se hace click
  			if (id)
    			dragObj.elNode = document.getElementById(id);
  			else {
    			if (browser.isIE)
      				dragObj.elNode = window.event.srcElement;
    			if (browser.isNS)
      			dragObj.elNode = event.target;
    			// Si es un nodo de texto, utilizamos su elemento padre
    			if (dragObj.elNode.nodeType == 3)
      				dragObj.elNode = dragObj.elNode.parentNode;
  			}
   			//Capturamos la posición del cursor respecto de la página
   			if (browser.isIE)
   			{
				x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
				y = window.event.clientY + document.documentElement.scrollTop +document.body.scrollTop;
			}
			if (browser.isNS) 
			{
				x = event.clientX + window.scrollX;
				y = event.clientY + window.scrollY;
			}
			// Guardamos la posicioninicial del cursor y del elemento
			dragObj.cursorStartX = x;
			dragObj.cursorStartY = y;
			dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10);
			dragObj.elStartTop = parseInt(dragObj.elNode.style.top,  10);
		    
			if (isNaN(dragObj.elStartLeft)) 
    			dragObj.elStartLeft = parseInt(window.screen.height*0.35,10);
			if (isNaN(dragObj.elStartTop))  
				dragObj.elStartTop  = parseInt(window.screen.width*0.35,10);
			// Actualizamos los z.index de los elementos
			dragObj.elNode.style.zIndex = ++dragObj.zIndex;
			// Capturamos los mausemove y los maoseup en la página
			if (browser.isIE) 
			{
				document.attachEvent("onmousemove", dragGo);
				document.attachEvent("onmouseup",   dragStop);
				window.event.cancelBubble = true;
				window.event.returnValue = false;
			}
			if (browser.isNS) 
			{
    			document.addEventListener("mousemove", dragGo,   true);
				document.addEventListener("mouseup",   dragStop, true);
				event.preventDefault();
			}
		}
		function dragGo(event) 
		{
			if (browser.isIE && event.button !=1) return;
			if (dragObj.elNode != null)
			{
				//Obtenemos la posición del cursor respecto de la página
				if (browser.isIE) 
				{
					x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
					y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
				}
				if (browser.isNS) 
				{
    				x = event.clientX + window.scrollX;
					y = event.clientY + window.scrollY;
				}
				// Movemos el drag a la misma posición a la que se mueve el cursor
				if ((dragObj.elStartTop  + y - dragObj.cursorStartY)< -0 ) 
					dragObj.elNode.style.top="0px";
				else
					dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";
				dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
				if (browser.isIE) 
				{
					window.event.cancelBubble = true;
					window.event.returnValue = false;
				}
				if (browser.isNS)
					event.preventDefault();
			}
		}
		function dragStop(event) 
		{
			
			//Vaciamos el elemento drag global	
			dragObj.elNode = null;
			//Dejamos de capturar los eventos mousemove y mouse up.
			if (browser.isIE) 
			{
				document.detachEvent("onmousemove", dragGo);
				document.detachEvent("onmouseup",   dragStop);
			}
			if (browser.isNS) 
			{
				document.removeEventListener("mousemove", dragGo,   true);
				document.removeEventListener("mouseup",   dragStop, true);
			}
		}
		
/*******************************************************************************
Scripts utilizados para agregar los flash de statistics de Auidit Info a la pagina
No se colocan los objetos flash directamente en la página debido al problema que 
dan con IE7,(aperece un recuadro y se solicita su activación)
********************************************************************************/	
function ActivarFlashAuditInfoSp()
{
    document.write('<OBJECT codeBase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="422" width="526" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>\n');
    document.write('<PARAM NAME="_cx" VALUE="13917">\n');
    document.write('<PARAM NAME="_cy" VALUE="11165">\n');
    document.write('<PARAM NAME="FlashVars" VALUE="">\n');
    document.write('<PARAM NAME="Movie" VALUE="images/grafica_ya.swf">\n');
    document.write('<PARAM NAME="Movie" VALUE="images/grafica_ya.swf">\n');
    document.write('<PARAM NAME="Src" VALUE="images/grafica_ya.swf">\n');
    document.write('<PARAM NAME="WMode" VALUE="opaque">\n');
    document.write('<PARAM NAME="Play" VALUE="-1">\n');
    document.write('<PARAM NAME="Loop" VALUE="-1">\n');
    document.write('<PARAM NAME="Quality" VALUE="High">\n');
    document.write('<PARAM NAME="SAlign" VALUE="">\n');
    document.write('<PARAM NAME="Menu" VALUE="-1">\n');
    document.write('<PARAM NAME="Base" VALUE="">\n');
    document.write('<PARAM NAME="AllowScriptAccess" VALUE="always">\n');
    document.write('<PARAM NAME="Scale" VALUE="ShowAll">\n');
    document.write('<PARAM NAME="DeviceFont" VALUE="0">\n');
    document.write('<PARAM NAME="EmbedMovie" VALUE="0">\n');
    document.write('<PARAM NAME="BGColor" VALUE="">\n');
    document.write('<PARAM NAME="SWRemote" VALUE="">\n');
    document.write('<PARAM NAME="MovieData" VALUE="">\n');
    document.write('<PARAM NAME="SeamlessTabbing" VALUE="1">\n');
    document.write('<PARAM NAME="Profile" VALUE="0">\n');
    document.write('<PARAM NAME="ProfileAddress" VALUE="">\n');
    document.write('<PARAM NAME="ProfilePort" VALUE="0">\n');
    document.write('\n');
    document.write('\n');
    document.write('\n');
    document.write('<embed src="images/grafica_ya.swf" wmode="opaque" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer"	type="application/x-shockwave-flash" width="526" height="422">\n');
    document.write('</embed>\n');
    document.write('</object>\n');
}
//******************************************************************************
function ActivarFlashAuditInfoEn()
{
    document.write('<OBJECT codeBase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="422" width="526" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>\n');
    document.write('<PARAM NAME="_cx" VALUE="13917">\n');
    document.write('<PARAM NAME="_cy" VALUE="11165">\n');
    document.write('<PARAM NAME="FlashVars" VALUE="">\n');
    document.write('<PARAM NAME="Movie" VALUE="images/grafica_ya_eng.swf">\n');
    document.write('<PARAM NAME="Src" VALUE="images/grafica_ya_eng.swf">\n');
    document.write('<PARAM NAME="WMode" VALUE="opaque">\n');
    document.write('<PARAM NAME="Play" VALUE="-1">\n');
    document.write('<PARAM NAME="Loop" VALUE="-1">\n');
    document.write('<PARAM NAME="Quality" VALUE="High">\n');
    document.write('<PARAM NAME="SAlign" VALUE="">\n');
    document.write('<PARAM NAME="Menu" VALUE="-1">\n');
    document.write('<PARAM NAME="Base" VALUE="">\n');
    document.write('<PARAM NAME="AllowScriptAccess" VALUE="always">\n');
    document.write('<PARAM NAME="Scale" VALUE="ShowAll">\n');
    document.write('<PARAM NAME="DeviceFont" VALUE="0">\n');
    document.write('<PARAM NAME="EmbedMovie" VALUE="0">\n');
    document.write('<PARAM NAME="BGColor" VALUE="">\n');
    document.write('<PARAM NAME="SWRemote" VALUE="">\n');
    document.write('<PARAM NAME="MovieData" VALUE="">\n');
    document.write('<PARAM NAME="SeamlessTabbing" VALUE="1">\n');
    document.write('<PARAM NAME="Profile" VALUE="0">\n');
    document.write('<PARAM NAME="ProfileAddress" VALUE="">\n');
    document.write('<PARAM NAME="ProfilePort" VALUE="0">\n');
    document.write('<embed src="images/grafica_ya_eng.swf" wmode="opaque" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer"	type="application/x-shockwave-flash" width="526" height="422"> </embed>\n');
    document.write('</OBJECT>\n');
}
//******************************************************************************

		