// JavaScript Document

addLoadEvent(
	function(){
		/*if($('user')){
			$('user').addEvent('focus',function(){this.value='';})}
			if($('pass2')){
				$('pass2').addEvent('focus',function(){
					this.style.display='none';
					$('pass').style.display='block';
					$('pass').focus();
					$('pass').value='';
				}				   
			)
		}
		if($('logo')){
			$('logo').css('cursor','pointer').addEvent('click',function(){window.location='index.php';});	
		}*/
	}			 
);
function showPass() {
	$('pass').style.display='block';
	$('pass').focus();
	$('pass').value='';
}
function getElementPosition() {

		var offsetTrail = this;

		var offsetLeft = 0;

		var offsetTop = 0;

		while (offsetTrail) {

			offsetLeft += offsetTrail.offsetLeft;

			offsetTop += offsetTrail.offsetTop;

			offsetTrail = offsetTrail.offsetParent;

		}

		return {left:offsetLeft, top:offsetTop};

}



function getElementsByClassName(rel,scope){

    var col=[];

	var sc=scope || document;

    var tCol=sc.getElementsByTagName('*');

    for(var ii=0;ii<tCol.length;ii++)

        if(tCol[ii].className==rel)

            col.push(tCol[ii])

    return col;

}  

function getElementsByRelName(rel){

    var col=[];

    var tCol=document.getElementsByTagName('*');

    for(var ii=0;ii<tCol.length;ii++)

        if(tCol[ii].rel==rel || tCol[ii].getAttribute('rel')==rel)

            col.push(tCol[ii])

    return col;

}

function cancelEvent(e){

	if(e && e.preventDefault)

		e.preventDefault();

	else if(window.event)

		window.event.returnValue=false;

}

function stopEvent(e){

	if(e && e.stopPropagation)

		e.stopPropagation();

	else if(window.event)

		window.event.cancelBubble=true;

}

function galeria(vec,identificador){

	this.miarray=vec;

	this.indice=0;

	this.directorio='';

	this.precarga=function(){

		for(var i=0;i<this.miarray.length;i++){

			eval("imagen"+i+"=new Image();");

			eval("imagen"+i+".src=" + "\"" +this.directorio+this.miarray[i]+"\";");

		} 

	}

	this.cambia=function(como){

		if(como=='menos'){

			this.indice--;

		}else{

			this.indice++;

		}

		if (this.indice < 0) this.indice = this.miarray.length - 1;

		if (this.indice > this.miarray.length-1) this.indice = 0;

		$('foto_'+identificador).src=this.miarray[this.indice];

		$('label_'+identificador).innerHTML=(this.indice+1)+' - '+this.miarray.length;

	}

}

function enviar(id,valor){

	var txt=location.search || '?';

	var pat=new RegExp("("+id+"\=)([^&]*)",'g');

	if(pat.test(txt)){

		var ruta=txt.replace(pat,function(){return arguments[1]+valor});

	}else{

		var ruta=txt+'&'+id+'='+valor;

	}

	var pat2=new RegExp("("+'puntero'+"\=)([^&]*)",'g');

	if(pat2.test(ruta)){

		ruta=ruta.replace(pat2,function(){return arguments[1]+'0'});

	}else{

		ruta=ruta+'&puntero='+'0';

	}

	window.location=ruta;

}

function chrRest(e,restId,cant){

	var evt=e || window.event;

	obj=evt.target || evt.srcElement;

	var largo=obj.value.length;

	if(largo>=cant){

		obj.value=obj.value.substr(0,cant);

		$(restId).innerHTML='caracteres restantes: 0';

		return;

	}

	$(restId).innerHTML=parseInt(cant-largo);

	

}

function estMouseOver(){

	this.style.background='url(images/menu_busqueda3.gif) no-repeat';

	this.style.bottom='0';

	this.style.color='#333';

}

function estMouseOut(){

	this.style.background='url(images/menu_busqueda4.gif) no-repeat';

	this.style.bottom='-6px';

	this.style.color='#333';

}

function estilizar(obj){

	$('solapa1').style.background='url(images/menu_busqueda4.gif) no-repeat';

	$('solapa1').style.bottom='-6px';

	$('solapa1').style.color='#333';
	
	

	

	$('solapa1').onmouseover=estMouseOver;

	$('solapa1').onmouseout= estMouseOut;

	$('solapa2').onmouseover=estMouseOver;

	$('solapa2').onmouseout=estMouseOut;

	$('solapa3').onmouseover=estMouseOver;

	$('solapa3').onmouseout=estMouseOut;

	

	$('solapa2').style.background='url(images/menu_busqueda4.gif) no-repeat';

	$('solapa2').style.bottom='-6px';

	$('solapa2').style.color='#333';

	$('solapa3').style.background='url(images/menu_busqueda4.gif) no-repeat';

	$('solapa3').style.bottom='-6px';

	$('solapa3').style.color='#333';

	obj.style.background='url(images/menu_busqueda3.gif) no-repeat';

	obj.style.bottom='0';

	obj.style.color='#dc441b';

	obj.onmouseover=obj.onmouseout=function(){}

}


