// JavaScript Document

function get(id) {
	return document.getElementById(id);
}

// get the animation elements
function anim() {
	
	get("land1").style.display = "block";
	get("land2").style.display = "block";
	get("land3").style.display = "block";
	get("land4").style.display = "block";
	get("land5").style.display = "block";
	get("cloudsTop").style.display = "block";
	get("sun").style.display = "block";
	get("plane").style.display = "block";
	get("birds").style.display = "block";
	get("sunrays").style.display = "block";
	
	//get("cloud1").style.display = "block";
//	get("cloud2").style.display = "block";
	//get("cloud3").style.display = "block";
	
	//get ("spot1").style.display ="none";

// create the instance
	man = new jsAnimManager();

// set initial positions
	man.registerPosition("land1");
	l1 = get("land1");
	l1.setPosition(0,800);
	
	man.registerPosition("land2");
	l2 = get("land2");
	l2.setPosition(0,950);
	
	man.registerPosition("land3");
	l3 = get("land3");
	l3.setPosition(0,980);
	
	man.registerPosition("land4");
	l4 = get("land4");
	l4.setPosition(0,980);
	
	man.registerPosition("land5");
	l5 = get("land5");
	l5.setPosition(0,980);
	
	man.registerPosition("cloudsTop");
	ct = get("cloudsTop");
	ct.setPosition(0,-150);
	
	man.registerPosition("sun");
	sunrise = get("sun");
	sunrise.setPosition(395,700);
	
	man.registerPosition("sunrays");
	sunny = get("sunrays");
	sunny.setPosition(390,775);
	
	man.registerPosition("plane");
	planefly = get("plane");
	planefly.setPosition(-1100,850);
	
	man.registerPosition("birds");
	birdsup = get("birds");
	birdsup.setPosition(1100,850);
	
	man.registerPosition("cloud1");
	cld1 = get("cloud1");
	cld1.setPosition(1100,125);
	
	man.registerPosition("cloud2");
	cld2 = get("cloud2");
	cld2.setPosition(800,200);
	
	man.registerPosition("cloud3");
	cld3 = get("cloud3");
	cld3.setPosition(1200,350);
	
	//man.registerPosition("spot1");
	//hs1 = get("spot1");
	//hs1.setPosition(-200,500);
	
		
// instantiate elements	
	ld1 = man.createAnimObject("land1");
	ld2 = man.createAnimObject("land2");
	ld3 = man.createAnimObject("land3");
	ld4 = man.createAnimObject("land4");
	ld5 = man.createAnimObject("land5");

	ctop = man.createAnimObject("cloudsTop");
	sunrise = man.createAnimObject("sun");
	sunny = man.createAnimObject("sunrays");
	
	planefly = man.createAnimObject("plane");
	birdsup = man.createAnimObject("birds");
	
	cld1 = man.createAnimObject("cloud1");
	cld2 = man.createAnimObject("cloud2");
	cld3 = man.createAnimObject("cloud3");
	
	//hs1 = man.createAnimObject("spot1");
	//hs1Vanish = man.createAnimObject("spot1");
	

// makes the elements line up and wait for previous animations
	ld2.add({property: Prop.wait, duration: 300});
	ld3.add({property: Prop.wait, duration: 700});
	ld4.add({property: Prop.wait, duration: 800});
	ld5.add({property: Prop.wait, duration: 900});
	
	ctop.add({property: Prop.wait, duration: 1200});
	sunrise.add({property: Prop.wait, duration: 1400});
	sunny.add({property: Prop.wait, duration: 1400});
	
	planefly.add({property: Prop.wait, duration: 1500});
	birdsup.add({property: Prop.wait, duration: 2200});
	
	cld1.add({property: Prop.wait, duration: 1500});
	cld2.add({property: Prop.wait, duration: 1500});
	cld3.add({property: Prop.wait, duration: 1500});
	
	
	
// animate!
	
	ld1.add({property: Prop.position, to: new Pos(0,598), duration: 800, ease: jsAnimEase.backout(0.4)});
	ld2.add({property: Prop.position, to: new Pos(0,520), duration: 800, ease: jsAnimEase.backout(0.3)});
	ld3.add({property: Prop.position, to: new Pos(0,545), duration: 1000, ease: jsAnimEase.backout(0.2)});
	ld4.add({property: Prop.position, to: new Pos(0,515), duration: 1100, ease: jsAnimEase.backout(0.2)});
	ld5.add({property: Prop.position, to: new Pos(0,515), duration: 1100, ease: jsAnimEase.backout(0.2)});
	
	ctop.add({property: Prop.position, to: new Pos(0,250), duration: 600, ease: jsAnimEase.backout(0.4)});
	sunrise.add({property: Prop.position, to: new Pos(395,140), duration:600, ease: jsAnimEase.backout(0.2)});
	sunny.add({property: Prop.position, to: new Pos(390,175), duration:600, ease: jsAnimEase.backout(0.2)});
	
	planefly.add({property: Prop.position, to: new Pos(-200,250), duration:1500, ease: jsAnimEase.linear});
	birdsup.add({property: Prop.position, to: new Pos(400,150), duration:1600});
	
	cld1.add({property: Prop.position, to: new Pos(-1000,125) , duration: 45000, loop: -1});
	cld2.add({property: Prop.position, to: new Pos(-900,200) , duration: 35000, loop: -1});
	cld3.add({property: Prop.position, to: new Pos(-1200,350) , duration: 50000, loop: -1});	
}


