// Jeff
// www.huntingground.freeserve.co.uk

// ********** User Defining Area **********

hs4Arr=[
["wp-content/themes/c2st/images/sponsors/adler-planetarium.jpg","http://adlerplanetarium.org","Adler Planetarium"],
["wp-content/themes/c2st/images/sponsors/argonne.jpg","http://www.anl.gov","Argonne National Laboratory"],
["wp-content/themes/c2st/images/sponsors/baxter.jpg","http://www.baxter.com","Baxter International Inc."],
["wp-content/themes/c2st/images/sponsors/cbc.jpg","http://www.chicagobiomedicalconsortium.org","Chicago Biomedical Consortium"],
["wp-content/themes/c2st/images/sponsors/chicago-botanic.jpg","http://www.chicago-botanic.org","Chicago Botanic Garden"],
["wp-content/themes/c2st/images/sponsors/cct.jpg","http://www.cct.org","Chicago Community Trust"],
["wp-content/themes/c2st/images/sponsors/cmrc.jpg","http://www.childrensmrc.org","Childrens Memorial Research Center"],
["wp-content/themes/c2st/images/sponsors/city-chicago.jpg","http://cityofchicago.org","City of Chicago"],
["wp-content/themes/c2st/images/sponsors/depaul.jpg","http://www.depaul.edu","DePaul University"],
["wp-content/themes/c2st/images/sponsors/devry.jpg","http://www.devry.edu","DeVry University"],
["wp-content/themes/c2st/images/sponsors/exelon.jpg","http://www.exeloncorp.com","Exelon Corporation"],
["wp-content/themes/c2st/images/sponsors/fermilab.jpg","http://www.fnal.gov","Fermi National Accelerator Laboratory"],
["wp-content/themes/c2st/images/sponsors/field-museum.jpg","http://www.fieldmuseum.org","Field Museum"],
["wp-content/themes/c2st/images/sponsors/gti.jpg","http://www.gastechnology.org","Gas Technology Institute"],
["wp-content/themes/c2st/images/sponsors/iit.jpg","http://www.iit.edu","Illinois Institute of Technology"],
["wp-content/themes/c2st/images/sponsors/loyola.jpg","http://loyolamedicine.org","Loyola University Medical Center"],
["wp-content/themes/c2st/images/sponsors/macarthur.jpg","http://www.macfound.org","MacArthur Foundation"],
["wp-content/themes/c2st/images/sponsors/mayer-brown.jpg","http://www.mayerbrown.com","Mayer Brown LLP"],
["wp-content/themes/c2st/images/sponsors/museum-si.jpg","http://www.msichicago.org","Museum of Science & Industry"],
["wp-content/themes/c2st/images/sponsors/nu-univ.jpg","http://www.northwestern.edu","Northwestern University"],
["wp-content/themes/c2st/images/sponsors/science-chicago.jpg","http://www.sciencechicago.com","Science Chicago"],
["wp-content/themes/c2st/images/sponsors/shedd.jpg","http://www.sheddaquarium.org","Shedd Aquarium"],
["wp-content/themes/c2st/images/sponsors/tcm-mgt.jpg","http://www.torshencapital.com","Torshen Capital Management"],
["wp-content/themes/c2st/images/sponsors/u_of_c.jpg","http://www.uchicago.edu","University of Chicago"],
["wp-content/themes/c2st/images/sponsors/uic-medicine-02.jpg","http://www.uic.edu","University of Illinois at Chicago"],
["wp-content/themes/c2st/images/sponsors/uiuc.jpg","http://illinois.edu","University of Illinois at Urbana & Champaign"]// no comma at the end of last index

]

dir=0 // 0 = left 1 = right
speed=1
imageSize=100  // % set to zero to use fixedWidth and fixedHeight values
fixedWidth=120 // set a fixed width
fixedHeight=60 // set a fixed height
spacerWidth=40 // space between images

alwaysCenter=1 // center the popup 0 = no 1 = yes
popupLeft=0 // popup default left, use if not centering
popupTop=0 // popup default top, use if not centering

biggest=0
ieBorder=0
totalWidth=0
hs4Timer=null

preload=new Array()
for(var i=0;i<hs4Arr.length;i++){
preload[i]=new Image()
preload[i].src=hs4Arr[i][0]
}

function initHS4(){
scroll1=document.getElementById("scroller1")

for(var j=0;j<hs4Arr.length;j++){

scroll1.innerHTML+='<img id="pic'+j+'" src="'+preload[j].src+'" alt="'+hs4Arr[j][2]+'" title="'+hs4Arr[j][2]+'" onclick="showBigPic('+j+')">' 
if(imageSize!=0){ // use percentage size
newWidth=preload[j].width/100*imageSize
newHeight=preload[j].height/100*imageSize
}
else{ // use fixed size
newWidth=fixedWidth
newHeight=fixedHeight
}

document.getElementById("pic"+j).style.width=newWidth+"px"
document.getElementById("pic"+j).style.height=newHeight+"px"

if(document.getElementById("pic"+j).offsetHeight>biggest){
biggest=document.getElementById("pic"+j).offsetHeight
}

document.getElementById("pic"+j).style.marginLeft=spacerWidth+"px"

totalWidth+=document.getElementById("pic"+j).offsetWidth+spacerWidth

}

totalWidth+=1

for(var k=0;k<hs4Arr.length;k++){ // vertically center images
document.getElementById("pic"+k).style.marginBottom = (biggest-document.getElementById("pic"+k).offsetHeight)/2+"px"
}

scrollBox=document.getElementById("scroll_box")

if(document.uniqueID && scrollBox.currentStyle && document.compatMode!="CSS1Compat"){
ieBorder=parseInt(scrollBox.currentStyle.borderWidth)*2
} 
if(document.getElementById&&document.all){
ieBorder=parseInt(scrollBox.style.borderTopWidth)*2
}

scrollBox.style.height=biggest+ieBorder+"px"

scroll1.style.width=totalWidth+"px"

scroll2=document.getElementById("scroller2")
scroll2.innerHTML=scroll1.innerHTML
scroll2.style.left= scroll1.offsetWidth+"px"
scroll2.style.top= 0+"px"
scroll2.style.width=totalWidth+"px"

if(dir==1){
speed= -speed
}

scrollHS4()
}


function scrollHS4(){
if(paused==1){return}
clearTimeout(hs4Timer)

scroll1Pos=parseInt(scroll1.style.left)
scroll2Pos=parseInt(scroll2.style.left)

scroll1Pos-=speed
scroll2Pos-=speed

scroll1.style.left=scroll1Pos+"px"
scroll2.style.left=scroll2Pos+"px"

hs4Timer=setTimeout("scrollHS4()",50)

if(dir==0){
if(scroll1Pos< -scroll1.offsetWidth){
scroll1.style.left=scroll1.offsetWidth+"px"
}

if(scroll2Pos< -scroll1.offsetWidth){
scroll2.style.left=scroll1.offsetWidth+"px"
}
}

if(dir==1){
if(scroll1Pos>parseInt(scrollBox.style.width)){
scroll1.style.left=scroll2Pos+ (-scroll1.offsetWidth)+"px"
}

if(scroll2Pos>parseInt(scrollBox.style.width)){
scroll2.style.left=scroll1Pos+ (-scroll2.offsetWidth)+"px"
}
}

}

st=null
function pause(){
clearTimeout(hs4Timer)
clearTimeout(st)
}

function reStartHS4(){
clearTimeout(st)
st=setTimeout("scrollHS4()",100)
}

paused=0
picWin=null

function showBigPic(p){

if(hs4Arr[p][1]!=""){
paused=1

if(picWin&&picWin.open&&!picWin.closed){picWin.close()} // if picWin exists close it

if(hs4Arr[p][1].indexOf("jpg")!=-1){
bigImg=new Image()
bigImg.src=hs4Arr[p][1]

if(alwaysCenter==1){
popupLeft = (screen.availWidth - bigImg.width) / 2
popupTop = (screen.availHeight - bigImg.height) / 2
}

data="\n<center>\n<img src='"+bigImg.src+"'>\n<\/center>\n"

var winProps = "left= "+popupLeft+", top = "+popupTop+", width="+(bigImg.width+20)+", height="+(bigImg.height+20)+", scrollbars=no, toolbar=no, directories=no, menu bar=no, resizable=yes, status=no" 
picWin=window.open("","win1",winProps)
picWin.document.write("<HTML>\n<HEAD>\n<TITLE><\/TITLE>\n")
picWin.document.write("<\/HEAD>\n")
picWin.document.write("<BODY style='background-color:black;margin-top:10px;margin-left:10px'>\n")
picWin.document.write("<div id=\"display\">"+data+"<\/div>")
picWin.document.write("\n<\/BODY>\n<\/HTML>")
}
else{
picWin=window.open(hs4Arr[p][1])
}

}

}

window.onfocus=function(){
paused=0
scrollHS4()
}

onunload=function(){ // close the popup when leaving page
if(picWin&&picWin.open&&!picWin.closed){
picWin.close()
}
}