function OcultarPublicidad() {
	layer_Publicidad.style["display"] = "none";
}

function VerContacto() {
    if (document.getElementById('Contacto').style.display == 'none') {
		document.getElementById('Contacto').style.display = 'block';
	} else {
		document.getElementById('Contacto').style.display = 'none';
    }
}

function EnviarAmigo(pid, modo) {
    ow('../contenidos/EnviarAmigo.aspx?pid='+pid+'&mode='+modo, 'EnviarAmigo', '350', '268');
}

function irAPrograma(pid) {
	document.location.href = '/contenidos/programas.asp?pid=' + pid;
}

function flash(movie, w, h, flashvars, transparent) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ w +'" height="'+ h +'">');
	document.write ('	<param name="movie" value="'+ movie +'">');
	document.write ('	<param name="quality" value="high">');
	document.write ('	<param name="flashvars" value="'+ flashvars +'">');
	document.write ('	<param name="menu" value="0">');
	document.write ('	<param name="wmode" value="'+ transparent +'">');
	document.write ('	<embed src="'+ movie +'" flashvars="'+ flashvars +'" wmode="'+ transparent +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ w +'" height="'+ h +'"></embed>');
	document.write ('</object>');
}

function o(td) {
	td.style.backgroundColor='';
}
function h(td) {
	td.style.backgroundColor='F0F0F0'; td.style.cursor="hand";
}

function hrf(url) {
	document.location.href = url;
}

function ow(page, name, w, h) {
  window.open(page,name,"resizable=0,width="+w+",height="+h+",left=10,top=10,scrollbars=no");
}

function ows(page, name, w, h) {
  window.open(page,name,"resizable=0,width="+w+",height="+h+",left=50,top=50,scrollbars=yes");
}

function hrf(url) {
	document.location.href = url;
}

function foco(obj) {
	if (obj) { obj.focus(); }
}

function confirmar(url, mensaje) {
	if ( confirm(mensaje) )
	document.location.href = url;
}

function clock() {
	if (!document.layers && !document.all) return;
	var digital = new Date();
		var hours = digital.getHours();
		var minutes = digital.getMinutes();
		var seconds = digital.getSeconds();
		var amOrPm = "AM";
		if (hours > 11) amOrPm = "PM";
		if (hours > 12) hours = hours - 12;
		if (hours == 0) hours = 12;
		if (minutes <= 9) minutes = "0" + minutes;
		if (seconds <= 9) seconds = "0" + seconds;
		dispTime = hours + ":" + minutes + ":" + seconds + " " + amOrPm;

	var months = new Array(13);
		months[1]="Enero";
		months[2]="Febrero";
		months[3]="Marzo";
		months[4]="Abril";
		months[5]="Mayo";
		months[6]="Junio";
		months[7]="Julio";
		months[8]="Augosto";
		months[9]="Septiembre";
		months[10]="Octubre";
		months[11]="Noviembre";
		months[12]="Diciembre";

	var time = new Date();
		var lmonth=months[time.getMonth() + 1];
		var date=time.getDate();
		var year=time.getYear();
		if (year < 2000)    
		year = year + 1900;

	if (document.layers) {
			document.layers.pendule.document.write(dispTime);
			document.layers.pendule.document.close();
		}
	else
		if (document.all.pendule)
			pendule.innerHTML = date + " de " + lmonth + " de " + year + " - " + dispTime;
			setTimeout("clock()", 1000);
}

function cargar_combo(file, sql, name, value, cid, cnm, rq, sel, nuevo){
	var scriptTag = document.getElementById('loadScript');
	var head = document.getElementsByTagName('head').item(0);
	script		= document.createElement('script');
	script.src	= file+'?cid='+cid+'&cnm='+cnm+'&sql='+sql+'&sel='+sel+'&vl='+value+'&rq='+rq+'&name='+name+'&nuevo='+nuevo;
	script.type = 'text/javascript';
	script.id	= 'loadScript';
	head.appendChild(script);
}

function crear_combo(file, sql, name, value, cid, cnm, rq, sel, nuevo){
	var scriptTag = document.getElementById('loadScript');
	var head = document.getElementsByTagName('head').item(0);
	script		= document.createElement('script');
	script.src	= file+'?cid='+cid+'&cnm='+cnm+'&sql='+sql+'&sel='+sel+'&vl='+value+'&rq='+rq+'&name='+name+'&nuevo='+nuevo;
	script.type = 'text/javascript';
	script.id	= 'loadScript';
	head.appendChild(script);
}

function cargar_submenu(valor) {
	cargar_combo('/includes/rs.asp', 'sp_submenu', 'submenu', valor, 'id', 'name', '', 'Selecciones uno...', '');
}

function cargar_dependencias(valor, objeto, value) {
	cargar_combo('/includes/rs.asp', 'sp_types_search @p_relations='+ valor +', @p_nivel=2, @p_order=2', objeto, '', 'reference', 'name', value, 'Seleccione uno...', '');
}

function crear_dependencias(valor, objeto) {
	crear_combo('/includes/rs_combos.asp', 'sp_types_search @p_relations='+ valor +', @p_nivel=2, @p_order=2', objeto, '', 'reference', 'name', '', 'Seleccione uno...', '');
}

function resize() {
	if (document.images[0]) window.resizeTo(document.images[0].width+10, document.images[0].height+29);
		self.focus();
	}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		//otherwise, update 'characters left' counter;
	else
		countfield.value = maxlimit - field.value.length;
}

function menu(seccion) {
	if (document.all.publicar) {
			switch(seccion)	{
					case 'vender':
						document.getElementById('publicar').className = 'menu_seleccionado';
						document.getElementById('publicar_menu').style.display = 'block';
				break;
					case 'buscar':
						document.getElementById('buscar').className = 'menu_seleccionado';
						document.getElementById('buscar_menu').style.display = 'block';
				break;
					case 'productos':
						document.getElementById('productos').className = 'menu_seleccionado';
						document.getElementById('productos_menu').style.display = 'block';
				break;
					case 'repuestos':
						document.getElementById('repuestos').className = 'menu_seleccionado';
						document.getElementById('repuestos_menu').style.display = 'block';
				break;
					case 'informacion':
						document.getElementById('informacion').className = 'menu_seleccionado';
						document.getElementById('informacion_menu').style.display = 'block';
				break;
					case 'servicios':
						document.all.servicios.background = '/images/v2_menu_servicios02.gif';
				break;
					case 'faq':
						document.all.faq.background = '/images/v2_menu_preguntas02.gif';
				break;
					default:
						document.getElementById('publicar').className = 'menu_seleccionado';
						document.getElementById('publicar_menu').style.display = 'block';
				break;
			}
		}
}

function cambiar_estilo(objeto, nombre_estilo, estilo_restaurar) {
	if (objeto) {
		if (document.getElementById(objeto).className == nombre_estilo) {
				document.getElementById(objeto).className = estilo_restaurar;
			}
		else {
				document.getElementById(objeto).className = nombre_estilo;
		}
	}
}

function encuesta_validar(form) {
	var f = form;
	var i;
	for(i=0;i<f.votes.length;i++) {
		if (f.votes[i].checked == true) {
            return true;
        }
	}
	//alert('Debe seleccionar alguna opción');
	return false;
}

function seleccionarTodos(objeto) {
	var i;
	var f = document.form;
	for(i=0;i<f.elements.length;i++)
	{
		e = f.elements[i];

		if (e.type == 'checkbox' && e.name == objeto) {
			e.checked =f.chkTodos.checked;
		}

	}
}

function seleccionarTodosTR(objeto, tr_prefijo, tr_estilo, tr_estilo_restaurar) {
	var i;
	var f = document.form;
	for(i=0;i<f.elements.length;i++)
	{
		e = f.elements[i];

		if (e.type == 'checkbox' && e.name == objeto) {
			e.checked = f.chkTodos.checked;

			if (e.checked) {
				document.getElementById(tr_prefijo + e.value).className = tr_estilo;
			} else {
				document.getElementById(tr_prefijo + e.value).className = tr_estilo_restaurar;
			}
		}

	}
}

function operaciones(valor) {
		switch(valor)	{
			case 'activate':
				if (confirm("Está seguro que desea activar todos los registros seleccionados?")) {
					document.form.submit();
				}
				else {
					document.form.operations.options[0].selected = true;
				}
			break;
			case 'inactivate':
				if (confirm("Está seguro que desea desactivar todos los registros seleccionados?")) {
					document.form.submit();
				}
				else {
					document.form.operations.options[0].selected = true;
				}
			break;
			case 'delete':
				if (confirm("Está seguro que desea eliminar todos los registros seleccionados?")) {
					document.form.submit();
				}
				else {
					document.form.operations.options[0].selected = true;
				}
			break;
			case 'deleteall':
				if (confirm("¿Está seguro que desea Eliminar definitivamente el Registro?\n\nNo podrá volver a recuperarlo.")) {
					document.form.submit();
				}
				else {
					document.form.operations.options[0].selected = true;
				}
			break;			
	}
}

function abrime(url,ancho,largo,nombre)
{
     if ((nombre) == '')
     nombre = 'miron';
     window.open(url,nombre,'top='+(screen.height - largo) / 2 +',left='+(screen.width - ancho) / 2 +'dependent=1,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+ancho+',height='+largo)
}
