<!--

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 mostrarOcultar(ly) { //v6.0
	var elLayer = document.getElementById(ly);
		if( elLayer.style.display=='block' ){
		elLayer.style.display='none';
	} else {
		elLayer.style.display='block';
	}
}

// Funcion mostrar y ocultar menu de ciudad y botcomun con ul y li
navHover = function() {
  var existe_div_1 = document.getElementById("menu_vertical");
  if (existe_div_1 != null){

	  var lis = document.getElementById("menu_vertical").getElementsByTagName("LI");
	  for (var i=0; i<lis.length; i++) {
		  lis[i].onmouseover=function() {
			  this.className+=" iehover";
		  }
		  lis[i].onmouseout=function() {
			  this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		  }
	  }
  }
	
	// mostrar y ocultar botcomun
  var existe_div_2 = document.getElementById("botcomun");
  if (existe_div_2 != null){

	  var lis_1 = document.getElementById("botcomun").getElementsByTagName("LI");
	  for (var i=0; i<lis_1.length; i++) {
		  lis_1[i].onmouseover=function() {
			  this.className+=" iehover";
		  }
		  lis_1[i].onmouseout=function() {
			  this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		  }
	  }
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);


//// AJAX

//	Vamos a presuponer que el usuario es una persona inteligente...
var isIE = false;

//	Creamos una variable para el objeto XMLHttpRequest
var req;

//	Creamos una funcion para cargar los datos en nuestro objeto.
//	Logicamente, antes tenemos que crear el objeto.
//	Vease que la sintaxis varia dependiendo de si usamos un navegador decente
//	o Internet Explorer
var id_div;
function AjaxFotos(url,div) {
	id_div = div;
	//	Primero vamos a ver si la URL es una URL :)
	if(url==''){
		return;
	}
	//	Usuario inteligente...
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChangeAutofillFac;
		req.open("GET", url, true);
		req.send(null);
	//	...y usuario de Internet Explorer Windows
	} else if (window.ActiveXObject) {
		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChangeAutofillFac;
			req.open("GET", url, true);
			req.send();
		}
	}
}

function AjaxComentario(url) {
	//	Primero vamos a ver si la URL es una URL :)
	if(url==''){
		return;
	}
	//	Usuario inteligente...
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = procesaComentario;
		req.open("GET", url, true);
		req.send(null);
	//	...y usuario de Internet Explorer Windows
	} else if (window.ActiveXObject) {
		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = procesaComentario;
			req.open("GET", url, true);
			req.send();
		}
	}
}

var AjaxLibre = 0;
//	Funcion que se llama cada vez que se dispara el evento onreadystatechange
//	del objeto XMLHttpRequest
function processReqChangeAutofillFac(){
	var detalles = document.getElementById(id_div);
	if(req.readyState == 4){
		AjaxLibre = 1;
		detalles.innerHTML = req.responseText;
	} else {
		detalles.innerHTML = '<div align="center" style="font-size:10px;color:#666666;margin:13px;text-align:center">'+cargando+' <br/><br/><img src="img/enviando.gif" alt="" width="32" height="32" /></div>';
	}
}

function procesaComentario(){
  var respuesta = '';
	if(req.readyState == 4){
		eval(req.responseText);
    if( respuesta.status != 'ok' ){
      $('enviando_comentarios').innerHTML = '<div class="validation-advice">'+respuesta.msg+'</div>';
    } else {
      $('enviando_comentarios').innerHTML = '<p><strong>'+respuesta.nombre+' dice:</strong><br/>'+respuesta.comentario+'<br/><small>'+menos_un_minuto+'</small></p>';
      new Effect.toggle($('frm_comentarios'),'blind',{duration:0.3});
      $('link_comentario').hide();
    }
	} else {
		$('enviando_comentarios').innerHTML = '<div align="center" style="font-size:10px;color:#666666;margin:13px;text-align:center">'+cargando+' <br/><br/><img src="img/enviando.gif" alt="" width="32" height="32" /></div>';
	}
}

function set_star(num){
  $A($R(1,num)).each(function(n){
    $('star'+n).removeClassName('gris');
    $('star'+n).addClassName('negrita');
  })
}

function unset_star(num){
  $A($R(1,num)).each(function(n){
    $('star'+n).removeClassName('negrita');
    $('star'+n).addClassName('gris');
  })
}

  function enviar_amigo(){
    if( valid.validate() ){
      $('enviando').show();
      AjaxFotos('enviar_amigo.html?'+$('iform').serialize(),'enviando');
      new Effect.toggle($('form_enviar'),'blind',{duration:0.3});
    }
  }

  function enviar_comentario(){
    if( validC.validate() ){
      //alert('mando comentario: '+$('frm_comentarios').serialize());
      $('enviando_comentarios').show();
      AjaxComentario('enviar_comentario.html?'+$('frm_comentarios').serialize());
    }
  }

	function agregar_a_favoritos(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// 
		window.external.AddFavorite(url, title);
	}

	function clk_enviar_amigo(){
		['enviando','form_buscar'].each(Element.hide);
		$('email_amigos').innerHTML='';
		$('email_amigo1').clear();
		$('mensaje').clear();
		$$('a.masamigos').each(Element.show);
		emailAmigo=1;
		new Effect.toggle($('form_enviar'),'blind',{duration:0.5,afterFinish:foco('nombre')}); 
		return false
	}

	function clk_buscar(){
		['enviando','form_enviar'].each(Element.hide);
		new Effect.toggle($('form_buscar'),'blind',{duration:0.2,afterFinish:foco('buscar')}); 
		return false;
	}

	function clk_comentar(){
		new Effect.toggle($('frm_comentarios'),'blind',{duration:0.5,afterFinish:foco('nombre_comentarios')}); 
		return false;
	}

//AGREGADO PARA EL CARROUSEL

function ajaxJfotos(q) {//funcion que devuelve comandos javascript para procesar
  if( q.size()==0 ){
    if( colaActual.size()>0 ){
      buscoDatos();
    }else{     
      if( (cajafoto[actual.get('cajafoto')]-(nfotos*3)+1)>0 ){ $(('navControlI_'+actual.get('caja'))).show(); 
      }
      if( cajafoto[actual.get('cajafoto')] < actual.get('array').size()-1 ){ $(('navControlD_'+actual.get('caja'))).show();}
    }
    return false; 
  }
	//	Usuario inteligente...
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = procesaJfotos;
		req.open("GET", 'buscaDatos.html?q='+q, true);
		req.send(null);
	//	...y usuario de Internet Explorer Windows
	} else if (window.ActiveXObject) {
		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = procesaJfotos;
			req.open("GET", 'buscaDatos.html?q='+q, true);
			req.send();
		}
	}
}

function dibujaCaja(i,c){// i es el id de la foto, c es el id de la caja, caja es el div de la foto (reciente,calificada, etc.)
  var f = aFotos[i];
  if( Object.isNumber(idfoto) ){
    if( f.id==idfoto ){
      var sel=' seleccionada';
    } else {
      var sel='';
    }
  } else {
    var sel='';
  }
  if( f.vistas>1 ){
    var v=f.vistas+" "+veces;
  } else {
    var v=" "+solo_una_vez;
  }
  if( $((actual.get('caja')+'_'+c)).childElements().size()==0 ){
    var txtfotodeldia = ''
    if( f.anio ){
      txtfotodeldia = '<p style="display:block;margin:-7px 0 3px 0;padding:0"><img src="img/fdeldia.gif" width="16" height="19" title="'+fotodeldia+'" align="absmiddle"/> '+fechacorta(f.mes,f.dia)+'</p>';
    }
    $((actual.get('caja')+'_'+c)).innerHTML = '<a href="'+foto+'_'+f.id+'.html#'+actual.get('tab')+'" onmouseover="muestraATip('+i+')" onmouseout="ocultaTip()"><img src="fotos/'+f.id+'_ch.jpg" class="foto'+sel+'" width="'+f.ancho+'" height="'+f.alto+'" border="0"/></a><p align="center" style="margin-top: 3px;">'+txtfotodeldia+'<p>'+vista+' '+v+'</p><p class="votos">'+estrellitas(f.estrellas)+'</p></div>';
  }
}


function procesaJfotos(){
	if(req.readyState == 4){
		AjaxLibre = 1;
    var aDatos = [];
		eval(req.responseText);
    //actualizo datos en el array de fotos y cargo los datos correspondientes en cajaFoto
    aDatos.each(function(f){
      for( n = (cajafoto[actual.get('cajafoto')]-(nfotos*3)+1); n<=cajafoto[actual.get('cajafoto')]; n++ ){
        if( actual.get('array')[n] == f.id ){
          aFotos[f.id] = f;
          dibujaCaja(f.id,n);
          break;
        }
      }
    });
    if( (cajafoto[actual.get('cajafoto')]-(nfotos*3)+1)>0 ){ $(('navControlI_'+actual.get('caja'))).show(); 
    }
    if( cajafoto[actual.get('cajafoto')] < actual.get('array').size()-1 ){ $(('navControlD_'+actual.get('caja'))).show();}
    if( colaActual.size()>0 ){
      buscoDatos();
    }
	}
}


  function estrellitas(s){//muestra las estrellas promedio que tiene la foto
    var r = '';
        switch(s){
          case '1':
            r = '<span><img src="img/stars.gif" width="14" height="14"></span><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14">';
            break;
          case '2':
            r = '<span><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"></span><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14">';
            break;
          case '3':
            r = '<span><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"></span><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14">';
            break;
          case '4':
            r = '<span><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"></span><img src="img/stars_gris.gif" width="14" height="14">';
            break;
          case '5':
            r = '<span><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"><img src="img/stars.gif" width="14" height="14"></span>';
            break;
          default:
            r = '<img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14"><img src="img/stars_gris.gif" width="14" height="14">';
            break;
        }
        return r;
  }

  var emailAmigo = 1;
  function agregarEmailAmigos(e){
    emailAmigo++;
    $('email_amigos').insert('<div><label>'+txtemailamigo+' '+emailAmigo+': </label><input name="email_amigo[]" type="text"  class="required validate-email" id="email_amigo'+emailAmigo+'" title="'+titemailamigo+'" value="" size="35"/></div><a href="#email_amigos" onclick="agregarEmailAmigos(this)" class="masamigos">+ '+amigos+'</a>');
    e.hide();
    foco('email_amigo'+emailAmigo);
  }


	function foco(e){
		setTimeout("$('"+e+"').focus()",500);
	}


//#VALIDATION
/*
* Really easy field validation with Prototype
* http://tetlaw.id.au/view/javascript/really-easy-field-validation
* Andrew Tetlaw
* Version 1.5.4.1 (2007-01-05)
* 
* Copyright (c) 2007 Andrew Tetlaw
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* 
*/
var Validator = Class.create();

Validator.prototype = {
	initialize : function(className, error, test, options) {
		if(typeof test == 'function'){
			this.options = $H(options);
			this._test = test;
		} else {
			this.options = $H(test);
			this._test = function(){return true};
		}
		this.error = error || 'Validation failed.';
		this.className = className;
	},
	test : function(v, elm) {
		return (this._test(v,elm) && this.options.all(function(p){
			return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;
		}));
	}
}
Validator.methods = {
	pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},
	minLength : function(v,elm,opt) {return v.length >= opt},
	maxLength : function(v,elm,opt) {return v.length <= opt},
	min : function(v,elm,opt) {return v >= parseFloat(opt)}, 
	max : function(v,elm,opt) {return v <= parseFloat(opt)},
	notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {
		return v != value;
	})},
	oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {
		return v == value;
	})},
	is : function(v,elm,opt) {return v == opt},
	isNot : function(v,elm,opt) {return v != opt},
	equalToField : function(v,elm,opt) {return v == $F(opt)},
	notEqualToField : function(v,elm,opt) {return v != $F(opt)},
	include : function(v,elm,opt) {return $A(opt).all(function(value) {
		return Validation.get(value).test(v,elm);
	})}
}

var Validation = Class.create();

Validation.prototype = {
	initialize : function(form, options){
		this.options = Object.extend({
			onSubmit : true,
			stopOnFirst : false,
			immediate : false,
			focusOnError : true,
			useTitles : false,
			onFormValidate : function(result, form) {},
			onElementValidate : function(result, elm) {}
		}, options || {});
		this.form = $(form);
		if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);
		if(this.options.immediate) {
			var useTitles = this.options.useTitles;
			var callback = this.options.onElementValidate;
			Form.getElements(this.form).each(function(input) { // Thanks Mike!
				Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
			});
		}
	},
	onSubmit :  function(ev){
		if(!this.validate()) Event.stop(ev);
	},
	validate : function() {
		var result = false;
		var useTitles = this.options.useTitles;
		var callback = this.options.onElementValidate;
		if(this.options.stopOnFirst) {
			result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); });
		} else {
			result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); }).all();
		}
		if(!result && this.options.focusOnError) {
			Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
		}
		this.options.onFormValidate(result, this.form);
		return result;
	},
	reset : function() {
		Form.getElements(this.form).each(Validation.reset);
	}
}

Object.extend(Validation, {
	validate : function(elm, options){
		options = Object.extend({
			useTitle : false,
			onElementValidate : function(result, elm) {}
		}, options || {});
		elm = $(elm);
		var cn = elm.classNames();
		return result = cn.all(function(value) {
			var test = Validation.test(value,elm,options.useTitle);
			options.onElementValidate(test, elm);
			return test;
		});
	},
	test : function(name, elm, useTitle) {
		var v = Validation.get(name);
		var prop = '__advice'+name.camelize();
		try {
		if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
			if(!elm[prop]) {
				var advice = Validation.getAdvice(name, elm);
				if(advice == null) {
					var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
					advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					switch (elm.type.toLowerCase()) {
						case 'checkbox':
						case 'radio':
							var p = elm.parentNode;
							if(p) {
								new Insertion.Bottom(p, advice);
							} else {
								new Insertion.After(elm, advice);
							}
							break;
						default:
							new Insertion.After(elm, advice);
				    }
					advice = Validation.getAdvice(name, elm);
				}
				if(typeof Effect == 'undefined') {
					advice.style.display = 'block';
				} else {
					new Effect.Appear(advice, {duration : 1 });
				}
			}
			elm[prop] = true;
			elm.removeClassName('validation-passed');
			elm.addClassName('validation-failed');
			return false;
		} else {
			var advice = Validation.getAdvice(name, elm);
			if(advice != null) advice.hide();
			elm[prop] = '';
			elm.removeClassName('validation-failed');
			elm.addClassName('validation-passed');
			return true;
		}
		} catch(e) {
			throw(e)
		}
	},
	isVisible : function(elm) {
		while(elm.tagName != 'BODY') {
			if(!$(elm).visible()) return false;
			elm = elm.parentNode;
		}
		return true;
	},
	getAdvice : function(name, elm) {
		return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
	},
	getElmID : function(elm) {
		return elm.id ? elm.id : elm.name;
	},
	reset : function(elm) {
		elm = $(elm);
		var cn = elm.classNames();
		cn.each(function(value) {
			var prop = '__advice'+value.camelize();
			if(elm[prop]) {
				var advice = Validation.getAdvice(value, elm);
				advice.hide();
				elm[prop] = '';
			}
			elm.removeClassName('validation-failed');
			elm.removeClassName('validation-passed');
		});
	},
	add : function(className, error, test, options) {
		var nv = {};
		nv[className] = new Validator(className, error, test, options);
		Object.extend(Validation.methods, nv);
	},
	addAllThese : function(validators) {
		var nv = {};
		$A(validators).each(function(value) {
				nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
			});
		Object.extend(Validation.methods, nv);
	},
	get : function(name) {
		return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
	},
	methods : {
		'_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})
	}
});

Validation.add('IsEmpty', '', function(v) {
				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
			});

Validation.addAllThese([
	['required', 'Este es un campo obligatorio.', function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-number', 'Please enter a valid number in this field.', function(v) {
				return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
			}],
	['validate-digits', 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);
			}],
	['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)
			}],
	['validate-alphanum', 'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/\W/.test(v)
			}],
	['validate-date', 'Please enter a valid date.', function(v) {
				var test = new Date(v);
				return Validation.get('IsEmpty').test(v) || !isNaN(test);
			}],
	['validate-email', 'Ingrese una direcci&oacute;n de email v&aacute;lida. Por ejemplo info@interpatagonia.com .', function (v) {
				return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)
			}],
	['validate-url', 'Please enter a valid URL.', function (v) {
				return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-date-au', 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				if(!regex.test(v)) return false;
				var d = new Date(v.replace(regex, '$2/$1/$3'));
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-currency-dollar', 'Please enter a valid $ amount. For example $100.00 .', function(v) {
				// [$]1[##][,###]+[.##]
				// [$]1###+[.##]
				// [$]0.##
				// [$].##
				return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
			}],
	['validate-selection', 'Please make a selection', function(v,elm){
				return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
			}],
	['validate-one-required', 'Please select one of the above options.', function (v,elm) {
				var p = elm.parentNode;
				var options = p.getElementsByTagName('INPUT');
				return $A(options).any(function(elm) {
					return $F(elm);
				});
			}]
]);

// Para el Contador de caracteres.
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

// Contador de caracteres.
function Contar(entrada,salida,texto,caracteres) {
  var entradaObj=getObject(entrada);
  var salidaObj=getObject(salida);
  var longitud=caracteres - entradaObj.value.length;
  if(longitud <= 0) {
    longitud=0;
    texto='<span class="rojo"> '+texto+' </span>';
    entradaObj.value=entradaObj.value.substr(0,caracteres);
  }
  salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
}


function Popup(url,name,width,height,resize,scroll) {
	var dialogWin = new Object();
	dialogWin.width = width;
	dialogWin.height = height;
	if (navigator.appName == "Netscape") {
		dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
		dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
		var attr = 'screenX=' + dialogWin.left + ',screenY=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	} else if (document.all) {
		dialogWin.left = (screen.width - dialogWin.width) / 2;
		dialogWin.top = (screen.height - dialogWin.height) / 2;
		var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	}
	window.open(url,name,attr);
}

// moviemiento de capas
// Declaro las variables para el carro
var Calculo = 0;
//var Mover = 400; //esta declarado en foto.html
var PosicionActual;
var MasMover = 0;

// Función para mover a la izquierda un layer con aceleración
function siguiente(capa){
  
  // Busco el DIV que tiene el scroll
  var Contenedor = document.getElementById(capa);
  
  //Para debug, escribe en un layer con ID=valor1 la variable "Calculo"
  //var datos=document.getElementById('valor1');
  //datos.innerHTML = Contenedor.scrollLeft+'-'+Contenedor.scrollWidth+'-'+Contenedor.offsetWidth;
    
  // solo se ejecuta el movimiento si la posición del scroll es < al ancho total del layer que esta dentro del contenedor
  if ( Contenedor.scrollTop < ( Contenedor.scrollHeight -  Contenedor.offsetHeight ) ){
    
    // Función matemática para aceleración
    Calculo -= Mover
    Calculo *= 0.80
    Calculo += Mover
    
    
    // Le doy el valor al que se tiene que mover + el valor donde esta
    Contenedor.scrollTop = Calculo + MasMover;
    PosicionActual = Calculo;
    
    //Para debug, escribe en un layer con ID=valor la variable "Calculo"
    //var ejs=document.getElementById('valor');
    //ejs.innerHTML += Calculo+'<br>';
    
    // si todavía no llega al lugar requerido vuelve a ejecutar la función
    // de lo contrario resetea todas las variables
    if(Mover > PosicionActual+1){
      setTimeout('siguiente("'+capa+'")',20);
    } else {
      MasMover = MasMover + Mover;
      PosicionActual = 0;
      Calculo = 0;
    }
  }
}

// Función para mover a la derecha un layer con aceleración
function anterior(capa){
  
  // Busco el DIV que tiene el scroll
  var Contenedor = document.getElementById(capa);
  
  //Para debug, escribe en un layer con ID=valor1 la variable "Calculo"
  //var datos=document.getElementById('valor1');
  //datos.innerHTML = Contenedor.scrollLeft+'-'+Contenedor.scrollWidth+'-'+Contenedor.offsetWidth;
  
  // solo se ejecuta el movimiento si la posición del scroll es > 0
  if ( Contenedor.scrollTop >0 ){
  
    // Función matemática para aceleración
    Calculo += Mover
    Calculo *= 0.80
    Calculo -= Mover
    
    // Le doy el valor al que se tiene que mover + el valor donde esta
    Contenedor.scrollTop = Calculo + MasMover;
    PosicionActual = Calculo;
    
    //Para debug, escribe en un layer con ID=valor la variable "Calculo"
    //var ejs=document.getElementById('valor');
    //ejs.innerHTML += Calculo+'<br>';
    
    // si todavía no llega al lugar requerido vuelve a ejecutar la función
    // de lo contrario resetea todas las variables
    if(Mover > -PosicionActual+1){
      setTimeout('anterior("'+capa+'")',20);
    } else {
      MasMover = MasMover - Mover;
      PosicionActual = 0;
      Calculo = 0;
    }
  }
}

//-->


