function CasePreloader(){
	this.pageIsLoaded=false;
	this.casesIsLoaded=false;
	this.preloaded=0;
	this.preloadCase();
	this.updateStatus();
}

CasePreloader.prototype.preloadCase=function(){
	if(this.preloaded>=casesHandler.length) return;
	this.imgsPreloaded=0;
	this.ts=new Date().getTime();
	this.imgs=casesHandler[this.preloaded].container.getElementsByTagName('img');
	var i=this.imgs.length; var j=i;
	
	if(i>0)do{
		if(this.imgs[j-i].complete) this.imgsPreloaded++;
		else{
			this.imgs[j-i].onload=function(){casePreloader.onComplete();}
			this.imgs[j-i].onabort=function(){casePreloader.onComplete();}
			this.imgs[j-i].onerror=function(){casePreloader.onComplete();}
		}
	}while(--i);
	if(this.imgsPreloaded>=this.imgs.length){
		this.preloaded++;
		this.updateStatus();
		setTimeout(function(){casePreloader.preloadCase();},100);
	}
}
CasePreloader.prototype.onComplete=function(){
	this.imgsPreloaded++;
	if(this.imgsPreloaded>=this.imgs.length){
		this.preloaded++;
		this.updateStatus();
		setTimeout(function(){casePreloader.preloadCase();},Math.max(1,100-(new Date().getTime()-this.ts)));
	}
}
var totalwidth=parseInt(document.getElementById('preloader_container').offsetWidth)-200;
CasePreloader.prototype.updateStatus=function(){
	var status=Math.round(this.preloaded/(casesHandler.length+3)*totalwidth);
	document.getElementById('preload_status').style.width=status+'px';
	document.getElementById('preload_status2').style.left=status+'px';
	document.getElementById('preload_status2').style.width=(totalwidth-status)+'px';
	if(this.preloaded==casesHandler.length){
		if(this.pageIsLoaded) this.done();
		else this.casesIsLoaded=true;
	}
}

CasePreloader.prototype.done=function(){
	window.scrollTo(0,0);
	caseList=new CaseList();
	setTimeout(function(){
		var status=Math.round((casesHandler.length+1)/(casesHandler.length+3)*totalwidth);
		document.getElementById('preload_status').style.width=status+'px';
		document.getElementById('preload_status2').style.left=status+'px';
		document.getElementById('preload_status2').style.width=(totalwidth-status)+'px';
	},300);
	setTimeout(function(){
		var status=Math.round((casesHandler.length+2)/(casesHandler.length+3)*totalwidth);
		document.getElementById('preload_status').style.width=status+'px';
		document.getElementById('preload_status2').style.left=status+'px';
		document.getElementById('preload_status2').style.width=(totalwidth-status)+'px';
	},600);
	setTimeout(function(){
		document.getElementById('preload_status').style.width=totalwidth+'px';
		document.getElementById('preload_status2').style.left=totalwidth+'px';
		document.getElementById('preload_status2').style.width='0px';
	},900);
	setTimeout(function(){
		var tmp=document.getElementById('preloader_container');
		tmp.parentNode.removeChild(tmp);
	},1000);
}
function CaseList(){
	this.wrapper=document.getElementById('case_wrapper');
	this.inAnimation=false;
	this.inSlideAnimation=false;
	this.isDragging=false;
	this.caseOpen=false;
	this.speed=0;
	var caseWidth=220+220*casesHandler.length;
	var winWidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
	this.wrapper.style.width=(1100*casesHandler.length+20)+'px';
	this.maxScroll=-Math.max(1100,Math.ceil((caseWidth-winWidth-1100)/220)*220);
	setTimeout(function(){
		var i=casesHandler.length; var j=i;
		if(i>0)do{
			casesHandler[j-i].container.style.background='url('+document.getElementsByTagName('base')[0].href+'images/border.png) repeat-y';
			casesHandler[j-i].logo.style.visibility='visible';
		}while(--i);

		new Effect(function(p){var i=casesHandler.length; var j=i; if(i>0)do{var tmp=casesHandler[j-i].logo_img; tmp.style.opacity=p; tmp.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+Math.round(100*p)+')'; tmp=null;}while(--i);
	},{duration:1.5});},1000);
	var hash=window.location.hash.split('#').join('');
	if(hash.substring(0,5)!='case='){
		this.introAnimation=true;
		var wrapper=this.wrapper;
		setTimeout(function(){new Effect(function(p){wrapper.style.left=(-1000*p)+'px'; if(p==1){caseList.introAnimation=false; wrapper=null;}},{duration:1.5,ease:true});},1000);
	}else{
		var i=casesHandler.length; var j=i; var x=-1;
		if(i>0)do{
			if(casesHandler[j-i].caseID==hash.substring(5,hash.length)){
				x=j-i;
				break;
			}
		}while(--i);
		if(x>-1){
			this.introAnimation=true;
			var tmp=casesHandler[x]; var z=0;
			setTimeout(function(){
				new Effect(function(p){
					var left=Math.round((x-1)*200*p);
					while(z-left<=-1000){
						var tmp3=casesHandler[0];
						var end=caseList.wrapper.getElementsByTagName('div');
						end=end[end.length-1];
						caseList.wrapper.insertBefore(tmp3.container,end);
						z+=200;
						casesHandler.splice(0,1);
						casesHandler[casesHandler.length]=tmp3;
						tmp3=null; end=null;
					}
					while(z-left>=-200){
						var tmp3=casesHandler[casesHandler.length-1];
						caseList.wrapper.insertBefore(tmp3.container,caseList.wrapper.getElementsByTagName('div')[0]);
						z-=200;
						casesHandler.splice(casesHandler.length-1,1);
						casesHandler.splice(0,0,tmp3);
						tmp3=null;
					}
					caseList.wrapper.style.left=(z-left)+'px';
					if(p==1){
						var tmp2=tmp; var slogan=document.getElementById('slogan');
						setTimeout(function(){tmp2.over(); new Effect(function(p){slogan.style.opacity=(1-p); slogan.style.filter='alpha(opacity='+(100-p*100)+')'; if(p==1){slogan=null;}},{duration:0.15,ease:false});},200);
						setTimeout(function(){tmp2.expand(); tmp2=null; caseList.introAnimation=false;},900);
						tmp=null;
					}
				},{duration:1.5,ease:true});
			},1000);
		}else{
			this.introAnimation=true;
			var wrapper=this.wrapper;
			setTimeout(function(){new Effect(function(p){wrapper.style.left=(-1000*p)+'px'; if(p==1){caseList.introAnimation=false; wrapper=null;}},{duration:1.5,ease:true});},1000);
		}
	}
}
CaseList.prototype.resize=function(){
	var caseWidth=220+220*casesHandler.length;
	var winWidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
	this.maxScroll=-Math.max(1100,Math.ceil((caseWidth-winWidth-1100)/220)*220);
}
CaseList.prototype.initDrag=function(e){
	this.x=e.clientX||e.pageX;
	if(!this.inSlideAnimation) document.body.style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand2.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand2.gif"), move';
	document.getElementById('cursorbox').style.visibility='hidden';
	document.getElementById('cursorbox').cursorState=1;
	this.isDragging=true;
	this.inSlideAnimation=true;
	this.speed=[];
	new Effect(function(p){
		var i=casesHandler.length; var j=i;
		if(i>0)do{
			if(document.all) casesHandler[j-i].logo_img.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+Math.round(100-50*p)+')';
			else casesHandler[j-i].logo_img.style.opacity=1-0.5*p;
		}while(--i);
	},{duration:0.15,ease:false});
	stopEvent(e);
}
CaseList.prototype.drag=function(e){
	var x=this.x-(e.clientX||e.pageX);
	this.dir=(e.clientX||e.pageX)>this.x;
	this.speed[this.speed.length]=[this.x-(e.clientX||e.pageX),new Date().getTime()];
	if(this.speed.length>5) this.speed.splice(0,1);
	this.x=e.clientX||e.pageX;
	var x=(this.wrapper.offsetLeft-x);
	while(x<=-600){
		var tmp=casesHandler[0];
		var end=this.wrapper.getElementsByTagName('div');
		end=end[end.length-1];
		this.wrapper.insertBefore(tmp.container,end);
		x+=200;
		casesHandler.splice(0,1);
		casesHandler[casesHandler.length]=tmp;
		tmp=null; end=null;
	}
	while(x>=-200){
		var tmp=casesHandler[casesHandler.length-1];
		this.wrapper.insertBefore(tmp.container,this.wrapper.getElementsByTagName('div')[0]);
		x-=200;
		casesHandler.splice(casesHandler.length-1,1);
		casesHandler.splice(0,0,tmp);
		tmp=null;
	}
	this.wrapper.style.left=x+'px';
	stopEvent(e);
}
CaseList.prototype.endDrag=function(e){
	if(this.speed.length){
		var i=this.speed.length;var x=0; var z=0;
		if(i>0)do{
			x+=this.speed[i-1][0]*i;
			z+=i;
		}while(--i);
		x/=z;
		var z=Math.max(0.25,(new Date().getTime()-this.speed[0][1])/this.speed.length/50);
		x=x/z*4;
		if(this.dir) var x=this.wrapper.offsetLeft-Math.round((this.wrapper.offsetLeft-x+55)/200)*200;
		else var x=this.wrapper.offsetLeft-Math.round((this.wrapper.offsetLeft-x-55)/200)*200;
		var wrapper=this.wrapper; var z=this.wrapper.offsetLeft;
		new Effect(function(p){
			if(caseList.isDragging) wrapper=null;
			if(wrapper){
				while(z-x*p<=-600){
					var tmp=casesHandler[0];
					var end=wrapper.getElementsByTagName('div');
					end=end[end.length-1];
					wrapper.insertBefore(tmp.container,end);
					z+=200;
					casesHandler.splice(0,1);
					casesHandler[casesHandler.length]=tmp;
					tmp=null; end=null;
				}
				while(z-x*p>=-200){
					var tmp=casesHandler[casesHandler.length-1];
					wrapper.insertBefore(tmp.container,wrapper.getElementsByTagName('div')[0]);
					z-=200;
					casesHandler.splice(casesHandler.length-1,1);
					casesHandler.splice(0,0,tmp);
					tmp=null;
				}
				wrapper.style.left=(z-x*p)+'px';
				if(p==1){
					wrapper=null;
					setTimeout("document.getElementById('cursorbox').cursorState=2;",100);
				}
			}
		},{duration:0.75,ease:true});
	}else
		document.getElementById('cursorbox').cursorState=2;
	var fader=true;
	setTimeout(function(){
		new Effect(function(p){
			if(caseList.isDragging) fader=false;

			if(fader){
				var i=casesHandler.length; var j=i;
				if(i>0)do{
					if(document.all) casesHandler[j-i].logo_img.style.filter='alpha(opacity='+Math.round(50+50*p)+')';
					else casesHandler[j-i].logo_img.style.opacity=0.5+0.5*p;
				}while(--i);

				if(p==1){
					document.body.style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.gif"), move';
					caseList.inSlideAnimation=false;
				}
			}
		},{duration:0.15,ease:false});
	},((this.speed.length && x)?500:10));
	this.isDragging=false;
	stopEvent(e);
}
CaseList.prototype.display=function(e){
	if(caseList.introAnimation || caseList.isDragging || caseList.inSlideAnimation || caseList.inAnimation) return false;
	if(!pageDisplayed) return;
	var tmp=document.getElementById('page_wrapper');
	var tmp2=document.getElementById('cases');
	caseList.inAnimation=true;
	new Effect(function(p){tmp.style.left=Math.round(-740*p)+'px'; tmp2.style.left=Math.round(941-740*p)+'px'; if(p==1){for(var p in pagesHandler) pagesHandler[p].container.style.display='none'; tmp=null; tmp2=null; document.getElementById('pages').style.display='none'; caseList.inAnimation=false;}},{duration:1,ease:false});
	setTimeout(function(){new Effect(function(p){if(document.all) document.getElementById('slogan').style.filter='alpha(opacity='+Math.round(p*100)+')'; else document.getElementById('slogan').style.opacity=p;},{duration:0.2,ease:false});},1000);
	var list=document.getElementById('pagemenu').getElementsByTagName('a');
	var i=list.length; var j=i;
	if(i>0)do{
		list[j-i].className='';
	}while(--i);

	list[0].className='active'; list=null;
	Cufon.refresh('#pagemenu');
	document.body.style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.gif"), move';
	pageDisplayed=false;
/*
	if(window.pageTracker && window.pageTracker._trackPageview){
		var url=window.location.pathname;
		if(url.charAt(url.length-1)!='/') url+='/';
		window.pageTracker._trackPageview(url);
	}
*/
	stopEvent(e);
}
function CaseHandler(id,caseID){
	this.container=document.getElementById(id);
	this.caseID=caseID;
	this.speed=[];
	var tmp=this.container.getElementsByTagName('div');
	var i=tmp.length; var j=i;

	if(i>0)do{
		if(tmp[j-i].className.toLowerCase()=='case_logo') this.logo=tmp[j-i];
		else if(tmp[j-i].className.toLowerCase()=='case_info') this.info=tmp[j-i];
		else if(tmp[j-i].className.toLowerCase()=='case_photos') this.photos=tmp[j-i];
	}while(--i);
	tmp=null; delete tmp;
	var tmp=this.logo.getElementsByTagName('div');
	var i=tmp.length; var j=i;
	
	if(i>0)do{
		if(tmp[j-i].className.toLowerCase()=='case_logo_img') this.logo_img=tmp[j-i];
	}while(--i);
	tmp=null; delete tmp;

	var tmp=this.logo.getElementsByTagName('img');
	var i=tmp.length; var j=i;
	
	if(i>0)do{
		if(tmp[j-i].className.toLowerCase()=='case_logo_img') this.logo_img=tmp[j-i];
	}while(--i);
	tmp=null; delete tmp;
	var tmp=this.info.getElementsByTagName('div');
	var i=tmp.length; var j=i;

	if(i>0)do{
		if(tmp[j-i].className.toLowerCase()=='case_top') this.info_top=tmp[j-i];
		else if(tmp[j-i].className.toLowerCase()=='case_description') this.info_description=tmp[j-i];
	}while(--i);
	this.info_gradient=this.info_top.getElementsByTagName('div')[0];
	tmp=null; delete tmp;
	var img=new Image();
	img.src=this.logo.getElementsByTagName('img')[0].src.split('_logo.png').join('_top.jpg');
	if(document.attachEvent){
		this.logo.getElementsByTagName('div')[0].attachEvent('mouseover',function(e){var e=e||window.event; var src=e.srcElement||e.target; while(!src.handler) src=src.parentNode; if(!src.handler.infoOver) src.handler.over(); src=null; e=null;});
		this.logo.getElementsByTagName('div')[0].attachEvent('mouseout',function(e){var e=e||window.event; var src=e.srcElement||e.target; while(!src.handler) src=src.parentNode; if(src.handler.infoOver) src.handler.out(); src=null; e=null;});
	}else{
		this.logo.getElementsByTagName('div')[0].addEventListener('onmouseover',function(e){var e=e||window.event; var src=e.srcElement||e.target; while(!src.handler) src=src.parentNode; if(!src.handler.infoOver) src.handler.over(); src=null; e=null;},false);
		this.logo.getElementsByTagName('div')[0].addEventListener('onmouseout',function(e){var e=e||window.event; var src=e.srcElement||e.target; while(!src.handler) src=src.parentNode; if(src.handler.infoOver) src.handler.out(); src=null; e=null;},false);
	}
	this.fadingIn=false;
	this.fadingOut=false;
	this.timer=null;
	this.infoOver=false;
	this.infoOver2=false;
	this.inSlideAnimation=false;
	var images=this.photos.getElementsByTagName('div')[0].innerHTML.split('|'); var res=[];
	var i=images.length; var j=i; var caseHeight=-20;
	if(i>0)do{
		var tmp=images[j-i].split(':');
		res[res.length]={url:tmp[0],height:tmp[1]};
		caseHeight+=parseInt(tmp[1]);
	}while(--i);
	this.images=res; this.preloaded=0;
	this.photos.getElementsByTagName('div')[0].innerHTML='';
	var winHeight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;
	this.maxScroll=Math.min(0,-(caseHeight-winHeight));
	this.caseHeight=caseHeight;
	this.logo.handler=this;
	this.info.handler=this;
	this.photos.handler=this;
}
function print_r (array, return_val) {
    var output = "", pad_char = " ", pad_val = 4, d = this.window.document;    var getFuncName = function (fn) {
        var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
        if (!name) {
            return '(Anonymous)';
        }        return name[1];
    };
    var repeat_char = function (len, pad_char) {
        var str = "";        for (var i=0; i < len; i++) {
            str += pad_char;
        }
        return str;
    }; 
    var formatArray = function (obj, cur_depth, pad_val, pad_char) {
        if (cur_depth > 0) {
            cur_depth++;
        } 
        var base_pad = repeat_char(pad_val*cur_depth, pad_char);
        var thick_pad = repeat_char(pad_val*(cur_depth+1), pad_char);
        var str = "";
         if (typeof obj === 'object' && obj !== null && obj.constructor && getFuncName(obj.constructor) !== 'PHPJS_Resource') {
            str += "Array\n" + base_pad + "(\n";
            for (var key in obj) {
                if (obj[key] instanceof Array) {
                    str += thick_pad + "["+key+"] => "+formatArray(obj[key], cur_depth+1, pad_val, pad_char);                } else {
                    str += thick_pad + "["+key+"] => " + obj[key] + "\n";
                }
            }
            str += base_pad + ")\n";        } else if (obj === null || obj === undefined) {
            str = '';
        } else { 
            str = obj.toString();
        } 
        return str;
    };
 
    output = formatArray(array, 0, pad_val, pad_char); 
    if (return_val !== true) {
        if (d.body) {
            this.echo(output);
        }        else {
            try {
                d = XULDocument; 
                this.echo('<pre xmlns="http://www.w3.org/1999/xhtml" style="white-space:pre;">'+output+'</pre>');
            }            catch (e) {
                this.echo(output); 
            }
        }
        return true;    } else {
        return output;
    }
}
CaseHandler.prototype.resize=function(){
	var winHeight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;
	this.maxScroll=-(this.caseHeight-winHeight);
	this.photos.style.top=Math.min(0,Math.max(this.photos.offsetTop,this.maxScroll))+'px';
}
CaseHandler.prototype.over=function(){
	clearTimeout(this.timer);
	if(this.fadingIn || (!this.fadingIn && !this.fadingOut && this.infoOver)) return false;
	if(this.fadingOut){
		return false;
	}
	var elm=this.info;
	var elm2=this.info_top;
	elm.style.opacity=0; elm.style.filter='alpha(opacity=0)';
	elm.style.display='block';
	this.fadingIn=true;
	this.fadingOut=false;
	this.infoOver=true;
	this.infoOver2=true;
	new Effect(function(p){if(document.all){elm.style.filter='alpha(opacity='+(p*100)+')';}else{elm.style.opacity=p;}  if(p==1){elm.handler.fadingIn=false; elm=null; elm2=null;}},{duration:(document.all?0.8:0.6),ease:false});
	e=null;
}
CaseHandler.prototype.out=function(){
	clearTimeout(this.timer);
	this.infoOver2=false;
	if(this.fadingOut || (!this.fadingIn && !this.fadingOut && !this.infoOver)) return false;
	if(this.fadingIn){
		var t=this;
		this.timer=setTimeout(function(){t.out(); t=null;},50);
		return false;
	}
	this.fadingIn=false;
	this.fadingOut=true;
	this.infoOver=false;
	var elm=this.info;
	new Effect(function(p){elm.style.opacity=(1-p); elm.style.filter='alpha(opacity='+((1-p)*100)+')'; if(p==1){elm.style.display='none'; elm.handler.fadingOut=false; tmp=null; elm=null;}},{duration:0.6,ease:false});
	e=null;
}
CaseHandler.prototype.expand=function(){
	if(document.all) this.expandIE();
	else this.expand2();
}
CaseHandler.prototype.expand2=function(){

	if(caseList.inSlideAnimation) return false;

	caseList.inAnimation=true;
	this.photos.style.display='block';

	var container=this.photos; var wrapper=this.photos.getElementsByTagName('div')[0]; var x=caseList.wrapper.offsetLeft;
	var top=this.info_top; var description=this.info_description;

	var l1=-(this.container.offsetLeft)+220;
	var l2=l1-caseList.wrapper.offsetLeft;
	var l3=-caseList.wrapper.offsetLeft;
	if(l2<0) setTimeout(function(){new Effect(function(p){caseList.wrapper.style.left=(l1-220-Math.round(l2*(1-p)))+'px';},{duration:0.75,ease:true});},1000);
	else if(l2>0) setTimeout(function(){new Effect(function(p){caseList.wrapper.style.left=-Math.round(l3-(l2-220)*p)+'px';},{duration:0.75,ease:true});},400);

	if(document.all){
		var description2=description;
		setTimeout(function(){description2.style.visibility='hidden'; description2=null;},200);
	}
	new Effect(function(p){top.style.opacity=(1-p); description.style.opacity=(1-p); top.style.filter='alpha(opacity='+Math.round(100-100*p)+')'; if(p==1){top=null; description=null;}},{duration:0.4,ease:false});
	setTimeout(function(){new Effect(function(p){var l=Math.round(220*p); container.parentNode.style.padding='0 '+l+'px 0 '+(1+l)+'px'; wrapper.style.width=(199+2*l)+'px'; if(l2<=0) caseList.wrapper.style.left=(x-l)+'px'; if(p==1){container=null; wrapper=null;}},{duration:0.75,ease:true});},400);

	handleCursor('dragv');

	this.isOpen=true;
	this.displayIndex=-1;
	caseList.caseOpen=this;
	document.body.style.cursor='default';

	var t=this; var info=this.info;
	setTimeout(function(){t.out();},1750);
	setTimeout(function(){
		t.photos.style.background='url('+document.getElementsByTagName('base')[0].href+'images/casebg.png) repeat-x bottom left';

		caseList.inAnimation=false;
		t.displayImage();
		t=null;
	},2650);

	t.preloadImage();
	window.location.hash='case='+this.caseID;
	/*
	if(window.pageTracker && window.pageTracker._trackPageview){
		var url=window.location.pathname;
		if(url.charAt(url.length-1)!='/') url+='/';
		url+='case-'+this.caseID;
		window.pageTracker._trackPageview(url);
	}
	*/
	close_opened=true;
}
function findPos(obj) {
  var curleft = curtop = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curleft += obj.offsetLeft;
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  }
  return [curleft,curtop];
}
CaseHandler.prototype.expandIE=function(){
	if(caseList.inSlideAnimation) return false;
	caseList.inAnimation=true;
	this.photos.style.display='block';
	var container=this.photos; var wrapper=this.photos.getElementsByTagName('div')[0]; var x=caseList.wrapper.offsetLeft;
	var top=this.info_top; var description=this.info_description;
	var l1=-(this.container.offsetLeft)+220;
	var l2=l1-caseList.wrapper.offsetLeft;
	var l3=-caseList.wrapper.offsetLeft;
	if(l2<0) setTimeout(function(){new Effect(function(p){caseList.wrapper.style.left=(l1-220-Math.round(l2*(1-p)))+'px';},{duration:1.25,ease:true});},1800);
	else if(l2>0) setTimeout(function(){new Effect(function(p){caseList.wrapper.style.left=-Math.round(l3-(l2-220)*p)+'px';},{duration:1.25,ease:true});},1800);
	if(document.all){
		var description2=description;
		setTimeout(function(){description2.style.visibility='hidden'; description2=null;},200);
	}
	new Effect(function(p){top.style.opacity=(1-p); description.style.opacity=(1-p); top.style.filter='alpha(opacity='+Math.round(100-100*p)+')'; if(p==1){top=null; description=null;}},{duration:0.8,ease:false});
	setTimeout(function(){new Effect(function(p){var l=Math.round(220*p); container.parentNode.style.padding='0 '+l+'px 0 '+(1+l)+'px'; wrapper.style.width=(199+2*l)+'px'; if(l2<=0) caseList.wrapper.style.left=(x-l)+'px'; if(p==1){container=null; wrapper=null;}},{duration:1,ease:true});},850);
	setTimeout("handleCursor('dragv');",3000);
	this.isOpen=true;
	this.displayIndex=-1;
	caseList.caseOpen=this;
	document.body.style.cursor='default';
	var t=this; var info=this.info;
	setTimeout(function(){t.out();},3100);
	setTimeout(function(){
		t.photos.style.background='url('+document.getElementsByTagName('base')[0].href+'images/casebg.png) repeat-x bottom left';
		caseList.inAnimation=false;
		t.displayImage();
		t=null;
	},3900);
	t.preloadImage();
	window.location.hash='case='+this.caseID;

	/*
	if(window.pageTracker && window.pageTracker._trackPageview){
		var url=window.location.pathname;
		if(url.charAt(url.length-1)!='/') url+='/';
		url+='case-'+this.caseID;
		window.pageTracker._trackPageview(url);
	}
	*/
	close_opened=true;
}
CaseHandler.prototype.initDrag=function(e){
	this.y=e.clientY||e.pageY;

	if(!this.inSlideAnimation){
		this.photos.style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand2.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand2.gif"), move';
		var list=this.photos.getElementsByTagName('div'); var list2=this.photos.getElementsByTagName('img');
		var i=list.length; var j=i;
		if(i>0)do{
			try{list[j-i].style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand2.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand2.gif"), move';}catch(e){}
			try{list2[j-i].style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand2.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand2.gif"), move';}catch(e){}
		}while(--i);
	}
	this.isDragging=true;
	this.inSlideAnimation=true;
	this.speed=[];

	stopEvent(e);
}
CaseHandler.prototype.drag=function(e){
	var y=this.y-(e.clientY||e.pageY);

	this.dir=(e.clientY||e.pageY)>this.y;
	this.speed[this.speed.length]=[y,new Date().getTime()];
	if(this.speed.length>5) this.speed.splice(0,1);
	this.y=e.clientY||e.pageY;
	var y=(this.photos.getElementsByTagName('div')[0].offsetTop-y);
	y=Math.max(this.maxScroll,Math.min(0,y));
	this.photos.getElementsByTagName('div')[0].style.top=y+'px';
	stopEvent(e);
}
CaseHandler.prototype.endDrag=function(e){
	if(this.speed.length){
		var i=this.speed.length;var y=0; var z=0;
		if(i>0)do{
			y+=this.speed[i-1][0]*i;
			z+=i;
		}while(--i);
		y/=z;

		var z=(new Date().getTime()-this.speed[0][1])/this.speed.length/50;
		y=y/z*5.5;

		y=this.photos.getElementsByTagName('div')[0].offsetTop-Math.max(this.maxScroll,Math.min(0,Math.round(this.photos.getElementsByTagName('div')[0].offsetTop-y)));

		var t=this; var z=this.photos.getElementsByTagName('div')[0].offsetTop;
		new Effect(function(p){if(t && t.isDragging) t=null; if(t) t.photos.getElementsByTagName('div')[0].style.top=(z-y*p)+'px'; if(p==1) t=null;},{duration:1,ease:true});
	}

	this.isDragging=false;
	this.speed=[];

	var t2=this;
	setTimeout(function(){
		t2.photos.style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.gif"), move';
		var list=t2.photos.getElementsByTagName('div'); var list2=t2.photos.getElementsByTagName('img');
		var i=list.length; var j=i;
		if(i>0)do{
			try{list[j-i].style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.gif"), move';}catch(e){}
			try{list2[j-i].style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.gif"), move';}catch(e){}
		}while(--i);
		t2.inSlideAnimation=false;
		t2=null;
	},(this.speed.length?1000:10))

	stopEvent(e);
}
function HideCloseBtn(){
	close_opened=false;
	document.getElementById('close_btn_case').style.display='none';
}
CaseHandler.prototype.close=function(){
	HideCloseBtn();
	caseList.inAnimation=true; var t=this;
	var photos=this.photos.getElementsByTagName('img'); var slideup=this.photos.getElementsByTagName('div')[0]; var z=slideup.offsetTop; var timeoutDelay=z?700:10;
	new Effect(function(p){slideup.style.top=Math.round(z-z*p)+'px'; if(p==1) slideup=null;},{duration:0.7,ease:true});
	setTimeout(function(){HideCloseBtn();t.photos.style.background='none'; new Effect(function(p){var i=photos.length; var j=i; if(i>0)do{photos[j-i].style.opacity=(1-p); photos[j-i].style.filter='alpha(opacity='+Math.round(100-100*p)+')';}while(--i); if(p==1){var i=photos.length; var j=i; if(i>0)do{photos[j-i].style.visibility='hidden';}while(--i); photos=null;}},{duration:0.4,ease:false});},timeoutDelay);

	var info=this.info; info.style.display='block';
	setTimeout(function(){HideCloseBtn();new Effect(function(p){info.style.opacity=p; info.style.filter='alpha(opacity='+Math.round(100*p)+')';},{duration:0.4,ease:false});},700+timeoutDelay);

	var container=this.photos; var wrapper=this.photos.getElementsByTagName('div')[0]; var t=this; var x=caseList.wrapper.offsetLeft;
	setTimeout(function(){HideCloseBtn();new Effect(function(p){var l=Math.round(220*p); container.parentNode.style.padding='0 '+(220-l)+'px 0 '+(1+220-l)+'px'; wrapper.style.width=(639-2*l)+'px'; caseList.wrapper.style.left=Math.round(x+200*p)+'px'; if(p==1){container.style.display='none'; container=null; wrapper=null;}},{duration:0.7,ease:true});},1300+timeoutDelay);

	setTimeout(function(){HideCloseBtn();new Effect(function(p){info.style.opacity=(1-p); info.style.filter='alpha(opacity='+Math.round(100-100*p)+')'; if(p==1){info.style.display='none'; info.handler.info_top.style.opacity=1; info.handler.info_description.style.opacity=1; info.handler.info_top.style.filter='alpha(opacity=100)'; info.handler.info_description.style.visibility='visible'; info=null; caseList.inAnimation=false;}},{duration:0.4,ease:false});},2200+timeoutDelay);
	setTimeout(function(){HideCloseBtn();t.isOpen=false; caseList.caseOpen=null; document.body.style.cursor='url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.cur"), url("'+document.getElementsByTagName('base')[0].href+'cursors/hand.gif"), move'; handleCursor('dragh'); t=null; if(caseList.onClosed){caseList.onClosed(); caseList.onClosed=null;}},2600+timeoutDelay);

	window.location.hash='collapsed';
	/*
	if(window.pageTracker && window.pageTracker._trackPageview){
		var url=window.location.pathname;
		if(url.charAt(url.length-1)!='/') url+='/';
		window.pageTracker._trackPageview(url);
	}*/
}
CaseHandler.prototype.preloadImage=function(){
	if(this.preloaded>=this.images.length || !this.isOpen) return;

	var preloaded=this.preloaded;

	var div=document.createElement('div');
	var img=document.createElement('img');

	div.style.height=this.images[preloaded].height+'px';
	img.style.height=this.images[preloaded].height+'px';
	img.style.opacity=0;
	img.style.filter='alpha(opacity=0)';

	var t=this;
	img.onload=function(){div.appendChild(img); div.style.background='none'; t.preloaded++; if(t.displayIndex>-1) t.displayImage(); t.preloadImage(); t=null;}
	img.onerror=function(){div.appendChild(img); div.style.background='none'; img=null; t.preloaded++; if(t.displayIndex>-1) t.displayImage(); t.preloadImage(); t=null;}
	img.onabort=function(){div.appendChild(img); div.style.background='none'; img=null; t.preloaded++; if(t.displayIndex>-1) t.displayImage(); t.preloadImage(); t=null;}

	img.src=this.images[preloaded].url;
	this.photos.getElementsByTagName('div')[0].appendChild(div);
}
var close_opened=false;
CaseHandler.prototype.displayImage=function(){

	if(!this.isOpen){
		HideCloseBtn();
		return false;
	}

	this.displayIndex=Math.max(0,this.displayIndex);

	if(this.displayIndex>=this.preloaded || this.displayIndex>=this.images.length) return;

	var img=this.photos.getElementsByTagName('img')[this.displayIndex];
	this.displayIndex++;

	var t=this; img.style.visibility='visible';
	new Effect(function(p){if(!caseList.inAnimation){img.style.opacity=p; img.style.filter='alpha(opacity='+Math.round(100*p)+')';} if(p==1){img=null; t.displayImage(); t=null;}},{duration:0.4,ease:false});
	if ( close_opened ){
		tmp=findPos(this.photos);
		document.getElementById('close_btn_case').style.left=(tmp[0]+parseInt(this.photos.offsetWidth,10)-34)+'px';
		document.getElementById('close_btn_case').style.top=tmp[1]+'px';
		document.getElementById('close_btn_case').style.display='';
	}
}
CaseHandler.prototype.mouseWheel=function(e){
	if(this.mouseWheelTimer) clearTimeout(this.mouseWheelTimer);
	this.inSlideAnimation=true;

	var e=e||window.event;
	var scroll=e.detail? e.detail*(-120): e.wheelDelta;
	scroll=Math.round(scroll/20);

	this.speed[this.speed.length]=[-scroll,new Date().getTime()];
	if(this.speed.length>5) this.speed.splice(0,1);

	var y=this.photos.getElementsByTagName('div')[0].offsetTop+scroll;
	y=Math.max(this.maxScroll,Math.min(0,y));

	this.photos.getElementsByTagName('div')[0].style.top=y+'px';

	var t=this;
	this.mouseWheelTimer=setTimeout(function(){
		t.inSlideAnimation=false;

		if(t.speed.length){
			var i=t.speed.length;var y=0; var z=0;
			if(i>0)do{
				y+=t.speed[i-1][0]*i;
				z+=i;
			}while(--i);
			y/=z;

			var z=50/((new Date().getTime()-t.speed[0][1])/t.speed.length);
			y=y/z*7.5;

			y=t.photos.getElementsByTagName('div')[0].offsetTop-Math.max(t.maxScroll,Math.min(0,Math.round(t.photos.getElementsByTagName('div')[0].offsetTop-y)));

			var t2=t; var z=t.photos.getElementsByTagName('div')[0].offsetTop;
			new Effect(function(p){if(t2 && (t2.isDragging || t2.inSlideAnimation)) t2=null; if(t2) t2.photos.getElementsByTagName('div')[0].style.top=(z-y*p)+'px'; if(p==1){if(t2) t2.speed=[]; t2=null;}},{duration:1,ease:true});

			t=null;
		}
	},30);
}
function PageHandler(pageID){
	this.container=document.getElementById(pageID);
	this.link=document.getElementById(pageID+'_link');
	this.url=encodeURIComponent(this.link.innerHTML.split(' ').join('-').toLowerCase());

	var list=this.container.getElementsByTagName('div');
	this.top=list[0];
	this.wrapper=list[1];
	this.bottom=list[list.length-1];

	list=null;
}
PageHandler.prototype.display=function(e){
	if(window.caseList && !caseList.introAnimation && !caseList.isDragging && !caseList.inSlideAnimation && !caseList.inAnimation){
		if(this.link.className.toLowerCase()!='active'){
			caseList.inAnimation=true;

			if(caseList.caseOpen) this.doHideDisplay();
			else if(pageDisplayed) this.doSwitchDisplay();
			else this.doDisplay(false);

			pageDisplayed=true;
/*
			if(window.pageTracker && window.pageTracker._trackPageview){
				var url=window.location.pathname;
				if(url.charAt(url.length-1)!='/') url+='/';
				url+=this.url;
				window.pageTracker._trackPageview(url);
			}
*/
			stopEvent(e);
		}
	}
}
PageHandler.prototype.doHideDisplay=function(){
	var t=this;
	caseList.onClosed=function(){t.doDisplay(false); t=null;HideCloseBtn();}
	caseList.caseOpen.close();

	var list=document.getElementById('pagemenu').getElementsByTagName('a');
	var i=list.length; var j=i;

	if(i>0)do{
		list[j-i].className='';
	}while(--i);
	list=null;

	this.link.className='active';
	Cufon.refresh('#pagemenu');

	handleCursor('none');
}
PageHandler.prototype.doSwitchDisplay=function(){
	var tmp=document.getElementById('page_wrapper');
	var tmp2=document.getElementById('cases');

	new Effect(function(p){tmp.style.left=Math.round(-740*p)+'px'; tmp2.style.left=Math.round(941-740*p)+'px';},{duration:1,ease:true});

	var list=document.getElementById('pagemenu').getElementsByTagName('a');
	var i=list.length; var j=i;

	if(i>0)do{
		list[j-i].className='';
	}while(--i);
	list=null;

	this.link.className='active';
	Cufon.refresh('#pagemenu');

	var t=this;
	setTimeout(function(){t.doDisplay(true); t=null;},1200);
}
PageHandler.prototype.doDisplay=function(isSwitch){
	var tmp=document.getElementById('page_wrapper');
	var tmp2=document.getElementById('cases');

	for(var p in pagesHandler) pagesHandler[p].container.style.display='none';

	tmp.style.left='-740px';
	document.getElementById('pages').style.display='block';
	this.container.style.display='block';
	document.body.style.cursor='auto';

	this.top.style.height='0px'; this.bottom.style.height='0px';

	var winHeight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;
	var pageHeight=this.wrapper.offsetHeight+40;

	this.top.style.height=Math.max(0,Math.round((winHeight-pageHeight)/2))+'px';
	this.bottom.style.height=Math.max(0,Math.round((winHeight-pageHeight)/2))+'px';

	setTimeout(function(){new Effect(function(p){tmp.style.left=Math.round(740*p-740)+'px'; tmp2.style.left=Math.round(740*p+201)+'px'; if(p==1){tmp=null; tmp2=null; caseList.inAnimation=false;}},{duration:1,ease:true});},(!isSwitch?250:1));

	if(!isSwitch) new Effect(function(p){if(document.all) document.getElementById('slogan').style.filter='alpha(opacity='+Math.round(100-p*100)+')'; else document.getElementById('slogan').style.opacity=(1-p);},{duration:0.2,ease:false});

	var list=document.getElementById('pagemenu').getElementsByTagName('a');
	var i=list.length; var j=i;

	if(i>0)do{
		list[j-i].className='';
	}while(--i);
	list=null;

	this.link.className='active';
	Cufon.refresh('#pagemenu');
}
function handleCursor(state){
	var tmp=document.getElementById('cursorbox');
	clearTimeout(tmp.delay);

	if(!window.cursorboxHandler) return false;
	if(tmp.state==state && (tmp.fadedIn || tmp.fadingIn)) return false;

	tmp.delay=setTimeout("handleCursor2('"+state+"');",50);
}
function handleCursor2(state){
	var tmp=document.getElementById('cursorbox');
	var tmp2=document.getElementById('slogan');
	tmp.style.width='auto';
	clearTimeout(tmp.timer); clearTimeout(tmp2.timer);
	clearTimeout(tmp.delay);

	if(tmp.fadingIn){
		tmp.timer=setTimeout("handleCursor2('"+state+"');",50);
		return;
	}

	if(!tmp.fadingOut && !tmp.fadedOut){
		new Effect(function(p){tmp.style.opacity=(1-p); tmp.style.filter='alpha(opacity='+(100-p*100)+')'; if(p==1){tmp.fadedOut=true; tmp.fadingOut=false; tmp.className=''; tmp.style.display='none'; tmp=null;}},{duration:0.15,ease:false});
		if(!tmp2.isHidden && state!='none' && state!='dragh'){
			tmp2.isHidden=true;
			new Effect(function(p){tmp2.style.opacity=(1-p); tmp2.style.filter='alpha(opacity='+(100-p*100)+')'; if(p==1){tmp2=null;}},{duration:0.15,ease:false});
		}
		tmp.fadingOut=true;
		tmp.fadedIn=false;
		tmp.fadingIn=false;
	}

	if(!tmp.fadedOut && !tmp.fadedIn){
		tmp.timer=setTimeout("handleCursor2('"+state+"');",50);
		return;
	}

	if(state!='none'){
		tmp.getElementsByTagName('span')[0].innerHTML=cursorboxHandler[state];
		Cufon.replace('#cursorbox');

		tmp.className=state;
		tmp.style.display='block';
		tmp.style.width='300px';
		tmp.getElementsByTagName('span')[0].style.width='auto';
		tmp.getElementsByTagName('span')[0].style.width=tmp.getElementsByTagName('span')[0].offsetWidth+'px';
		tmp.style.width=tmp.getElementsByTagName('span')[0].offsetWidth+'px';

		if(!tmp.fadedIn && !tmp.fadingIn){
			tmp.timer=new Effect(function(p){tmp.style.opacity=p; tmp.style.filter='alpha(opacity='+(p*100)+')'; if(p==1){tmp.fadedIn=true; tmp.fadingIn=false; tmp=null;}},{duration:0.15,ease:false});
			if((state=='none' || state=='dragh') && tmp2.isHidden){
				tmp2.isHidden=false;
				tmp2.timer=new Effect(function(p){tmp2.style.opacity=p; tmp2.style.filter='alpha(opacity='+(p*100)+')'; if(p==1){tmp2=null;}},{duration:0.15,ease:false});
			}

			tmp.fadingIn=true;
			tmp.fadingOut=false;
			tmp.fadedOut=false;
		}
	}

	tmp.state=state;
}
function mouseMove(e){
	var e=e||window.event;
	var src=e.srcElement||e.target;

	var tmp=document.getElementById('cursorbox');
	try{
		if(tmp.cursorState!=1){
			tmp.style.left=((e.clientX||e.pageX)+10)+'px';
			tmp.style.top=((e.clientY||e.pageY)+15)+'px';
		}
		if(tmp.cursorState==2){
			tmp.style.visibility='visible';
			tmp.cursorState=0;
		}
	}catch(e){}

	if(pageDisplayed){
		var casesIsOver=false;
		while(src){if(src && src.id && src.id.toLowerCase()=='cases'){casesIsOver=true; break;} src=src.parentNode;}

		if(!casesIsOver) handleCursor('none');
		else handleCursor('close2');		

		stopEvent(e);
		return false;
	}

	if(window.caseList && caseList.introAnimation){
		stopEvent(e);
		return false;
	}

	if((src && src.id && src.id.toLowerCase()=='cursorbox') || (src && src.parentNode && src.parentNode.id && src.parentNode.id.toLowerCase()=='cursorbox')){
		stopEvent(e);
		return false;
	}

	var caseOver=false;
	var photosOver=false;
	var linkOver=false;

	var tmp=src;
	while(tmp){if(tmp.tagName && tmp.tagName.toLowerCase()=='a'){linkOver=true; break;} tmp=tmp.parentNode;}

	if(window.caseList && !caseList.isDragging && !caseList.inAnimation){
		var i=casesHandler.length; var j=i;
		if(i>0)do{
			var tmp=src; var over=false; var over2=false;
			while(tmp){
				if(tmp==casesHandler[j-i].info || tmp==casesHandler[j-i].logo.getElementsByTagName('div')[0]) over=true;
				if(tmp==casesHandler[j-i].photos) over2=true;

				tmp=tmp.parentNode;
			}
			tmp=null;

			if(over && !casesHandler[j-i].infoOver && window.caseList && !caseList.caseOpen) casesHandler[j-i].over();
			else if(!over && casesHandler[j-i].infoOver && window.caseList && !caseList.caseOpen) casesHandler[j-i].out();

			if(casesHandler[j-i].isDragging) casesHandler[j-i].drag(e);

			casesHandler[j-i].photosOver=over2;

			caseOver|=over;
			photosOver|=over2;
		}while(--i);
	}

	if(window.caseList && caseList.isDragging && !pageDisplayed) caseList.drag(e);

	if(window.caseList && caseList.caseOpen && (caseList.caseOpen.photosOver || caseList.caseOpen.caseOver) && !pageDisplayed){
		handleCursor('dragv');
	}

	else if(window.caseList && caseList.caseOpen && !linkOver && !pageDisplayed) handleCursor('close');

	else if(caseOver && !pageDisplayed) handleCursor('more');

	else if(!linkOver && !pageDisplayed){
		handleCursor('dragh');
	}

	else handleCursor('none');

	stopEvent(e);

	e=null;
	src=null;
	tmp=null;
}
 var downed=false;
function mouseDown(e){
	downed=true;
	var tmp=document.getElementById('cursorbox');
	tmp.style.left=((e.clientX||e.pageX)+10)+'px';
	tmp.style.top=((e.clientY||e.pageY)+15)+'px';
	if(window.caseList && caseList.introAnimation){
		stopEvent(e);
		return false;
	}

	if(window.caseList && caseList.inAnimation){
		stopEvent(e);
		return;
	}

	if(pageDisplayed){
		stopEvent(e);
		return false;
	}

	var e=e||window.event;
	var src=e.srcElement||e.target;

	var tmp=src; var linkOver=false;
	while(tmp){if(tmp.tagName && tmp.tagName.toLowerCase()=='a'){linkOver=true; break;} tmp=tmp.parentNode;}

	if(!linkOver){
		var i=casesHandler.length; var j=i; var infoOver=false; var photosOver=false;
		if(i>0)do{
			if(casesHandler[j-i].infoOver2) infoOver=true;
			if(casesHandler[j-i].photosOver) photosOver=casesHandler[j-i];
		}while(--i);
	}

	if(!infoOver && !photosOver && !linkOver && !caseList.caseOpen) caseList.initDrag(e);
	else if(photosOver) photosOver.initDrag(e);
	photosOver=null;

	stopEvent(e);

	src=null;
	mouseMove(e);
	e=null;
}

function mouseUp(e){
	downed=false;
	var tmp=document.getElementById('cursorbox');
	tmp.style.left=((e.clientX||e.pageX)+10)+'px';
	tmp.style.top=((e.clientY||e.pageY)+15)+'px';
	if(window.caseList && caseList.introAnimation){
		stopEvent(e);
		return false;
	}
	if(window.caseList && caseList.inAnimation){
		stopEvent(e);
		return;
	}
	if(pageDisplayed){
		var e=e||window.event;
		var src=e.srcElement||e.target;
		var casesClicked=false;

		while(src){if(src && src.id && src.id.toLowerCase()=='cases'){casesClicked=true; break;} src=src.parentNode;}
		if(casesClicked) caseList.display();
		stopEvent(e);
		return false;
	}
	var e=e||window.event;
	var i=casesHandler.length; var j=i; var over=false;
	if(i>0)do{
		if(casesHandler[j-i].infoOver2) casesHandler[j-i].expand();
		else if(casesHandler[j-i].isDragging) casesHandler[j-i].endDrag(e);
		else if(casesHandler[j-i].isOpen && !casesHandler[j-i].photosOver) casesHandler[j-i].close();
	}while(--i);
	if(caseList.isDragging) caseList.endDrag(e);
	stopEvent(e);
	mouseMove(e);
	e=null;
}
function mouseWheel(e){
	if(!window.caseList || !window.caseList.caseOpen || window.caseList.inAnimation || window.caseList.inSlideAnimation || window.caseList.introAnimation){
		stopEvent(e);
		return false;
	}
	caseList.caseOpen.mouseWheel(e);
	stopEvent(e);
}
function resize(){
	try{
		if(!caseList) return;
	}catch(e){
		return;
	}
	caseList.resize();
	var i=casesHandler.length; var j=i;
	if(i>0)do{casesHandler[j-i].resize();}while(--i);
}

if(document.attachEvent){
	document.attachEvent('onmousemove',mouseMove);
	document.attachEvent('onmousedown',mouseDown);
	document.attachEvent('onmouseup',mouseUp);
	window.attachEvent('onresize',resize);
	document.attachEvent('onscroll',stopEvent);
	document.attachEvent('onmousewheel',mouseWheel,false);
}else{
	var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
	window.addEventListener('mousemove',mouseMove,false);
	window.addEventListener('mousedown',mouseDown,false);
	window.addEventListener('mouseup',mouseUp,false);
	window.addEventListener('resize',resize,false);
	window.addEventListener('scroll',stopEvent,false);
	document.addEventListener(mousewheelevt,mouseWheel,false);
}

document.getElementById('cursorbox').state='none';
document.getElementById('cursorbox').fadedOut=false;

pageDisplayed=false;
var imgGradient=new Image();
imgGradient.src=document.getElementsByTagName('base')[0].href+'images/casegradient.png';

function stopEvent(e){
	var e=e||window.event;
	if(e.preventDefault)e.preventDefault();
	if(e.stopPropagation)e.stopPropagation();
	if(e.stop)e.stop();
	if(document.all&&e.keyCode)try{e.keyCode=0;}catch(e){}
	e.cancelBubble=true;
	e.returnValue=false;
}
function get_case_wrapper_width(){
	var returnwidth = 0;
	divs=getElementsByClass('case',document.getElementById('case_wrapper'),'div');
	for(i=0;i<divs.length;i++){
		returnwidth = parseInt(returnwidth,10) + parseInt(divs[i].offsetWidth,10);
	}
	return parseInt(returnwidth,10);
}
setTimeout("autoscroll()",1);
var autoscrollstarted=false;
function autoscroll(){
	if ( document.getElementById('cursorbox').state == 'dragh' && !downed && (document.getElementById('cursorbox').style.visibility == 'visible'||document.getElementById('cursorbox').style.display == 'block') ){
		x=parseInt(document.getElementById('cursorbox').style.left,10);
		totalwidth=parseInt(document.getElementById('cases').offsetWidth);
		start_x=parseInt(findPos(document.getElementById('cases'))[0],10);
		totalwidth_onpos=totalwidth*0.1;
		if ( x>start_x && x< (totalwidth_onpos+start_x) ){
			newleft=(parseInt(document.getElementById('case_wrapper').style.left,10)+4);
			if ( newleft > 0 ){
				newleft=0-((parseInt(get_case_wrapper_width(),10)/2)+4);
			}
			document.getElementById('case_wrapper').style.left=newleft+"px";
			autoscrollstarted=true;
		} else if ( x>(totalwidth-totalwidth_onpos) && x< totalwidth ){
			newleft=(parseInt(document.getElementById('case_wrapper').style.left,10)-4);
			if ( newleft < (0-(get_case_wrapper_width()/2)) ){
				console.log('if ( '+newleft+' < '+(0-(get_case_wrapper_width()/2))+' ');
				console.log('case_wrapper offsetLeft:'+document.getElementById('case_wrapper').offsetLeft);
				newleft=0-4;
			}
			document.getElementById('case_wrapper').style.left=newleft+"px";
			autoscrollstarted=true;
		} else if ( autoscrollstarted ){
			autoscroll_stopped();
		}
	} else {
		if ( autoscrollstarted ){
			autoscroll_stopped();
		}
	}
	setTimeout("autoscroll()",1);
}
function getElementsByClass(searchClass,node,tag) {

	var classElements = new Array();

	if ( node == null )

		node = document;

	if ( tag == null )

		tag = '*';

	var els = node.getElementsByTagName(tag);

	var elsLen = els.length;

	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");

	for (i = 0, j = 0; i < elsLen; i++) {

		if ( pattern.test(els[i].className) ) {

			classElements[j] = els[i];

			j++;

		}

	}

	return classElements;

}
function autoscroll_stopped(){
	autoscrollstarted=false;
	
}
if(window.innerWidth!=undefined){
	function getViewportWidth(){ return window.innerWidth;};
}
else if(document.documentElement!=undefined && document.documentElement.clientWidth!=undefined){
	function getViewportWidth(){ return document.documentElement.clientWidth;};
}
else if(document.body.clientWidth!=undefined){
	function getViewportWidth(){ return document.body.clientWidth;};
}
