 function gi(n,e){return(e||document).getElementById(n);}function gt(t,e){return(e||document).getElementsByTagName(t);}function ne(n){return document.createElement(n);}function ae(e,t,f,c){if(e.addEventListener)e.addEventListener(t,f,c);else if(e.attachEvent)e.attachEvent('on'+t,f);else e['on'+t]=f;}var lock=0,ajax,subajax,timeout=0,width,height,make_task=0,ajax_dest;function checktimeout(){if(timeout){if(ajax_dest==undefined){ajax_dest=ajax.src;}document.location=ajax_dest;ajax_dest=undefined;}}var cache=new Array(),tasks=new Array(),page_now,page_load='',page;function change_page(){if(!ajax)return 1;if(lock)return 0;timeout=1;first=0;return 1;}function page_loaded(e){timeout=0;if(first)return;var r=getContent(e);if(r){if(pageTracker){var track=r.location.href.substring(r.location.href.lastIndexOf('/',20));pageTracker._trackPageview(track);}document.title=gt('title',r).item(0).text;if(lock&&!make_task){if(tasks.length<20)tasks.push(r.location);return;}make_task=0;lock=1;if(!gi('link_left',r)||!gi('link_right',r)||!gi('menu',r)){document.location=r.location;return;}page_load=new String(r.location);page_load=page_load.substr(page_load.lastIndexOf('/',20));if(!gi('layout',r)||!gi('content',r)||!pages[page_now]||!pages[page_now][page_load]){document.location=r.location;return;}if(pages[page_now][page_load][pages[page_now][page_load].length-1][0].indexOf('_mid')>-1)cache.push(gi('middle',r).innerHTML);else cache.push(gi('content',r).innerHTML);page_html=gi('layout',r).innerHTML;if(cache.length==pages[page_now][page_load].length){page=1;page_scroller(0);}else{try{timeout=1;subajax.src=pages[page_now][page_load][cache.length-1][1];}catch(err){document.location=r.location;}}}}function subpage_loaded(e){timeout=0;if(first)return;var r=getContent(e);if(r){if(page_load==''&&!lock){history.back(1);}if(!gi('content',r)){document.location=r.location;return;}if(pages[page_now][page_load][cache.length][0].indexOf('_mid')>-1)cache.push(gi('middle',r).innerHTML);else cache.push(gi('content',r).innerHTML);if(cache.length==pages[page_now][page_load].length){page=1;page_scroller(1);}else{timeout=1;subajax.src=pages[page_now][page_load][cache.length-1][1];}}}function page_scroller(slide_fast){if(page>cache.length){delete cache;cache=new Array();page_now=page_load;gi('layout').innerHTML=page_html;if(!gi('newcontent'))gi('page-body').innerHTML+='<div id="newcontent" class="content" style="display:none"></div>';if(tasks.length>0){make_task=1;ajax.src=tasks.shift();}else{check_links();page_load='';lock=0;}return;}switch(pages[page_now][page_load][page-1][0]){case'top_mid':;case'bottom_mid':;if(!gi('newmiddle'))gi('middle').parentNode.innerHTML+='<div id="newmiddle"></div>';if(page==cache.length)gi('newmiddle').innerHTML=cache[0];else gi('newmiddle').innerHTML=cache[page];break;default:;if(page==cache.length)gi('newcontent').innerHTML=cache[0];else gi('newcontent').innerHTML=cache[page];}switch(pages[page_now][page_load][page-1][0]){case'right':;slide(1,0,0,slide_fast);break;case'left':;slide(1,1,0,slide_fast);break;case'top':;slide(0,0,0,slide_fast);break;case'bottom':;slide(0,1,0,slide_fast);break;case'top_mid':;slide(0,0,1,slide_fast);break;case'bottom_mid':;slide(0,1,1,slide_fast);break;}}var wci;function slide(h,s,m,f){if(wci)window.clearInterval(wci);var c,n;if(m){c=gi('middle');n=gi('newmiddle');mh=c.clientHeight;mw=width;}else{c=gi('content');n=gi('newcontent');mh=height;mw=width;}c.style.overflow='hidden';n.style.overflow='hidden';if(h){n.style.currentWidth=0;n.style.width='0px';if(!s)n.style.left=width+'px';else{n.style.left='0px';n.scrollLeft=mw;}}else{n.style.currentHight=0;n.style.height='0px';if(!s)n.style.top=mh+'px';else{n.style.top='0px';n.scrollTop=mh;}}n.style.display='block';p=0;wci=window.setInterval(function(){if(h){if(f)p+=120;else p+=60;c.currentWidth=mw-p;c.style.width=(mw-p)+"px";if(!s){c.scrollLeft=p;n.style.left=(mw-p)+"px";}else{n.scrollLeft=mw-p;c.scrollLeft=0;c.style.left=p+"px";}n.currentWidth=p;n.style.width=p+"px";}else{if(f)p+=60;else p+=40;c.currentHeight=mh-p;c.style.height=(mh-p)+"px";if(!s){c.scrollTop+=p;n.style.top=(mh-p)+'px';}else{n.scrollTop=mh-p;c.scrollTop=0;c.style.top=p+'px';}n.currentHeight=p;n.style.height=p+"px";}var offset_horiz=60;if(f)offset_horiz=120;var offset_vert=40;if(f)offset_vert=60;if((h&&mw-p<offset_horiz)||(!h&&mh-p<offset_vert)){window.clearInterval(wci);c.style.display='none';c.innerHTML=n.innerHTML;if(h){c.style.left='0px';c.scrollLeft=0;c.currentWidth=mw;c.style.width='';}else{c.style.top='0px';c.scrollTop=0;c.style.height='';}c.style.overflow='';c.style.display='';n.style.display='none';n.innerHTML='';n.scrollLeft=0;n.scrollTop=0;page++;page_scroller(f);}},5);}function check_links(){if(pages[page_now]){var s;var o=gt('A');var glubRE=new RegExp("/*(glub\.com)/");for(i=0,l=o.length;i<l;i++){var href=o[i].href;if(!href.match(glubRE))continue;s=o[i].href.substr(o[i].href.lastIndexOf('/',20));if(pages[page_now][s]){ae(o[i],'click',change_page,1);o[i].target='ajx';}}delete href;delete glubRE;delete o;}var c=gi('middle');if(!c)c=gi('content').clientHeight;else c=c.clientHeight+105;if(c>562){gt('DIV',gi('page-right'))[0].style.height=(c-320)+'px';gt('DIV',gi('page-left'))[0].style.height=(c-320)+'px';}}function getContent(i){var d=i.contentDocument;if(!d&&window.frames)d=window.frames[i.id].document;if(!d&&i.contentWindow)d=i.contentWindow.document;if(d)return d;return null;}if(parent==window)ae(window,'load',function(){page_now=new String(document.location);page_now=page_now.substr(page_now.lastIndexOf('/',20));first=1;width=gi('content').clientWidth;height=gi('content').clientHeight;var d=ne('DIV');d.innerHTML='<iframe name="ajx" id="ajx" style="display:none" onload="page_loaded(this)" src="'+document.location+'"></iframe><iframe name="subajx" id="subajx" style="display:none" onload="subpage_loaded(this)" src="'+document.location+'"></iframe>';document.body.appendChild(d);gi('page-body').innerHTML+='<div id="newcontent" class="content" style="display:none"></div>';ajax=gi('ajx');subajax=gi('subajx');check_links();},1)
