IE5=NN4=NN6=OPA=false
if(navigator.userAgent.toLowerCase().indexOf("opera")+1)OPA=true
else if(document.all)IE5=true
else if(document.layers)NN4=true
else if(document.getElementById)NN6=true

onresize=rePos

function rePos() {
	w=720
	h=483
	xc=0
	yc=0

	if(NN4||NN6) {
		xc=Math.round((window.innerWidth/2)-(w/2))
		yc=Math.round((window.innerHeight/2)-(h/2))
	} else {
		if(document.documentElement.clientWidth) xc=Math.round((document.documentElement.clientWidth/2)-(w/2))
		else if(document.body.clientWidth) xc=Math.round((document.body.clientWidth/2)-(w/2))
		if(document.documentElement.clientHeight) yc=Math.round((document.documentElement.clientHeight/2)-(h/2))
		else if(document.body.clientHeight) yc=Math.round((document.body.clientHeight/2)-(h/2))
	}

	if(xc<0) xc=0 

	if(yc>50) yc=50 
	else if(yc<0) yc=0

	if(this.NN4) {
		g_canvasObj.moveTo(xc,yc)
	} else {
		g_canvasObj.left = xc + "px"
		g_canvasObj.top = yc + "px"
	}
}

var g_page=0
var g_xloc=329
var g_yloc=105
var g_numsfobj=0
var g_canvasObj=0
var g_numdivs=6
var g_portfolioMode=false
var g_galleryMode=false
numpix=5

function initialize() {

	window.defaultStatus=""
	if(NN4) g_canvasObj=document.canvas
	else g_canvasObj=document.getElementById("canvas").style

	rePos()

	aboutus = new series( "aboutus", 75, "nav" );
		aboutus.loadimage( "gfx/aboutus100.jpg" );
		aboutus.loadimage( "gfx/aboutus075.jpg" );
		aboutus.loadimage( "gfx/aboutus050.jpg" );
		aboutus.loadimage( "gfx/aboutus025.jpg" );
		aboutus.loadimage( "gfx/aboutus000.jpg" );
	services = new series( "services", 75, "nav" );
		services.loadimage( "gfx/services100.jpg" );
		services.loadimage( "gfx/services075.jpg" );
		services.loadimage( "gfx/services050.jpg" );
		services.loadimage( "gfx/services025.jpg" );
		services.loadimage( "gfx/services000.jpg" );
	portfolio = new series( "portfolio", 75, "nav" );
		portfolio.loadimage( "gfx/portfolio100.jpg" );
		portfolio.loadimage( "gfx/portfolio075.jpg" );
		portfolio.loadimage( "gfx/portfolio050.jpg" );
		portfolio.loadimage( "gfx/portfolio025.jpg" );
		portfolio.loadimage( "gfx/portfolio000.jpg" );
	gallery = new series( "gallery", 75, "nav" );
		gallery.loadimage( "gfx/gallery100.jpg" );
		gallery.loadimage( "gfx/gallery075.jpg" );
		gallery.loadimage( "gfx/gallery050.jpg" );
		gallery.loadimage( "gfx/gallery025.jpg" );
		gallery.loadimage( "gfx/gallery000.jpg" );
	contactus = new series( "contactus", 75, "nav" );
		contactus.loadimage( "gfx/contactus100.jpg" );
		contactus.loadimage( "gfx/contactus075.jpg" );
		contactus.loadimage( "gfx/contactus050.jpg" );
		contactus.loadimage( "gfx/contactus025.jpg" );
		contactus.loadimage( "gfx/contactus000.jpg" );

	document.getElementById("nav").style.visibility="visible"
	document.getElementById("content").style.visibility="visible"
	document.getElementById("canvas").style.visibility="visible"
	document.getElementById("load").style.visibility="hidden"

	if(g_galleryMode) {
		if(IE5) {
			sf0 = new stripFaderObject(200,50,"h","transparent","solid 0px #cc0","0px")
			sf0.pixgap=50
			sf0.pixwidth=400
			sf0.pixheight=20
			sf0.sweetspot=0
			sf0.s=50
		    sf0.addpic("gfx/blank.gif")		
		    sf0.addpic("gfx/gallery_spacer.gif")		
		    sf0.addpic("gfx/gallery_spacer.gif")		
		    sf0.addpic("gfx/gallery_spacer.gif")		
		    sf0.addpic("gfx/gallery.gif")		
		    sf0.addpic("gfx/blank.gif")
		}
		document.getElementById("thumbpage").style.visibility="visible"
		g_page=4
		gallery.fall('GALLERY',0)
		window.status='Gallery'
		init_gallery()
	} else if(g_portfolioMode) {
		g_page=3
		portfolio.fall('PORTFOLIO',0)
		window.status='Portfolio'
	} else {

		buds = new series( "buds", 75, "budsDiv" );
			buds.loadimage( "gfx/threebuds_all.jpg" );
			buds.loadimage( "gfx/threebuds_lanie.jpg" );
			buds.loadimage( "gfx/threebuds_wella.jpg" );
			buds.loadimage( "gfx/threebuds_rocena.jpg" );

		if(IE5) {
			sf0 = new stripFaderObject(300,50,"h","transparent","solid 0px #cc0","0px")
			sf0.pixgap=50
			sf0.pixwidth=200
			sf0.pixheight=20
			sf0.sweetspot=0
			sf0.s=50
		    sf0.addpic("gfx/blank.gif")		
		    sf0.addpic("gfx/aboutus.gif")		
		    sf0.addpic("gfx/services.gif")		
		    sf0.addpic("gfx/portfolio.gif")		
		    sf0.addpic("gfx/gallery.gif")		
		    sf0.addpic("gfx/contactus.gif")
		}
	
		document.getElementById("page0").style.visibility="visible"
		document.getElementById("page1").style.visibility="visible"
		document.getElementById("page2").style.visibility="visible"
		document.getElementById("page3").style.visibility="visible"
		document.getElementById("page4").style.visibility="visible"
		document.getElementById("page5").style.visibility="visible"

		var initPage = document.location.href.slice(-1)
//		alert( "href = \""+document.location.href+"\"  initial page = "+initPage )
		if(initPage>=0 && initPage<g_numdivs) {
			g_page = initPage
		} else {
			g_page = 0
		}
		xshowDiv(g_page)

		q = new textFader(document.getElementById("quotesDiv"),10000)
		q.loadItem( "Autumn is a second spring when every leaf is a flower. ~Albert Camus" )
		q.loadItem( "The Amen of nature is always a flower.  ~Oliver Wendell Holmes" )
		q.loadItem( "There are always flowers for those who want to see them.  ~Henri Matisse" )
		q.loadItem( "Life is the flower for which love is the honey.  ~Victor Hugo" )
		q.loadItem( "Earth laughs in flowers. ~Ralph Waldo Emerson" )
		q.loadItem( "Every flower is a soul blossoming in nature.  ~Gerard de Nerval" )
		q.loadItem( "All my life I have tried to pluck a thistle and plant a flower wherever the flower would grow in thought and mind. ~Abraham Lincoln" )
		q.loadItem( "The earth laughs in flowers.  ~E. E. Cummings" )
		q.loadItem( "Flowers are happy things.  ~P. G. Wodehouse" )
		q.loadItem( "Flowers are the sweetest things God ever made, and forgot to put a soul into.  ~Henry Beecher" )
		q.loadItem( "Flowers... are a proud assertion that a ray of beauty outvalues all the utilities of the world.  ~Ralph Waldo Emerson" )
		q.loadItem( "Tis my faith that every flower Enjoys the air it breathes!  ~William Wordsworth" )
		q.loadItem( "Flowers seem intended for the solace of ordinary humanity.  ~John Ruskin" )
		q.loadItem( "The flower is the poetry of reproduction.  It is an example of the eternal seductiveness of life.  ~Jean Giraudoux" )
		q.loadItem( "I perhaps owe having become a painter to flowers.  ~Claude Monet" )
		q.loop()
		document.getElementById("quotesDiv").style.visibility="visible"
	}
}

function stripFaderObject(xinit, yinit, orientation, bgcolor, border, border2) {

	this.numpix=0
	if(!(this.orientation=orientation)) this.orientation="h"
	this.fade=true
	this.pixgap=5
	this.pixwidth=100
	this.pixheight=100
	this.sweetspot=0
	this.a=100
	this.s=50
	if(!bgcolor) this.bgcolor="transparent" 
	else this.bgcolor=bgcolor
	if(!border) this.border="0px solid red"
	else this.border=border
	if(!border2) this.imgborder="0px solid green"
	else this.imgborder=border2
	this.pixObj = new Array()
	this.IE5=this.NN6=false
	if(document.all)this.IE5=true
	else if(document.getElementById)this.NN6=true
	this.hx=xinit
	this.hy=yinit
	this.constrainX=false
	this.constrainY=false
	this.timer=null
	this.speed=10
	this.active=false
	this.decay = 5
	this.gotopicxy = gotoPicxy
	this.chase = chaseTo
	this.show = showDiv
	this.hide = hideDiv
	this.setzindex = setZindex
	this.getzindex = getZindex
	this.getx = getX
	this.gety = getY
	this.setx = setX
	this.sety = setY
	this.getwidth = getWidth
	this.getheight = getHeight
	this.setwidth = setWidth
	this.setheight = setHeight
	this.warp = warpTo
	this.clearall = clearAll
	this.doalpha = doAlpha
	this.addpic = addPic
		document.getElementById("canvas").appendChild(this.obj=document.createElement("DIV"))
		with(this.obj.style) {
			position="absolute"
			left=this.hx+"px"
			top=this.hy+"px"
			width=this.pixwidth+2*this.pixgap+1+"px"
			height=this.pixheight+2*this.pixgap+1+"px"
			border=this.border
			backgroundColor=this.bgcolor
			zIndex=0
			overflow="hidden"
		}
		this.obj.name = "sf"+g_numsfobj
	g_numsfobj++
}

function addPic(picname) {
	this.obj.appendChild(this.pixObj[this.numpix]=document.createElement("DIV"))
	this.pixObj[this.numpix].id="P"+this.numpix
	this.pixObj[this.numpix].appendChild(document.createElement("<img src='"+picname+"' width='"+this.pixwidth+"' height='"+this.pixheight+"' alt='' border='0'>"))
	with(this.pixObj[this.numpix].style) {
		position="absolute"
		width=this.pixwidth+"px"      // IE5 and IE6 are at variance here.
		height=this.pixheight+"px"     // IE5 and IE6 are at variance here.
		if(this.orientation=="h") {
			top=this.pixgap+"px"
			left=(this.pixwidth*this.numpix)+(this.pixgap*this.numpix)+"px"
		} else {
			top=(this.pixheight*this.numpix)+(this.pixgap*this.numpix)+"px"
			left=this.pixgap+"px"
		}
		border=this.imgborder
		if(IE5)filter="alpha(opacity=100)" 
		if(NN6)MozOpacity=1
	}

	this.pixObj[this.numpix].getx = function() { 
		if(parent.IE5)return parseInt(this.style.pixelLeft)
		else if(parent.NN6)return parseInt(this.style.left)
	}
	this.pixObj[this.numpix].gety = function() { 
		if(parent.IE5)return parseInt(this.style.pixelTop)
		else if(parent.NN6)return parseInt(this.style.top)
	}
	this.pixObj[this.numpix].setopacity = function(c) {
		if(this.filters && parent.IE5) this.filters.alpha.opacity = c
		else if(typeof this.style.MozOpacity && parent.NN6) this.style.MozOpacity = c/100
	}
	this.numpix++
	if(this.orientation=="h") {
		this.setwidth(this.numpix*(this.pixwidth+this.pixgap))
		this.setheight(this.pixheight+2*this.pixgap+1)
	} else {
		this.setwidth(this.pixwidth+2*this.pixgap+1)
		this.setheight(this.numpix*(this.pixheight+this.pixgap))
	}
	this.warp(this.hx,this.hy)
}

function clearAll() {
	clearTimeout(this.timer)
}
function getX() {
	if(this.IE5)return parseInt(this.obj.style.pixelLeft)
	else if(this.NN4)return parseInt(this.obj.style.left)
	else if(this.NN6)return parseInt(this.obj.style.left)
}
function getY() {
	if(this.IE5)return parseInt(this.obj.style.pixelTop)
	else if(this.NN4)return parseInt(this.obj.style.top)
	else if(this.NN6)return parseInt(this.obj.style.top)
}
function setX(x) {
	if(!this.constrainX) {
		if(this.IE5)this.obj.style.pixelLeft=x
		else if(this.NN4)this.obj.style.left=x
		else if(this.NN6)this.obj.style.left=x + "px"
	}
}
function setY(y) {
	if(!this.constrainY) {
		if(this.IE5)this.obj.style.pixelTop=y
		else if(this.NN4)this.obj.style.top=y
		else if(this.NN6)this.obj.style.top=y + "px"
	}
}
function getWidth() {
	return this.id.offsetWidth
}
function getHeight() {
    return this.id.offsetHeight
}
function setWidth(w) {
	this.obj.style.width=w
}
function setHeight(h) {
	this.obj.style.height=h
}
function showDiv() {
	this.obj.style.visibility="visible"
}
function hideDiv() {
	this.obj.style.visibility="hidden"
}
function setZindex( z ) {
	this.obj.style.zIndex = z
}
function getZindex() {
	return this.obj.style.zIndex
}
function warpTo(x,y) {
	if(this.active)clearTimeout(this.timer)
	if(this.IE5) {
		this.obj.style.pixelLeft=x
		this.obj.style.pixelTop=y
	} else if(this.NN4) {
		this.obj.style.moveTo(x,y)
	} else if(this.NN6) {
		this.obj.style.left = x + "px"
		this.obj.style.top = y + "px"
	}
	if(this.fade)this.doalpha()
}
function chaseTo( x, y ) {
	if(this.active)clearTimeout(this.timer)
	dx=x-this.getx()
	dy=this.gety()-y
	distance=Math.round(Math.sqrt(dx*dx+dy*dy))
	if(dx==0) angle=Math.PI*((dy>0)?.5:1.5)
	else angle=Math.atan(dy/dx)+(Math.PI*((dx<0)?1:(dy<0)?2:0))
	xstep=(dx>1)?Math.ceil(distance*Math.cos(angle)/this.decay):Math.floor(distance*Math.cos(angle)/this.decay)
	ystep=(dy<1)?Math.ceil(-distance*Math.sin(angle)/this.decay):Math.floor(-distance*Math.sin(angle)/this.decay)
	this.setx(this.getx()+xstep)
	this.sety(this.gety()+ystep)
	if(this.fade)this.doalpha()
	if( distance>1 ) {
		this.active=true
		this.timer=setTimeout(this.obj.name+".chase("+x+","+y+")", this.speed)
	} else {
		clearTimeout(this.timer)
		this.warp(x,y)
		this.active=false
	}
}

function doAlpha() {
	for(i=0; i<this.numpix; i++) {
		x=Math.abs( this.sweetspot-this.getx()-this.pixObj[i].getx() )
		o=this.a*Math.exp((-x^2)/this.s) 
		this.pixObj[i].setopacity(Math.abs(o))
	}
}

function gotoPicxy(which,x,y) {
	if(which>=this.numpix)which=this.numpix-1
	if(which<0)which=0
	this.sweetspot = x
	this.chase( this.sweetspot-this.pixObj[which].getx(), y-this.pixgap)
}

function xshowDiv( which ) {

	if(IE5) sf0.gotopicxy(which,g_xloc,g_yloc);

	if(which>g_numdivs-1)which=g_numdivs-1

	for(i=0;i<g_numdivs;i++) {
		eval("document.getElementById('page"+i+"').style.visibility='hidden'")
	}
	eval("document.getElementById('page"+which+"').style.visibility='visible'")

	if(which==1 && g_page!=1) aboutus.fall('ABOUTUS',0)
	if(which==2 && g_page!=2) services.fall('SERVICES',0)
	if(which==3 && g_page!=3) portfolio.fall('PORTFOLIO',0)
	if(which==4 && g_page!=4) gallery.fall('GALLERY',0)
	if(which==5 && g_page!=5) contactus.fall('CONTACTUS',0)
	if(which!=g_page) {
		if(g_page==1) aboutus.rise('ABOUTUS',0)
		if(g_page==2) services.rise('SERVICES',0)
		if(g_page==3) portfolio.rise('PORTFOLIO',0)
		if(g_page==4) gallery.rise('GALLERY',0)
		if(g_page==5) contactus.rise('CONTACTUS',0)
	}
	g_page=which

	if(g_page==1) aboutus.fall('ABOUTUS',0)
	if(g_page==2) services.fall('SERVICES',0)
	if(g_page==3) portfolio.fall('PORTFOLIO',0)
	if(g_page==4) gallery.fall('GALLERY',0)
	if(g_page==5) contactus.fall('CONTACTUS',0)
}

onload=initialize

function series( objectName, rate, divString ) {
	this.IE5=this.NN4=this.NN6=false
	if(document.all)this.IE5=true
	else if(document.layers)this.NN4=true
	else if(document.getElementById)this.NN6=true

	this.objname  = objectName
	this.rate = rate
	this.divname = divString
	this.imageindex = -1
	this.numimages = 0
	this.stopall = false
	this.timer = null
	this.img = new Array()
	this.loadimage = loadImg
	this.showimage = showImg
	this.rise = Rise
	this.fall = Fall
}

function Fall( placement, delay ) {
	for( k=1; k<this.numimages; k++, delay++ ) {
		this.timer=setTimeout( this.objname+".showimage('"+placement+"','"+k+"')", delay*this.rate );
		this.imageindex=k;
	}
	return delay;
}

function Rise( placement, delay ) {
	for( k=this.numimages-2; k>=0; k--, delay++ ) {
		this.timer=setTimeout( this.objname+".showimage('"+placement+"','"+k+"')", delay*this.rate );
		this.imageindex=k;
	}
	return delay;
}

function showImg( placement, imagenum ) {
	if( imagenum<this.numimages ) document.getElementById(placement).src=this.img[imagenum].src;
	this.imageindex=imagenum;
}

function loadImg( source ) {
	this.img[this.numimages] = new Image();
	this.img[this.numimages].src = source;
	this.numimages++;
}

