﻿
/** begin pageload **/
function pageLoad() {
    var hetdomein = $('.jsPath').val();
    init_buttons();


    /*** validatie ***/
    $('.validatie-pointer').each(function() {
        active = ($(this).css('display'));
        if (active == "inline") { $(this).parents('p.rij').find('.textbox').addClass('error'); }
    });
    $('input').blur(function() {
        $('.validatie-pointer:hidden').parents('p.rij').find('.textbox').removeClass('error');
        $('.validatie-pointer:visible').parents('p.rij').find('.textbox').addClass('error');
        $(this).removeClass('has-focus');
    });
    $('input').focus(function() {
        $('.validatie-pointer:hidden').parents('p.rij').find('.textbox').removeClass('error');
        $('.validatie-pointer:visible').parents('p.rij').find('.textbox').addClass('error');
        $(this).addClass('has-focus');
    });
    $('.do-validate').click(function() {
        $('.validatie-pointer:hidden').parents('p.rij').find('.textbox').removeClass('error');
        $('.validatie-pointer:visible').parents('p.rij').find('.textbox').addClass('error');
        setTimeout(check, 100);
    });
    
}
function check() {
    $('.validatie-pointer:hidden').parents('p.rij').find('.textbox').removeClass('error');
    $('.validatie-pointer:visible').parents('p.rij').find('.textbox').addClass('error');
    if ($('.textbox').hasClass('error')) { $('.errorlist').slideDown(500); }
}
/** einde pageload **/



/** begin document ready **/
$('document').ready(function() {
    check();
    //betaalwijzes
    if ($('#betaalwijze-container').length > 0) {
        $('#betaalwijze-container .betaalwijze').click(function() {
            $(this).parents('#betaalwijze-container').find('.betaalwijze').removeClass('selected');
            $(this).addClass('selected');
            $(this).find('input').attr("checked", "checked");
        });
    }

    if (!jQuery.fn.flash.hasFlash(8, 0, 0)) {
        $('.browse').hide();
        $('.browse-noflash').show();
    }


    /** start lightbox met vergroting **/
    $('.vergroot-link').click(function() {
    
        //indien nodig, zet het juiste plaatje aan
        if ( $(this).attr('rel').length > 0 ) {
            var theImage = $(this).attr('rel');
            $('#overlay-content img').attr('src',theImage).show();
        }
    
        $('form').after("<div id=\"overlay\">&nbsp;</div>");
        $(this).blur();
        $('#overlay').css('opacity', '0.5');
        $('#overlay').fadeIn(500, overlay_ingeladen);
        // $("#overlay").fixedPosition();
        return false;
    });

    $('.blader-link').click(function() {
        $('form').after("<div id=\"overlay\">&nbsp;</div>");
        $(this).blur();
        $('#overlay').css('opacity', '0.5');

        var language = $(this).attr('language');
        var bookid = $(this).attr('bookid');
        var flashheight = $(this).attr('flashheight');
        var flashwidth = $(this).attr('flashwidth');

        $('#overlay').fadeIn(500, overlay_flash_ingeladen(language, bookid, flashheight, flashwidth));
        //  $("#overlay").fixedPosition();
        return false;
    });

    //breek uit frame
    if (top.location != location) {
        top.location.href = document.location.href;
    }


	var pathname = window.location.pathname;
	if ((pathname.search('signout.aspx')) > 0) {
		$('#ctl00_ctl00_content_contentLeft_lnCheckOut').css({'top':'10px'});
	}
	

});      
//einde document ready




function init_buttons() {
 $('.btn-blue, .btn-blue-arrow, .btn-add').each(function(){
    $(this).append('<div class="btn-right"></div>');
 });
}


function overlay_ingeladen() {
    $('#overlay-content').center();
    $('#overlay-content').css({'z-index':'4000'})
    $('#overlay-content').show();
    $('#overlay').click(close_overlay);
    //$('#overlay-content').fixedPosition({vpos: null,hpos: null});
}

//vanuit flash
function sluit_overlay() { $('#overlay-flash-content-container').remove(); $('#overlay-flash-content').remove(); overlay_gesloten(); }
//vanuit html popup
function close_overlay() {  
    $('#overlay-content').hide();   
    overlay_gesloten();
 }

function overlay_gesloten() {
    $('#overlay').fadeOut(500);
    setTimeout("$('#overlay').remove()", 500);
    $('overlay-flash-content-container').remove();
    
}



function overlay_flash_ingeladen(language, bookid, flashheight, flashwidth) {
    //alert(language);
    //alert(bookid);
    //alert(flashwidth);
    //alert(flashheight);
        
    $('#overlay').click(sluit_overlay);
    $('#overlay').before('<div id="overlay-flash-content-container" style="width:' + flashwidth + 'px;height:' + flashheight + 'px;"><div id="overlay-flash-content" style="width:' + flashwidth + 'px;height:' + flashheight + 'px;"></div></div>');

    
    if (jQuery.fn.flash.hasFlash(8, 0, 0)) {
                    
                     $('#overlay-flash-content').flash(
                        { 
                          src: '../leuksteliedjes.nl/swf/flipbook/flipbook.swf',
                          width: flashwidth,
                          height: flashheight,
                          menu: "false", 
                          wmode: "transparent", 
                          allowScriptAccess: "always",
                          flashvars: { language: language, bookID: bookid, staticPath:"http://staticcontent.orange-juice.nl/leuksteliedjesnl/"  }
                        },
                        { version: 8 }
                    );
                                    
                    /*
                    var flashvars = {
                        language: language,
                        bookID: bookid,
                        staticPath: 'http://staticcontent.orange-juice.nl/leuksteliedjesnl/'
                    };
                    var params = {
                        menu: "false",
                        wmode: "transparent",
                        allowScriptAccess: "always"
                    };
                    var attributes = {};
                    swfobject.embedSWF("../swf/flipbook/flipbook.swf", "overlay-flash-content", flashwidth, flashheight, "8", "", flashvars, params, attributes);
                    */
                }
                else { $('#alt').css('z-index', 90000); }

                //$('#overlay-flash-content').fixedPosition({ vpos: null, hpos: 'center' });
                setTimeout("centreer();", 100);               
                //centreer();
  }




function trim(value) {
    value = value.replace(/^\s+/, '');
    value = value.replace(/\s+$/, '');
    return value;
}





$(window).resize(function() {
    centreer();
});

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 centreer() {
    $('#overlay-content').center();
    $('#overlay-flash-content-container').center();
}

