var nroTabActual = 0;
function mostrarTab(nroTab,cantidadTabs) {
	for (i=1;i<=cantidadTabs;i++) {
		if (i==nroTab) {
			document.getElementById('TabsContenido' + i).style.display='inline';
			document.getElementById('tabsBot' + i).src='img/tabsBot' + i + '_over.jpg';
		} else {
			document.getElementById('TabsContenido' + i).style.display='none';
			document.getElementById('tabsBot' + i).src='img/tabsBot' + i + '.jpg';			
		}
	}
	nroTabActual=nroTab;
}

var nroTabProgActual = 0;
function mostrarTabProg(nroTab,cantidadTabs) {
	for (i=1;i<=cantidadTabs;i++) {
		if (i==nroTab) {
			document.getElementById('TabsContenido' + i).style.display='inline';
			document.getElementById('tabsProg' + i).src='img/tabsProg' + i + '_over.jpg';
		} else {
			document.getElementById('TabsContenido' + i).style.display='none';
			document.getElementById('tabsProg' + i).src='img/tabsProg' + i + '.jpg';			
		}
	}
	nroTabProgActual=nroTab;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function abrirImagen(titulo,imagen) { //v2.0
  window.open('imagen.php?titulo=' + titulo + '&imagen=' + imagen,'Imagen','status=yes,width=50,height=50,resizable=1');
}
function OpenWidget() {
	  window.open('widget.php','Imagen','status=yes,width=391,height=290,resizable=0');
}
function cerrarVentana() {
	window.close();
}

function ajustarVentana(imagenAncho,imagenAlto) {
	window.resizeTo(imagenAlto,imagenAncho);
}

var nav4 = window.Event ? true : false;
function acceptNum(evt){	
	var key = nav4 ? evt.which : evt.keyCode;	
	return (key <= 13 || (key >= 48 && key <= 57));
}

function controlarContactenos() {
	var msg='';
	var error = false;
	var Nombre=document.Contactenos.Nombre.value;
	var Apellido=escape(document.Contactenos.Apellido.value);
	var Telefono=escape(document.Contactenos.Telefono.value);
	var Email=escape(document.Contactenos.Email.value);	
	var Observaciones=escape(document.Contactenos.Observaciones.value);	

	Nombre=validarTexto(Nombre);
	Apellido=validarTexto(Apellido);
	Telefono=validarTexto(Telefono);
	Observaciones=validarTexto(Observaciones);

	if (Nombre=='')
	{
		msg += "- Nombre.\n"
		error = true;
	}

	if (Apellido=='')
	{
		msg += "- Apellido.\n"
		error = true;
	}

	if (Telefono=='')
	{
		msg += "- Teléfono.\n"
		error = true;
	}

	if (!isEMailAddr(Email))
	{
		msg += "- Email.\n"
		error = true;
	}

	if (Observaciones=='')
	{
		msg += "- Comentarios.\n"
		error = true;
	}

	if (!error) {
		document.Contactenos.envio.value='true';
		document.Contactenos.submit();	
	}
	else {
		window.alert('Verificá los siguientes campos: \n\n'+msg);
	}
}

function GetRadioValue( radioObject ) { 
	var value = null;
	if (radioObject == null)
		return null;
		for (var i=0; i < radioObject.length; i++) { 
			if (radioObject[i].checked) { 
				value = radioObject[i].value;
			break;
		} 
	} 

	return value;
} 

function controlarPromo() {
	var msg='';
	var error = false;

	var Nombre=document.Registro.Nombre.value;
	var Apellido=escape(document.Registro.Apellido.value);
	var Area=escape(document.Registro.Area.value);
	var Telefono=escape(document.Registro.Telefono.value);
	var Email=escape(document.Registro.Email.value);	
	var Edad=escape(document.Registro.Edad.value);	
	var DNI=escape(document.Registro.DNI.value);	
	var Provincia=escape(document.Registro.Provincia.value);	


	Nombre=validarTexto(Nombre);
	Apellido=validarTexto(Apellido);
	Telefono=validarTexto(Telefono);
	Area=validarTexto(Area);
	Email=validarTexto(Email);
	Edad=validarTexto(Edad);
	DNI=validarTexto(DNI);
	Provincia=validarTexto(Provincia);
	
	if (Nombre=='')
	{
		msg += "- Nombre.\n"
		error = true;
	}

	if (Apellido=='')
	{
		msg += "- Apellido.\n"
		error = true;
	}

	if (DNI=='')
	{
		msg += "- DNI.\n"
		error = true;
	}

	if (Area=='')
	{
		msg += "- Código de Area.\n"
		error = true;
	}

	if (Telefono=='')
	{
		msg += "- Teléfono.\n"
		error = true;
	}

	if (Edad=='')
	{
		msg += "- Edad.\n"
		error = true;
	}

	if (!isEMailAddr(Email))
	{
		msg += "- Email.\n"
		error = true;
	}

	if (document.Registro.Sexo[0].checked==false&&document.Registro.Sexo[1].checked==false)
	{
		msg += "- Sexo.\n"
		error = true;
	}
	if (Provincia=='--')
	{
		msg += "- Provincia.\n"
		error = true;
	}

	if (!error) {
		document.Registro.envio.value='true';
		document.Registro.submit();	
	}
	else {
		window.alert('Verificá los siguientes campos: \n\n'+msg);
	}
}

function controlarRecomendar() {

	var msg='';
	var error = false;
	var NombreAmigo1=escape(document.Recomendar.NombreAmigo1.value);
	var EmailAmigo1=escape(document.Recomendar.EmailAmigo1.value);
	var NombreAmigo2=escape(document.Recomendar.NombreAmigo2.value);
	var EmailAmigo2=escape(document.Recomendar.EmailAmigo2.value);
	var NombreAmigo3=escape(document.Recomendar.NombreAmigo3.value);
	var EmailAmigo3=escape(document.Recomendar.EmailAmigo3.value);
	var TuNombre=escape(document.Recomendar.TuNombre.value);
	var TuEmail=escape(document.Recomendar.TuEmail.value);

	if (TuNombre=='')
	{
		msg += "- Tú nombre.\n"
		error = true;
	}

	if (!isEMailAddr(TuEmail))
	{
		msg += "- Tú Email.\n"
		error = true;
	}	

	if (NombreAmigo1=='')
	{
		msg += "- Nombre de tú amigo.\n"
		error = true;
	}

	if (!isEMailAddr(EmailAmigo1))
	{
		msg += "- Email de tú primer amigo.\n"
		error = true;
	}

	if (EmailAmigo2!='') {
		if (!isEMailAddr(EmailAmigo2))
		{
			msg += "- Email de tú segundo amigo.\n"
			error = true;
		}
	}

	if (EmailAmigo3!='') {
		if (!isEMailAddr(EmailAmigo3))
		{
			msg += "- Email de tú tercer amigo.\n"
			error = true;
		}
	}

	if (!error) {
		document.Recomendar.envio.value='true';
		document.Recomendar.submit();	
	}
	else {
		window.alert('Verificá los siguientes campos: \n\n'+msg);
	}	
}

function isEMailAddr(elem) {

	var str = elem;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!str.match(re)) {
		return false;
	} else {
		return true;
	}

}

function validarTexto(elem) {
	var tex='';
	tex=elem.replace(/Select/gi, '');
	tex=tex.replace(/Update/gi, '');
	tex=tex.replace(/Delete/gi, '');
	tex=tex.replace(/From/gi, '');
	tex=tex.replace(/Drop/gi, '');
	tex=tex.replace(/Kill/gi, '');
	return tex;
	//alert('Validar '+tex);
}

function TemaSel(Valor) {
	//alert(Valor);
	if (Valor=='Tarifas') {
		document.getElementById('contCerros').style.display='block';		
	}
	else {
		document.getElementById('contCerros').style.display='none';				
	}
}

var bookmarkurl="http://www.nieveargentina.org.ar"
var bookmarktitle="Sitio Nieve Argentina, información de los centros turísticos."

function addbookmark(){
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}