// tabs events for all pages
var totaltabs  = 4;

window.onload = function(){ 
    setTabsOnReady(1);
}

$(document).ready(function() {

    // set mainmenu actions
    $("#ctl00_Wuc_header1_HL_products").mouseover(function() {
            showMenu(this,"products_flyout");
    });
    
    $("#ctl00_Wuc_header1_HL_solutions").mouseover(function() {
            showMenu(this,"solutions_flyout");
    });
    
    $("#ctl00_Wuc_header1_HL_infrastructuur").mouseover(function() {
            showMenu(this,"infrastructuur_flyout");
    });
    
    $("#ctl00_Wuc_header1_HL_partners").mouseover(function() {
            showMenu(this,"partners_flyout");
    });
    
    $("#ctl00_Wuc_header1_HL_support").mouseover(function() {
            showMenu(this,"support_flyout");
    });
    
    $("#ctl00_Wuc_header1_HL_contact_overview").mouseover(function() {
            showMenu(this,"contact_flyout");
    });
    
    $("#ctl00_Wuc_header1_HL_pins").mouseover(function() {
            showMenu(this,"pins_flyout");
    });
    
    /* set clearing spaces */
    $("#logo_pins").mouseover(function() { clearSelected(); });
    $("#logo_text").mouseover(function() { clearSelected(); });
    $("#menumain_home").mouseover(function() { clearSelected(); });
    $("#mainlinks_right").mouseover(function() { clearSelected(); });
    $("#contents").mouseover(function() { clearSelected(); });
    
    // set tab actions
    $("#tab1").mouseover(function(){
	    setTabsOnReady(1);
	});	
	
	$("#tab2").mouseover(function(){
	    setTabsOnReady(2);
	});	
	
	$("#tab3").mouseover(function(){
	    setTabsOnReady(3);
	});	
	
	$("#tab4").mouseover(function(){
	    setTabsOnReady(4);
	});	
	
	// set button actions
	$("#buttons_starter").hide();
    $("#buttons_business").hide();
    $("#buttons_e_commerce").hide();

	$("#order_items_starter").click(function(){
	    $("#buttons_starter").show();
    });
    
    $("#order_items_business").click(function(){
    	$("#buttons_business").show();
    });
    
    $("#order_items_e_commerce").click(function(){
    	$("#buttons_e_commerce").show();
    });

    $("#infobox_link1").mouseover(function() {
        showInfoboxContent(1);
    });

    $("#infobox_link2").mouseover(function() {
        showInfoboxContent(2);
    });

    $("#infobox_link3").mouseover(function() {
        showInfoboxContent(3);
    });

    $("#infobox_link4").mouseover(function() {
        showInfoboxContent(4);
    });

});

function clearSelected() {
    $("ul.main_menu").find("a").removeClass("main_menu_hover");
    $("div.main_menu_flyout").hide();
}

function showMenu(el, sub) {
    //cleanup
    clearSelected();
    //add placeholder class
    $(el).addClass("main_menu_hover");
    //get the position of the placeholder element
    var pos = $(el).offset();  
    //show the menu on the placeholder position
    $("#"+sub).css( { "left":pos.left + "px", "top":(pos.top+20) + "px" } );
    $("#"+sub).show();
}

// set the tabs on the page after document.ready state
function setTabsOnReady(TabID) {
    for (var i = 1; i <= totaltabs; i++) {
		if (i == TabID) {
		    $("#tab"+i).hide();
	        $("#tab_hover"+i).show();
			$("#tab"+i+"content").show();
		} else {
		    $("#tab"+i).show();
	        $("#tab_hover"+i).hide();
			$("#tab"+i+"content").hide();
		}
	}
}

function showInfoboxContent(cntID) {
    //cleanup
    $("ul.infobox_menu").find("a").removeClass("infobox_menu_hover");
    $("div.infobox_content").hide();
    //show stuff
    $("#infobox_link"+cntID).addClass("infobox_menu_hover");
    $("#infobox_cont"+cntID).show();
}

function showFadeInHover(urlID, panID, clng) {
    var pos = $(urlID).offset();
    var ofs = ($(urlID).text().length * 4) + clng;
    $("#"+panID).css( { "left":pos.left + ofs + "px", "top":(pos.top) + "px" } );
    fadein(panID, 500);
}

