var total_projects;var current_top_project;var project_slide_delta=1;var project_slide=new Array();var image_array;var current_pi;var current_pi_display;var pi_count;var islide;var mslide;var pi_prev_in=0;var pi_next_in=0;var playing_flash=false;var imagefade;var fade_state=0;var image_waiting=""
function pnorm(p){p=p%total_projects;while(p<0)p+=total_projects;return p}
function projects_start(pfirst,n,scroll_offset){var p;for(p=pfirst;p<pfirst+n;p++){var norm=pnorm(p);var y=(p-current_top_project)*117;var ele=document.getElementById("p"+(norm+1));ele.style.position="absolute";ele.style.top=y+"px";ele.style.visibility="visible";if(scroll_offset!=0)project_slide[norm].startv(y+scroll_offset,150)};for(a=0;a<(total_projects-n);a++){var ele=document.getElementById("p"+(pnorm(p+a)+1));ele.style.visibility="hidden"}}
function initialise_projects(top_project){var p;for(p=0;p<total_projects;p++)project_slide[p]=new emootslide("p"+(p+1),0,0);current_top_project=top_project;projects_start(current_top_project,4,0)}
function scroll_projects(dir){if(dir<0){projects_start(current_top_project-project_slide_delta,8,project_slide_delta*117)}else projects_start(current_top_project,4+project_slide_delta,project_slide_delta*-117);current_top_project=pnorm(current_top_project+(dir*project_slide_delta))}
function check_pi_arrows(){if(current_pi_display<=0){hilite("piprev",piprevo)}else if(pi_prev_in){hilite("piprev",piprevr)}else hilite("piprev",piprevg);if(current_pi_display>=(pi_count-1)){hilite("pinext",pinexto)}else if(pi_next_in){hilite("pinext",pinextr)}else hilite("pinext",pinextg)}
function pi_hilite_prev(prev_in){pi_prev_in=prev_in;check_pi_arrows()}
function pi_hilite_next(next_in){pi_next_in=next_in;check_pi_arrows()}
function check_pi_scroll(){if(pi_count<=5)return;var new_pi=current_pi_display-2;if(new_pi<0){new_pi=0}else if((new_pi+5)>pi_count)new_pi=pi_count-5;if(new_pi!=current_pi){current_pi=new_pi;islide.starth(current_pi*-101,150)}}
function scroll_pi(dir){if(dir<0&&current_pi_display<=0){check_pi_arrows();return};if(dir>0&&current_pi_display>=(pi_count-1)){check_pi_arrows();return};display_image(current_pi_display+dir)}
function fade_image_now(im,alt){var ele=document.getElementById("mainimage");if(ie6){ele.setAttribute('src',im.src);return};var ele2=document.getElementById("mainimage2");switch(fade_state){case 0:fade_state=1;ele.alt=alt;ele.setAttribute('src',im.src);imagefade.start(0,0);break;case 1:fade_state=2;ele2.alt=alt;ele2.setAttribute('src',im.src);imagefade.start(1,250);break;case 2:fade_state=1;ele.alt=alt;ele.setAttribute('src',im.src);imagefade.start(0,250);break};ele=document.getElementById("maincaption");ele.innerHTML=image_array[current_pi_display].caption}
function imagepanel(image_filename,alt,cap){this.filename=image_filename;this.alt=alt;this.caption=cap;this.loaded=false;this.image=new Image();this.complete_timer=0};imagepanel.prototype.onload=function(){if(this.image.complete){this.loaded=true;if(this.complete_timer){clearInterval(this.complete_timer);this.complete_timer=0};if(image_waiting==this.filename)fade_image_now(this.image,this.alt)}else if(this.complete_timer==0){var self=this;this.complete_timer=setInterval(function(){self.onload()},20)}};imagepanel.prototype.load_image=function(){if(this.loaded)return true;var self=this;this.image.onload=function(){self.onload()};this.image.src="projects/images/"+this.filename+".jpg";return false}
function display_image(i){var ele;var hline=document.getElementById("pitop");var pnum=document.getElementById("pagenumber");current_pi_display=i;check_pi_arrows();check_pi_scroll();pnum.innerHTML=(current_pi_display+1)+" / "+pi_count;mslide.starth(15+((current_pi_display-current_pi)*101),150);if(playing_flash){var ic=document.getElementById("iframeid");var fc=document.getElementById("flashvideo");fc.removeChild(ic);playing_flash=false};if(image_array[i].alt=="video"){image_waiting="";fade_image_now(videob,"");var fc=document.getElementById("flashvideo");var ic=document.createElement("iframe");ic.width="502";ic.height="282";ic.frameborder="0";ic.id="iframeid";ic.scrolling="no";fc.appendChild(ic);playing_flash=true;ic.src="projects/videos/"+image_array[i].filename+".html"}else{image_waiting=image_array[i].filename;if(image_array[i].load_image())fade_image_now(image_array[i].image,image_array[i].alt)};check_pi_arrows()}
function initialise_project_images(){var i;var ele=document.getElementById("piimages");var im;var id;var ni;var newa;pi_count=image_array.length;if(pi_count==0){document.getElementById("piprev").style.visibility="hidden";document.getElementById("pinext").style.visibility="hidden";document.getElementById("pitop").style.visibility="hidden";document.getElementById("pibottom").style.visibility="hidden";return};for(i=0;i<pi_count;i++){newa=document.createElement("a");id="pi"+i;im=document.createElement(id);im.style.position="absolute";im.style.left=(i*101)+"px";im.style.top="6px";ni=document.createElement('img');ni.src="projects/thumbs/"+image_array[i].filename+".jpg";ni.alt=image_array[i].alt;newa.href="#";newa.className=""+i;newa.onclick=function(){display_image(parseInt(this.className))};im.appendChild(ni);newa.appendChild(im);ele.appendChild(newa)};islide=new emootslide("piimages",0,0);mslide=new emootslide("mslide",0,0);current_pi=0;imagefade=new emootfade("mainimage2",0);display_image(0)}
function add_pinfo(me,stub){}
function add_qinfo(me,stub){}
function main_in(se){slide_effect[se].main_in()}
function main_out(se){slide_effect[se].main_out()}
function sub_in(se){slide_effect[se].sub_in()}
function sub_out(se){slide_effect[se].sub_out()}
function get_project_number(project){var ele;var ss;for(p=1;p<=total_projects;p++){ele=document.getElementById("p"+p);ss=""+ele;if(ss.indexOf(project)>=0)return p};return 0}
function go_projects(n){var project_number=0;var p;total_projects=n;if(which_project!="all")project_number=get_project_number(which_project);for(p=1;p<=total_projects;p++){slide_effect[p-1]=new emootslide("slide"+p,(project_number==p)?0:115,0);if(project_number==p){var ele=document.getElementById("slide"+p);ele.style.backgroundColor="#8d101d"}};if(which_project!="all"){initialise_project_images();var which_first=gup('top');var which_fint=0;if(which_first){which_fint=parseInt(which_first);if(which_fint<0||which_fint>=total_projects)which_fint=0}else which_fint=(which_project=="all")?0:pnorm(project_number-2);initialise_projects(which_fint)}}