function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}
function addResizeEvent(func){var oldonresize=window.onresize;if(typeof window.onresize!='function'){window.onresize=func;}else{window.onresize=function(){oldonresize();func();}}}
function replaceAlign(){if(!document.getElementsByTagName)return false;if(!document.getElementsByTagName('img'))return false;var imgList=document.getElementsByTagName('img');for(var i=0;i<imgList.length;i++){var align=imgList[i].getAttribute('align');if(align){if(align=='left'){imgList[i].className+=' left';}
if(align=='right'){imgList[i].className+=' right';}
if(align=='middle'){imgList[i].className+=' middle';}
imgList[i].removeAttribute('align')}}}
function replaceTarget(){if(!document.getElementsByTagName)return false;if(!document.getElementsByTagName('a'))return false;var aList=document.getElementsByTagName('a');for(var i=0;i<aList.length;i++){var target=aList[i].getAttribute('target');if(target){aList[i].className+=' newwindow';aList[i].removeAttribute('target')}}}
window.onload=function(){if(!document.getElementsByTagName)return false;var lnks=document.getElementsByTagName("a");for(var i=0;i<lnks.length;i++){if(lnks[i].className=="popup"){lnks[i].onclick=function(){popUp(this.getAttribute("href"));return false;}}}}
function popUp(winURL){window.open(winURL,"popup");}
hdrHover=function(){if(document.getElementById('headerNav')!=null){if((document.all)&&(document.getElementById)){var hdrCat=document.getElementById("headerNav").getElementsByTagName("li");for(var i=0;i<hdrCat.length;i++){hdrCat[i].onmouseover=function(){this.className+=" hdrhover";}
hdrCat[i].onmouseout=function(){this.className=this.className.replace(new RegExp(" hdrhover\\b"),"");}}}}}
function setFooterHeight(){if(!document.getElementById)return false;if(!document.getElementById('header'))return false;if(!document.getElementById('content'))return false;if(!document.getElementById('footer'))return false;hdrHght=document.getElementById('header').offsetHeight;cntHght=document.getElementById('content').offsetHeight;ftrHght=document.getElementById('footer').offsetHeight;bdyHght=alertSize();totHght=hdrHght+cntHght+ftrHght;if(totHght<bdyHght){difHght=bdyHght-totHght;document.getElementById('footer').style.height=((ftrHght+difHght)-65+'px');}}
function alertSize(){var myHeight=0;if(typeof(window.innerWidth)=='number'){myHeight=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientHeight)){myHeight=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientHeight)){myHeight=document.body.clientHeight;}
return myHeight;}
function projectSwitch(){if(!document.getElementById)return false;if(!document.getElementById('projectGallery'))return false;if(!document.getElementById('mainImage'))return false;var aList=document.getElementById('projectGallery').getElementsByTagName("a");var image=document.getElementById('mainImage');if(aList.length<2){document.getElementById('featureImages').className+=" hide";}
for(var i=0;i<aList.length;i++){aList[i].onclick=function(){image.setAttribute('src',this.getAttribute('href'));return false;}}}
function initializeFlash(){if(!document.getElementById)return false;if(document.getElementById('flashcontent-left')){var so=new SWFObject("/swf/header-home-left.swf","flash-left","697","319","8","#fff");so.addParam("wmode","transparent");so.write("flashcontent-left");}
if(document.getElementById('flashcontent-right')){var so=new SWFObject("/swf/header-home-right.swf","flash-right","261","319","8","#fff");so.addParam("wmode","transparent");so.write("flashcontent-right");}
if(document.getElementById('flashcontent-project')){var so=new SWFObject("/swf/featuredprojects.swf","flash-project","550","400","8","#fff");so.addParam("wmode","transparent");so.write("flashcontent-project");}}
addLoadEvent(replaceAlign);addLoadEvent(replaceTarget);addLoadEvent(hdrHover);addLoadEvent(setFooterHeight);addResizeEvent(setFooterHeight);addLoadEvent(projectSwitch);addLoadEvent(initializeFlash);