﻿/**
 * Script to initialize and handle the links
 */
var singlePoppedOut = false;
var allPoppedOut = false;
var headerHidden = false;
var menuText;
var popupText;
var pictureSettings;

/**
 *  Functions to load on document ready event (page load done)
 **/
$(document).ready(function(){
    //fetch texts and settings
    getMenuTexts();
    getPictureSettings();
    getPopupTexts();
    //check settings in cookie, otherwise set cookie with default properties
    cookieRequest(true);
    //load a random startup picture
    loadStartupPicture();
    //bind the resizing of the browser window to the resize event of the
    bindResize();
    //load the audio player
    loadAudioPlayer();
    //load menu hovering info bindings
    loadMenuHoverInfos();
    //load gallery link bindings
    loadGalleryLinks();
    //load menu link bindings
    loadMenuLinks();
});
/**
 *  Fetches the bilingual menu item texts
 **/
function getMenuTexts(){
    $.ajax({
	url:"script/texts.php",
	type:"POST",
	data:{
	    type:"menuTexts"
	},
	dataType:"json",
	success: function(data){
	    if(data!=null){
		menuText = data;
		loadContactLanguage();
		loadAllMenusLanguage();
	    }
	}
    });
}
/**
 *  Fetches the picture settings
 **/
function getPictureSettings(){
    $.ajax({
	url:"script/texts.php",
	type:"POST",
	data:{
	    type:"pictureSettings"
	},
	dataType:"json",
	success: function(data){
	    if(data!=null){
		pictureSettings = data;
	    }
	}
    });
}
/**
 *  Fetches the popup texts
 **/
function getPopupTexts(){
    $.ajax({
	url:"script/texts.php",
	type:"POST",
	data:{
	    type:"popupTexts"
	},
	dataType:"json",
	success: function(data){
	    if(data!=null){
		popupText = data;
	    }
	}
    });
}
/**
 *  Disables all content, but the one specified as parameter
 *  @content Class of the content which will be shown
 **/
function showContent(content){
    $(".content").children().css({
	display:"none"
    });
    $("."+content).css({
	display:"block"
    });
}
/**
 *  Loads the audio player and plays a presetted song
 *  TODO: write generic function for getting songs from the audio/music/ folder
 **/
function loadAudioPlayer(){
    $("#audio_player").jPlayer({
	swfPath:"script",
	volume:66,
	oggSupport: false,
	nativeSupport: true,//natvively support html5 standards
	customCssIds: true,//for own styling
	graphicsFix: false,//for having no progress bar
	//	errorAlerts: true,//for debugging
	//	warningAlerts: true, //for debugging
	position: "absolute",
	left: "-60px",
	top: "200px",
	width: "60px",
	height: "30px",
	quality: "hight",
	bgcolor: "#000000",
	ready: function(){
	    if(audio){
		this.element.jPlayer("setFile", "audio/music/U2-Beautiful_Day.mp3").jPlayer("play");
	    }else{
		this.element.jPlayer("setFile", "audio/music/U2-Beautiful_Day.mp3");
	    }
	}
    });
}
/**
 *  Show hover info for the audio& language toggle buttons
 **/
function showHoverInfo(id){
    if($("#"+id).parent().attr("id")=="page_link"){
	$("#page_link_hover").text(menuText[language[languageSet]+id]);
	$("#page_link_hover").css({
	   "display":"block"
	});
    }else{
	$("#dynamic_buttons_hover").text(menuText[language[languageSet]+id]);
	$("#dynamic_buttons_hover").css({
	    "display":"block"
	});
    }
}
/**
 *  Hide hover info for the audio& language toggle buttions
 **/
function hideHoverInfo(){
    $(".hover_info").text("");
    $(".hover_info").css({
	"display":"none"
    });
}
/**
 *  Loads the menu span hovering on mouseover (language & audio toggle)
 **/
function loadMenuHoverInfos(){
    $("#toggle_audio").livequery("mouseover", function(event){
	var id = $(this).attr("id");
	showHoverInfo(id);
    });
    $("#toggle_audio").livequery("mouseout", function(event){
	hideHoverInfo();
    });
    $("#toggle_language").livequery("mouseover",function(event){
	var id = $(this).attr("id");
	showHoverInfo(id);
    });
    $("#toggle_language").livequery("mouseout", function(event){
	hideHoverInfo();
    });
    $("#toggle_fullscreen").hover(function(){
	var id = $(this).attr("id");
	showHoverInfo(id);
    }, function(){
	hideHoverInfo();
    });
    $("#link_tamsen_maritim").hover(function(){
	var id = $(this).attr("id");
	showHoverInfo(id);
    }, function(){
	hideHoverInfo();
    });
}
/**
 *  Switches the language of the page either from english to german
 *  or the other way round respectively
 **/
function switchLanguage(){
    //if German, set to English, otherwise set to German
    if(languageSet==0){
	languageSet = 1;
    }else{
	languageSet = 0;
    }
    //submit the request for storing this information in the cookie
    cookieRequest(false);
}
/**
 *  Toggles the audio on the page on or off. This setting will also be saved to the cookie
 **/
function toggleAudio(){
    if(audio){
	audio = false;
	$("#audio_player").jPlayer("stop");
    }else{
	audio = true;
	$("#audio_player").jPlayer("play");
    }
    cookieRequest(false);
}
/**
 *  Reloads the opened content
 **/
function reloadContent(){
    if(!allPoppedOut){
	if(lastUsedMenuLink!=""){
	    $("#"+lastUsedMenuLink).click();
	}
    }else{
	reloadPopup();
    }
}
/**
 *  Load the language for all menus depending on global language state
 **/
function loadAllMenusLanguage(){
    $(".header ul:not(#slide)").each(function(){
	loadMenuLanguage($(this).attr("class"));
    });
}
/**
 *  Sets the flag icon of the language toggle button to the opposing language,
 *  depending on which is currently shown. (ie. Site is shown in German, show English flag)
 *  @config Do not call this function directly, rather include it in a global setting!
 **/
function setFlag(){
    if(languageSet==0){
	$("#toggle_language").css({
	    "background":"url('images/menu/flag_en.png') no-repeat top left"
	});
    }else{
	$("#toggle_language").css({
	    "background":"url('images/menu/flag_de.png') no-repeat top left"
	});
    }
}
/**
 *  Sets the audio icon of the audio toggle button according to the current setting
 *  @config Do not call this function directly, rather include it in a global setting!
 **/
function setAudioIcon(){
    if(audio){
	$("#toggle_audio").css({
	    "background":"url('images/menu/player_stop.png') no-repeat top left"
	});
    }else{
	$("#toggle_audio").css({
	    "background":"url('images/menu/player_start.png') no-repeat top left"
	});
    }
}
/**
 *  Get or set the script settings in a cookie
 *  @param get True for getting the settings from the cookie, false for setting new ones
 **/
function cookieRequest(get){
    $.ajax({
	url:"script/settings.php",
	type:"POST",
	data:{
	    get:get,
	    language:languageSet,
	    audio:audio,
	    popups:popups
	},
	dataType:"json",
	success:function(data){
	    if(data!=null){
		languageSet = parseInt(data.language);
		audio = stringToBoolean(data.audio);
		popups = stringToBoolean(data.popups);
		setFlag();
		setAudioIcon();
		loadContactLanguage();
		loadMaritimLinkLanguage();
		loadAllMenusLanguage();
		reloadContent();
	    }
	}
    });
}
/**
 *  Stops a picture popup (if just opening) and pops it back in very fast
 *  @param speed The speed used to hide the popup
 **/
function closePopup(speed){
    $("#picture_popup").clearQueue();
    $("#picture_popup").stop();
    $("#picture_popup").animate({
	left:"-520px"
    }, speed);
}
/**
 *  Load the gallery link functions
 **/
function loadGalleryLinks(){
    $("#exterior").click(function(){
	loadThumbList("41M/exterior/");
    });
    $("#interior_tatii").click(function(){
	loadThumbList("41M/interior_tatii/saloon/");
    });
    $("#interior_namaste").click(function(){
	loadThumbList("41M/interior_namaste/saloon/");
    });
    $("#tatii_saloon").click(function(){
	loadThumbList("41M/interior_tatii/saloon/");
    });
    $("#tatii_main_sun_deck").click(function(){
	loadThumbList("41M/interior_tatii/main_sun_deck/");
    });
    $("#tatii_owners_apartment").click(function(){
	loadThumbList("41M/interior_tatii/owners_apartment/");
    });
    $("#tatii_guest_cabins").click(function(){
	loadThumbList("41M/interior_tatii/guest_cabins/");
    });
    $("#tatii_skylounge").click(function(){
	loadThumbList("41M/interior_tatii/skylounge/");
    });
    $("#tatii_upper_sun_deck").click(function(){
	loadThumbList("41M/interior_tatii/upper_sun_deck/");
    });
    $("#tatii_galley").click(function(){
	loadThumbList("41M/interior_tatii/galley/");
    });
    $("#tatii_bridge").click(function(){
	loadThumbList("41M/interior_tatii/bridge/");
    });
    $("#tatii_garage").click(function(){
	loadThumbList("41M/interior_tatii/garage/");
    });
    $("#namaste_saloon").click(function(){
	loadThumbList("41M/interior_namaste/saloon/");
    });
    $("#namaste_owners_stateroom").click(function(){
	loadThumbList("41M/interior_namaste/owners_stateroom/");
    });
    $("#namaste_skylounge").click(function(){
	loadThumbList("41M/interior_namaste/skylounge/");
    });
    $("#namaste_upper_sun_deck").click(function(){
	loadThumbList("41M/interior_namaste/upper_sun_deck/");
    });
    $("#namaste_captains_cabin").click(function(){
	loadThumbList("41M/interior_namaste/captains_cabin/");
    });
    $("#namaste_guest_cabins").click(function(){
	loadThumbList("41M/interior_namaste/guest_cabins/");
    });
    $("#namaste_bridge").click(function(){
	loadThumbList("41M/interior_namaste/bridge/");
    });
    $("#namaste_engine_room").click(function(){
	loadThumbList("41M/interior_namaste/engine_room/");
    });
    $("#popup_close").click(function(){
	closePopup(popupHideSpeed);
    });
}
/**
 *  Loads the menu link functions and their delegations to sub click events
 **/
function loadMenuLinks(){
    $("#toggle_audio").click(function(){
	toggleAudio();
    });
    //hover function for the menu items to switch color and show the bullet images when clicked
    $(".menu ul li p").hover(function(){
	$(this).parent().children("img").attr("src", "images/menu/menu_marker_hover.png");
	$(this).css({
	    color:"#b8b7af"
	});
    }, function(){
	$(this).parent().children("img").attr("src", "images/menu/menu_marker.png");
	$(this).css({
	    color:"#595c5f"
	});
    });
    //hover function for the menu item bullet images to switch color of their parent menu item
    $(".menu ul li img").hover(function(){
	$(this).attr("src", "images/menu/menu_marker_hover.png");
	$(this).parent().children("p").css({
	    color:"#b8b7af"
	});
    }, function(){
	$(this).attr("src", "images/menu/menu_marker.png");
	$(this).parent().children("p").css({
	    color:"#595c5f"
	});
    });
    //delegate the menu bullet click function to the actual link
    $(".menu ul li img").click(function(){
	$(this).parent().children("p").click();
    });
    /**
     *	Click functions for elements of the first menu with no sub menu (but content most likely)
     **/
    $("#first p.none").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	unloadSecondMenu();
	unloadThirdMenu();
	if(allPoppedOut){
	    hideSecondMenu();
	    hideSlides();
	    hideThirdMenu();
	    allPoppedOut = false;
	}
	if(singlePoppedOut){
	    hideSecondMenu();
	    singlePoppedOut = false;
	}
	showMenuBullet(id);
	setContentPosition(contentFirstMenu, true);
    });
    /**
     *  Click function of menu item from first menu which will open
     *  only one dropdown menu (and content most likely)
     **/
    $("#first p.single").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	lastUsedFirstSingle = id;
	unloadSecondMenu();
	unloadThirdMenu();
	if(allPoppedOut){
	    hideSlides();
	    hideThirdMenu();
	    loadSecondMenu(id);
	    allPoppedOut = false;
	    singlePoppedOut = true;
	}
	if(singlePoppedOut){
	    loadSecondMenu(id);
	}else{
	    showSecondMenu(id);
	    singlePoppedOut = true;
	}
	setContentPosition(contentFirstMenu, true);
	showMenuBullet(id);
	//load content of first link in list
	$("."+id+" li:eq(0)").children().click();
    });
    /**
     *  Click event/function of menu item from first menu which will open
     *  the whole dropdown menu (at least at first)
     **/
    $("#first p.double").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	lastUsedFirstDouble = id;
	unloadSecondMenu();
	unloadThirdMenu();
	if(singlePoppedOut){
	    showSlides();
	    showThirdMenu();
	    loadSecondMenu(id);
	    singlePoppedOut = false;
	    allPoppedOut = true;
	}
	if(allPoppedOut){
	    loadSecondMenu(id);
	}else{
	    showSecondMenu(id);
	    showSlides();
	    showThirdMenu();
	    allPoppedOut = true;
	}
	setContentPosition(contentFirstMenu, false);
	showMenuBullet(id);
	//load first click function of underlying menu
	$("."+id+" li:eq(0)").children().click();
    });
    /**
     *	Click function for item of the second menu, which will open content only
     **/
    $("#second p.none").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	if(allPoppedOut){
	    unloadThirdMenu();
	    hideThirdMenu();
	    hideSlides();
	    allPoppedOut = false;
	    singlePoppedOut = true;
	}
	setContentPosition(contentSecondMenu, true);
	showMenuBullet(id);
    });
    /**
     *	Click function for the second menu which will open the photo slides, but has no third menu
     **/
    $("#second p.single").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	lastUsedSecondSingle = id;
	if(singlePoppedOut){
	    showSlides();
	    showThirdMenu();
	    singlePoppedOut = false;
	    allPoppedOut = true;
	}
	setContentPosition(contentFirstMenu, false);
	unloadThirdMenu();
	showMenuBullet(id);
	showContent("picture");
    });
    /**
     *	Click function for item of the second menu which will open the photo slide and the third menu
     **/
    $("#second p.double").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	lastUsedSecondDouble = id;
	if(singlePoppedOut){
	    showSlides();
	    showThirdMenu();
	    singlePoppedOut = false;
	    allPoppedOut = true;
	}
	setContentPosition(contentFirstMenu, false);
	unloadThirdMenu();
	loadThirdMenu(id);
	showMenuBullet(id);
	showContent("picture");
	$("."+id+" li:eq(0)").children().click();
    });
    $("#third p").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	lastUsedThird = id;
	showMenuBullet(id);
    });
    /**
     *	Content clicks
     **/
    //about tamsen
    $("#about").click(function(){
	$(".about").children().remove();
	$(".about").load(language[languageSet]+"about.html", function(){
	    setContentPosition(contentFirstMenu, true);
	    //set the about content height and padding
	    $(".about").css({
		"height":"1200px",
		"padding-bottom":"200px"
	    });
	    showContent("about");
	});
	
    });
/**
 *  Info: Upcoming projects not needed anymore?
 **/
//    //upcoming_projects->fortyeight_m
//    $("#fortyeight_m").click(function(){
//	$(".content_upcoming_projects").children().remove();
//	$(".content_upcoming_projects").load(language[languageSet]+"upcoming_project_48m.html", function(){
//	    setContentPosition(contentSecondMenu, true);
//	    //set the inner content height and padding properties
//	    var pictures = $(".content_upcoming_projects .content_picture img").length;
//	    var upcomingHeight = 175*pictures+200;
//	    $(".content_upcoming_projects").css({
//		"height":upcomingHeight+"px",
//		"padding-bottom":"200px"
//	    });
//	    showContent("content_upcoming_projects");
//	});
//    });
//    //upcoming_projects->fiftyfive_m
//    $("#fiftyfive_m").click(function(){
//	$(".content_upcoming_projects").children().remove();
//	$(".content_upcoming_projects").load(language[languageSet]+"upcoming_project_55m.html", function(){
//	    setContentPosition(contentSecondMenu, true);
//	    //set the inner content height and padding properties
//	    var pictures = $(".content_upcoming_projects .content_picture img").length;
//	    var upcomingHeight = 175*pictures+200;
//	    $(".content_upcoming_projects").css({
//		"height":upcomingHeight+"px",
//		"padding-bottom":"200px"
//	    });
//	    showContent("content_upcoming_projects");
//	});
//    });
    //opens the finest brands content in the globally set language
    $("#finest_brands").click(function(){
	$(".finest_brands").children().remove();
	$(".finest_brands").load(language[languageSet]+"finest_brands.html", function(){
	    setContentPosition(contentFirstMenu, true);
	    showContent("finest_brands");
	    //set the inner content height and padding properties
	    $(".finest_brands").css({
		"padding-bottom": "200px",
		"height": "1300px"
	    });
	    //center the pictures
	    $(".center_picture img").each(function(){
		var containerHalf = 80;
		var imgHeight = $(this).height();
		$(this).css({
		    "margin-top":containerHalf-imgHeight/2+"px"
		});
	    });
	    showContent("finest_brands");
	});
    });
    //opens the service content in the globally set language
    $("#service").click(function(){
	$(".service").children().remove();
	$(".service").load(language[languageSet]+"service.html", function(){
	    setContentPosition(contentFirstMenu, true);
	    showContent("service");
	});
    });
    //downloads->specification
    $("#downloads_specification").click(function(){
	$(".content_downloads").children().remove();
	$(".content_downloads").load(language[languageSet]+"downloads_specification.html", function(){
	    setContentPosition(contentSecondMenu, true);
	    //set the inner content height and padding properties
	    var entries = $(".download_entry").length;
	    var downloadsHeight = entries*200;
	    $(".content_downloads").css({
	       "padding-bottom":"200px",
	       "height":downloadsHeight+100+"px"
	    });
	    showContent("content_downloads");
	});
    });
    //downloads->press
    $("#downloads_press").click(function(){
	$(".content_downloads").children().remove();
	$(".content_downloads").load(language[languageSet]+"downloads_press.html", function(){
	    setContentPosition(contentSecondMenu, true);
	    //set the inner content height and padding properties
	    var entries = $(".download_entry").length;
	    var downloadsHeight = entries*200;
	    $(".content_downloads").css({
	       "padding-bottom":"200px",
	       "height":downloadsHeight+100+"px"
	    });
	    showContent("content_downloads");
	});
    });
    //logo click (load random picture)
    $("#logo").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	if(allPoppedOut){
	    hideSecondMenu();
	    hideSlides();
	    hideThirdMenu();
	    closePopup(0);
	    allPoppedOut = false;
	}
	if(singlePoppedOut){
	    hideSecondMenu();
	    singlePoppedOut = false;
	}
	hideMenuBullets();
	loadStartupPicture();
    });
    //click for the 41m layout in 41M Yacht->Layout
    $("#fortyone_m_layout").click(function(){
	$(".fortyone_m_layout").children().remove();
	$(".fortyone_m_layout").load(language[languageSet]+"layout_41m.html", function(){
	    setContentPosition(contentSecondMenu, true);
	    //set the inner content height and padding properties
	    var pictures = $(".fortyone_m_layout .content_picture img").length;
	    var layoutHeight = 175*pictures+200;
	    $(".fortyone_m_layout").css({
		"height": layoutHeight+"px",
		"padding-bottom": "200px"
	    });
	    showContent("fortyone_m_layout");
	});
    });
    //click for the 41m topdeck plus layout in 41M Yacht->41M Topdeck Plus
    $("#fortyone_m_topdeck_plus").click(function(){
	$(".fortyone_m_topdeck_plus_layout").children().remove();
	$(".fortyone_m_topdeck_plus_layout").load(language[languageSet]+"layout_41m_topdeck_plus.html", function(){
	    setContentPosition(contentSecondMenu, true);
	    //set the inner content height and padding properties
	    var pictures = $(".fortyone_m_topdeck_plus_layout .content_picture img").length;
	    var layoutHeight = 175*pictures+200;
	    $(".fortyone_m_topdeck_plus_layout").css({
		"height": layoutHeight+"px",
		"padding-bottom": "200px"
	    });
	    showContent("fortyone_m_topdeck_plus_layout");
	});
    });
    //click for the 41m specification in 41M Yacht->Specification
    $("#fortyone_m_specification").click(function(){
	$(".fortyone_m_specification").children().remove();
	$(".fortyone_m_specification").load(language[languageSet]+"specification_41m.html", function(){
	    setContentPosition(contentSecondMenu, true);
	    //set the inner content height and padding properties
	    var rows = $(".fortyone_m_specification .content_text p br").length;
	    var textHeight = 12*rows+200;
	    $(".fortyone_m_specification").css({
		"height": textHeight+"px",
		"padding-bottom": "200px"
	    });
	    showContent("fortyone_m_specification");
	});
    });
    //click function for the contact link
    $("#contact").click(function(){
	var id = $(this).attr("id");
	lastUsedMenuLink = id;
	if(allPoppedOut){
	    hideSecondMenu();
	    hideSlides();
	    hideThirdMenu();
	    closePopup(0);
	    allPoppedOut = false;
	}
	if(singlePoppedOut){
	    hideSecondMenu();
	    singlePoppedOut = false;
	}
	$(".contact").children().remove();
	$(".contact").load(language[languageSet]+"contact.html", function(){
	    setContentPosition(contentFirstMenu, true);
	    hideMenuBullets();
	    showContent("contact");
	});
    });
    //click function of news menu button
    $("#news").click(function(){
	$(".news").children().remove();
	$(".news").load(language[languageSet]+"news.html", function(){
	    setContentPosition(contentFirstMenu, true);
	    //set the inner content height and padding properties
	    var news_entries = $(".news_entry").length;
	    var news_height = news_entries*220+100;
	    $(".news").css({
		"padding-bottom":"200px",
		"height":news_height+"px"
	    });
	    showContent("news");
	});
    });
    //click function of toggle language button
    $("#toggle_language").click(function(){
	switchLanguage();
    });
}
/**
 *  Set bindings for the window resize to be able to have a resized picture
 **/
function bindResize(){
    setPictureSize();
    $(window).resize(setPictureSize);
}
/**
 *  Shows the bullet icon (image) when a menu point is pressed
 *  Will automatically check if it has to unset other bullet images in parent menus
 *  @param id The id of a menu entry that should get the bullet image activated
 **/
function showMenuBullet(id){
    //if it's in photomode
    if(allPoppedOut){
	//deactive all bullets in the first menu
	$("#first ul li img").css({
	    display: "none"
	});
	//deactive all bullets in the second menu
	$("#second ul li img").css({
	    display: "none"
	});
	//deactivate all bullets in the third menu
	$("#third ul li img").css({
	    display:"none"
	});
	//set the last used double menu item in the first menu (because otherwise you could not get here, only from a double menu item!)
	$("#"+lastUsedFirstDouble).parent().children("img").css({
	    display:"inline"
	});
	//if it's not a single attribute menu item from the second menu producing this call
	if($("#"+id).attr("class")!="single"){
	    //get the class of the list, which correlates to the link it has been called from
	    var menuLink = $("#"+id).parent().parent().attr("class");
	    //if the menuLink this item has been spawned from is a double menu link
	    if($("#"+menuLink).attr("class")=="double"){
		$("#"+lastUsedSecondDouble).parent().children("img").css({
		    display:"inline"
		});
	    }
	}
    }else{
	//if there's only one submenu popped out
	if(singlePoppedOut){
	    //deactive all bullets in the first menu
	    $("#first ul li img").css({
		display: "none"
	    });
	    //get the parent item of this item from the first menu
	    var firstMenuParent = $("#"+id).parent().parent().attr("class");
	    //show the bullet accordingly
	    showFirstMenuBullet($("#"+firstMenuParent).attr("class"));
	    //deactivate all bullets in the second menu
	    $("#second ul li img").css({
		display:"none"
	    });
	}
	//if it's a parent menu
	else{
	    //disable all bullet images in all menus
	    hideMenuBullets();
	}
    }
    //show the menu item bullet for the caller item
    $("#"+id).parent().children("img").css({
	display: "inline"
    });
}
/**
 *  Hides all menu bullet images
 **/
function hideMenuBullets(){
    $(".menu ul li img").css({
	display:"none"
    });
}
/**
 *  Shows the menu item bullet according to the passed linkClass from the first menu
 **/
function showFirstMenuBullet(linkClass){
    if(linkClass=="single"){
	//activate the last used bullet from the first menu with single property
	$("#"+lastUsedFirstSingle).parent().children("img").css({
	    display:"inline"
	});
    }
    if(linkClass=="double"){
	//activate the last used bullet from the first menu with double property
	$("#"+lastUsedFirstDouble).parent().children("img").css({
	    display:"inline"
	});
    }
}
/**
 *  Evaluates a boolean from a String
 **/
function stringToBoolean(string){
    switch(string.toLowerCase()){
	case "true": case "yes": case "1":
	    return true;
	case "false": case "no": case "0": case null:
	    return false;
	default:
	    return Boolean(string);
    }
}
/**
 *  Sets the content position (top value) and its scrolling properties
 *  @param top The top positioning where the content should be shown
 *  @param scrolling Boolean indicating wether the content should be scrollable or not
 **/
function setContentPosition(top, scrolling){
    var contentScrolling = "";
    if(scrolling){
	contentScrolling = "auto";
    }else{
	contentScrolling = "hidden";
    }
    $(".content").css({
	"top":top,
	"overflow":contentScrolling
    });
    //reset the scrollbar to the top of the content
    $(".content").scrollTop(0);
}
