
var disableTracker = false;
var currentlyPlayingVideo;

function menuMouseOver(section){
    showMouseOverImage(section);
    showNavigationSection(section);
}

function menuMouseOut(event, section){
    showMouseOutImage(section);
    hideNavigation(event, this, section);
}

function showMouseOverImage(section)
{
    var menuLink = document.getElementById("menu_"+section);;
    if(menuLink != null && menuLink.className.indexOf("_over_") == -1)
    {
        var sectionName = menuLink.className.substr(0, menuLink.className.indexOf("_"));
        var languageName = menuLink.className.substr(menuLink.className.indexOf("_")+1);
        menuLink.className = sectionName + "_over_" + languageName;
    }
}

function showMouseOutImage(section)
{
    var menuLink = document.getElementById("menu_"+section);;
    if(menuLink != null && menuLink.className.indexOf("_over_") > -1)
    {
        var sectionName = menuLink.className.substr(0, menuLink.className.indexOf("_"));
        var languageName = menuLink.className.substr(menuLink.className.lastIndexOf("_")+1);
        menuLink.className = sectionName + "_" + languageName;
    }
}

function showNavigationSection(section)
{
	if(typeof swfobject != "undefined" && typeof getMainFlashId != "undefined")
	{
        var flash = swfobject.getObjectById(getMainFlashId());
        if (typeof flash != "undefined") {
            if(typeof flash.showNavigationSection != "undefined"){
	            flash.showNavigationSection(section); 
	        }
        }
	}
}

function hideNavigation(event, element, section)
{
	if( event.clientY < (element.offsetTop+20+2) )
	{
		var flash = swfobject.getObjectById(getMainFlashId());
		if (flash.hideNavigation) {
			flash.hideNavigation(); 
		}
	}
}

function initSifrAfterPartialPostback()
{
    if(typeof sIFR != "undefined") {
        sIFR.replaceElement(named(
                                {
                                    sSelector:"h2",
                                    sFlashSrc:"/Frontend/FuturaND.swf",
                                    sColor:"#111111",
                                    sLinkColor:"#111111",
                                    sBgColor:null,
                                    sHoverColor:"#111111",
                                    nPaddingTop:0,
                                    nPaddingBottom:0,
                                    sFlashVars:"textalign=left&amp;offsetTop=0"
                                })
        );
        sIFR.replaceElement(named(
                                {
                                    sSelector:"h1",
                                    sFlashSrc:"/Frontend/FuturaND.swf",
                                    sColor:"#111111",
                                    sLinkColor:"#111111",
                                    sBgColor:null,
                                    sHoverColor:"#111111",
                                    nPaddingTop:0,
                                    nPaddingBottom:0,
                                    sFlashVars:"textalign=left&amp;offsetTop=0"
                                })
        );
    }
}

function detectFlash()
{
    if( navigator.mimeTypes.length > 0 )
    {
        return navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin != null;
    }
    else if( window.ActiveXObject )
    {
        try
        {
            new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" );
            return true;
        }
        catch( oError )
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}

function DoSearchOnEnter(e)
{
	var keynum;
	var keychar;
	var numcheck;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if(keynum==13)
	{
		DoSearch();
		return false;
	}
	return true;
}


function imageClickCallback(url) {
    if (url != "") {
        window.location.href = url;
    }
}


function gaTrackPageview(value) {
    try {
        value = value.toLowerCase().replace("_", "-");
        pageTracker._trackPageview(value);
    }
    catch (err) {
    }
}

function gaTrackEvent(category, action, label, value) {
    try {
        pageTracker._trackEvent(category, action, label, value);
    }
    catch (err) {
        
    }
}

/** 
* HACK
* getBaseURL method freflects that of the SWFAddress implementation
* This is to make sure that flash can call the method on pages
* that doesn't implement SWFAddress.
*/
var SWFAddress = new function() {
    this.getBaseURL = function() {
        var wnd = null;
        try {
            wnd = top.document;
        } catch (e) {
            wnd = window;
        }
        return wnd.location.href;
    };
}

//function storeLocatorCallback(param) {
//    var url = window.location.href;
//    if (url.indexOf("/en/") > -1) {
//        url = "/en/fritz-hansen/store-locator.aspx";
//    } else if (url.indexOf("/de/") > -1) {
//        url = "/de/fritz-hansen/shop-suche.aspx";
//    }

//    param = param.replace(/\//g, "_");                              // regex replaces all instances of "/"
//    var arr = param.replace(/ /g, "-").toLowerCase().split(";");    // regex replaces all instances of " "
//    
//    url = url.substr(0, url.length - 5) + "/";

//    // dealer type
//    url += arr[0].replace("dealers-", "") + "/";

//    // region
//    url += arr[1] + "/";

//    // country
//    url += arr[2].replace("u.s.a.", "usa");

//    if (arr.length > 3) {
//        // state
//        url += "/" + arr[3];
//    }

//    url += ".aspx#content";

//    window.location = url;
//}


function activateVideo(videoId) {
    deactivateVideo();
    currentlyPlayingVideo = videoId;
    $("#videoContainer_" + videoId + " > .open").css({ display: "none" });
    $("#videoContainer_" + videoId + " > .close").css({ display: "inline" });
    $("#videoContainer_" + videoId).animate({
        width: "575",
        height: "300"
    }, 500, function () {
        $("#videoContainer_" + videoId + " > .video").css({ display: "inline" });

        var p = getVideoPlayer(videoId);
        if (typeof (p.startPlayback) == "function") {
            p.startPlayback();
        }
    });

    $("#videoContainer_" + videoId).parent().animate({
        height: 300
    });
}

function deactivateVideo() {
    if (currentlyPlayingVideo == undefined) return;
    videoId = currentlyPlayingVideo;
    currentlyPlayingVideo = undefined;
    var p = getVideoPlayer(videoId);
    
    if (typeof (p.pausePlayback) == "function") {
        p.pausePlayback();
    }

    $("#videoContainer_" + videoId + " > .video").css({ display: "none" });
    $("#videoContainer_" + videoId).animate({
        width: "185",
        height: "111"
    }, 500, function () {
        $("#videoContainer_" + videoId + " > .open").css({ display: "inline" });
        $("#videoContainer_" + videoId + " > .close").css({ display: "none" });
    });

    $("#videoContainer_" + videoId).parent().animate({
        height: 111
    }, 500);
}

function toggleVideoShortcut() {
    if ($("#videos").is(':visible')) {
        $("#videoRightLink").css({ display: "block" });
    }
}

function scrollToVideos() {
    $(document).scrollTo($("#videos"), 800);
}

function getVideoPlayer(id) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? document.getElementById(id + "_ie") : document.getElementById(id + "_moz");
}

function customerServiceCallback(param) {
    window.location = param;
}