// Reloj Internacional
function negativo(h){

	if(h<=0){
		h=h+24;
	}
	
	if(h==24)
		h='00';
	
	return h;	
	
}

function Clock(hora){
	momentoActual = new Date();
	minuto = momentoActual.getMinutes();	
	
	hora=parseInt(hora);
	
	str_minuto = new String (minuto);
	if (str_minuto.length == 1)
	   minuto = "0" + minuto;
	   
	str_hora = new String (hora);
	if (str_hora.length == 1)
	   hora = "0" + hora;
   
	
	hora_es = hora + ":" + minuto + "h";
	hora_fr = hora + ":" + minuto + "h";
	hora_pt = negativo(hora-1) + ":" + minuto + "h";
	hora_ar = negativo(hora-5) + ":" + minuto + "h";
	hora_ch = negativo(hora-6) + ":" + minuto + "h";
	hora_pe = negativo(hora-7) + ":" + minuto + "h";
	hora_mx = negativo(hora-7) + ":" + minuto + "h";
	hora_us = negativo(hora-6) + ":" + minuto + "h";


	$('clock_es').innerHTML = hora_es;
	$('clock_fr').innerHTML = hora_fr;
	$('clock_pt').innerHTML = hora_pt;
	$('clock_ar').innerHTML = hora_ar;
	$('clock_ch').innerHTML = hora_ch;
	$('clock_pe').innerHTML = hora_pe;
	$('clock_mx').innerHTML = hora_mx;
	$('clock_us').innerHTML = hora_us;

	setTimeout('Clock('+hora+')',1000);
} 



// href javascript
function go_to(target, href)
{
	try {
		target.location = href;
	} catch (e) {
	}
}
// Mis Cosas
/////////////////////////////////////////// FUNCIÓN PARA LANZAR MENSAJE Y CONFIRMAR

function confirma(msg) {
  
  if(confirm(msg)){
  
  	return true;
  
  }else{
  
 	 return false;
  
  }
  
}

/////////////////////////////////////////// FUNCIÓN PARA EMPOTRAR CONTENIDOS SOBRE objID

function makerequest(url, objID){	
	
	var pageRequest = false;
	if (window.XMLHttpRequest) {
		pageRequest = new XMLHttpRequest();
	}
	else if (window.ActiveXObject){ 
		//Comprobamos si estamos navegando con IE y version +5
		try {
			pageRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) {
			//Si no utilizar el tradicional objeto ActiveX
			try{
				pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
	}
	else return false;
	
	var obj =document.getElementById(objID);
	
	pageRequest.open('GET',url);
	
	pageRequest.onreadystatechange=function() {	
		if (pageRequest.readyState == 4 && pageRequest.status==200) {
			obj.innerHTML= pageRequest.responseText;
		}
			
	}
		
	pageRequest.send(null)	;
	
}

/////////////////////////////////////////// MENÚ DE SALTO Dw
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}			


function quickupdate(url, form)
{
// Pasamos la url del archivo php que ejecuta sobre db y el nombre de form
	var param="";
	
	if(confirm("Desea actualizar?")){
	
		// Extraemos todos los elementos de form y los pasamos por GET a Ajax
		for (i=0; i<form.elements.length; i++){
	
			param+= form.elements[i].name+ '=' + form.elements[i].value;
	
			if(i!=(form.elements.length-1)){
				// Si NO es el último elemento de la cadena concatenamos con &
				param +='&';
			}
		}
		
		// alert(param);
		  
			  var ajaxRequest = new Ajax.Request(
								url,
								{
										method: 'get',
										parameters: param,
										asynchronous: true,
										onComplete: respuesta
										
								});
		  	
	}
}

function respuesta(resp){

	document.getElementById('respuesta').innerHTML=resp.responseText;
}

function printer(id) {
	var ventana = window.open("", "", "");
	var contenido = "<html><head><link href='../../css/comun.css' rel='stylesheet' type='text/css'><link href='../../css/contenedor.css' rel='stylesheet' type='text/css'></head><body onload='window.print();window.close();'>";
	contenido = contenido + document.getElementById(id).innerHTML + "</body></html>";
	ventana.document.open();
	ventana.document.write(contenido);
	ventana.document.close();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function insertarArticulo()
{

	
$('articulo').request({

onComplete: function(cb)
{
var rep=cb.responseText;

$('respuesta').update(rep); 
}
})


}

//////////////////////////////// MOSTAR Y OCULTAR UNA CAPA
var show = false;

function opentree(tree, idObj)
{
	var cls = '';
	if (document.getElementById) {
		var el = document.getElementById (tree);
		var obj = document.getElementById(idObj);
		
		if (obj && obj.className) {
			obj.className = (obj.className == 'mostrar') ? 'ocultar' : 'mostrar';			
		}
		
	}
	return false;
}

function setActiveNode(id)
{
	try {
		if (activeItem == id) {
			return false;
		}
		if (activeItem != '' ) {
			var cur = document.getElementById(activeItem);
			cur.className = 'node';
		}
		activeItem = id;
		var el = document.getElementById(id);
		el.className='nodeActive';
	} catch(e) {}

	return false;
}

function openScreen(id, url)
{
	setActiveNode(id);
	try {
		lon(top.workFrame);
	} catch (e) {
	}
	return go_to(url);
}

function mover(o)
{
	o.className = 'navTitleOver';
}

function mout(o)
{
	o.className = 'navTitle';
}