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


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GOOGLE MAPS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 
function cargarMapa( nLat, nLong, nLatMarcador, nLongMarcador, sMarcador) 
{
	//javascript:void(prompt('',gApplication.getMap().getCenter())); 
   
	var latlng = new google.maps.LatLng( nLat, nLong);
	
	//Mapa
	var myOptions = { zoom: 15, center: latlng, mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: true, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, mapTypeId: google.maps.MapTypeId.ROADMAP }

	var map = new google.maps.Map(document.getElementById("iMapa"), myOptions);
	
   //Marcador
   var companyPos = new google.maps.LatLng(nLatMarcador, nLongMarcador);
  
   var companyMarker = new google.maps.Marker( {position: companyPos,map: map,title:sMarcador});
      
   //Cuadro Info   
   //var contentString = '';
	//	var infowindow = new google.maps.InfoWindow({  content: contentString  });
	//infowindow.open(map,companyMarker);
    //google.maps.event.addListener(companyMarker, 'click', function() { infowindow.open(map,companyMarker); });
}




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EVENTOS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function wheel(event)
{
	var delta = 0;
	
	/* For IE. */
	if (!event) 
	{
		event = window.event;
	}
	if (event.wheelDelta) 
	{ 
		/* IE/Opera. */
		delta = event.wheelDelta/120;
		
		/** In Opera 9, delta differs in sign as compared to IE. */
		if (window.opera) delta = -delta;
	}
	else if (event.detail) 
	{ 
		/** Mozilla case. In Mozilla, sign of delta is different than in IE. Also, delta is multiple of 3.*/
		  delta = -event.detail/3;
	}
	/** If delta is nonzero, handle it. Basically, delta is now positive if wheel was scrolled up, and negative, if wheel was scrolled down.*/
	if (delta) handle(delta);
	
	/** Prevent default actions caused by mouse wheel. That might be ugly, but we handle scrolls somehow anyway, so don't bother here..*/
	if (event.preventDefault) event.preventDefault();
		
	event.returnValue = false;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ARRAYS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function ordenar(o)
{
    var v=new Array();
	
    for (var i=0; i<o.options.length; i++) 
	{
        v[v.length]=new Array(o[i].text,o[i].value);
    }
	
    v.sort(compara);
	
    for (var i=0; i<o.options.length; i++) 
	{
        o[i]=new Option(v[i][0],v[i][1],false,false);
    }
}

function compara(a, b) 
{
    return (a[0]<b[0]?"-1":"1");
}


function getPropiedadTransform() 
{
    var sPropiedad = "";
	
	if ( sNavegador.indexOf( "explorer" ) != -1 ) sPropiedad = 'msTransform';
	else if( sNavegador == "safari" ) sPropiedad = 'WebkitTransform';
	else if( sNavegador == "ipad" ) sPropiedad = 'WebkitTransform';
	else if( sNavegador == "iphone" ) sPropiedad = 'WebkitTransform';
	else if( sNavegador == "firefox" ) sPropiedad = 'MozTransform';
	else if( sNavegador == "opera" ) sPropiedad = 'OTransform';
	else if( sNavegador == "chrome" ) sPropiedad = 'khtmlTransform';
	else sPropiedad = 'transform';
		
    return sPropiedad;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DIVS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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 ( sNavegador.indexOf( "explorer" ) != -1 )
	{ 
		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 ( sNavegador.indexOf( "explorer" ) != -1 )
	{		
		for( rul=0; rul < document.styleSheets.length; rul++ ) misReglas[ misReglas.length ] = document.styleSheets[ rul ].rules; 
	}
	else
	{	
		for( rul=0; 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=0; nCSS < clasesCSS.length; nCSS++)
	{
		if ( clasesCSS[ nCSS ].selectorText.toLowerCase() == selector.toLowerCase() ) return clasesCSS[ nCSS ];
	}
}

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


function setProp( selector, propiedad, valor ) 
{
	for ( nCSS=2; 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 = "";
	bExplorer = false;
	
	if( navigator.userAgent.toLowerCase().indexOf( "ipad" ) != -1 )
	{
		sNavegador = "ipad";
	}
	
	else if( navigator.userAgent.toLowerCase().indexOf( "iphone" ) != -1 )
	{
		sNavegador = "iphone";
	}
	
	else if( navigator.appName.toLowerCase().indexOf( "explorer" ) != -1 ) 
	{	
		sNavegador = "explorer";
		bExplorer = true;
		
		if( navigator.appVersion.indexOf("MSIE 6") != -1 || navigator.appVersion.indexOf("MSIE 7") != -1)
		{			
			sNavegador = "explorer67";
			
			//alert( "Esta web ha sido desarrollada para una versión superior de Internet Explorer\nPuede descargar la versión correcta aquí..." );
			
			//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 ] ) >= 10 );
		else
		{
			//alert( "Esta web ha sido desarrollada para una versión superior de FireFox\nPuede descargar la versión 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 versión superior de Google Chrome\nPuede descargar la versión 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 versión superior de Safari\nPuede descargar la versión correcta aquí..." );
			//
			//window.location.href = "http://www.apple.com/es/safari/download/";
		}			
	}
	else if( navigator.userAgent.toLowerCase().indexOf( "opera" ) != -1 ) 
	{
		sNavegador = "opera";

		if( navigator.userAgent.toLowerCase().indexOf( "version/" ) >= 0 )
		{
			var asPartes = navigator.userAgent.toLowerCase().split( "version/" );
				//alert(navigator.userAgent.toLowerCase());	
			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 versión superior de Opera\nPuede descargar la versión 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 );
}



*/
