// DEFINE ROOT
var _root = "/";

//CONTROLLING EVENTS IN jQuery
function HideHeaderTabs()
{
    $("#HeaderInfoMenu ul a").each(function() {
        $(this).removeClass("Selected");
        var tempName = $(this).attr("rel");
	    if(tempName != "")
	    {
	        // Is this for mockup? Commented out.
	        //$("#"+tempName).hide();
	    }
    });
}
$(document).ready(function(){
    
    $(".ImageHolderBgOrange").each(function(){
        
        if($(this).text().length > 250)
        {
            $(this).text($(this).text().substr(0,200));
            $(this).text($(this).text() + "...");
        }
    
    });
    
    
    
    $("ul.HeaderMenuList").droppy({speed: 10});
    
    // Menu selected
	$(".QuickSearchCategoryDropDown").hover(function() {
	    $(".PortalMenu").show();
	},function() {
	    $(".PortalMenu").hide();
	});
    
    
    $(".BottomProduct").hover(function(){
    $(this).find(".ImageHover").stop(true, true).fadeIn(100);
        }, function() {
          $(this).find(".ImageHover").stop(true, true).fadeOut(100);
        });

    
            $('#hoverme-stop-2').hover(function() {
          $(this).find('img').stop(true, true).fadeOut();
        }, function() {
          $(this).find('img').stop(true, true).fadeIn();
        });
    
	// Homepage brand hover
	$(".PositionHover").hover(function() {
	    var movie = $("a", this).attr("rel");
	    PlayCricle(movie);
	}, function() {
	    var movie = $("a", this).attr("rel");
	    RemoveCricle(movie);
	});
	
	
	// Toggle related products on the shoppingcart page
	$(".RelatedProductsToggle a").click(function() {
	    if($(this).parents("table").prev(".ToggleRelatedProducts").is(":hidden")) {
            $(this).parents("table").prev(".ToggleRelatedProducts").show();
            $(this).parents("td").children(".OpenRelated").hide();
            $(this).parents("td").children(".CloseRelated").show();
        } else {
            $(this).parents("table").prev(".ToggleRelatedProducts").hide();
            $(this).parents("td").children(".OpenRelated").show();
            $(this).parents("td").children(".CloseRelated").hide();
        }
	});
	
	//Prefiller
	$('.emailForm').val('Vul uw e-mail adres in...');
	    $('.emailForm').focus(function () {
	        $(this).val('');
	    });
	
	$('.loginTextBox').val('Gebruikersnaam');
	    $('.loginTextBox').focus(function () {
	        $(this).val('');
	    });
	$('.loginTextBoxPassword').val('Password');
	    $('.loginTextBoxPassword').focus(function () {
	            $(this).val('');
	        });
	
});

// Control flashmovie (red circle on home)
function getFlashMovieObject(movieName) {
    if (window.document[movieName]) {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1) {
        if (document.embeds && document.embeds[movieName]) {
            return document.embeds[movieName]; 
        }
    } else {
        return document.getElementById(movieName);
    }
}

function PlayCricle(m) {
    var flashMovie = getFlashMovieObject(m);
    flashMovie.Play();
}

function RemoveCricle(m) {
    var flashMovie = getFlashMovieObject(m);
    flashMovie.Rewind();
}

