// JavaScript Document

jQuery(function(){
	
	document.forms[0].action = window.location.href;
	
	jQuery('#nav h1 a').each(function(){
		
		//jQuery(this).css("text-indent","-500px");
		
		if (jQuery(this).attr('href') == 'javascript:void(0)'){
			jQuery(this)
			    .toggle(function(){                
			        jQuery(this).parent().next()
				        .css("opacity",0)
				        .slideDown(300, function(){
					        jQuery(this).animate({ "opacity" : 1 }, 200)
				        });					
			    }, function(){
				    jQuery(this).parent().next()
					    .animate({ "opacity" : 0 }, 200, function(){
							    jQuery(this).slideUp(300);
					    });
			})

			if (jQuery(this).attr("class") !== "active")
			{
			    jQuery(this).parent().next().hide().end();
			}
		}
	});
	
	// Hide news tablet
    indexWidth = parseFloat(jQuery("#index").width()) - 70
    bodyWidth = parseFloat(jQuery("body").width())
    if (bodyWidth < 1280)
    {
        indexWidth -= 50
	    toggleNewsTablet(jQuery('#news > img'));
	}
	jQuery("#index-flash").css("left", indexWidth + "px");
});	

function toggleNewsTablet(el)
{
	// get parent
	elParent = jQuery(el).parent();
	
	// Find width (new right pos of container) of the content to show
	rightPos = 0 - parseFloat(jQuery(el).next().width());
	
	// if already open
	if ( parseFloat(elParent.css("right")) !== 0)
	{
		rightPos = 0;
	}
	if (jQuery(el).siblings().filter('.subscribe').css("display") == "block")
	{
		toggleSubscribeTablet();
	}
	jQuery(el).parent().animate({ 'right': rightPos }, 300, "backin");
}

function toggleSubscribeTablet()
{
	jQuery('#news .subscribe').dequeue().slideToggle(300)	
}
