/*********************************************************************************************************************************/

function MensajeOK(request) {
	$('#IngresoNewsletter').show();
	$('#IngresoNewsletter').html(request);
}
function MensajeError() {
	$('#IngresoNewsletter').show();
	$('#IngresoNewsletter').html('<strong class="textor">Ha ocurrido<br>un error!</strong><br> Por favor intente<br>nuevamente.');
}
function Suscribirse(pTipoSuscripcion) {
	Formulario = document.getElementById('FormNewsletter');
	if (ValidaNewsletter(Formulario)) {
		$.ajax({
			url: '/includes/Newsletter.asp?Email='+ $('#EmailNewsletter').val() +'&TipoSuscripcion='+ pTipoSuscripcion,
			cache: false,
			error: MensajeError,
			success: MensajeOK
		});
	}
}
function ValidaNewsletter(theform) {
	if (!ValidateRequired(theform.EmailNewsletter) )
		{ alert('El campo «« Email »» ' + sMsg );
		theform.EmailNewsletter.focus();
	return (false); }
	
	if (!ValidateEmail(theform.EmailNewsletter) )
		{ alert('El campo «« Email »» ' + sMsg );
		theform.EmailNewsletter.focus();
	return (false); }
return true;
}



/*********************************************************************************************************************************/

function BuscarObjeto(pObjeto) {
	return document.getElementById(pObjeto);
}

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 marqueeStop(){
	document.getElementById("marq").stop();
}

function marqueePlay(){
	document.getElementById("marq").start();
}

function ocultar_todos(mascara) {
	document.getElementById('menu_socios').className = 'menu01';
	document.getElementById(obj + '_links').style.display = 'block';
}

function flash_banners(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="scale" value="exactfit">');
	document.write ('	<param name="menu" value="0">');
	document.write ('	<param name="wmode" value="'+ transparent +'">');
	document.write ('	<embed src="'+ movie +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
	document.write ('</object>');
}

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="scale" value="noscale">');
	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.Hora.document.write(dispTime);
	document.Hora.document.close();
}
else
if (document.all.Hora)
	//Hora.innerHTML = date + " de " + lmonth + " de " + year + " - " + dispTime;
	document.getElementById('Hora').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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function cargar_submenu(valor) {
	cargar_combo('/includes/rs.asp', 'sp_submenu', 'submenu', valor, 'id', 'name', '', 'Selecciones uno...', '');
}

function resize() {
	if (document.images[0]) window.resizeTo(document.images[0].width +10, document.images[0].height+35);
		self.focus();
	}


function background_change() {
	var speed = 1000
	var Pic	= new Array()
		Pic[0] = '/images/home_top_central01.jpg'
		Pic[1] = '/images/home_top_central02.jpg'
		Pic[2] = '/images/home_top_central03.jpg'
	
		var t
		var j = 0
		var p = Pic.length
		
		var preLoad = new Array()
		for (i = 0; i < p; i++){
		   preLoad[i] = new Image()
		   preLoad[i].src = Pic[i]
		}
	
		function runBGSlideShow(){
		   if (document.all.topfondo){
				document.all.topfondo.background = Pic[j];
				j = j + 1
		   if (j > (p-1)) j=0
			   t = setTimeout('runBGSlideShow()', speed)
		   }
		}
}