//
function RSS(ID){
		opcion = document.getElementById(ID).options[document.getElementById(ID).selectedIndex].value;
		//location.href="noticias_rss.php?ch="+ID+"&urlx="+opcion;
		location.href = "index.php?o=noticias1&ch="+ID+"&urlx="+opcion;
		document.getElementById(ID).options[0].selected = true;
}


function submenu(ID){
	if(document.getElementById(ID).style.display == "none"){
		document.getElementById(ID).style.display = "block";
	}else{
		document.getElementById(ID).style.display = "none";
	}
}
//CROSS BROWSER
//POP UP
function PopUp(url,nombreVentana,anchoVentana,altoVentana,scrollBars,left,top) {
	window.open(url,nombreVentana,"width="+anchoVentana+",height="+altoVentana+",resizable=no,status=no,scrollbars="+scrollBars+",left="+left+",top="+top);
}
function PopUp2(url,nombreVentana,anchoVentana,altoVentana,scrollBars,left,top) {
	window.open(url,nombreVentana);
}
//************************************************
//			      PROPIEDADES
//************************************************
//REFERENCIAR OBJETOS
function cb_ref_obj(id) {
    if(document.getElementById && document.getElementById(id)) {
	// W3C DOM
		return document.getElementById(id);
    } else if (document.all && document.all(id)) {
	// MSIE 4 DOM
		return document.all(id);
    } else if (document.layers && document.layers[id]) {
	// NN 4 DOM
		return document.layers[id];
    } else {
		return false;
    }
}
//PAGE OFFSET Y
function cb_page_offsetY(){
	if (self.pageYOffset) {// all except Explorer
		var y = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {// Explorer 6 Strict
		var y = document.documentElement.scrollTop;
	} else if (document.all) {// all other Explorers / Opera
		var y = document.body.scrollTop;
	} else if (document.getElementById) {// NS
		var y = self.pageYOffset;
	}
	return y;
}
//PAGE OFFSET X
function cb_page_offsetX(){
	if (self.pageXOffset) {// all except Explorer
		var x = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft) {// Explorer 6 Strict
		var x = document.documentElement.scrollLeft;
	} else if (document.all) {// all other Explorers / Opera
		var x = document.body.scrollLeft;
	} else if (document.getElementById) {// NS
		var x = self.pageXOffset;
	}
	return x;
}
//ANCHO DE VENTANA DISPONIBLE
function cb_win_width() {
	if (self.innerWidth) {// all except Explorer
		var x = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {// Explorer 6 Strict Mode
		var x = document.documentElement.clientWidth;
	} else if (document.all) {// other Explorers
		var x = document.body.clientWidth;
	}
	return x;
}
//ALTO DE VENTANA DISPONIBLE
function cb_win_height() {
	if (self.innerHeight) {// all except Explorer
		var y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {// Explorer 6 Strict Mode
		var y = document.documentElement.clientHeight;
	} else if (document.all) {// other Explorers
		var y = document.body.clientHeight;
	}
	return y;
}
//CB EVENT Type
//RETORNA EL TIPO DE EVENTO
function cb_event_type(e){
	if (!e){
		var e = window.event;
	}
	return e.type;
}
//Si esta funcion esta dentro de otra/s
//debera pasarse el parametro (e)
//POSICION X DEL MOUSE
function cb_mouseX(e,css) {
    if (document.layers) {
		//NS
        var x = e.pageX;
    } else if (document.all) {
        var x = window.event.x;
    } else if (document.getElementById) {
        var x = e.clientX;
    }
	if(css != null && css != undefined) {
		if(css){
			return x + "px";
		}else{
			return x;
		}
	}else{
		return x;
	}
}

//POSICION Y DEL MOUSE
function cb_mouseY(e,css) {
    if (document.layers) {
       var  y = e.pageY;
    } else if (document.all) {
        var y = window.event.y;
    } else if (document.getElementById) { 
        var y = e.clientY;
    }
	if(css != null && css != undefined) {
		if(css){
			return y + "px";
		}else{
			return y;
		}
	}else{
		return y;
	}
}

//************************************************
//			      EVENTOS
//************************************************
//EJECUTAN LAS FUNCIONES PASADAS COMO PARAMETRO
//MOVIMIENTO DEL MOUSE
function cb_onmousemove(funcion){
	if (document.layers) { // Netscape
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = funcion;
	} else if (document.all) { // Internet Explorer
		document.onmousemove = funcion;
	} else if (document.getElementById) { // Netcsape 6
		document.onmousemove = funcion;
	}
}
//UP
function cb_onmouseup(funcion){
	if (document.layers) { // Netscape
		document.captureEvents(Event.MOUSEUP);
		document.onmouseup = funcion;
	} else if (document.all) { // Internet Explorer
		document.onmouseup = funcion;
	} else if (document.getElementById) { // Netcsape 6
		document.onmouseup = funcion;
	}
}
//DOWN
function cb_onmousedown(funcion){
	if (document.layers) { // Netscape
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown = funcion;
	} else if (document.all) { // Internet Explorer
		document.onmousedown = funcion;
	} else if (document.getElementById) { // Netcsape 6
		document.onmousedown = funcion;
	}
}
function cb_onkeyup(funcion){
	if (document.layers) { // Netscape
		document.captureEvents(Event.KEYUP);
		document.onkeyup = funcion;
	} else if (document.all) { // Internet Explorer
		document.onkeyup = funcion;
	} else if (document.getElementById) { // Netcsape 6
		document.onkeyup = funcion;
	}
}
//************************************************
//DEVUELVE TRUE SI SE PRECIONO EL BOTON DERECHO
//NECESITA DE LOS METODOS cb_onmousedown/cb_onmouseup PARA SER EJECUTADA
//NO FUNCIONA CON EL "Opera"
function cb_is_rightclick(e) {
	var is_rightclick = false;
	if (!e){
		if (event.button == 2) {	
			is_rightclick = true;
		}
	}else{
		if  (e.which > 1) {
			is_rightclick = true;
		} 
	}
	return is_rightclick;
}
//*************************************************
/*
LAS FUNCIONES COOKIE FUERON BAJADAS Y MODIFICADAS DE:
http://www.quirksmode.org/js/cookies.html
*/
function crear_cookie(nombre,valor,dias){
	if(dias){
		var date = new Date();
		date.setTime(date.getTime()+(dias*24*60*60*1000));
		var expira = "; expires="+date.toGMTString();
	}else{
		var expira = "";
	}
	document.cookie = nombre+"="+valor+expira;
}

function leer_cookie(nombre){
	var buscar_nombre = nombre + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while(c.charAt(0)==' '){
			c = c.substring(1,c.length);
		}
		if (c.indexOf(buscar_nombre) != -1){
			return c.substring(buscar_nombre.length,c.length);
		}
	}
	return null;
}

function borrar_cookie(nombre){
	crear_cookie(nombre,"",-1);
}
//FORMATEAR DECIMALES
//numero: valor a formatear
//cantidad: cantidad de decimales
function form_dec(numero,cantidad){
	//Se trata de convertir el valor a numero
	num = parseFloat(numero);
	//Si no es un numero retorna falso y finaliza la funcion
	if(isNaN(num)){
		return num;
	}
	switch(cantidad){
		case 1:
			var cant = 10;
			break;
		case 2:
			var cant = 100;
			break;
		case 3:
			var cant = 1000;
			break;
		case 4:
			var cant = 10000;
			break;
		default:
			var cant = 100;
	}
	var n = numero*cant;
	n = Math.round(n);
	n = n/cant;
	return n;
}