/* 

jQuery FormBox - Copyright AddyOsmani.com, 2010.
Released under the GPL for open-source use

*/
var $j = jQuery.noConflict();
$j(window).load(function(){
	
var tabs = $j(".toplinks"); //div container
var tabPanesContainer = $j(".cart-sidebar");
var tabPanesAll = $j(".cart-sidebar").css({'position' : 'absolute', 'height' : '0px' , 'overflow' : 'hidden'});
var tabMenuLinks = $j("ul.links li.shp-itemport"); //selected li
var regularLinks = $j("ul.links li");
var dropDownSpeed = 500;
var dropUpSpeed   = 500;
//var menuHeight = '240px';
var menuHeight = document.getElementById('offsetheight').value;


/*Close the currently open menu*/
function closeMenu()
{
	tabMenuLinks.removeClass('activeTab');
	
	    tabPanesContainer.stop().animate({
	        height: '0px'
	    }, dropUpSpeed);	
}

/*Handle non tab-menu links*/
regularLinks.hover(function() 
{
    tabPanesContainer.stop().animate({
        height: '0px'
    });
    tabMenuLinks.removeClass('activeTab');
    $j(this).addClass('activeTab');
}, function() {
    $j(this).removeClass('activeTab');
});

/*Handle tab-menu links*/
tabMenuLinks.hover(function() 
{
	//alert(document.getElementById('cart-sidebar').offsetHeight);
    var thisMenuItem = $j(this);

    /*get the offset of this item in respect to the page*/
    var thisMargin   = thisMenuItem.offset().left;
    
    /*get the offset of the navigation bar in respect to the page*/
    var tabsOffset   = tabs.offset().left;
    var thisIndex = thisMenuItem.index();
    
    thisMargin = Math.floor(thisMargin - tabsOffset);
    
       
    var thisOffset = thisMargin - 52;
    
    /* handle IE margin difference*/
    if($j.browser.msie)
    {
      thisOffset = thisMargin - 15;
    }
    

    tabPanesContainer.css('margin-left', thisOffset);

    tabPanesContainer.stop().animate({
        height: menuHeight
    }, dropDownSpeed);
	
	
    
    tabMenuLinks.removeClass('activeTab');
    thisMenuItem.addClass('activeTab');


    var thisHash = thisMenuItem.find("a").attr('href');
    var tabClicked = tabPanesAll.filter(thisHash);

    
    tabClicked.appendTo(tabPanesContainer).show();
	
	
    
    return false;


}, function() {

   $j(this).stop();
   
});


/*
Display Tooltips on hovering over the input fields if an
alt tag is present
*/
$j('input').hover(function()
{
	var thisItem = $j(this);
	var msgTip = thisItem.attr('alt');
	
	if(msgTip.length)
	{
	
	  $j('body').append('<div id="menuTooltip">\
				<p>'+  msgTip +'</p>\</div>');
	 
			var pos = thisItem.offset();  
			var width = thisItem.width();
	 
			$j("#menuTooltip").css( { "left": (pos.left + 115) + "px", "top":pos.top - 90 + "px" } );
			$j("#menuTooltip").fadeIn('slow');
	}
	 
}, function()
{  
  $j('div#menuTooltip').remove();
});

/*Handle a user hovering over the tab container*/
tabPanesContainer.hover(function() 
{
 
}, function() 
{  
    closeMenu();
});


$j('.edges').hover(function()
{
   closeMenu();
   
}, function()
{
});

});
	
	
