function decodificarTexto( sTexto )
{
	sTexto = sTexto.replace('á','\u00e1');
	sTexto = sTexto.replace('é','\u00e9');
	sTexto = sTexto.replace('í','\u00ed');
	sTexto = sTexto.replace('ó','\u00f3');
	sTexto = sTexto.replace('ú','\u00fa');

	sTexto = sTexto.replace('Á','\u00c1');
	sTexto = sTexto.replace('É','\u00c9');
	sTexto = sTexto.replace('Í','\u00cd');
	sTexto = sTexto.replace('Ó','\u00d3');
	sTexto = sTexto.replace('Ú','\u00da');

	sTexto = sTexto.replace('ñ','\u00f1');
	sTexto = sTexto.replace('Ñ','\u00d1');

	return sTexto;
}


function cerrarSesion( sPag )
{
	if( confirm( decodificarTexto( "Desea cerrar la Sesi\u00f3n?") ) )
	{
		document.location.href=sPag+".php?accion=cerrar_sesion";
	}
}

function getElementsByClassName( obj, clase )
{	
	var retnode = [];
	
	var myclass = new RegExp("\\b"+clase+"\\b");
	
	var elem = obj.getElementsByTagName("*");
	
	for (var i = 0; i < elem.length; i++) 
	{
		var classes = elem[i].className;
		
		if (myclass.test(classes)) retnode.push(elem[i]);
	}

	return retnode;
}


function centrarDiv( selector )
{	
	var anTam = tamVentana();
	
	var nAnchura = 1*getPropNum( "#"+selector, "width" );
	var nAltura = 1*getPropNum( "#"+selector, "height" );	
	
	var nX = anTam[ 0 ]/2 - nAnchura/2;	
	var nY = anTam[ 1 ]/2 - nAltura/2;
	
	document.getElementById( selector ).style.left = nX+"px";
	document.getElementById( selector ).style.top = nY+"px";
}


function inicializarDivParaCSS( objDiv, sSelector )
{	
	for ( nCSS=0; nCSS < clasesCSS.length; nCSS++)
	{
		if ( clasesCSS[ nCSS ].selectorText.toLowerCase() == sSelector.toLowerCase() )
		{
			objDiv.style.left   = clasesCSS[ nCSS ].style.left;
			objDiv.style.top 	= clasesCSS[ nCSS ].style.top;
			objDiv.style.width  = clasesCSS[ nCSS ].style.width;
			objDiv.style.height = clasesCSS[ nCSS ].style.height;
			break;
		}
	}
}


function isRatonSobreDiv( objDiv )
{	
	var nX = 0;
	var nY = 0;
	var nW = 1*( objDiv.style.width.substring( 0, objDiv.style.width.indexOf( "px" ) ) );
	var nH = 1*( objDiv.style.height.substring( 0, objDiv.style.height.indexOf( "px" ) ) );
	
	while( objDiv.id != "" )
	{
		nX += 1*( objDiv.style.left.substring( 0, objDiv.style.left.indexOf( "px" ) ) );		
		nY += 1*( objDiv.style.top.substring( 0, objDiv.style.top.indexOf( "px" ) ) );	
	
		objDiv = objDiv.parentNode;		
	}
		
	if( nRatonX >= nX && nRatonX <= nX + nW && nRatonY >= nY && nRatonY <= nY + nH ) return true;
	
	return false;
}


function posRaton( e )
{
	if ( bExplorer ) 
	{ 
		nRatonX = event.clientX + document.body.scrollLeft;
		nRatonY = event.clientY + document.body.scrollTop;
	}
	else 
	{ 
		nRatonX = e.pageX;
		nRatonY = e.pageY;
	}
	
	if ( nRatonX < 0)  nRatonX = 0;
	if ( nRatonY < 0)  nRatonY = 0;		
	
}

function nuevoEvento( elemento, evento, funcion )
{
      if ( elemento.addEventListener ) 
	  {
           elemento.addEventListener( evento, funcion, false );
      } 
	  else 
	  {
           elemento.attachEvent( "on"+evento, funcion );
      }
}


function tamVentana() 
{  
	var Tamanyo = [0, 0];  
	
	//Mozilla
	if (typeof window.innerWidth != 'undefined') 
	{  
	 	Tamanyo = [ window.innerWidth, window.innerHeight ];  
	}  
	//Explorer
	else if( typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !=  'undefined' && document.documentElement.clientWidth != 0 )
	{  
		Tamanyo = [ document.documentElement.clientWidth, document.documentElement.clientHeight ];  
	}  
	else   
	{
		Tamanyo = [  document.getElementsByTagName('body')[0].clientWidth, document.getElementsByTagName('body')[0].clientHeight ];  
	}  
	
	return Tamanyo;  
}


function leerCSS()
{
	//if (document.all) clasesCSS = document.styleSheets[0].rules;
	//else clasesCSS = document.styleSheets[0].cssRules;	
	
	clasesCSS = new Array();
	
	var misReglas = new Array();
	
	if (document.all)
	{		
		for( rul=1; rul < document.styleSheets.length; rul++ ) misReglas[ misReglas.length ] = document.styleSheets[ rul ].rules;
	}
	else
	{	
		for( rul=1; rul < document.styleSheets.length; rul++ ) misReglas[ misReglas.length ] = document.styleSheets[ rul ].cssRules;		
	}
	
	for( reg=0; reg < misReglas.length; reg++ )
	{
		for( rul=0; rul < misReglas[ reg ].length; rul++ )	clasesCSS[ clasesCSS.length ] = misReglas[ reg ][ rul ];
	}		
}


function getClaseCSS( selector ) 
{
	for ( nCSS=1; nCSS < clasesCSS.length; nCSS++)
	{alert( nCSS+";"+clasesCSS[ nCSS ].selectorText );
		if ( clasesCSS[ nCSS ].selectorText.toLowerCase() == selector.toLowerCase() ) return clasesCSS[ nCSS ];
	}
}

function getProp( selector, propiedad ) 
{
	for ( nCSS=1; nCSS < clasesCSS.length; nCSS++)
	{
		if ( clasesCSS[ nCSS ].selectorText.toLowerCase() == selector.toLowerCase() ) return clasesCSS[ nCSS ].style[ propiedad ];
	}
}


function setProp( selector, propiedad, valor ) 
{
	for ( nCSS=1; nCSS < clasesCSS.length; nCSS++)
	{
		if ( clasesCSS[ nCSS ].selectorText.toLowerCase() == selector.toLowerCase() ) return clasesCSS[ nCSS ].style[ propiedad ] = valor;
	}
}

function getPropNum( selector, propiedad )
{
	for ( nCSS=1; nCSS < clasesCSS.length; nCSS++)
	{
		if ( clasesCSS[ nCSS ].selectorText.toLowerCase() == selector.toLowerCase() ) 
		{
			return 1*( clasesCSS[ nCSS ].style[ propiedad ].substring( 0, clasesCSS[ nCSS ].style[ propiedad ].indexOf( "px" ) ) );
		}
	}
}


function getPropIdNum( id, propiedad )
{
	return 1*( document.getElementById( id ).style[ propiedad ].substring( 0, document.getElementById( id ).style[ propiedad ].indexOf( "px" ) ) );
}


function rotar(obj,angulo)
{
    if (angulo >= 0) 
	{
        var rotation = Math.PI * angulo / 180;
    } 
	else 
	{
        var rotation = Math.PI * (360+angulo) / 180;
    }
	
    var costheta = Math.cos(rotation);
    var sintheta = Math.sin(rotation);
	
    if (document.createElement("canvas").getContext) 
	{
    	/* ---- canvas ---- */ 
        var c=document.createElement('canvas');
		
        c.width = Math.abs(costheta*obj.width) + Math.abs(sintheta*obj.height);
        c.style.width = c.width+'px';
        c.height = Math.abs(costheta*obj.height) + Math.abs(sintheta*obj.width);
        c.style.height=c.height+'px';
        c.id=obj.id;
        c.style.position='absolute';
		
        var ctx=c.getContext('2d');
		
        ctx.save();
		
        if (rotation <= Math.PI/2) 
		{
            ctx.translate(sintheta*obj.height,0);
        } 
		else if (rotation <= Math.PI) 
		{
            ctx.translate(c.width,-costheta*obj.height);
        } 
		else if (rotation <= 1.5*Math.PI) 
		{
            ctx.translate(-costheta*obj.width,c.height);
        } 
		else 
		{
            ctx.translate(0,-sintheta*obj.width);
        }
        ctx.rotate(rotation);
        ctx.drawImage(obj, 0, 0, obj.width, obj.height);
        obj.parentNode.replaceChild(c,obj);
        ctx.restore();
    }
	else
	{
    /* ---- DXImageTransform ---- */
        obj.style.position='absolute';
        obj.style.filter="progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";
        obj.filters.item(0).M11 = costheta;
        obj.filters.item(0).M12 = -sintheta;
        obj.filters.item(0).M21 = sintheta;
        obj.filters.item(0).M22 = costheta;
    }
}


function getNavegador()
{	
	//var a = new Array( navigator.appCodeName, navigator.appName, navigator.appVersion, navigator.cookieEnabled, navigator.platform, navigator.userAgent );		
	
	var sNavegador = "explorer";
	
	if( navigator.appName.toLowerCase().indexOf( "explorer" ) != -1 ) 
	{		
		if( navigator.appVersion.indexOf("MSIE 6") != -1 || navigator.appVersion.indexOf("MSIE 7") != -1)
		{			
			alert( "Esta web ha sido desarrollada para la version 8 o Superior de\nInternet Explorer. Puede descargar la versin correcta aqui..." );
			
			window.location.href = "http://www.microsoft.com/spain/windows/internet-explorer/";
		}
	}
	
	else if( navigator.userAgent.toLowerCase().indexOf( "firefox" ) != -1 )
	{
		sNavegador = "firefox";
	
		var asPartes = navigator.userAgent.toLowerCase().split( "firefox/" );
		
		var nPosSpace = asPartes[ 1 ].indexOf( " " );
		
		var sVersion = asPartes[ 1 ].substr( 0, nPosSpace );
		
		var asPartes = sVersion.split( "." );
		
		if( parseInt( asPartes[ 0 ] ) >= 3 && parseInt( asPartes[ 1 ] ) >= 6 && parseInt( asPartes[ 2 ] ) >= 8 );
		else
		{
			//alert( "Esta web ha sido desarrollada para una versin superior de FireFox\nPuede descargar la versin correcta aqu..." );
			
			//window.location.href = "http://www.mozilla-europe.org/es/firefox/";
		}	
	}
	else if( navigator.userAgent.toLowerCase().indexOf( "chrome" ) != -1 )
	{
		sNavegador = "chrome";
		
		var asPartes = navigator.userAgent.toLowerCase().split( "chrome/" );
		
		var nPosSpace = asPartes[ 1 ].indexOf( " " );
		
		var sVersion = asPartes[ 1 ].substr( 0, nPosSpace );
		
		var asPartes = sVersion.split( "." );
		
		if( parseInt( asPartes[ 0 ] ) >= 6 && parseInt( asPartes[ 1 ] ) >= 0 && parseInt( asPartes[ 2 ] ) >= 472 );
		else
		{
			//alert( "Esta web ha sido desarrollada para una versin superior de Google Chrome\nPuede descargar la versin correcta aqu..." );
			
			//window.location.href = "http://www.google.es/chrome/?installdataindex=nosearch&hl=es&brand=CHMA&utm_campaign=es&utm_source=es-ha-emea-es-bk&utm_medium=ha";
		}
	}
	else if( navigator.userAgent.toLowerCase().indexOf( "safari" ) != -1 ) 
	{
		sNavegador = "safari";	
		
		var asPartes = navigator.userAgent.toLowerCase().split( "version/" );
		
		var nPosSpace = asPartes[ 1 ].indexOf( " " );
		
		var sVersion = asPartes[ 1 ].substr( 0, nPosSpace );
		
		var asPartes = sVersion.split( "." );
		
		if( parseInt( asPartes[ 0 ] ) >= 5 && parseInt( asPartes[ 1 ] ) >= 0 && parseInt( asPartes[ 2 ] ) >= 1 );
		else
		{
			//alert( "Esta web ha sido desarrollada para una versin superior de Safari\nPuede descargar la versin correcta aqu..." );
			
			//window.location.href = "http://www.apple.com/es/safari/download/";
		}			
	}
	else if( navigator.userAgent.toLowerCase().indexOf( "opera" ) != -1 ) 
	{
		sNavegador = "opera";

		var asPartes = navigator.userAgent.toLowerCase().split( "version/" );
				
		var sVersion = asPartes[ 1 ].substr( 0 );
		
		var asPartes = sVersion.split( "." );
		
		if( parseInt( asPartes[ 0 ] ) >= 10 && parseInt( asPartes[ 1 ] ) >= 62 );
		else
		{
			//alert( "Esta web ha sido desarrollada para una versin superior de Opera\nPuede descargar la versin correcta aqu..." );
			
			//window.location.href = "http://www.opera.com/download/";
		}
	}
	else if( navigator.appName.toLowerCase().indexOf( "netscape" ) != -1 ) sNavegador = "netscape";
	
	//alert( navigator.appCodeName+","+navigator.appName+","+navigator.appVersion+","+navigator.cookieEnabled+","+navigator.platform+","+navigator.userAgent );
	
	return sNavegador;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
function getNavegador3()
{
	var a = new Array();
	
	// Internet Explorer	
	a[ 0 ] = document.all != null;  //ie4 and above	
	a[ 1 ] = document.getElementById && document.all; //ie5
	a[ 2 ] = document.getElementById && document.all&&(navigator.appVersion.indexOf("MSIE 6.")>=0); //ie6
		
	// Netscape	
	a[ 3 ] = document.layers != null; //ns4
	a[ 4 ] = document.getElementById && !document.all; //ns6
	a[ 5 ]  = a[ 3 ] || a[ 4 ]; //ns
	
	// Firefox	
	a[ 6 ]  = !document.layers && !document.all; //ff
	
	// Opera	
	a[ 7 ]  = navigator.userAgent.indexOf("opera")>0; //op	
	a[ 8 ] = a[ 7 ] && operaVersion() <= 7;	//op7
	a[ 9 ] = a[ 7 ] && operaVersion()>= 8; //op8
	
	// Detects the Opera version
	alert( a );
}




function pausa( sFuncion, nMiliseg )
{	
	window.clearInterval( intervalo );
	
	intervalo = window.setInterval( sFuncion, nMiliseg );
}



*/
