function init() {
	smartRollover();
	bgChange();
}


/*smoothscroll*/

var pointTOP=0;

function ECOGetVersion(){
if (navigator.userAgent.indexOf('Mac',0) != -1){ useos='Mac';}
else if (navigator.userAgent.indexOf('Win',0) != -1){ useos='Win';}
else {useos='other'; }
if (navigator.userAgent.indexOf('MSIE 3.',0) != -1){usebrowser='IE3';}
else if (navigator.userAgent.indexOf('MSIE 4.',0) != -1){usebrowser='IE4';}
else if (navigator.userAgent.indexOf('MSIE 5.',0) != -1){usebrowser='IE5';}
else if (navigator.userAgent.indexOf('MSIE 6.',0) != -1){usebrowser='IE6';}
else if (navigator.userAgent.indexOf('MSIE 7.',0) != -1){usebrowser='IE7';}
else if (navigator.userAgent.indexOf('Netscape/7.',0) != -1){usebrowser='NN7';}
else if (navigator.userAgent.indexOf('Netscape/6.',0) != -1){usebrowser='NN6';}
else if (navigator.userAgent.indexOf('Mozilla/4.',0) != -1){usebrowser='NN4';}
else if (navigator.userAgent.indexOf('Firefox',0) != -1){usebrowser='Firefox_NN';}
else if (navigator.userAgent.indexOf('Gecko',0) != -1){usebrowser='other_Gecko_NN';}
else {usebrowser='other_IE';}
return (usebrowser);
}

function ECOpagemove(Y){
ua=ECOGetVersion();
if ( ua.indexOf('IE',0)!= -1){ 
	if ( document.compatMode == 'CSS1Compat'){ nowY=document.documentElement.scrollTop; }
	else{ nowY=document.body.scrollTop; }
windowY=document.body.clientWidth
}
else if ( ua.indexOf('NN',0)!= -1){
nowY=window.pageYOffset;
windowY=window.innerWidth;
}
else { return(0,0) ; }
if (Y < nowY){ setTimeout("Lscroll("+Y+","+nowY+")",20); }
else{ setTimeout("Rscroll("+Y+","+nowY+")",8); }
}

function Lscroll(Y,nowY){
if (Y >= nowY)return;
moveY = Math.ceil( (nowY - Y) * 0.16)+2;
if (Y >= (nowY-moveY)){moveY=nowY-Y;}
scrollBy(0,-moveY);
nowY=nowY-moveY;
setTimeout("Lscroll("+Y+","+nowY+")",20);
}

function Rscroll(Y,nowY){
if (Y <= nowY)return;
moveY = Math.ceil( (Y - nowY) * 0.16)+2;
if (Y <= (nowY+moveY)){moveY=Y-nowY;}
scrollBy(0,moveY);
nowY=nowY+moveY;
setTimeout("Rscroll("+Y+","+nowY+")",20);
}


/*background change*/

function bgChange(){
	if(!document.getElementById("wrapper")){
		return;
	}
	var images = ["./images/wrapper1.jpg", "./images/wrapper2.jpg", "./images/wrapper3.jpg", "./images/wrapper4.jpg", "./images/wrapper5.jpg", "./images/wrapper6.jpg"];
	var ix = Math.floor(Math.random() * images.length);
	document.getElementById("wrapper").style.backgroundImage = "url(" + images[ix] + ")";
	document.getElementById("wrapper").style.backgroundRepeat='no-repeat';
	document.getElementById("wrapper").style.backgroundPosition='center top';
}

function getC(k){
	if (document.cookie.length!=0){ var C=document.cookie.split(";");
		for(i=0;i<C.length;i++){ var p=C[i].split("=");
			if(p[0]==k) return p[1];
		} } return "0";
}
function setC(k,t){ document.cookie=k+"="+t+";"}
function bgChanger(X,N,G,S){
	var R=getC(X); var RR=new Array();
	for(i=0;i<N-1;i++){
		if(R=="0"){RR[i]=0} else {RR[i]=R.split("/")[i]}
	}
	var n=0;
	while(n==0){ n=(Math.floor(Math.random()*N)+1)
		for(i=0;i<N-1;i++){ if(RR[i]==n) n=0;
	} }
	var F ="url(./images/"+ X + n+"."+G+") "+S;
	document.getElementById(X).style.background=F;
	F=""+n;  for(i=0;i<N-2;i++){ F+=("/"+RR[i]) }
	setC(X,F)
}


/*hover box*/

var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"

var bouncelimit=8 //(must be divisible by 8)
var direction="up"

function initbox(){
if (!dom&&!ie&&!ns4)
return
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-250+calunits
crossobj.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropin()",50)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<100+scroll_top)
crossobj.top=parseInt(crossobj.top)+40+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)
}
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


/*roll over*/

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_out."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_out.", "_over."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_over.", "_out."));
				}
			}
		}
	}
}

window.onload=init;