﻿function highlightPara(para,opacity){
    //document.getElementById(para).className = newClass
    

    
     document.getElementById(para).style.filter = "alpha(opacity:"+opacity+")";

}

function showContent(imgID,contentID){

    var contentDiv = document.getElementById(contentID)
    //var imgID = document.getElementById(imgID);
        for (var x = 1; x <= 9; x++){
        document.getElementById('ex'+x).style.display = 'none';
        }
        for (var x = 1; x <= 9; x++){
        document.getElementById('ex'+x+'Link').className = '';
        }

    contentDiv.style.display = 'block';
    document.getElementById(imgID).className = 'current';
    fadeInEx(imgID,50);


}



function showContentWho(linkID){

    var contentDiv = $('ex_'+linkID)
    var newImage = 'staff_img_'+linkID+'.jpg'
    var imgID = 'img'+linkID
   
        for (var x = 1; x <= 9; x++){
            document.getElementById('ex'+x).style.display = 'none';
        }
        for (var x = 1; x <= 9; x++){
        document.getElementById('ex'+x+'Link').className = '';
        }

    document.getElementById(imgID).src = "images/"+newImage;
    //alert(document.getElementById(imgID).src)
    contentDiv.style.display = 'block';
    document.getElementById(linkID).className = 'current';
    //fadeInEx(linkID,50);


}
function revertImage(newImage,imgID){
    document.getElementById(imgID).src = "images/"+newImage;
}
function fadeInEx(objId,opacity,content,min,max) {

  if (document.getElementById) {
    obj = document.getElementById(objId);
    
        if (opacity < 100) {
       
          setOpacity(obj, opacity);
          
          opacity += 5;
         
            window.setTimeout("fadeInEx('"+objId+"',"+opacity+","+content+","+min+","+max+")", 100);
        }else{
        }
     
  }
}

function showDiv(divID,cT,cR,cB,cL){
    //document.getElementById(divID).style.opacity = '100';
    
    if (document.getElementById(divID).style.zIndex == 100){
        hideDiv(divID,cT,cR,cB,cL)
    }else{
        document.getElementById(divID).style.filter = "alpha(opacity:100)";
        document.getElementById(divID).style.zIndex = "100";
        //document.getElementById(divID).style.clip="rect(0px,550px,350px,0px)"
       // alert("L")
        grow(divID,cT,cR,cB,cL);
        
        document.getElementById('introDiv').style.display = 'none';
        
        for (var x = 1; x <= 9; x++){
        document.getElementById('ex'+x+'Div').style.display = 'none';
        }
         document.getElementById(divID+'Div').style.display = 'block';

     }
}
function hideDiv(divID,cT,cR,cB,cL){
    document.getElementById(divID).style.filter = "alpha(opacity:50)";
    document.getElementById(divID).style.zIndex = "1";
    document.getElementById(divID).style.clip="rect("+cT+"px,"+cR+"px,"+cB+"px,"+cL+"px)"
 }



//function grow(objId,imgWidth,imgHeight,marHeight) {
function grow(objId,cT,cR,cB,cL) {

  var cTFinal = 0;
  var cRFinal = 550;
  var cBFinal = 350;
  var cLFinal = 0;
  var cTNext = cT;
  var cRNext = cR;
  var cBNext = cB;
  var cLNext = cL;
  
  var nextStep;
  
  if (document.getElementById) {
  

    obj = document.getElementById(objId);
    if (cT > cTFinal) {
        cTNext -= 5;
        document.getElementById(objId).style.clip="rect("+cTNext+"px,"+cRNext+"px,"+cBNext+"px,"+cLNext+"px)"
        nextStep = true;
    }
    if (cR < cRFinal) {
        cRNext += 5;
        document.getElementById(objId).style.clip="rect("+cTNext+"px,"+cRNext+"px,"+cBNext+"px,"+cLNext+"px)"
        nextStep = true;
    }else if (cR > cRFinal) {
        cRNext -= 5;
        document.getElementById(objId).style.clip="rect("+cTNext+"px,"+cRNext+"px,"+cBNext+"px,"+cLNext+"px)"
        nextStep = true;
    }

    if (cB < cBFinal) {
        cBNext += 5;
        document.getElementById(objId).style.clip="rect("+cTNext+"px,"+cRNext+"px,"+cBNext+"px,"+cLNext+"px)"
        nextStep = true;
    }else if(cB > cBFinal) {
        cBNext -= 5;
        document.getElementById(objId).style.clip="rect("+cTNext+"px,"+cRNext+"px,"+cBNext+"px,"+cLNext+"px)"
        nextStep = true;
    }
    if (cL < cLFinal) {
        cLNext += 5;
        document.getElementById(objId).style.clip="rect("+cTNext+"px,"+cRNext+"px,"+cBNext+"px,"+cLNext+"px)"
        nextStep = true;
    }else if(cL > cLFinal) {
        cLNext -= 5;
        document.getElementById(objId).style.clip="rect("+cTNext+"px,"+cRNext+"px,"+cBNext+"px,"+cLNext+"px)"
        nextStep = true;
    }    
    if (nextStep == true) {
      //alert(""+objId+","+cTNext+","+cRNext+","+cRNext+","+cRNext+"")
      window.setTimeout("grow('"+objId+"',"+cTNext+","+cRNext+","+cBNext+","+cLNext+")", 1);
    }
  }
}





function fadeOut(objId,opacity,content) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    
        if (opacity > 10) {
        
          setOpacity(obj, opacity);
          
          opacity -= 5;
            window.setTimeout("fadeOut('"+objId+"',"+opacity+","+content+")", 50);
        }else{
            
            
            //var content = parseInt(content)+1;
            //if (content == 9){
           //     content = 0;
           // }
            //loadExpertise(content)
           
        }
     
  }
}



function fadeIn(objId,opacity,content,min,max) {

  if (document.getElementById) {
    obj = document.getElementById(objId);
    
        if (opacity < 100) {
       
          setOpacity(obj, opacity);
          
          opacity += 5;
         
            window.setTimeout("fadeIn('"+objId+"',"+opacity+","+content+","+min+","+max+")", 100);
        }else{
         
            if (content == max){
                content = min
            }else{
            content = content + 1
            }
           window.setTimeout("loadExpertise('"+objId+"',"+content+","+min+","+max+")", 2000);
        }
     
  }
}
function setOpacity(obj, opacity) {

  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
    }

var pausecontent=new Array()
pausecontent[0]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_1.jpg" alt"Concept Labs"/></a>'
pausecontent[1]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_2.jpg" alt="Workshops"/></a>'
pausecontent[2]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_3.jpg" alt="Projectives"/></a>'
pausecontent[3]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_4.jpg" alt="Collages"/></a>'
pausecontent[4]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_5.jpg" alt="Video"/></a>'
pausecontent[5]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_6.jpg" alt="In-Situ Sessions"/></a>'
pausecontent[6]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_7.jpg" alt="Banter Buses"/></a>'
pausecontent[7]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_8.jpg" alt="Ethnography"/></a>'
pausecontent[8]='<a href="expertise.htm" class="head"><img src="images/expertise/expertise_9.jpg" alt="Digital People"/></a>'



function loadExpertise(divID,content,min,max){

    document.getElementById(divID).innerHTML = pausecontent[content];
    
    fadeIn(divID,0,content,min,max)
}



function pageInit() {
    if ($('expertise2')){
        var links = document.getElementsByTagName("a");
        for (var i=0; i < links.length; i++) {
            if (links[i].className.match("profileLink")) {
                links[i].onmouseover = function() {
                
                    
                    var title_search = this.id.split("_");
                    showProfile(title_search[1]);
                }
                links[i].onmouseout = function() {
                    showProfile(false);
                }
                
            }
        }
    }


}

function showProfile(profileID){
        
        var imgs = document.getElementsByTagName("img");
        for (var i=0; i < imgs.length; i++) {
            if (imgs[i].className.match("profileImg")) {
              
                    var imageID = imgs[i].id.split("_");
                    imgs[i].src = "images/staff_"+imageID[1]+".jpg"
                    $('ex'+imageID[1]).hide();
            }
        }
        
        if ($('img_'+profileID)){
            var selImage = $('img_'+profileID)
            selImage.src = "images/staff_img_"+profileID+".jpg"
            $('ex'+profileID).style.display = 'block';
        }
        
 

}
Event.observe ( window, "load", function(){ pageInit(); } );
