    var tempImg;
    var projSubTitle =[];
    var projSubArray = ["Urban Design","Product Design","Exhibits","Architecture"];
    var projSubSubArray =[];
    var myHTML;
    var myText;
    var secArray;
    var curHead;
    var tempHead;
    var curSub;
    var tempSub;
    var tempList;
    imgArray = new Array();
    
$(document).ready(function(){
var firstTime = true;
var myHTML = '';
    //READ IN MENU VALUES CREATED BY INDEXIBIT
    //REMOVE FIRST UL (MAIN) AND CREATE SIDEBAR MENU
    $('#navigation ul:first-child').remove();
    //Start new nav html
    //myHTML = '<ul>';    
    //Step through all navigation ul's, for each section title...
    $('#navigation ul').each(function(){
        secArray = ($(this).find("li:first-child").html()).split("_");
        //REMOVE THE SECTION TITLE AND GET ALL THE OTHER ITEMS
        $(this).find("li:first-child").remove();
        tempList = $(this).html();
        if(firstTime){
            //firstTime = false;
            curHead = secArray[0];
            curSub = secArray[1];
            myHTML = myHTML + '<ul class="header">&raquo; '+curHead+'</ul><ul class="sublists"><ul class="subheader">&ndash; '+curSub+'</ul>';
        }
        tempHead = secArray[0];
        tempSub = secArray[1];
        if(tempSub == undefined){
           
           
            if(firstTime){
                firstTime = false;
                myHTML = '<ul class="header">&raquo; '+curHead+'</ul><ul class="list">'+tempList+'</ul>';
            }else{
                firstTime = false;
                //alert(myHTML);
                curHead = tempHead;
                if(curHead == $('a', this).html()){
                    var tempConst = ($('li', this).html()).toLowerCase();
                    myHTML = myHTML +'</ul><ul class="header_link">&raquo; '+tempConst+'</ul>';
                }else{
                    myHTML = myHTML +'</ul><ul class="header">&raquo; '+curHead+'</ul><ul class="list">'+tempList+'</ul>';
                }
            }
        }else{
        
            if(tempHead == curHead){
                //We're in the Same Main Header
                if(tempSub == curSub){
                        myHTML = myHTML+'<ul class="list">'+tempList+'</ul>';
                }else{
                    //We're in the same Header, but a new subHeader
                    curSub = tempSub;
                    myHTML = myHTML + '<ul class="subheader">&ndash; '+curSub+'</ul><ul class="list">'+tempList+'</ul>';
                }
            }else{
                //We're in a new Header
                curSub = tempSub;
                curHead = tempHead;
                myHTML = myHTML + '</ul><ul class="header">&raquo; '+curHead+'</ul><ul class="sublists"><ul class="subheader">&ndash; '+curSub+'</ul><ul class="list">'+tempList+'</ul>';
            }
        }
    });
    //CLOSE NAVIGATION
    myHTML = myHTML + '<ul class="header_link">» <a href="http://rocker-lange.com/blog/">news blog</a></ul></ul>';
    $('#navigation').html(myHTML);


    //HIDE AND SHOW SUBMENU FUNCTIONS
    $(".sublists").hide();
    $(".list").hide();
    $(".subheader").toggle(function(){
        $(this).next().show();
    },function(){
        $(this).next().hide();
    });
    $(".header").toggle(function(){
        $(this).next().show();
    },function(){
        $(this).next().hide();
    });
    
    
    //EXPAND LIST TO CURRENT MENU ITEM
  if(window.location.href.indexOf('?')!=-1){
  $("li a").each(function(){
    if($(this).attr("href").indexOf(window.location.href)!=(-1)){
        if($(this).parent().parent().prev().attr("class")=="subheader"){
            $(this).parent().parent().show();
            $(this).parent().parent().prev().show();
            $(this).parent().parent().parent().show();
        }
        if($(this).parent().parent().prev().attr("class")=="header"){
            $(this).parent().parent().show();
            $(this).parent().parent().prev().show();
        }
    }
  });  
  }

    
    //BIND CLICK OF ITEM TO LOAD TITLE
    $('#navigation li').bind("click",function(){
    });
    
    //BIND CLICK OF "MORE..." TO SHOW REST OF TEXT
    $('.seeMore').bind("click",function(){
        $(".maintext").html(myText);
        $(".maintext").css({height:"auto"});
        $(this).remove();
    });
    
    //GET ALL THUMB SOURCES IF THEY EXIST
    var firstTime = true;
    var imgCount = 0;
    var myHTML = '<ul>';
    try{
        $(".thumb img").each(function(){
            imgCount++;
            if(firstTime){
                myHTML = myHTML + "<li><img class='active' height='40px' src='"+$(this).attr("src")+"' /></li>";
                tempImg = $(this).attr("src");
                imgArray.push(tempImg);
                firstTime = false;
            }else{
                myHTML = myHTML + "<li><img height='40px' src='"+$(this).attr("src")+"' /></li>";
                imgArray.push($(this).attr("src"));
            }
        });
        myHTML = myHTML+"</ul>";
        //REMOVE PHP CREATED IMG CONTAINE AND WRITE THE HTML IN OUR THUMB CONTAINER
        $("#img-container").remove();
        if(imgCount>1){
            $("#thumbs").html(myHTML);
        }else{
            $("#thumbs").remove();
        }
        //SET THE MAIN IMAGE TO THE FIRST IMAGE, TRIM OFF THE FIRST 3 LETTERS TO GET MAIN IMAGE, NOT THUMB
        getSource(tempImg);
        //LOAD IMAGE SRC INTO AN ARRAY FOR PRELOADER
        myHTML = "<img src='"+tempImg+"' />";
        $("#mainimage").html(myHTML);
    }catch(err){
        //REMOVE IMAGE CONTAINER
        $("#imagecontainer").remove();
    }
    
    //PRELOAD IMAGES
     preload_image_object = new Image();
     for(var i=0; i<imgArray.length; i++) {
         getSource(imgArray[i]);
         preload_image_object.src = tempImg;
      }
    
        //CHANGE IMAGE AND FOCUS ON THUMB CLICK
    $("#thumbs img").each(function(){
        $(this).bind("click",function(){
            $("#thumbs img").attr("class","");
            $(this).attr("class","active");
            getSource($(this).attr("src"));
            $("#mainimage img").attr("src",tempImg);
        });
    });

    //REMOVE TEXTBOX IF THIS IS THE HOMEPAGE
    var isMain=($("body").attr("class")).split("-");
    var urlVars =(window.location.href.substring(window.location.href.lastIndexOf('?'),window.location.href.length));
    
    
    if(isMain[1]==1){
        $("#textcontainer").remove();
    }else{
        myText = $(".maintext").html();
        if((urlVars.toLowerCase().indexOf('profile')==(-1))&&(urlVars.toLowerCase().indexOf('profoffice')==(-1))&&(urlVars.toLowerCase().indexOf('contact')==(-1))){
            var tempText = myText.substring(0,400); 
            tempText = tempText.substring(0, tempText.lastIndexOf(' '));
            $(".maintext").html(tempText+"...");
             $(".maintext").css({height:"auto"});
        }else{
            $(".maintext").css({height:"auto"});
            $(".seeMore").remove();
        }
    }
    
    //RESIZE IMAGE IF PARTNERS PAGE
    if($("#title h1").html().toLowerCase().indexOf("partners")!=(-1)){
        $("#mainimage").height(200);
    };
    


});

function getSource(mySrc){
    var startTrim = mySrc.lastIndexOf('/');
    tempImg = mySrc.substring(0,startTrim) +"/"+ mySrc.substring(startTrim+4);
    return;
}



