
var ix;
var tblSep = 160;
var iCenter = calcCanvas();
var curTab;
var newTab;
var fadeSpeed = 500;
//var imgOver = 'url(/images/clipart/menuOver.png)';
var imgOver = '';
var imgOut = '';
var clickable = true;

$(document).ready(function(){

    
    $('.menuOver').click(function(event) {
        menuShow(this.id);
    })
    
     $(window).resize(function(){
        iCenter = calcCanvas();
    });
    
});


function calcCanvas()
{
    var bleed =184;

    if ($.browser.msie)
	bleed =186;
	

    if ($(window).width()>1000)
        return (($(window).width()-1016)/2)+bleed;
    else
        return bleed;    
}


function SnapTo()
{
    var iLeft = ($("#"+obj2itm(newTab)).position().left)-iCenter;
    $('#tbl').stop().animate({backgroundPosition: iLeft+'px 0px'});
}

function setDefault(obj)
{

    var miObj = document.getElementById(obj + "Item");
    
    if (miObj != undefined)
    {
        setBackImg('tbl','url(/images/clipart/menuOver.png) ' + 2000  + 'px 0px no-repeat');

        $("#"+miObj.id).fadeIn(fadeSpeed,function() {fixIE(this);SnapTo();} );
        curTab = miObj;
        newTab = miObj;
    }
}

function menuShow(obj)
{
    if (obj != obj2itm(curTab) && clickable)
    {
        clickable = false;
       
        var miObj = document.getElementById(obj + "Item");
        newTab = miObj;
        
        
        if (newTab.id == "jqWorkItem")
            $(".jqMiddle").animate({height: "600px"}, 700);
        else
            $(".jqMiddle").animate({height: "280px"}, 700);
        
        
        
        
        $("#"+curTab.id).stop().fadeOut(fadeSpeed,function() { $("#"+miObj.id).fadeIn(fadeSpeed,function(){ fixIE(this); });curTab = miObj;clickable=true;SnapTo(); } );
    }
}

function fixIE(obj)
{
    if(jQuery.browser.msie)
        obj.style.removeAttribute('filter')
}

function obj2itm(obj)
{
   return obj.id.substring(0,curTab.id.length-4) 
}


function setBackImg(obj,img)
{
    document.getElementById(obj).style.background = img;
}



function getItem(obj)
{
    objTbl = document.getElementById("tbl"+obj.id.substring(3,obj.id.length));
    FadeIn(objTbl.id);
}


function FadeIn(obj)
{
    $("#"+obj).fadeIn(2000);
}


function FadeOut(obj)
{
    $("#"+obj).fadeOut(2000);
}





/////////////////////////////////////
/*
function writeTxt(obj)
{
    $('.'+obj).jTypeWriter({duration:1,type:"letter"});
}
*/
///////////////////////////////////////////



