var actual=0;
var limit = 2
function prevNews()
{
	if(actual>0)
		actual--
	else
		actual=limit
	printNews()
}
function nextNews()
{
	if(actual<limit)
		actual++
	else
		actual=0
	printNews()
}
function printNews()
{
	document.getElementById('newsImg').src='images/noticiaHome'+actual+'.jpg'
	//document.getElementById('newsContent').innerHTML= t
}
showedLayer = ''
function changeLayer( id )
{
	//oculto el layer
	if( showedLayer==id )
	{
		hideLayer(showedLayer)
		showedLayer = ''
	}
	//oculto el layer y muestro el layer id
	else if( showedLayer!='' )
	{
		hideLayer(showedLayer)
		centerLayerH2_(id);
		if (navigator.appName.indexOf("Explorer") != -1) {
			centerLayerV2_( id, 274 );
		} else {
			centerLayerV2_( id, 264 );
		}
		showLayer(id)
		showedLayer = id
	}
	//muestro el layer id
	else
	{
		centerLayerH2_(id)
		if (navigator.appName.indexOf("Explorer") != -1) {
			centerLayerV2_( id, 274 );
		} else {
			centerLayerV2_( id, 264 );
		}
		showLayer(id)
		showedLayer = id
	}
}

lastLayer2 = 'div_8'
function changeLayer_2( id )
{
	//oculto el layer
	if( showedLayer==id )
	{
		hideLayer(showedLayer)
		showedLayer = ''
	}
	//oculto el layer y muestro el layer id
	else if( showedLayer!='' )
	{
		hideLayer(showedLayer)
		centerLayerH(id,-30)
		if ((screen.width == 800) && (screen.height == 600)) 
			centerLayerH(id,-115)
		showLayer(id)
		showedLayer = id
	}
	//muestro el layer id
	else
	{
		centerLayerH(id,-30)
		if ((screen.width == 800) && (screen.height == 600)) 
			centerLayerH(id,-115)
		showLayer(id)
		showedLayer = id
	}
	
	if( lastLayer2!='' )
	{
		document.getElementById(lastLayer2+'_1').src = '../img/espacioTitleMenu2_49.gif'
		document.getElementById(lastLayer2+'_2').className = 'BordeSupPestanaHomeNoSelect'
		document.getElementById(lastLayer2+'_3').className = 'BordeInfPestanaHomeNoSelect'
		document.getElementById(lastLayer2+'_4').src = '../img/espacioTitleMenu2_49.gif'
	}
	document.getElementById(id+'_1').src = '../img/patanaMenu2_47.gif'
		//myImage = "url(../img/patanaMenu2_47.gif)"
		//document.getElementById(id+'_1').style.backgroundImage = myImage
	//document.getElementById(id+'_1').className = 'BordeIzqPestanaHomeSelect'
	document.getElementById(id+'_2').className = 'BordeSupPestanaHomeSelect'
	document.getElementById(id+'_3').className = 'BordeInfPestanaHomeSelect'
	document.getElementById(id+'_4').src = '../img/patanaMenu2_49.gif'
	lastLayer2 = id
}


//variables generales
//variable que me permite saber si el menu esta o no abierto
var menuProject = false;

function showLayerSmooth( id, pos )
{
	lay = document.getElementById(id)
	if( lay )
		appear(id,0,pos)
}
function rotateLayerSmooth( id, pos )
{
	if( document.getElementById(id) )
	{
		if( document.getElementById(id).style.visibility == 'hidden' )
			showLayerSmooth(id,pos)
		else
			hideLayerSmooth(id,pos)
	}
}
function hideLayerSmooth( id, pos )
{
	lay = document.getElementById(id)
	if( lay )
	{
		disappear(id,1,pos)
		//opacity: .8;filter: alpha(opacity=80);
	}
}
function disappear( id, op, pos )
{
	op = parseFloat(op)
	document.getElementById(id).style.opacity = op
	if( op<=0 )
	{
		if( pos!=undefined && pos==1 )
			document.getElementById(id).style.position = 'absolute'
		document.getElementById(id).style.visibility = 'hidden'
		return
	}
	else
	{
		op -= 0.1
		setTimeout('disappear("'+ id +'","'+ op +'","'+ pos +'")',20)
	}
}
function appear( id, op, pos )
{
	op = parseFloat(op)
	document.getElementById(id).style.opacity = op
	if( pos!=undefined && pos==1 )
		document.getElementById(id).style.position = 'relative'
	document.getElementById(id).style.visibility = 'visible'
	if( op<1 )
	{
		op += 0.1
		setTimeout('appear("'+ id +'","'+ op +'","'+ pos +'")',20)
	}
}

function centerLayer( id, halfWidth, halfHeight )
{
	centerLayerH( id, halfWidth )
	centerLayerV( id, halfHeight )
}

function centerLayerH( id, halfWidth )
{
	o = document.getElementById(id)
	if( o )
	{
		//la mitad de los tamannos para los calculos
		hw = document.body.clientWidth/2
		o.style.left = (hw-halfWidth)+'px'
	}
}

function centerLayerV( id, halfHeight )
{
	o = document.getElementById(id)
	if( o )
	{
		//la mitad de los tamannos para los calculos
		hh = document.body.clientHeight/2
		alert(hh-halfHeight)
		o.style.top = hh-halfHeight
	}
}
//Div superior UMNG
function centerLayerV2_( id, topPosition )
{
	o = document.getElementById(id)
	if( o )
	{
		o.style.top = topPosition;
	}
}
function centerLayerH2_( id )
{
	o = document.getElementById(id);
	if( o )
	{
		if (document.body.clientWidth>=950) {
			hw = ((document.body.clientWidth-950)/2) + 35;
		
		} else {
			hw = 35;
		}
		o.style.left = hw;
	}
}


function setParagraph(id, text)
{
	document.getElementById(id).innerHTML = text
}

function setParagraphText( par, text, field )
{
	if( par.all )
	{
		par.all(field).innerText = text;
	}
	else if( par.getElementById )
	{
		par.getElementById(field).firstChild.data = text;
	}
	else
		alert('Su navegador no soporta la actualización, pese a esto, el texto adicionado quedará grabado.');
}

function addParagraphText( par, text, field )
{
	if( par.all )
	{
		par.all(field).innerText += text;
	}
	else if( par.getElementById )
	{
		par.getElementById(field).firstChild.data += text;
	}
	else
		alert('Su navegador no soporta la actualización, pese a esto, el texto adicionado quedará grabado.');
}


if (document.layers) 
{ // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all || document.getElementById)
{ // Internet Explorer o mozilla
    document.onmousemove = captureMousePosition;
}

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {//Netscape
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) { //IE
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {//Mozilla
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}

function moveLayerMouse(id,offsetX,offsetY)
{
	if( document.all )
	{
		document.all(id).style.left = xMousePos + offsetX
		document.all(id).style.top = yMousePos + offsetY
	}
	else if( document.getElementById )
	{
		document.getElementById(id).style.left = xMousePos + offsetX
		document.getElementById(id).style.top = yMousePos + offsetY
	}
}

function showLayerMouse( id, offsetX, offsetY )
{
	if( !offsetX )
		offsetX = 20
	if( !offsetY )
		offsetY = 15
	lay = document.getElementById(id)
	lay.style.left = xMousePos+offsetX
	lay.style.top = yMousePos+offsetY
	if( lay )
		appear(id,0,false)
}

function setHelp( value, helpPosition )
{
	if( !helpPosition )
		helpPosition = 'br'
	helpWidth = value.length*7
	rows = 1
	if( helpWidth>400 )
	{
		helpWidth = 400;
		rows = (helpWidth/401)+1
	}
	if( helpPosition=='br' )
	{
		helpXOffset = 10
		helpYOffset = 10
	}
	else if( helpPosition=='bl' )
	{
		helpXOffset = -1*helpWidth
		helpYOffset = 10
	}
	else if( helpPosition=='bc' )
	{
		helpXOffset = -1*(helpWidth/2)
		helpYOffset = 10
	}
	setParagraph('helpContent',value)
	document.getElementById('help').style.width=helpWidth;
	showLayerMouse('help',helpXOffset,helpYOffset)
}
function resetHelp()
{
	hideLayerSmooth('help',false)
}

function showLayer( id, pos )
{
	if( document.getElementById(id) )
	{
		if( pos )
			document.getElementById(id).style.position = 'relative'
		document.getElementById(id).style.visibility = 'visible'
	}
}
function rotateLayer( id, pos )
{
	if( document.getElementById(id) )
	{
		if( document.getElementById(id).style.visibility == 'hidden' )
			showLayer(id,pos)
		else
			hideLayer(id,pos)
	}
}

function hideLayer( id, pos )
{
	lay = document.getElementById(id)
	if( lay )
	{
		if( pos )
			lay.style.position = 'absolute'
		lay.style.visibility = 'hidden'
	}
}


var newwin;

function launchwin(winurl,winname,winfeatures)
{
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	newwin = window.open(winurl,winname,'location=no,scrollbars=yes,width=515,height=305,top=100,left=100');
	
	if(javascript_version > 1.0)
	{
		//delay a bit here because IE4 encounters errors
		//when trying to focus a recently opened window
 		setTimeout('newwin.focus();',250);
	}
}

function MM_reloadPage(init) 
{
  	//reloads the window if Nav4 resized 
	if (init==true) with (navigator) 
	{
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
		{ 
			document.MM_pgW=innerWidth; 
			document.MM_pgH=innerHeight; 
			onresize=MM_reloadPage; 
		}
	} 
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) 
		location.reload(); 
} 

MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
  	if ((obj=MM_findObj(args[i]))!=null) 
	{ 
		v=args[i+2];
		if (obj.style) 
		{ 
			obj=obj.style; 
			v=(v=='show')?'visible':(v='hide')?'hidden':v; 
		}
		obj.visibility=v; 
	}
  }
}


function P7_hideDiv(evt) { //v1.3 by PVII
 var b,relT,mT=false; 
 if(document.layers)	//Netscape Communicator 
 {
	 b=evt.target;
	 if(b.p7aHide)
	 {
	 	b.visibility="hidden";
	 }
	 else
	 {
	 	routeEvent(evt);
	 }
 }
 else if(document.all&&!window.opera)	//MSIE
 {
	 b=event.srcElement;
	 while(b!=null)
	 {
	 	if(b.tagName=="DIV" && b.p7ahD)
	 	{
	 		mT=true;
	 		break;
	 	}
	 	b=b.parentElement;
	 }
	 if(!b.contains(event.toElement))
	 {
	 	b.style.visibility="hidden";
	 }
 }
 else if(document.getElementById)	//Mozilla, Netscape 6 y7
 {
	 b=evt.currentTarget;
	 relT=evt.relatedTarget;
	 original = relT
	 var mt = false
	 while(relT!=null)
	 {
		 if(b==relT)
		 {
			 mT=true;
		 	break;
		 }
  		relT=relT.parentNode;
 	}
		//alert(original)
 	if(!mT && original!=null)
 	{
		b.style.visibility="hidden";
 	}
 }
}


function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function P7_Snap() { //v2.62 by PVII
  var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,args=P7_Snap.arguments;a=parseInt(a);
  for (k=0; k<(args.length-3); k+=4)
   if ((g=MM_findObj(args[k]))!=null) {
    el=eval(MM_findObj(args[k+1]));
    a=parseInt(args[k+2]);b=parseInt(args[k+3]);
    x=0;y=0;ox=0;oy=0;p="";tx=1;da="document.all['"+args[k]+"']";
    if(document.getElementById) {
     d="document.getElementsByName('"+args[k]+"')[0]";
     if(!eval(d)) {d="document.getElementById('"+args[k]+"')";if(!eval(d)) {d=da;}}
    }else if(document.all) {d=da;} 
    if (document.all || document.getElementById) {
     while (tx==1) {p+=".offsetParent";
      if(eval(d+p)) {x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
      }else{tx=0;}}
     ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);var tw=x+ox+y+oy;
     if(tw==0 || (navigator.appVersion.indexOf("MSIE 4")>-1 && navigator.appVersion.indexOf("Mac")>-1)) {
      ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);
      }else{var w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;
      a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
      x=document.body.scrollLeft + event.clientX + bx;
      y=document.body.scrollTop + event.clientY;}}
   }else if (document.layers) {x=g.x;y=g.y;var q0=document.layers,dd="";
    for(var s=0;s<q0.length;s++) {dd='document.'+q0[s].name;
     if(eval(dd+'.document.'+args[k])) {x+=eval(dd+'.left');y+=eval(dd+'.top');break;}}}
   if(el) {e=(document.layers)?el:el.style;
   var xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
   if(navigator.appName=="Netscape" && parseInt(navigator.appVersion)>4){xx+="px";yy+="px";}
   if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
    xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);
    xx+="px";yy+="px";}e.left=xx;e.top=yy;}}
}

function P7_autoHide() { //v1.3 by PVII
	var i,g,args=P7_autoHide.arguments;
	for(i=0;i<args.length;i++)
	{
		if((g=MM_findObj(args[i]))!=null)
		{
			g.p7aHide=true;
			if(document.layers)
			{
				g.captureEvents(Event.MOUSEOUT);
			}
			g.onmouseout=P7_hideDiv;
			g.p7ahD=true;
		}
	}
}

function P7_autoLayers() { //v1.4 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<args.length;k++){
 if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";f=false;
 for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
 if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}



function changeStyle(id, newClass) {
	var identity=document.getElementById(id);
	identity.className=newClass;
}

function artContent(pId, pVis){
	try{ 
		if (pVis=='1'){
			document.getElementById(pId).style.position = 'relative';
			document.getElementById(pId).style.visibility = 'visible';
		}
		else{
			document.getElementById(pId).style.position = 'absolute';
			document.getElementById(pId).style.visibility = 'hidden';
		}
		
		var artid_substring = "";
		if (pId!=null)
			artid_substring = pId.substring(4);
			window.location.hash = artid_substring;
	}
	catch (e){
		alert(e);
	}
}

/*Para que no aparesca opcion de activar swf en IE*/
/**********************************************************************
 * Software:	JS Embedded Content
 * Versión:	1.1 Final (Oct 13, 2006)
 * Autor:	Raspu (donraspu arroba gmail punto com)
 * Copyleft 2006, Raspu - Algunos derechos reservados. 
 *
 * Puedes consultar una copia de la licencia en http://www.gnu.org/copyleft/gpl.html
 *
 * DESCRIPCIÓN:
 * ------------
 * "JS Embedded Content" es una pequeña aplicación desarrollada
 * mediante Javascript no intrusivo ni obstructivo, que permite la
 * activación automática de todos los elementos incrustados en un
 * documento HTML mediante las etiquetas OBJECT, EMBED y/o APPLET.
 *
 * NAVEGADORES COMPATIBLES:
 * ------------------------
 * - Ópera 9 final o superior (para versiones anteriores no es requerido)
 * - Internet Explorer 5 o superior (Windows, en MAC no he probado)
 * El resto de navegadores no es compatible debido al uso outerHTML,
 * pero como por el momento no lo requieren no es mayor problema.
 *
 * NOTA: el uso del atributo DEFER es imprescindible para poder emular en 
 * I. Explorer el evento DOMContentLoaded.
 **********************************************************************/
var embeddedContent = 
{

	isMSIE : (document.all && !window.opera) ? true : false,
	
	
	/**
	 * Reinserta en el documento HTML los elementos que han sido incrustados mediante
	 * las etiquetas OBJECT, EMBED y/o APPLET, redefiniendo su propiedad outerHTML
	 */
	reinsertContent : function()
	{	
	var totalNodes = new Array(3);
		totalNodes['OBJECT'] = document.getElementsByTagName('OBJECT').length;
		totalNodes['EMBED'] = document.getElementsByTagName('EMBED').length;
		totalNodes['APPLET'] = document.getElementsByTagName('APPLET').length;
		for(var tagName in totalNodes)
		{
			var counter = totalNodes[tagName] - 1;
			for(var node; node = document.getElementsByTagName(tagName)[counter]; counter--)
			{
				sourceCode = embeddedContent.getSourceCode(node);
				if(sourceCode)
				{
					node.outerHTML = sourceCode;
				}
			}
		}
		embeddedContent.isMSIE = null;
	},
	
	
	/**
	 * Obtiene el código HTML completo de un determinado nodo.
	 * @param	node (object) - El nodo analizado
	 * @return	sourceCode (string) - El código HTML obtenido
	 */
	getSourceCode : function(node)
	{
		var sourceCode = node.outerHTML;
		switch(node.nodeName)
		{
			case 'EMBED':
				return sourceCode;
			break;
			case 'OBJECT':
			case 'APPLET':
				var openTag = sourceCode.substr(0, sourceCode.indexOf('>') + 1).toLowerCase();
				var closeTag = sourceCode.substr(sourceCode.length - 9).toLowerCase();
				if(closeTag != '</object>' && closeTag != '</applet>')
				{
					/* Si el nodo está mal formado (etiquetas de apertura y cierre) se debe 
					anular el script ya que podría devolver un resultado incorrecto */
					return null;
				}
				if(embeddedContent.isMSIE)
				{
					/* Para I. Explorer se debe obtener aparte el código HTML de los nodos hijos,
					ya que la propiedad outerHTML en ocasiones devolverá un resultado incompleto */
					var innerCode = embeddedContent.getInnerCode(node);
					sourceCode = openTag + innerCode + closeTag;
				}
				return sourceCode;
			break;
		}
	},
	
	
	/**
	 * Obtiene el código HTML de los nodos hijos de un determinado nodo. No se debe utilizar directamente
	 * la propiedad innerHTML ya que en ciertos casos I. Explorer devolverá un resultado incompleto.
	 * @param	node (object) - El nodo padre que será analizado
	 * @return	innerCode (string) - El código HTML obtenido
	 */
	getInnerCode : function(node)
	{
		var innerCode = '';
		var totalChilds = node.childNodes.length - 1;
		for(var counter = totalChilds, child; child = node.childNodes[counter]; counter--)
		{
			innerCode += child.outerHTML;
		}
		return innerCode;
	}
	
}


/**
 * Activación:
 * -----------
 * Detectamos el soporte de attachEvent() como filtro para I. Explorer y Ópera.
 * Para ejecutar el script sólo necesitamos que el DOM (Document Object Model); para
 * ello en Ópera recurrimos al evento DOMContentLoaded, mientras que en I. Explorer
 * emulamos dicho evento apoyándonos en el atributo DEFER de la etiqueta SCRIPT
 * con la que estamos cargando este archivo.
 */
if(document.attachEvent)
{
	if(window.opera)
	{
		document.attachEvent("DOMContentLoaded", embeddedContent.reinsertContent);
	}
	else
	{
		embeddedContent.reinsertContent();
	}
}
