﻿//
var size=-1,time,obj,t,load;
function stripFileName (f) {
	var index=0,str;
		
		while (f.indexOf('/',index)>=0) {	
			index=f.indexOf('/',index)+1;
		}
			
	str=f.slice(index);	
	return str;
} // eo stripFileName
 // showing the images of the gallery
function gallery (pics) {
	gllry=document.getElementById('gallery');
	//alert(g[1]);
	
	for (i=1;i<=3;i++) {gllry.innerHTML+='<img src="'+pics[i]+'" alt="'+stripFileName(pics[i])+'" title="'+stripFileName(pics[i])+'" onmouseover="rise(this)" onmouseout="fall(this)" />';}
} //eo gallery

function rise (ob) {
	if((size<0 || !size) && ob){
		size=15;
		obj=ob;
		obj.style.width=100+'px';
		rise(obj);}
	else if (size>0 && obj) {
		size-=3;
		//time=12-Math.round((Math.log(size+2)/Math.log(12))*10); // Poor attempt to implement some maths into the effects of the gallery 
		obj.style.width=100+(15-size)*2+'px';
		obj.style.margin=(size+15)+'px';
		t=setTimeout("rise()",3);	
}
	else {
		clearTimeout(t);
		size=-1; 
		}
} // eo rise

function fall(ob) {
	obj=ob;
	obj.style.width=100+'px';
	clearTimeout(t);
	obj.style.margin=30+'px';
	size=-1; 
} // eo fall

function moveContent(l,b) {
	var s=document.getElementById('smartadd');
	if (b && Math.abs(parseInt(s.style.left))<s.scrollWidth-20-l*3) {
		s.style.left=parseInt(s.style.left)-l+"px";
		
	} else if (!b && parseInt(s.style.left)<-5) {
		s.style.left=parseInt(s.style.left)+l+"px";
	}
}

function showArrows() {
	l=document.getElementById('lft');
	r=document.getElementById('rght');
	l.style.visibility='visible';
	r.style.visibility='visible';
}

function hideArrows() {
	l=document.getElementById('lft');
	r=document.getElementById('rght');
	l.style.visibility='hidden';
	r.style.visibility='hidden';
}

var c=0,z=1;

function appr () {
	if (c<=1) {
	
		fTxt.style.opacity=c;
		c+=0.05;
		setTimeout("appr()", 100);
	}
	
	else {c=0;}
}// eo appr

function disappear() {

// if (navigator.appName == 'Microsoft Internet Explorer' && z==1) frst.style.zoom=1;
	 if (z>=0) {
		frst.style.opacity=z;
		frst.style.filter='alpha(opacity='+z*100+')'; // IE!
		z-=0.05;
		setTimeout("disappear()", 80);

	}
	else {
		z=1;
		document.body.removeChild(frst);
	}
} //eo disappear

// onload function
Loaded = function() {
// assigning common names
fTxt=document.getElementById('ftext'); //The link 
fChild=document.getElementById('fc');	// SWF animation
frst=document.getElementById('first'); 	// The DIV containing the link and the SWF
if (!location.hash && frst) {

fTA=fTxt.childNodes[5];
fTxt.style.opacity=0;


// place SWF in the center

frst.style.height=screen.availHeight+'px'; // frst.height=screen.height

var h=parseInt(frst.style.height.replace('px',''), 10); //h=frst.height 
var h2=fChild.offsetHeight;								//h2=height of SWF
var h3=document.getElementById("ftext").offsetHeight; 	//h3=height of link
h=(h-h2)/2-h3;
fChild.style.position='relative';
fChild.style.top=h+'px';

// display link to main page
 appr(); } 
 else if (!frst) {}
 else { document.body.removeChild(frst); }
 // smartAdd functions
var sadd=document.getElementById('smartadd');
if (sadd) {
	var d=0,l;
	for (var i=0; i<sadd.childNodes.length;i++) {
		if (sadd.childNodes[i].className=="smartbox") {d++;l=sadd.childNodes[i].scrollWidth+10;}
	}
	sadd.style.width=d*l+20+"px";
	if (navigator.userAgent.indexOf('MSIE 6.0')!= -1 || navigator.userAgent.indexOf('MSIE 7.0') != -1) sadd.style.left=5+"px";
	else sadd.style.left=-5+"px";
	
	if (sadd.scrollWidth-20>l*3) {
		document.getElementById('rght').onclick= function () { moveContent(l,1);}
		document.getElementById('lft').onclick= function () { moveContent(l,0);}
		sadd.parentNode.onmouseover=function () { showArrows();}
		sadd.parentNode.onmouseout=function () { hideArrows();}
		}
}
 // Call gallery if needed
 if (document.getElementById('gallery')) gallery(g);
// umenu functions
menu=document.getElementById('ulMenu');
function onOver () {
var x=(navigator.userAgent.indexOf('MSIE 6.0')!= -1 || navigator.userAgent.indexOf('MSIE 7.0') != -1) ? 2 : 1;
if (this.childNodes.length>x) this.childNodes[2].className=this.childNodes[2].className.replace('off','');
this.childNodes[0].style.backgroundColor='rgb(160,3,1)';
} //eo onOver
function onOut () {
var x=(navigator.userAgent.indexOf('MSIE 6.0')!= -1 || navigator.userAgent.indexOf('MSIE 7.0') != -1) ? 2 : 1;
if (this.childNodes.length>x) this.childNodes[2].className='off';
this.childNodes[0].style.backgroundColor='rgb(110,0,0)';
} //eo onOut
// assign functions to mouseover and mouseout
for (var i=0;i<menu.childNodes.length; i++) {
var node=menu.childNodes[i];
// center umenu
var y=(navigator.userAgent.indexOf('MSIE 6.0')!= -1 || navigator.userAgent.indexOf('MSIE 7.0') != -1) ? 2 : 1;
if (typeof(node) !== 'null' && typeof(node) !== 'undefined' && node.childNodes.length>y) {
var x=(typeof(node.childNodes[2])==='undefined') ? 0 : 2;

node.childNodes[x].className=node.childNodes[x].className.replace('off','');
var w=node.childNodes[x].scrollWidth;
w=(73-w/2)+14;
node.childNodes[x].style.marginLeft=w+"px";
node.childNodes[x].className='off';
}
node.onmouseover= function () {
onOver.call(this);
}
node.onmouseout= function () {
onOut.call(this);
}
}


}
window.onload = Loaded;
