
var alpha=0;
var so=0;
function init() {
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	
	//if (ns4) block = document.Layer1
	//if (ie4) block = Layer1.style
	
	var ancho=screen.width;
	var alto=screen.height;
	w=ancho;
	//clipTo(block,0,w,130,0);
	//avanza();		
	//showimage();
	fade();
	//lanza_luz() 
}

	
	
function clipValues(obj,which) {
	if (ns4) {
		if (which=="t") return obj.clip.top
		if (which=="r") return obj.clip.right
		if (which=="b") return obj.clip.bottom
		if (which=="l") return obj.clip.left
	}
	else if (ie4) {
		var clipv = obj.clip.split("rect(")[1].split(")")[0].split("px")
		if (which=="t") return Number(clipv[0])
		if (which=="r") return Number(clipv[1])
		if (which=="b") return Number(clipv[2])
		if (which=="l") return Number(clipv[3])
	}
}

function clipTo(obj,t,r,b,l) {
	if (ns4) {
		obj.clip.top = t
		obj.clip.right = r
		obj.clip.bottom = b
		obj.clip.left = l
	}
	else if (ie4) obj.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
}

function clipBy(obj,t,r,b,l) {
	if (ns4) {
		obj.clip.top = clipValues(obj,'t') + t
		obj.clip.right = clipValues(obj,'r') + r
		obj.clip.bottom = clipValues(obj,'b') + b
		obj.clip.left = clipValues(obj,'l') + l
	}
	else if (ie4) obj.clip = "rect("+(this.clipValues(obj,'t')+t)+"px "+(this.clipValues(obj,'r')+r)+"px "+Number(this.clipValues(obj,'b')+b)+"px "+Number(this.clipValues(obj,'l')+l)+"px)"
}


function attach(id)
{
 var obj
  if(ns4) obj = document.layers[id];
  else if(ie4) obj = document.all[id];
   else if(ie5 || ns6) obj = document.getElementById(id);
  return obj
} 

function baja(){
	altura=attach('Layer1');
	altura.style.top= parseInt(altura.style.top)-2;
	}

function sube(){
	altura=attach('Layer1');
	altura.style.top= parseInt(altura.style.top)+2;
	}
	
	

	

function move(coso,coso2,p) {
			
		coso.style.top=30+20*Math.sin(0.02*p)//*Math.sin(alpha);
		coso2.style.top=30+20*Math.sin(0.02*p)//*Math.sin(alpha);
	}	

function move_luz(coso,coso2,p) {
			
		coso.style.top=20+10*Math.cos(0.01*p)//*Math.sin(alpha);
		coso2.style.top=70+10*Math.sin(0.01*p)//*Math.sin(alpha);
		
	}	
	
function lanza_luz() {
		coso=attach('Layer4');	
		coso2=attach('Layer5');	
		
		
		coso.style.left=parseInt(coso.style.left)+8;
		coso2.style.left=parseInt(coso2.style.left)+6;
		
		move_luz(coso,coso2,parseInt(coso.style.left))
		if (parseInt(coso.style.left) >= 1020){
		coso.style.left= 0;
		//coso2.style.left= (Math.random()*100);
		setTimeout("coso2.style.left=0",(Math.random()*1000)) 		
		}
	setTimeout("lanza_luz()",10) 		
	}
	
function avanza()
	{
	
		
	var a=true;
	var ancho=screen.width;
	var alto=screen.height;
	
	
	altura=attach('Layer1');
	aro_gra=attach('Layer2');
	
	
	altura2=attach('imagen');
	w=ancho+10;
	
	
	if((w%2)== 1){
		w=w+1;
		}
		
		
		altura.style.left= parseInt(altura.style.left)+4;
		aro_gra.style.left= parseInt(altura.style.left)+4;
		
		
		posi=altura.style.left;
		ultimo=posi.lastIndexOf("px");
		
		posta=posi.substring(0,ultimo);
			
		//move(altura,aro_gra,posta);
		
		if (parseInt(altura.style.left) >= w){
			rev();
		}else{
		setTimeout("avanza()",1) 	
		}
}

function rev()
	{
	
		altura=attach('Layer1');
		aro_gra=attach('Layer2');
		
		
		altura.style.left= parseInt(altura.style.left)-4;
		aro_gra.style.left= parseInt(altura.style.left)-4;
		
		posi=altura.style.left;
		ultimo=posi.lastIndexOf("px");
		
		posta=posi.substring(0,ultimo);
		//move(altura,aro_gra,posta);
		if(parseInt(altura.style.left) <= -200){
			
			avanza();
		}else{
			setTimeout("rev()",1) 	
		}
}