

	var timerId;

	var limitNews = 0;

	

	function $(id) { var id; return document.getElementById(id); }

	function hideElement(capa, estado) { var capa,estado;$(capa).style.visibility=estado!=true?'hidden':'visible';}

	function objOver(e) { e.style.border='1px solid #91C8FF';}

	function objOut(e) { e.style.border='1px solid #E6F2FF';}

	function getXY(el) { var x=el.offsetLeft,y=el.offsetTop;if (el.offsetParent!=null){var pos=getXY(el.offsetParent);x+=pos.x;y+=pos.y;}return {x:x,y:y};}

	function rF(objeto) { if(objeto.value.length>3){var pos=getXY(objeto);var el=$('sugres');hideElement('sugres',true);el.style.left=pos.x+"px";el.style.top=(pos.y+objeto.offsetHeight)+"px";obj.enlace('#theme.sugres#sugres='+objeto.value,'sugres');} else {hideElement('sugres',false);}}

	function vB(o) { if(o.value=='Buscar Productos') o.value=''; }	

	function lB(o) { if(o.value=='') o.value='Buscar Productos'; }	

	function rB() { var b=document.buscador;if(b.q.value!='Buscar Productos'&&b.q.value!=''){b.submit();}else{alert("Warning!\nEstimado Usuario,\nPrimero, debe ingresar nombre o codigo de nuestros productos \nhaciendo click en \"Buscar Productos\" y enseguida estara habilitada esta Opcion");b.q.focus();}}

	function showLpest(objeto,capa,contenido) { var objeto,capa,contenido,pos=getXY(objeto),el=$(capa),html=[],trozos=contenido.split(','),t;holdPest(capa);el.style.left=(pos.x+50)+"px";el.style.top=(pos.y+objeto.offsetHeight)+"px";for(var i=0;i<(trozos.length-1);i++){t=trozos[i].split('#');html.push('<a href="?go=pa&idClass='+t[0]+'">'+t[1]+'</a>');}$(capa).innerHTML=html.join("");}

	function showPest(objeto,capa,contenido) { var objeto,capa,contenido,pos=getXY(objeto),el=$(capa),html=[],trozos=contenido.split(','),t;holdPest(capa);el.style.left=pos.x+"px";el.style.top=(pos.y+objeto.offsetHeight-1)+"px";for(var i=0;i<(trozos.length-1);i++){t=trozos[i].split('#');html.push('<a href="?go=pa&idClass='+t[0]+'">'+t[1]+'</a>');}$(capa).innerHTML=html.join("");}

	function hidePest(capa) { var capa;timerId=setTimeout("hideElement(\'"+capa+"\',false)",500);}

	function holdPest(capa) { var capa;hideElement(capa,true);clearTimeout(timerId);}

	function subirArchivo(seccion) {

		wwin = 500;

		hwin = 200;

		w = screen.width;

		h = screen.height;

		window.open('pages/theme.uploadimg.php?section='+seccion, 'uploadimg', 'width='+wwin+',height='+hwin+',left='+((h/2)-(hwin/2))+',top='+((w/2)-(wwin/2))+',scrollbars=yes');

	}

	function mostrarImagen(nameimg, tipoImg, w, h) {

		var sb = (w>800||h>600)?'yes':'no';

		if(sb=='no') w=w-17;

		if(w>800) w=800-50;

		if(h>600) h=600-80;			

		window.open('pages/theme.showimagenes.php?imagen='+nameimg+'.'+tipoImg, 'Imagen', 'width='+w+',height='+h+',scrollbars='+sb+',left='+((screen.width/2)-(w/2))+',top='+(((screen.height/2)-(h/2))-30)+'');

	}

	function showCom(objeto,capa,contenido) { 

		var pos=getXY(objeto),el=$(capa);

		holdPest(capa);

		el.style.left=pos.x+"px";

		el.style.width=(objeto.width-8)+"px";

		el.style.border="1px solid #999"

		el.style.top=(pos.y+objeto.offsetHeight-1)+"px";		

		$(capa).innerHTML=contenido;

	}

	

	function submitForm() {

		try {

    		document.uploader.submit();

  		} catch(e) {

  			alert('No se puede Subir el Archivo');

  			hideElement('m', false);

		}

	}

	

	function savingInfo() {

		hideElement('m', true);			

		var el = document.createElement('div');

		el.id = 'cargador';

		el.innerHTML = '<img src="../images/loading.gif" align="absmiddle"> Cargando...';

		$('m').appendChild(el);

		setTimeout("submitForm()", 1000);

	}

		

	var c = 0;	

	function alternar_banner(){

		var bannerUrl = [
							["sical", "http://www.sical.cl"],
						];

		$('banner').src = "images/" + bannerUrl[c][0] + ".gif";

		$('links').href = bannerUrl[c][1];

		c = (c==1) ? 0 : (c+1);

		setTimeout("alternar_banner()",5000)

	}

	

	function uno(s,c) { s.bgColor=c;s.style.cursor='hand'; } 

	function dos(s,c) { s.bgColor=c;s.style.cursor='default'; }

	

	function agregarImagen(cantidad) {

		var cantidad = cantidad;

		if(limitNews < (6-cantidad)) {

			limitNews++;

			$('enlaces').innerHTML = $('enlaces').innerHTML + '<input type="file" name="imagen' + limitNews + '">';

			document.form1.limite.value = limitNews;

		}

		if(limitNews == (6-cantidad)) $('addimage').innerHTML = "";

	}

	

	
