ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

function statusDefault()
{
   window.defaultStatus = "Dynart - Alojamento e Web Design";
}

function display(n) {
	if (n == 1) {
		imgWindow=window.open("../shared/comparativo.html","","width=600,height=500,scrollbars=1")
	}
	if (n == 2) {
		imgWindow=window.open("../shared/manual.html","","width=600,height=500,scrollbars=1")
	}
	if (n == 3) {
		imgWindow=window.open("../shared/faq.html","","width=600,height=500,scrollbars=1")
	}
	if (n == 4) {
		imgWindow=window.open("inscricao.html","","width=600,height=500,scrollbars=1")
	}
	if (n == 5) {
		imgWindow=window.open("orcamento.html","","width=600,height=500,scrollbars=1")
	}
}

function init() {
	
	// ********** ANIMACOES DAS SECCOES **************
	
	// Alojamento
	seccao1 = new layerObj("seccao1Div")
	seccao1.path1 = new Path(seccao1,"path1",
	// valores em x
	new Array(40,50,63,77,90,103,117,130,143,157,170,183,197,210,223,237,250),
	// valores em y
	new Array(160,150,141,133,124,115,107,98,89,81,72,63,55,46,37,29,20))
	
	// Clientes
	seccao2 = new layerObj("seccao2Div")
	seccao2.path2 = new Path(seccao2,"path2",
	// valores em x
	new Array(40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250),
	// valores em y
	new Array(260,250,238,227,215,204,192,181,169,158,146,135,123,112,100,89,77,66,54,43,31,20))
	
	// Contacto
	seccao3 = new layerObj("seccao3Div")
	seccao3.path3 = new Path(seccao3,"path3",
	// valores em x
	new Array(40,50,58,66,74,82,90,98,106,114,122,130,138,146,154,162,170,178,186,194,202,210,218,226,234,242,250),
	// valores em y
	new Array(360,350,337,324,310,297,284,271,258,244,231,218,205,192,178,165,152,139,126,112,99,86,73,60,46,33,20))
	
	// Design
	seccao4 = new layerObj("seccao4Div")
	seccao4.path4 = new Path(seccao4,"path4",
	// valores em x
	new Array(140,150,160,170,180,190,200,210,220,230,240,250),
	// valores em y
	new Array(160,150,137,124,111,98,85,72,59,46,33,20))
	
	// Equipa
	seccao5 = new layerObj("seccao5Div")
	seccao5.path5 = new Path(seccao5,"path5",
	// valores em x
	new Array(140,150,156,162,169,175,181,188,194,200,206,212,219,225,231,237,244,250),
	// valores em y
	new Array(260,250,236,221,207,192,178,164,149,135,121,106,92,77,63,49,34,20))
	
	// Projecto
	seccao6 = new layerObj("seccao6Div")
	seccao6.path6 = new Path(seccao6,"path6",
	// valores em x
	new Array(140,150,155,159,164,168,173,177,182,186,191,195,200,205,209,214,218,223,227,232,236,241,245,250),
	// valores em y
	new Array(360,350,335,320,305,290,275,260,245,230,215,200,185,170,155,140,125,110,95,80,65,50,35,20))
	
	// *************** FIM **************
		
	// **************** ANIMACOES CENTRAIS ***********
	
	// **************** FIM *****************
	
	// ******************* ANIMACOES DOS TITULOS *************
	
	// Titulos de Alojamento
	titulo1 = new layerObj("titulo1Div")
	titulo2 = new layerObj("titulo2Div")
	titulo3 = new layerObj("titulo3Div")
	titulo4 = new layerObj("titulo4Div")
	titulo5 = new layerObj("titulo5Div")
	titulo6 = new layerObj("titulo6Div")
	titulo18 = new layerObj("titulo18Div")
	
	// Titulos de Clientes
	titulo7 = new layerObj("titulo7Div")
	titulo8 = new layerObj("titulo8Div")
	
	// Titulos de Contactos
	titulo9 = new layerObj("titulo9Div")
	titulo10 = new layerObj("titulo10Div")
	
	// Titulos de Design
	titulo11 = new layerObj("titulo11Div")
	titulo12 = new layerObj("titulo12Div")
	
	// Titulos de Equipa
	titulo13 = new layerObj("titulo13Div")
	titulo14 = new layerObj("titulo14Div")
	titulo15 = new layerObj("titulo15Div")
	titulo16 = new layerObj("titulo16Div")
	titulo17 = new layerObj("titulo17Div")

	// ********************* FIM **********************
	
	// ***************** OUTRAS ANIMACOES *****************
	
	// Animacao do Logo Grande
	bigLogo = new layerObj("bigLogoDiv")
	
	// ********************** FIM ***********************
		
	// **************** LAYERS ESTATICAS ****************
	
	// Paginas de Alojamento
	alojamento = new layerObj("alojamentoDiv")
	pagina1 = new layerObj("pagina1Div")
	pagina2 = new layerObj("pagina2Div")
	pagina3 = new layerObj("pagina3Div")
	pagina4 = new layerObj("pagina4Div")
	pagina5 = new layerObj("pagina5Div")
	pagina6 = new layerObj("pagina6Div")
	pagina18 = new layerObj("pagina18Div")
	
	// Paginas de Clientes
	clientes = new layerObj("clientesDiv")
	pagina7 = new layerObj("pagina7Div")
	pagina8 = new layerObj("pagina8Div")
	
	// Paginas de Contactos
	contactos = new layerObj("contactosDiv")
	pagina9 = new layerObj("pagina9Div")
	pagina10 = new layerObj("pagina10Div")
	
	// Paginas de Design
	design = new layerObj("designDiv")
	pagina11 = new layerObj("pagina11Div")
	pagina12 = new layerObj("pagina12Div")
	
	// Paginas de Equipa
	equipa = new layerObj("equipaDiv")
	pagina13 = new layerObj("pagina13Div")
	pagina14 = new layerObj("pagina14Div")
	pagina15 = new layerObj("pagina15Div")
	pagina16 = new layerObj("pagina16Div")
	pagina17 = new layerObj("pagina17Div")

	// Paginas de Projecto
	projecto = new layerObj("projectoDiv")
		
	// Gerais
	geral = new layerObj("geralDiv")
	barra1 = new layerObj("barra1Div")
	barra2 = new layerObj("barra2Div")
	logo = new layerObj("logoDiv")
	webmaster = new layerObj("webmasterDiv")
	aviso = new layerObj("avisoDiv")
	
	// ********************* FIM *************************
	
	statusDefault()
	animacoes()
}
	
function animacoes() {	
	bigLogo.show()
	eval("bigLogo.moveByX(bigLogo,48,-15)")
}

function layerObj(id) {
	if (ns4) {
		this.css = document.layers[id]
		this.x = this.css.left
		this.y = this.css.top
	}
	else if (ie4) {
		this.css = document.all[id].style
		this.x = this.css.pixelLeft
		this.y = this.css.pixelTop
	}
	
	this.moveTo = layerObjMoveTo
	this.moveByX = DynLayerMoveByX
	this.moveByY = DynLayerMoveByY
	this.show = DynLayerShow
	this.showme = DynLayerShowme
	this.hide = DynLayerHide
	this.addon = DynLayerAddon
	this.addon(id)
}

function DynLayerAddon(id) {
        this.obj = id + "DynLayer"
        eval(this.obj + "=this")
}

function layerObjMoveTo(x,y) {
	this.x = x
	this.css.left = this.x
	this.y = y
	this.css.top = this.y
}

function DynLayerMoveByX(dynlayer,stop,x) {
	this.dynlayer = dynlayer.obj
	if (x < 0) {
		if (this.x > stop) {
			this.x += x
			eval(this.dynlayer+".moveTo("+this.x+","+this.y+")")
			setTimeout(this.dynlayer+".moveByX("+this.dynlayer+","+stop+","+x+")", 5)
		} else {
			barra1.show()
			barra2.show()
			geral.show()
			}	
	} else {
		if (this.x < stop) {
			this.x += x
			eval(this.dynlayer+".moveTo("+this.x+","+this.y+")")
			setTimeout(this.dynlayer+".moveByX("+this.dynlayer+","+stop+","+x+")", 5)
		}
	}
}

function DynLayerMoveByY(dynlayer,stop,y) {
	this.dynlayer = dynlayer.obj
	if (this.y < stop) {
			this.y += y
			eval(this.dynlayer+".moveTo("+this.x+","+this.y+")")
			setTimeout(this.dynlayer+".moveByY("+this.dynlayer+","+stop+","+y+")", 5)
	}
}

function DynLayerShowme() {
		alojamento.hide()
		clientes.hide()
		contactos.hide()
		design.hide()
		equipa.hide()
		projecto.hide()
		for (i = 1; i < 19 ; i++)
			eval("pagina"+i+".hide()")
		this.css.visibility = (ns4)? "show" : "visible"
}

function DynLayerShow() {
	this.css.visibility = (ns4)? "show" : "visible"
}

function DynLayerHide() {
	this.css.visibility = (ns4)? "hide" : "hidden"
}

function Path(dynlayer,name,arrayX,arrayY) {
	this.dynlayer = dynlayer.obj
	this.name = name
	this.arrayX = arrayX
	this.arrayY = arrayY
	this.i = 0
	this.j = this.arrayX.length - 1
	this.start = PathStart 
	this.reverse = PathReverse
}

function play(layer, me) {
	if (bigLogo.x > 50) return
	if (me < 7) {
		shut()
		if (this.current == me) return
		if (!this.current) { 
			this.current = me		
			eval(layer+me+"."+"path"+me+".start()")
		}
		else {
			eval(layer+me+".path"+me+".i = 0")
			eval(layer+me+".path"+me+".start()")
			eval(layer+me+".path"+me+".j ="+layer+me+".path"+me+".arrayX.length - 1")
			eval(layer+this.current+".path"+this.current+".reverse()")
			this.current = me
		}
		this.child = playChild
		this.restart = restart
	}
	else { eval(layer+".path"+me+".start()") }
}

function PathStart() {
		if (this.i < this.arrayX.length) {
			eval(this.dynlayer+".moveTo("+this.arrayX[this.i]+","+this.arrayY[this.i]+")")
			this.i += 1
			setTimeout(this.dynlayer+"."+this.name+".start()",5)
		}
		else { eval("playChild()") }
}

function PathReverse() {
		if (this.j > -1) {
			eval(this.dynlayer+".moveTo("+this.arrayX[this.j]+","+this.arrayY[this.j]+")")
			this.j -= 1
			setTimeout(this.dynlayer+"."+this.name+".reverse()",5)
		}
}

function playChild() {
	for (i = 1; i < 19; i++) {
		eval("titulo"+i+".hide()")
	}	
	if (this.current == 1) {
		eval("alojamento.showme()")
		eval("titulo1.show()")
		eval("titulo2.show()")
		eval("titulo3.show()")
		eval("titulo4.show()")
		eval("titulo5.show()")
		eval("titulo6.show()")
		eval("titulo18.show()")
		eval("titulo1.moveByX(titulo1,340,5)")
		eval("titulo2.moveByX(titulo2,430,5)")
		eval("titulo3.moveByX(titulo3,550,5)")
		eval("titulo4.moveByX(titulo4,635,5)")
		eval("titulo5.moveByX(titulo5,410,5)")
		eval("titulo6.moveByX(titulo6,520,5)")
		eval("titulo18.moveByX(titulo18,600,5)")
	}
	if (this.current == 2) {
		eval("clientes.showme()")
		eval("titulo7.show()")
		eval("titulo8.show()")
		eval("titulo7.moveByX(titulo7,400,5)")
		eval("titulo8.moveByX(titulo8,500,5)")
	}
	if (this.current == 3) {
		eval("contactos.showme()")
		eval("titulo9.show()")
		eval("titulo10.show()")
		eval("titulo9.moveByX(titulo9,400,5)")
		eval("titulo10.moveByX(titulo10,486,5)")
	}
	if (this.current == 4) {
		eval("design.showme()")
		eval("titulo11.show()")
		eval("titulo12.show()")
		eval("titulo11.moveByX(titulo11,400,5)")
		eval("titulo12.moveByX(titulo12,486,5)")
	}
	if (this.current == 5) {
		eval("equipa.showme()")
		eval("titulo13.show()")
		eval("titulo14.show()")
		eval("titulo15.show()")
		eval("titulo16.show()")
		eval("titulo17.show()")
		eval("titulo13.moveByX(titulo13,335,5)")
		eval("titulo14.moveByX(titulo14,410,5)")
		eval("titulo15.moveByX(titulo15,490,5)")
		eval("titulo16.moveByX(titulo16,580,5)")
		eval("titulo17.moveByX(titulo17,650,5)")
	}
	if (this.current == 6) {
		eval("projecto.showme()")
	}
}

function shut() {
	logo.hide()
	barra1.hide()
	barra2.hide()
	webmaster.hide()
	geral.hide()
	aviso.hide()
}

function restart(layer) {
	for (i = 1; i < 19; i++) {
		eval("titulo"+i+".hide()")
	}
	logo.showme()
	if (this.current) {
		eval(layer+this.current+".path"+this.current+".reverse()")
	this.current = 0
	}
	logo.show()
	barra1.show()
	barra2.show()
	webmaster.show()
	geral.show()
	aviso.show()
}

function pagina(num) {
	eval("pagina"+num+".showme()")
	
}	
