function base(){
	var agent=navigator.userAgent.toLowerCase(), mimes=navigator.mimeTypes;
	this.wp=window.parent;
	this.wt=window.top;
	this.op=window.opera;
	this.url=location.href;
	this.loc=splitHref(this.url);
	if(!this.loc)this.loc=[,"index"];
	this.home=this.loc[1].match(/index|no_frames/)&&!this.wp.bw;
	this.hash=this.url.match(/#(.*)/);
	this.ie=agent.match(/msie/)&&!this.op;
	this.saf=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.iemac=agent.match(/msie/)&&!this.op&&this.mac;
	this.moz=agent.match(/gecko/);
	this.ns=agent.match(/netscape/);
	this.ns6=agent.match(/netscape\D?6/);
	this.oldop=this.op&&agent.match(/opera\W?[34567]/);
	this.oldmoz=!this.ns&&agent.match(/rv\:1\.[01234](\.\d)?\)\Wgecko/);
	this.osx=this.mac&&(this.saf||agent.match(/5\.22|os\s?x/i));
	this.fox=agent.match(/firefox/);
	this.oldsaf=this.saf&&agent.match(/safari\W8/i);
	this.email=new RegExp("^[a-z0-9\.\_\!\#\$\%\&\'\`\*\+\/=\?\^\_\{\|\}\~\-]+\@([a-z0-9\-]+[\.])+[a-z]{2,}$","i");
	this.scrH=screen.availHeight||screen.height;
	this.scrW=screen.availWidth||screen.width;
	this.noframe=this.loc[1]=="no_frames"||getCookie("vandaCHE");
	this.noscroll=this.oldop||this.ns6||this.iemac||this.oldmoz||this.ie50;
	this.pageOK=!this.iemac&&!this.op&&!this.ns6&&!this.ie50&&!this.oldmoz&&!this.noframe;
	this.pagination=this.pageOK&&(this.home||this.wp.bw&&this.wp.bw.home);
	this.popBlock="Your browser settings did not allow you to open a new content window.\nPlease check the status of your Popup Blocker.";
	this.list=[]; this.currL=0;
	this.order={"index":-1,"curators_intro":1,"the_exhibition":2,"your_che":3,"podcasts":4,"tell_a_friend":5,"visitor_information":6,"tickets":7,"events":8,"shop":9,"resources":10,"competition":11,"your_che_form":12};
}
base.prototype.getWinSize=function(){
	if(typeof(window.innerWidth)=='number'){ this.winW=window.innerWidth; this.winH=window.innerHeight; }
	else if(this.dd && (this.dd.clientWidth || this.dd.clientHeight)){ this.winW=this.dd.clientWidth; this.winH=this.dd.clientHeight; }else if(this.db && (this.db.clientWidth || this.db.clientHeight)){ this.winW=this.db.clientWidth; this.winH=this.db.clientHeight; }
		
}
base.prototype.getScrollTop=function(){
	this.db=document.body; this.dd=document.documentElement;
	if(this.dd && this.dd.scrollTop){ this.scrL=this.dd.scrollLeft; this.scrT=this.dd.scrollTop; }
	else if(this.db && this.db.scrollTop){ this.scrL=this.db.scrollLeft; this.scrT=this.db.scrollTop; }
	else if(window.pageYOffset){ this.scrL=self.pageXOffset; this.scrT=self.pageYOffset; }
	else if(window.scrollY){ this.scrL=window.scrollX; this.scrT=window.scrollY; }
}
bw=new base();
bw.pages=0;
bw.currP=0;
bw.pageTest=bw.pagination&&!bw.loc[1].match(/_conf/);
dLoad=0; 
if(bw.noframe){
	if(bw.loc[1]=="index")location.replace("no_frames.html");
	if(!getCookie("vandaCHE"))setCookie("vandaCHE",1,'Wednesday,21-Oct-08 16:14:21 GMT');
}
if(bw.hash)location.replace(bw.url.replace(/#(Image)?/i,(bw.url.match(/\?/)?"&":"?")+"goto=I"));
else if(bw.pageOK&&!bw.loc[1].match(/send|help|other|t_and_c/i)&&(!bw.home&&!bw.wp.bw||!bw.wp.bw.home))location.replace("index.html?page="+bw.loc[0]);
if(bw.iemac)document.write('<link rel="stylesheet" href="inc/iemac.css"/>');


function showDIV(el,tp){ if(el)el.style.visibility=tp?"visible":"hidden"; }
function get(el){ return document.getElementById(el); }
function make(el){ return document.createElement(el); }
function px(nr){ return nr+"px"; }
function blurit(){ this.blur(); }
function splitHref(hr){ return hr.match(/([^\/\.]+)\.(html|php)(.*)/i); }

page=[]; 
/*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; }},"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;
	switch(this.css){
		case "clipLeft": this.move=function(x){ this.el.style['clip']="rect(0px auto auto "+x+"px)"; }; break;
		case "clipBottom": this.move=function(x){ this.el.style['clip']="rect(0px auto "+x+"px auto)"; }; break;
		case "clipRight": this.move=function(x){ this.el.style['clip']="rect(0px "+x+"px auto 0px)"; }; break;
		case "opacity": this.move=function(x){ this.el.style['MozOpacity']=x/100;  }; break;
		case "scrollTop": this.move=function(x){ window.scrollTo(0,x); }; break;
		case "scrollLeft": this.move=function(x){ window.scrollTo(x,0); }; break;
		default: this.move=function(x){ this.el.style[this.css]=x+"px"; }
	}
	this.setTypes=function(tp1,tp2,tp3){ this.calc=easings[tp1][tp2]; this.css=tp3; }
	this.setValues=function(aX,oX,dur){ this.b=aX; this.c=oX; this.d=dur; }
	this.setDur=function(dur){ this.d=dur; }
	this.reset=function(){
		switch(this.css){
			case "clipRight": case "clipLeft": case "clipBottom": 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(bw.fox)this.tmpX=Math.round(this.tmpX);
		if(this.nt>0 && this.nt<this.d &&!bw.noscroll){
			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 setCookie(name,value,expires,path,domain,secure){
  var curCookie=name+"="+escape(value)
  	+(expires?"; expires="+expires:"")
	+(path?"; path="+path:"")
	+(domain?"; domain="+domain:"")
	+(secure?"; secure":"");
  document.cookie=curCookie;
}
function getCookie(name){
  var dc=document.cookie;
  var prefix=name+"=";
  var begin=dc.indexOf("; "+prefix);
  if(begin==-1){
    begin=dc.indexOf(prefix);
    if(begin!=0)return null;
  }else begin+=2;
  var end=document.cookie.indexOf(";",begin);
  if(end==-1)end=dc.length;
  return unescape(dc.substring(begin+prefix.length,end));
}
function deleteCookie(name,path,domain){
  if(getCookie(name)){
    document.cookie=name+"="+
    (path?"; path="+path:"")+
    (domain?"; domain="+domain:"")+
    "; expires=Thu,01-Jan-70 00:00:01 GMT";
  }
}


function popUp(){
	popw=window.open(this.href,'HELP','width=585,height=250,resizable=no,scrollbars=no');
	if(!popw)alert(bw.popBlock);
	return false;
}


function loading(tp){
	if(dLoad)showDIV(dLoad,tp);
}

function callPage(hr){
	pg=splitHref(hr); pgn=pg[1];
	IFpreload.location.href=bw.newPage=pg[0];
	return false;
}
function showPage(tp){
	if(tp){
		if(bw.nextPage==tp || bw.nextPage&&bw.nextPage.match(/your_che\.php/)&&tp.match(/your_che\.php/))return;
		pg=splitHref(tp);
		if(!bw.newPage){ bw.wt.scrollTo(0,0); bw.wt.location.href="index.html"; location.replace("about:blank"); return false; }
		if(bw.currP!="1")showDIV(page[1],0);
		if(bw.currP!="2")showDIV(page[2],0);
		switch(pg[1]){
			case "competition": bw.currP=3; break;
			case "index": bw.currP=0; break;
			default: bw.currP=bw.currP>1?bw.currP-1:bw.currP+1;
		}
		bw.nextPage=tp;
		if(bw.currP)eval("IF"+bw.currP+".location.replace('"+tp+"')"); else loading(0);
		showDIV(page[bw.currP],1);
	}else loading(0);
	bw.getWinSize();
	bw.db.slider.setValues(bw.currL,(tp?(bw.ie&&bw.currP==3?page[bw.currP].offsetLeft:bw.winW*2*bw.currP):0)-bw.currL,100);
	if(bw.ie||!bw.currP)setTimeout("bw.db.slider.go()",10);
}
function pagify(a){
	pg=splitHref(a.href); pgn=bw.home&&!pg?"index":pg[1]; 
	x=bw.pagination?"bw.wp.":"";
	if(bw.order[pgn]&&pgn!=bw.loc[1])a.onclick=new Function((pgn!="index"?("if(!"+x+"bw.list['"+pgn+"'])loading(1);"):"")+x+" callPage('"+a.href+"'); "+" return false");
}

function rover(el,tp){
	if(!el.onmouseout)el.onmouseout=new Function("rover(this,0)");
	get("ULpods").className=tp?"subs":"";
}
if(bw.loc[1]=="podcasts")init2=function(){
	get("LIsub1").onmouseover=get("LIsub2").onmouseover=new Function("rover(this,1)");
	for(i in imgs){
		el=get("DIV"+i);
		if(el){ img=make("IMG"); img.src="imgs/item_"+imgs[i]+".jpg"; el.insertBefore(img,el.firstChild); }
	}
	if(!bw.ie&&bw.pageTest)bw.wp.bw.db.slider.go();
}

function setContHeight(){
	if(dCont){
		bw.getWinSize();
		nH=bw.winH-dCont.offsetTop;
		dCont.style.height=px(nH>bw.mH?bw.mH:nH);
	}
}
function init(){
	if(doSlideNow&&!get("DIVerror")){ bw.wp.showPage(bw.loc[0]); return; }
	
	bw.db=document.body; bw.dd=document.documentElement; dCont=get("DIVcont");
	
	if(bw.home){
		window.scrollTo(0,0);
		dMain=get("DIVmain"); dMain.getElementsByTagName("a")[2].target="_blank";
		if(!bw.noframe){
			for(i=0;i<3;i++){
				var poster=dMain.firstChild.cloneNode(true);
				dMain.appendChild(poster);
			}
		}
	}
	if(bw.pagination){
		dLoad=make("DIV"); dLoad.id="DIVload"; bw.db.appendChild(dLoad);
		as=get(bw.home?"BODYhome":"ULmenu").getElementsByTagName("a");
		for(i=0;i<as.length;i++){
			asp=as[i].parentNode;
			if(!bw.noframe)as[i].onfocus=blurit;
			if(asp.tagName.match(/li/i)&&!asp.className.match(/book/i))pagify(as[i]); else as[i].target="_blank";
		}
	}
	if(bw.home && !bw.noframe){
		gotoPage=location.href.match(/\?page=(.*)/i);
		if(bw.pagination){
			bw.db.slider=new Slider(bw.db,"quint","InOut","scrollLeft",0,bw.winW,120);
			bw.db.slider.setCmd("bw.currL=bw.db.slider.maxX; bw.db.slider.setValues(bw.currL,0,0)");
			frms=["preload",1,2,3];
			for(i=0;i<frms.length;i++){
				if(bw.ie)page[i]=document.getElementsByTagName("iframe")[i];
				else{
					page[i]=make("IFRAME"); page[i].id=page[i].name="IF"+frms[i];
					page[i].pos=bw.winW*i;
					bw.db.appendChild(page[i]);
				} 
			}
			if(gotoPage)loading(1);
			callPage(gotoPage?gotoPage[1]:"index.html");
		}else if(gotoPage)location.href=gotoPage[1];
		return;
	}
	
	
	if(bw.saf){
		ds=document.styleSheets; cR=ds[0].rules;
		dbpt=new RegExp("\."+bw.db.className,"i"); bw.mH=bw.loc[1].match(/exhib|resour|event/)?500:525;
		for(i=0;i<cR.length;i++){
			cRs=cR[i].style; cRsT=cR[i].selectorText;
			if(cRsT.match(dbpt)&&cRsT.match(/DIVcont/)&&cRs.cssText.match(/max-height/i)){
				maxHeight=cRs.cssText.match(/max-height:\s?(\d+)px/i);
				bw.mH=maxHeight[1];
			}
		}
	}
	if(bw.noframe)return;
	as=document.getElementsByTagName("a"); bw.popup=bw.db.className.match(/Popup/);
	for(i=0;i<as.length;i++){
		if(!bw.noframe)as[i].onfocus=blurit;
		asp=as[i].parentNode;
		switch(asp.id){
			case "Ahom": if(bw.noframe)as[i].href="no_frames.html"; break;
			case "LIsub2": case "LIhelp": as[i].onclick=popUp; break;
			case "LIonline": case "LIsub1": as[i].target="_blank"; break;
			case "LIprint": as[i].onclick=new Function("window.print(); return false"); break;
			case "LIview": as[i].onclick=new Function("window.close(); return false"); break;
		}
		switch(as[i].id){
			case "Abt": case "Atell": if(bw.pageOK)pagify(as[i]); break;
			case "Aterms": case "Ahelp": as[i].onclick=popUp; break;
			case "Asend": case "Asubmit": case "Asubmit2": case "Aview": 
				as[i].onclick=new Function("submitForm("+(as[i].id=="Aview"?1:0)+"); return false"); break;
			case "Aremind": as[i].onclick=remindMe; break;
		}
		if(bw.popup || !asp.tagName.match(/li/i) && !(as[i].id&&as[i].id.match(/help|tandc|Abt|another|Atell|Anoframe/)))as[i].target="_blank";
	}
	if(window.init2)init2(); else if(!bw.ie&&bw.pageTest)bw.wp.bw.db.slider.go();
	if(bw.saf)setContHeight();
	window.focus();
}
var doSlideNow=!bw.home&&bw.pageTest&&bw.wp.bw.nextPage!=bw.loc[0]&&!(bw.loc[1]=="your_che"&&bw.wp.bw.nextPage&&bw.wp.bw.nextPage.match(/your_che\.php/));
if(!doSlideNow&&(bw.home||bw.saf))window.onresize=new Function(bw.ie?("setTimeout('callPage(\"index.html\")',50)"):(bw.home?"loading(0); bw.currL=0":"setContHeight()"));
window.onload=init;

