// easing equations copyright www.robertpenner.com
var easings={"back":{"InOut":function(t,b,c,d,s){ if(!s)s=1.70158; if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b; return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b; }},"quart":{"InOut":function(t,b,c,d){ if((t/=d/2)<1)return c/2*t*t*t*t+b; return -c/2*((t-=2)*t*t*t-2)+b; },"In":function(t,b,c,d){ return c*(t/=d)*t*t*t + b; },"Out":function(t,b,c,d){ return -c*((t=t/d-1)*t*t*t-1)+b; }},"quint":{"InOut":function(t,b,c,d){ if((t/=d/2)<1)return c/2*t*t*t*t*t+b; return c/2*((t-=2)*t*t*t*t+2)+b; }}};

function Slider(el,tp1,tp2,tp3,aX,oX,dur){
	this.el=el; this.b=aX; this.c=oX; this.tp1=tp1; this.tp2=tp2; this.d=dur; this.css=tp3; this.calc=easings[tp1][tp2]; this.off=0;
	
	this.setMove=function(){
		switch(this.css){
			case "clipLeft": this.move=function(x){ this.el.style['clip']="rect(0 auto auto "+x+"px)"; }; break;
			case "clipRight": this.move=function(x){ this.el.style['clip']="rect(0 "+x+"px auto 0)"; }; break;
			case "scrollTop": this.move=function(x){ window.scrollTo(0,x); }; break;
			default: this.move=function(x){ this.el.style[this.css]=x+"px"; if(this.css2)this.el.style[this.css2]=(this.b2+(x-this.b)*this.rel)+"px"; }
		}
	}
	this.setMove();
	this.setTypes=function(tp1,tp2,tp3){ this.calc=easings[tp1][tp2]; this.css=tp3;	this.setMove(); }
	this.setValues=function(aX,oX,dur){ this.b=aX; this.c=oX; this.d=dur; }
	this.setDur=function(dur){ this.d=dur; }
	this.setCss=function(tp3,aX,oX){ this.css2=tp3; this.b2=aX; this.rel=oX/this.c; }
	this.reset=function(){
		switch(this.css){
			case "clipRight": case "clipLeft": this.el.style['clip']="rect(auto auto auto auto)"; break;
			case "scrollTop": window.scrollTo(0,this.b); break;
			default: this.el.style[this.css]=this.b+"px";
		}
	}
	this.setCmd=function(cmd){ this.cmd=cmd; }
	this.setCall=function(call){ this.call=call; }
	this.setOff=function(off){ this.off=off; }
	this.getSecs=function(){ return new Date().getTime(); }
	this.go=function(rev){
		this.rev=rev;
		if(this.to)clearTimeout(this.to);
		if(this.tp2!="InOut")this.setTypes(this.tp1,this.tp2.match(/In/)?(this.rev?"Out":"In"):(this.rev?"In":"Out"),this.css);
		this.startT=this.getSecs()-this.off; this.maxX=this.rev?this.b:this.b+this.c;
		if(this.call){
			this.call.slider.startT=this.startT;
			this.call.slider.rev=rev; this.call.slider.setDur(this.d);
			this.call.slider.maxX=this.rev?this.call.slider.b:this.call.slider.b+this.call.slider.c;
		}
		this.ease();
	}
	this.ease=function(callee){
		if(callee)this.nt=callee; else{ this.nt=(this.getSecs()-this.startT)/10; if(!this.nt)this.nt=0.1; if(this.rev)this.nt=this.d-this.nt; }
		this.tmpX=this.calc(this.nt,this.b,this.c,this.d);
		if(this.nt>0 && this.nt<this.d){
			if(!callee)this.to=setTimeout("get('"+this.el.id+"').slider.ease()"
				+(this.call?("; get('"+this.call.id+"').slider.ease("+this.nt+")"):""),10);
		}else{
			clearTimeout(this.to); this.startT=0; this.tmpX=this.maxX;
			this.to=this.cmd?setTimeout(this.cmd,10):0;
		}
		this.move(this.tmpX);
	}
}



function base(){
	var agent=navigator.userAgent.toLowerCase(), mimes=navigator.mimeTypes;
	this.wp=window.parent;
	this.wt=window.top;
	this.op=window.opera;
	this.oldop=this.op&&agent.match(/opera\W?[34567]/);
	this.ie=agent.match(/msie/)&&!this.op;
	this.saf=0;//agent.match(/safari/);
	this.mac=agent.match(/mac/);
	this.ie5=this.ie&&agent.match(/msie\s5/);
	this.ie50=this.ie&&agent.match(/msie\s5\.0/);
	this.ie55=(this.ie5 && agent.match(/msie\s5\.5/));
	this.moz=agent.match(/gecko/);
	this.oldmoz=agent.match(/rv\:1\.[01234](\.\d)?\)\Wgecko/);
	this.ns6=agent.match(/netscape\D?6/);
	this.osx=this.mac&&(this.saf||agent.match(/5\.22|os\s?x/));
	this.fox=agent.match(/firefox/);
	this.ief=this.ie&&!this.ie50;
	this.isn=this.ie50||this.saf||this.ns6||this.op;
	this.cantscroll=(this.mac&&!this.osx||this.mac&&this.ie);
	this.oldsaf=this.saf&&agent.match(/safari\W8/i);
	this.server=this.wt.location.href.match(/(.*)\/([^\/]+)?$/);
	this.local=new RegExp(this.server[1].replace(/([\.\/\\])/g,"\$1"));
	this.email=new RegExp("^[a-z0-9\.\_\!\#\$\%\&\'\`\*\+\/=\?\^\_\{\|\}\~\-]+\@([a-z0-9\-]+[\.])+[a-z]{2,}$","i");
	this.loaded=0;
	this.oscrT=0;
}
var bw=new base(),curr={"z":5,"box":0}, e=0, dMenu=0, mTo=0;
if(bw.ie5&&bw.mac||bw.oldop)bw.text=1;

document.write('<style type="text/css">.box,.postit{visibility:hidden}</style>');

if(bw.ns6)document.write('<style type="text/css">.r{float:right !important} #box2{width:295px !important} #box10{width:599px !important}</style>');

function showDIV(el,tp){ el.style.visibility=tp?"visible":"hidden"; }
function get(el){ return document.getElementById(el); }
function gets(el,par){ return par.getElementsByTagName(el); }
function make(el){ return document.createElement(el); }
function blurit(){ this.blur(); }
function px(nr){ return nr+"px"; }
function getWinSize(){
	if(typeof(window.innerWidth)=='number'){ bw.winW=window.innerWidth; bw.winH=window.innerHeight; }
	else{ winel=bw.dd&&bw.dd.clientWidth?bw.dd:bw.db; bw.winW=winel.clientWidth; bw.winH=winel.clientHeight; }
}
function getScrollTop(){
	var x=0, y=0;
	if(bw.dd && bw.dd.scrollTop){ x=bw.dd.scrollLeft; y=bw.dd.scrollTop; }else if(bw.db && bw.db.scrollTop){ x=bw.db.scrollLeft; y=bw.db.scrollTop; }else if(window.pageYOffset){ x=self.pageXOffset; y=self.pageYOffset; }else if(window.scrollY){ x=window.scrollX; y=window.scrollY; }
	bw.scrL=x; bw.scrT=y;
}

//=====================================================drag
zI=8; popT=popL=0; 
popDown=function(e){
	this.style.zIndex=++zI;
	trg=e?e.target:event.srcElement;
	showDIV(get("DIVdrag"),0); this.onmousemove=this.onmouseout=null; bw.drag=1;
	if(!trg.tagName.match(/a/i)){
		getScrollTop(); bw.pop=this;
		popT=popL=0; popMouse(e); popL=popX-parseInt(this.offsetLeft); popT=popY-parseInt(this.offsetTop);
		document.onmousemove=popMove; document.onmouseup=popUp; _Vdrag=true; return false;
	}
}
popMove=function(e){
	popMouse(e); bw.pop.style.top=px(popY); bw.pop.style.left=px(popX>0?popX:0); if(document.all)return false;
}
popUp=function(){
	nX=nY=0;
	if(popX<-255)nX=-255; /*if(popY<0)nY=1;*/ //if(popX>winX-80)nX=winX-90;
	if(nY)bw.pop.style.top=px(nY); if(nX)bw.pop.style.left=px(nX);
	document.onmousemove=document.onmouseup=function(){return false}; _Vdrag=false; return true;
}
popMouse=new Function("e","popY=("+(document.all?"event.clientY+bw.scrT":"e.pageY")+")-popT; popX=("+(document.all?"event.clientX+bw.scrT":"e.pageX")+")-popL");
clickNdrag=function(e){
	if(bw.drag)return; popMouse(e); showDIV(get("DIVdrag"),1); get("DIVdrag").style.left=px(popX+10); get("DIVdrag").style.top=px(popY+20); if(document.all)return false;
}

ipat=/imgs\/[^\.]+\.\w{3}/; apat=/([^\/]+)\.html/; conts=[]; cl=["t","l","img","r","b","b2"]; prts={'10':1,'20':1,'21':3,'22':3,'23':5,'30':1,'40':1,'50':1,'60':3,'61':2,'62':2,'63':2,'70':3,'80':1,'210':3,'220':3,'230':5};
pgs={'10':3,'210':3,'220':1,'230':2,'30':33,'40':3,'50':3,'60':1,'61':16,'62':9,'63':18,'70':3,'80':23}; pos={'1':[470,7],'2':[220,290],'3':[460,360],'4':[610,200],'5':[610,55],'6':[380,80],'7':[290,180],'8':[100,280],'10':[135,0],'20':[0,0],'21':[210,-250],'22':[0,-300],'23':[-220,-250],'30':[0,0],'40':[0,0],'50':[-7,-2],'60':[1,-1],'61':[-169,-81],'62':[-66,-70],'63':[-129,-47],'70':[219,-5],'80':[0,0],'210':[7,-9],'220':[7,-9],'230':[7,-9]}; sliders=[];
btypes=[]; boxs=[];



cats={"10":'inspiration',"20":'product',"21":'africa',"22":'bruised',"23":'japanese',"210":'africa',"220":'bruised',"230":'japanese',"30":'press',"40":'store',"50":'contact',"60":'collection',"70":'prps',"80":'who'};
ii=-1; IMGpre=[];
preBox=[1,2,3,4,5,6,7,8,10,20,21,22,23,30,40,50,60,61,62,63,70,80,210,220,230];

for(b=0;b<preBox.length;b++){
	boxnr=preBox[b];
	card=boxnr>60&&boxnr<70; sub=boxnr>20&&boxnr<30;
	for(i=0;i<(boxnr==60?6:5);i++){
		parts=cl[i]=="img"&&(sub||boxnr>9)?prts[boxnr]:1;
		tp=boxnr<10||sub?cats[boxnr*10]:(card?"card"+(boxnr-60):cats[boxnr]);
		for(p=1;p<=parts;p++){
			if(cl[i]=="img"||(boxnr<62||boxnr>63))IMGpre[++ii]=(card&&cl[i]!="img"?"card":tp)+(card?"_":(boxnr<10||sub?"_cl_":"_op_"))+cl[i]+(cl[i]=="img"&&boxnr>9&&!sub?("_"+p):"")+(cl[i]=="img"?".jpg":".png");
		}
	}
}

IMGnr=IMGes=IMGpre.length;//+(bw.ief?7:0);
iimg=[];


function Box(boxnr,tp){ 
	this.id="box"+boxnr; this.nr=boxnr;
	this.el=get(this.id); this.el.onmousedown=popDown;
	this.slt=this.el.offsetTop; this.sll=this.el.offsetLeft;
	this.height=this.el.offsetHeight;
	this.width=this.el.offsetWidth;
	if(tp){
		this.type=tp; 
		if(this.type=="card"){
			this.card=1; this.parentBox=boxs[60];
			this.slt=this.parentBox.slt-pos[boxnr][1];
			this.el.style.left=px(this.parentBox.sll-pos[boxnr][0]);
		}else if(this.type=="sub"){
			this.sub=1; this.parentBox=boxs[20];
			this.slt=this.parentBox.slt-pos[boxnr][1]; if(this.nr==20)alert(this.slt)
			this.el.style.left=px(this.parentBox.sll-pos[boxnr][0]);
		}else{
			this.parentBox=boxs[boxnr/10];
			this.slt=boxnr.toString().match(/10|20|30|40|50|60|80/)?this.parentBox.slt:(bw.winH-this.width)/2;
			this.openBox=1;
		}
		if(this.slt<0)this.slt=20;
		this.el.style.zIndex=++zI;
		this.pages=pgs[boxnr];
		if(this.pages>1)this.currPage=1;
	}else{
		this.el.onmousemove=clickNdrag;
		this.el.onmouseout=function(){ showDIV(get("DIVdrag"),0); }
	}
	if((boxnr=="10"||boxnr=="50")&&!bw.saf&&!bw.ns6&&!bw.oldmoz){
		this.el.slider=new Slider(this.el,"quart","InOut","clipRight",1,this.width,10);
		this.parentBox.el.slider.setTypes("quart","InOut","clipLeft");
		this.parentBox.el.slider.setValues(1,this.parentBox.width,40);
		this.el.slider.setCall(this.parentBox.el);
	}else this.el.slider=new Slider(this.el,"quart","InOut","top",-500-this.height,this.slt+this.height+500,this.openBox||this.card||this.sub?0:70);
	this.el.style.top=px(-this.height-50);
	
	this.link=this.doLinks(gets("A",this.el));
	btypes[boxnr]=this.type;
	this.imgs=[]; this.to=0; this.inr=((boxnr==60?6:5))+(this.openBox||this.card?prts[boxnr]-1:0);
	this.zI=this.el.style.zIndex;
	this.divs=[];
	for(i=0;i<(boxnr==60?6:5);i++){
		this.divs[i]=make("div"); this.divs[i].className=cl[i];
		this.el.appendChild(this.divs[i]);
		if(cl[i]=="img")this.idiv=this.divs[i];
		parts=cl[i]=="img"&&(this.openBox||this.card)?prts[boxnr]:1;
		for(p=1;p<=parts;p++){
			this.Image([(this.card&&cl[i]!="img"?"card":this.type)+(this.card?"_":(this.nr<10||this.sub?"_cl_":"_op_"))+cl[i]
				+(cl[i]=="img"&&(this.openBox||this.card)?("_"+p):"")
				+(cl[i]=="img"?".jpg":".png")],cl[i],this.divs[i]);
		}
	}
}
Box.prototype.doLinks=function(as,tp){
	for(l=0;l<as.length;l++){
		a=as[l];
		a.box=this;
		a.onfocus=blurit;
		switch(a.className){
			case "email": break;
			case "close": a.onclick=closePage; break;
			case "turn": a.onclick=turnPage; break;
			case "more": a.onclick=readMore; break;
			case "switch": if(a.id.match(/scroll/))a.onmouseover=a.onmouseout=scrollTBL; else a.onclick=switchPage; break;
			default:
				a.onclick=menu; this.lnk=a;
				lnk=a.href.match(apat);
				conts[lnk[1]]=this.nr;
				this.type=lnk[1];
		}
	}
}
Box.prototype.Image=function(src,tp,elp){
	if(bw.op){
		elp.innerHTML='<img src="imgs/'+(src[0].match(/\.png|_op|card/)?"saf/":"")+src[0]+'" onload="safLoaded('+this.nr+')">';
		return elp.firstChild;
	}else{
		png=bw.ief&&src[0].match(/\.png$/);
		bsrc="imgs/"+(bw.saf&&src[0].match(/\.png/)?"saf/":"")+(bw.ie50?src[0].replace(/\.png/,".gif"):src[0]);
		bimg=iimg[bsrc]; //ie/
		if(png)elp.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="imgs/'+bsrc.replace(/^([^\/]+\/)/,"")+'")';
		else{
			elp.appendChild(this.card && src[0].match(/\.png/)?bimg.cloneNode(false):bimg);
		}
		this.loading();
		return bimg;
	}
}
safLoaded=function(snr){  boxs[snr].loading(); this.onload="return false"; }
Box.prototype.imageLoaded=function(snr){
	this.box.loading(); this.onload=""; 
	if(this.png)this.parent.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="imgs/'+this.nsrc.replace(/^([^\/]+\/)/,"")+'")';
}
Box.prototype.loading=function(){
	this.inr--;
	if(this.inr<1){
		this.loaded=1;
		this.el.slider.setCmd(0)
		if(this.openBox||this.card||this.sub){
			if(this.sub||this.card||this.nr.toString().match(/10|20|30|50|60|80/)){
				if(this.sub||this.nr==60||this.nr==50||this.nr==10||this.nr==20){
					this.slt=this.parentBox.el.offsetTop-pos[this.nr][1]; this.el.style.top=px(this.slt);
				}	
				this.el.style.left=px(this.parentBox.el.offsetLeft-pos[this.nr][0]);
				if(this.nr.toString().match(/20|30|60|80/))this.el.slider.setValues(-500-this.height,this.slt+this.height+500,0);
			}else{
				nW=this.parentBox.el.offsetLeft+this.parentBox.width/2-this.width/2; this.el.style.left=px(nW>0?nW:0);
			}
			this.el.style.zIndex=++zI;
			if(!this.card&&!this.sub&&(this.nr!=50&&this.nr!=10||bw.saf||bw.ns6||bw.oldmoz))this.el.slider.setCmd("showDIV(boxs["+this.parentBox.nr+"].el,0)");
		}
		this.next=this.nr+1;
		showDIV(this.el,1);
		
		if(boxs[this.next])boxs[this.next].loading();
		else if(get("box"+this.next))this.to=setTimeout("boxs["+this.next+"]=new Box("+this.next+(this.next>60&&this.next<70?",'card'":(this.next>20&&this.next<30?",'sub'":""))+")",bw.ie?10:100);
		if(bw.loaded&&(!bw.ie||bw.ieloaded))this.el.slider.go(0); else preLoaded();
		if(this.next==8)showDIV(get("DIVloading"),0);
	}
}
function startIE(){
	bw.ieloaded=1;
	for(y=1;y<9;y++)setTimeout("boxs["+y+"].el.slider.go(0)",y*150);
}

function closePage(){
	this.box.parentBox.el.style.zIndex=zI;
	if(this.box.nr=="60"){
		for(c=61;c<64;c++){ boxs[c].el.style.top=px(-1000); showDIV(boxs[c].el,0); }
	}else if(this.box.nr=="20"){
		for(c=21;c<24;c++){ boxs[c].el.style.top=px(-1000); showDIV(boxs[c].el,0); if(boxs[c*10]){ boxs[c*10].el.style.top=px(-1000); showDIV(boxs[c*10].el,0); } }
	}
	showDIV(this.box.parentBox.el,1);
	this.box.el.slider.setCmd(0);
	this.box.el.slider.go(-1);
	return false;
}
function turnPage(){
	cPage=this.box.currPage;
	nPage=cPage==this.box.pages?1:cPage+1;
	switch(prts[this.box.nr]){
		case 1: case 2: prt=0; break; case 3: prt=1; break; case 5: prt=2; break;
	}
	pimg=this.box.idiv.childNodes[prt]; pimg.onload=null;
	pimg.src=pimg.src.replace(cPage==1?/\.jpg/:/_\d\w?\.jpg/,(nPage>1?("_"+nPage):"")+".jpg");
	this.box.el.className="box page"+nPage;
	this.box.currPage=nPage;
	return false;
}
function readMore(){
	more=this.href.match(/(\d\w?)\.html/i);
	switch(prts[this.box.nr]){
		case 1: prt=0; break; case 3: prt=1; break; case 5: prt=2; break;
	}
	pimg=this.box.idiv.childNodes[prt];
	
	if(this.box.more){
		pimg.src=this.box.more[0]; this.box.el.className=this.box.more[1];
		this.box.more=0;
	}else{
		this.box.more=[pimg.src,this.box.el.className]; this.box.el.className+=" "+more[1].replace(/\d/,"");
		pimg.src=pimg.src.replace(/_\d\w?\.jpg/,"_"+more[1]+".jpg");
	}
	return false;
}
function switchPage(){
	if(!this.box.el.oldClass)this.box.el.oldClass=this.box.el.className;
	this.box.el.className=this.box.el.oldClass+" "+this.id;
	return false;
}
function scrollTBL(){
	this.screl=get(this.box.el.className.match(/2/)?"twomen":"tmen"); this.screl.scrdir=this.id.match(/1/);
	if(!this.screl.h){ this.screl.t=0; this.screl.h=this.screl.offsetHeight-191; }
	if(!this.screl.int)this.screl.int=setInterval("scrollGO(get('"+this.screl.id+"'))",20); else{ clearInterval(this.screl.int); this.screl.int=0; }
}
function scrollGO(el){
	el.t+=2*(el.scrdir?1:-1);
	if(el.t>=0)el.t=0; else if(el.t<=-el.h)el.t=-el.h;
	el.style.top=px(el.t);
}

function menu(){
	opnr=this.box.onr=this.box.nr*10;
	if(boxs[opnr])boxs[opnr].loading();
	else boxs[opnr]=new Box(opnr,this.box.type);
	return false;
	if(bw.loaded&&!dFrame.on){
		if(dMenu.on)showMenu();
		if(!dLoad.blink){ dLoad.blink=1; dLoad.firstChild.style.background="transparent url(imgs/loader_anim.gif) no-repeat"; }
		getScrollTop(); dLoad.style.top=px(bw.scrT>100?bw.scrT+20:120);
		showDIV(dLoad,1);
		if(this.trg)boxs[this.trg].link.onclick();
		else Iload.src=this.href;
	}
	this.blur();
	return false;
}
function rover(el,tp){
	if(!el.onmouseout)el.onmouseout=new Function("rover(this,0)");
	el.className=tp?"lihover":"";
}
function preLoaded(){
	IMGnr--;
	perc=Math.round(100-IMGnr*100/IMGes);
	currNr=perc.toString();
	this.onload=null;
	if(perc==93&&bw.ief)boxs=[0,new Box(1)];
	if(perc>99){
		get("DIVloading").className="done";
		bw.loaded=1;
		if(!bw.ief)boxs=[0,new Box(1)]; else startIE();
	}else{
		nr1.className=perc>9?"nr"+currNr.substr(0,1):"";
		nr2.className="nr"+currNr.substr(perc>9?1:0,1);
	}
	
}
function preLoadIMGs(nr){//ie/
	iisrc="imgs/"+(IMGpre[nr].match(/\.png/)?(bw.ie?"":(bw.saf?"saf/":"")):"")+(bw.ie50?IMGpre[nr].replace(/\.png/,".gif"):IMGpre[nr]);
	iimg[iisrc]=make("IMG");
	iimg[iisrc].onload=preLoaded; iimg[iisrc].src=iisrc;
	loadBin.appendChild(iimg[iisrc]);
}
function init(){
	bw.db=document.body; bw.dd=document.documentElement; getWinSize(); getScrollTop();
	nr1=get("DIVnr1"); nr2=get("DIVnr2"); loadBin=get("DIVbin");
	for(i in IMGpre)preLoadIMGs(i);
}
window.onload=init;
window.onresize=getWinSize;
