$(document).ready(function(){

$("#ShopLayOut_Topmenu_TD").find("a:last").css("background-image","none");

//Rette forsideprodukter til
var fp
if($(".Frontpage_Custom_TBL:last").length)
    fp = $(".Frontpage_Custom_TBL:last").find("td");
if($(".ProductList_Custom_TBL:last").length)
    fp = $(".ProductList_Custom_TBL:last").find("td");
if($(".Related_Custom_TBL:last").length)
    fp = $(".Related_Custom_TBL:last").find("td");    
    


$("#removeBr").find("br:last").css("display","none");

var remainer;
$(fp).each(  
    function( intIndex ){
        remainer = (intIndex+1) % 3;
        //alert(remainer + " " + (intIndex+1));
        if(remainer != 0)
        {
            //$('<td class="splitter"><div style="width:12px;"></div></td>').insertAfter(this);
            $(this).css("width","224px");
        }
        else
        {
            $(this).css("width","212px");
        }
    
});

var buttonValue;
$(".SubmitButton_Orderstep1, .SubmitButton_Orderstep2, .SubmitButton_Orderstep3").each( 
    function( intIndex ){
        buttonValue = $(this).attr("value");
        $(this).attr("value", "");
        $(this).addClass(buttonValue);
    
});

$("hr").parent().addClass("dots");


if(LanguageID == '26')
    $("#ShopLayOut_Topmenu_TD").append('<a href="http://www.elisabethgierus.com/shop/Eng/frontpage.html" class="languk"></a>');
else
    $("#ShopLayOut_Topmenu_TD").append('<a href="http://www.elisabethgierus.com/shop/frontpage.html" class="langdk"></a>');
    
    
if($("#ingredients").find(".Description_Productinfo").text() == '')
    $("#ingredients").css("display","none");    
    
//Rabatkode
var testkode;
$('.Videre, .Next').bind('click', function() {
    //alert('User clicked on "foo."');
    testkode = $("#Field11_0").find("input:last").val().toLowerCase();
    if(testkode == "everyone needs beauty")
        testkode = $("#Field12_0").find("input:last").val("tenoff");
});

    
var price;
var specialprice;
var currency;

$(window).load(
    function() {
    $(".PriceContainer").each(
        function( intIndex ){
            price = $(this).find(".price:first");                    
            //retailprice = $(this).find(".retailprice:first");
            specialprice = $(this).find(".specialprice:first");
            currency = $(this).find(".currency:first").text();
            
            //alert("");
            if($(specialprice).text() != "")
            {
                //$(price).prepend("Normal pris: ");
                $(price).append(currency);
                $(price).css({"font-size":"11px","text-decoration":"line-through"});
                
                
                //$(specialprice).prepend("Udsalgspris: ");
                $(specialprice).append(" " + currency);
                //$(specialprice).css({"font-weight":"bold","color":"#58434C"});               
            }
            else
            {
                //$(price).prepend("Pris: ");
                $(price).append(" " + currency);
                //$(price).css({"font-weight":"bold","color":"#58434C"});                    
            }
            
                                
    });  
    }
);      

}); 

jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}

function CreateCustomAlert(txt) {

    var h = ($(window).height()-$("#CustomAlert").height())/2;
    var w = ($(window).width()-$("#CustomAlert").width())/2;
    
    $("#CustomAlert").css({"display":"block"});
    $("#CustomAlert").center();

    setTimeout("FadeOut()", 5000)
}

function FadeOut()
{
    $("#CustomAlert").fadeOut(2000);
}



