function initMenu() {

    // hide all submenus to begin with
    $('#menu li ul').hide();
    //$('#menu li.nav a').attr("href","#");

    $('#menu li.nav>a').click(function(){
		root=$(this).parent();
		isExpandable=($(root).find('ul').length>0) ? true : false;
		
        // check that the menu is not currently animated
        if ($('#menu ul:animated').size() == 0) {
            // create a reference to the active element (this)
            // so we don't have to keep creating a jQuery object
            $heading = $(root);
            currentActiveTab=GetSiblingNumber($heading);
			
            // create a reference to visible sibling elements
            // so we don't have to keep creating a jQuery object
            $expandedSiblings = $heading.siblings().find('ul:visible');
			if(isExpandable) {
	            if ($expandedSiblings.size() > 0 ) {
	                $expandedSiblings.slideUp(300);
	                $heading.find('ul').slideDown(300);
					$.cookies.set("openMenu",currentActiveTab);
	            }
	            else {
	                $heading.find('ul').slideDown(500);
					$.cookies.set("openMenu",currentActiveTab);
	            }
			} else {
				$.cookies.set("openMenu",null);
			}
        }
		if(isExpandable) return false;
    });

    $('.nav_close').click(function(){
        $.cookies.set("openMenu",null);
    });
	
	activeTab=$.cookies.get("openMenu");
	if(activeTab) {
		$('#menu li.nav').eq(activeTab).find("ul").slideDown(300);
	}
}

function GetSiblingNumber(oElement) {
    return $(oElement).parent().children(oElement.nodeName).index(oElement);
}

function initSIFR() {


	sIFR.replace(helveticaNeueThin, {
	  selector: 'h1',
	  css: '.sIFR-root {color: #000000;}',
	  wmode: "transparent"

	});	

	sIFR.replace(helveticaNeueThin, {
	  selector: '.newsHead h2',
	  css: '.sIFR-root {color: #ffffff;}',
	  wmode: "transparent"

	});

        sIFR.replace(helveticaNeueThin, {
	  selector: '#case_head h2',
	  css: '.sIFR-root {color: #ffffff;}',
	  wmode: "transparent"
	});
        

    sIFR.replace(helveticaNeueThin, {
	  selector: '.mailingList h2',
	  css: '.sIFR-root {color: #ffffff;}',
	  wmode: "transparent"
	});

    sIFR.replace(helveticaNeueThin, {
	  selector: '#support_intro h2',
	  css: '.sIFR-root {color: #ffffff;}',
	  wmode: "transparent"
	});

    sIFR.replace(helveticaNeueThin, {
	  selector: '#support_login h2',
	  css: '.sIFR-root {color: #ffffff;}',
	  wmode: "transparent"
	});
    	
	sIFR.replace(helveticaNeueThin, {
	  selector: '.signInBG h2',
	  css: '.sIFR-root {color: #ffffff;}',
	  wmode: "transparent"

	});

	sIFR.replace(helveticaNeueThin, {
	  selector: 'h2',
	  css: '.sIFR-root {color: #000000;}',
	  wmode: "transparent"

	});

	sIFR.replace(helveticaNeueThin, {
	  selector: 'h3',
	  css: '.sIFR-root {color: #000000;}',
	  wmode: "transparent"

	});
        
        sIFR.replace(helveticaNeueThin, {
	  selector: 'span.question',
	  css: '.sIFR-root {color: #5d9fd1}',
	  wmode: "transparent"

	});

        sIFR.replace(helveticaNeueThin, {
	  selector: 'span.answer',
	  css: '.sIFR-root {color: #1266ae}',
	  wmode: "transparent"

	});

        sIFR.replace(helveticaNeueThin, {
	  selector: 'h4',
	  css: '.sIFR-root {color: #000000;}',
	  wmode: "transparent"

	});

        sIFR.replace(helveticaNeueThin, {
	  selector: 'dl#case_studies dt',
	  css: '.sIFR-root {color: #000000;}',
	  wmode: "transparent"

	});

    

}

function initNewsTabs() {

	$("#industry").hide();
	$("#events").hide();

	$(".tab1 a").bind("click",function() {
		$("#news").show();
		$("#industry").hide();
		$("#events").hide();
		$("div.tabHolder > ul").removeClass("tabSet2").removeClass("tabSet3").addClass("tabSet1");
	});
	$(".tab2 a").bind("click",function() {
		$("#news").hide();
		$("#industry").show();
		$("#events").hide();
		$("div.tabHolder > ul").removeClass("tabSet1").removeClass("tabSet3").addClass("tabSet2");
	});
	$(".tab3 a").bind("click",function() {
		$("#news").hide();
		$("#industry").hide();
		$("#events").show();
		$("div.tabHolder > ul").removeClass("tabSet1").removeClass("tabSet2").addClass("tabSet3");
	});
	
}

  $(document).ready(function(){
		initSIFR();
		initMenu();
		try {
			initNewsTabs();
		} catch (e) { };
  });