function setBgColor(oGenerico, sColor){
	oGenerico.style.backgroundColor = sColor;
}

function nuevaVentana (sPath, sTitulo, sPropiedades){
	window.open(sPath, sTitulo, sPropiedades);
}
function cambiarURL(sURLDestino){
	window.location = sURLDestino;
}

function crearRowsArray (oTabla){
  var rows = new Array();
  var r = 0;
  var r1;
  
  for (r1 = 0; r1 < oTabla.rows.length; r1++, r++)
  	rows[r] = oTabla.rows[r1];
  	
  return rows;
}

function buscarLocalidadProvincia(){
	alert("enviado");
}
function mostrarTodos(sIdTabla, oTD){
	var oTabla = document.getElementById(sIdTabla);
	var aRows = crearRowsArray(oTabla);
	
	var blnOperacion = (oTD.firstChild.data == "Desplegar todos");
	
	for (i = 0; i < aRows.length; i++){
		str = aRows[i].id.toString();
		size = str.length - 1;
		if (str != "" && str.substr(size,1) == 1){
			str = str.substr(0, size);
			mostrarYOcultar(str, blnOperacion);
		}
	}
	
	if (blnOperacion)
		oTD.firstChild.data = "Ocultar todos";
	else
		oTD.firstChild.data = "Desplegar todos";
}
function mostrarYOcultar(sIdSeccion, blnModo){
	if (sIdSeccion.substr(0,4) == "secc")
		blnSeccionPpal = false;
	else
		blnSeccionPpal = true;
		
	if (blnModo){
		hideItem(sIdSeccion + "1");
		showItem(sIdSeccion + "2");
		if (!blnSeccionPpal)
			showItem(sIdSeccion + "3");
	} else {
		hideItem(sIdSeccion + "2");
		if (!blnSeccionPpal)
			hideItem(sIdSeccion + "3");	
		showItem(sIdSeccion + "1");
	}	
}

function resaltar(sItem,style){ 
	sItem.className = style;
}

function mostrarSubItems(subitem) {
document.getElementById(subitem).className='level2 active';
document.getElementById('smenu').style.display = 'block';
}

function mostrarItems(subitem) {
document.getElementById(subitem).className='level1 active';
}

function show (oItem) {
	if(document.getElementById(oItem).style.display == 'none'){
		document.getElementById(oItem).style.visibility = 'visible';
	    document.getElementById(oItem).style.display    = 'block';	/*Usa el display por defecto del browser*/
	}
	else
		{
		document.getElementById(oItem).style.visibility = 'hidden';
	    document.getElementById(oItem).style.display    = 'none';	

		}
}

function showItem (sIdItem) {
	oItem = document.getElementById(sIdItem);
	show(oItem);	
}

function hide (oItem) {
	oItem.style.visibility ='hidden';
	oItem.style.display = 'none';	/*Usa el display por defecto del browser*/
}

function hideItem (sIdItem) {
	oItem = document.getElementById(sIdItem);
	hide(oItem);
}

function obtenerMes(iMes){
	var sMes = "";
	switch(iMes){
		case 1: 
			sMes = "Enero"; 
			break;
		case 2:
			sMes = "Febrero"; 
			break;
		case 3:
			sMes = "Marzo"; 
			break;
		case 4:
			sMes = "Abril"; 
			break;
		case 5:
			sMes = "Mayo"; 
			break;
		case 6:
			sMes = "Junio"; 
			break;
		case 7:
			sMes = "Julio"; 
			break;
		case 8:
			sMes = "Agosto"; 
			break;
		case 9:
			sMes = "Septiembre"; 
			break;
		case 10:
			sMes = "Octubre"; 
			break;
		case 11:
			sMes = "Noviembre"; 
			break;
		case 12:
			sMes = "Diciembre"; 
			break;
	}
	return sMes;
}

function obtenerDia(iDia){
	var sDia = "";
	switch(iDia){
		case 0: 
			sDia = "Domingo";
			break;
		case 1: 
			sDia = "Lunes";
			break;
		case 2: 
			sDia = "Martes";
			break;
		case 3: 
			sDia = "Mi&eacute;rcoles";
			break;
		case 4: 
			sDia = "Jueves";
			break;
		case 5: 
			sDia = "Viernes";
			break;
		case 6: 
			sDia = "S&aacute;bado";
			break;
	}
	return sDia;
		
}

function imprimirFecha(){
	var mydate = new Date();
	var year = mydate.getYear();
	if (year < 1000)
		year+=1900;
	var day = mydate.getDay();
	var month = mydate.getMonth()+1;
	var daym = mydate.getDate();
	var sMes = obtenerMes(month);
	var sDia = obtenerDia(day);
	document.write(sDia + " " + daym + " de " + sMes + " de " + year + "&nbsp;&nbsp;");
}

function checkBrowser(){
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.agent=navigator.userAgent.toLowerCase();
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
	return this;
}

function cm_bwcheck(){
	//In theory we should use object detection, but this script needs work-arounds for almost every browser...
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7//Use dom creation
  this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}


//bw = new checkBrowser();
var bw=new cm_bwcheck()

/*fromLeft = -147;
fromTop  = -85;*/
fromLeft = -147;
fromTop  = -85;

function mostrarDiv(sMensaje, sIdCursor, blnModo){
	if (blnModo)
	{
		document.getElementById("mensaje_div").firstChild.data = sMensaje;
		document.getElementById(sIdCursor).style.visibility = "visible";
		document.getElementById(sIdCursor).style.display = "block";
	}
	else
	{
		document.getElementById(sIdCursor).style.visibility = "hidden";
		document.getElementById(sIdCursor).style.display = "none";
	}
}

function cursorInit(sMensaje, blnModo){
	if (blnModo)
	{
		oCursor = new makeCursorObj('divCursor');
		scrolled = bw.ns4 || bw.ns5?"window.pageYOffset":"document.body.scrollTop";
		if (bw.ns4) 
		   document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = move;
		mostrarDiv(sMensaje, "divCursor", true);
	}
	else
	{
		document.onmousemove = null;
		mostrarDiv(sMensaje, "divCursor", false);
	}
}

function makeCursorObj(obj,nest)
{
	nest=(!nest) ? '':'document.'+nest+'.';
   	this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;
	this.moveIt=b_moveIt; 																	
	return this;
}

function b_moveIt(x,y)
{
	this.x = x; 
	this.y = y; 
	this.css.left = this.x; 
	this.css.top = this.y
}

function move(e)
{
	x = (bw.ns4 || bw.ns5)? e.pageX : event.x;
	y = (bw.ns4 || bw.ns5)? e.pageY : event.y;
	if(bw.ie4 || bw.ie5 || bw.ie55 || bw.ie6)
		y = y + eval(scrolled);
	oCursor.moveIt(x + fromLeft, y + fromTop);
}

function getExtraCSSName() {
    if (navigator.appName=='Microsoft Internet Explorer') {
        var iPos = navigator.appVersion.indexOf('MSIE ');
        var fVersion = parseFloat(navigator.appVersion.substr(iPos+5));
        if (fVersion>=7) {
             return('estilos_ie7.css');
        } else {
            return('estilos_ie6.css');
        }
    }
}