var SiteUrl = "http://www.bandini.be/"

$(document).ready(function(){	
	if ($.browser.msie) {
	    $('img[@src$=.png]').ifixpng(); 
    }

    getSiteUrl();

    $('.galleryRow a').lightBox({
        overlayBgColor: '#6F0000',
        overlayOpacity: 0.8,
        imageLoading: 'images/lightbox/loading.gif',
        imageBtnClose: 'images/lightbox/lightbox-btn-close.gif',
        imageBtnPrev: 'images/lightbox/prev.gif',
        imageBtnNext: 'images/lightbox/next.gif',
        imageBlank: 'images/lightbox/lightbox-blank.gif',
        txtImage: 'Picture',
        txtOf: 'of'
    });
	
    //Jquery UI -> datepickers
    var arrMonthNames = ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December'];
    var arrDayNames = ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag']; //let op, beginnen met zondag!
    var arrShortDayNames = ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za']; //let op, beginnen met zondag!

    $("#ctl00_cphBody_ctlInschrijven_txtGeboortedatum").datepicker({ yearRange: '-100:0', dateFormat: "dd/mm/yy", monthNames: arrMonthNames, dayNames: arrDayNames, dayNamesMin: arrShortDayNames, firstDay: 1, showWeeks: false });
    
});

///* //////////////////////////////////////////////////////////////////// */
///* /////////////////// IE6 BUGFIXES /////////////////////////////////// */
///* //////////////////////////////////////////////////////////////////// */

/* Opvragen SiteUrl */
function getSiteUrl() {
    realtime.GetSiteUrl(onSucceededSiteUrl, OnFailedSiteUrl);
}

function onSucceededSiteUrl(result, userContext, methodName) {
    // SiteUrl haalt asynchroon de SiteUrl uit de web.config.
    // Omdat de slideshows pas mag gestart worden als SiteUrl goed
    // opgehaald is, starten we hier de slideshows.
    SiteUrl = result;

    WaitForSiteUrl();
}

function OnFailedSiteUrl(error, userContext, methodName) {
    //alert("Er was een probleem bij het ophalen van de siteurl. Probeer opnieuw aub");

    WaitForSiteUrl();
}

function WaitForSiteUrl() {
    if ($("#homeAnim").length > 0) {
        var flashvars = {};
        flashvars.url = SiteUrl;
        var params = {};
        params.wmode = "transparent";
        params.allowScriptAccess = "sameDomain";
        var attributes = {};
        swfobject.embedSWF("" + SiteUrl + "frame_home.swf?t=" + new Date().getTime(), "homeAnim", "478", "202", "9.0.0", false, flashvars, params, attributes);
    }

    if ($("#foodAnim").length > 0) {
        var flashvars = {};
        flashvars.url = SiteUrl;
        var params = {};
        params.wmode = "transparent";
        params.allowScriptAccess = "sameDomain";
        var attributes = {};
        swfobject.embedSWF("" + SiteUrl + "frame_food.swf?t=" + new Date().getTime(), "foodAnim", "478", "202", "9.0.0", false, flashvars, params, attributes);
    }

    if ($("#drinksAnim").length > 0) {
        var flashvars = {};
        flashvars.url = SiteUrl;
        var params = {};
        params.wmode = "transparent";
        params.allowScriptAccess = "sameDomain";
        var attributes = {};
        swfobject.embedSWF("" + SiteUrl + "frame_drinks.swf?t=" + new Date().getTime(), "drinksAnim", "478", "202", "9.0.0", false, flashvars, params, attributes);
    }

    if ($("#menu").length > 0) {
        var flashvars = {};
        var params = {};
        params.wmode = "transparent";
        params.allowScriptAccess = "sameDomain";
        var attributes = {};
        swfobject.embedSWF("menu.swf?t=" + new Date().getTime(), "menu", "630", "60", "9.0.0", false, flashvars, params, attributes);
    }
}

function contactFormValidation() {

    $("#aspnetForm").validate({
        rules: {
            ctl00$txtNaam: {
                required: true
            },
            ctl00$txtVoornaam: {
                required: true
            },
            ctl00$txtPostcode: {
                required: true
            },
            ctl00$txtGemeente: {
                required: true
            },
            ctl00$txtEmail: {
                required: true,
                email: true
            }
        },

        messages: {
            ctl00$txtNaam: {
                required: "<img src=\"" + SiteUrl + "images/error.jpg\" alt=\"error\" />"
            },
            ctl00$txtVoornaam: {
                required: "<img src=\"" + SiteUrl + "images/error.jpg\" alt=\"error\" />"
            },
            ctl00$txtPostcode: {
                required: "<img src=\"" + SiteUrl + "images/error.jpg\" alt=\"error\" />"
            },
            ctl00$txtGemeente: {
                required: "<img src=\"" + SiteUrl + "images/error.jpg\" alt=\"error\" />"
            },
            ctl00$txtEmail: {
                required: "<img src=\"" + SiteUrl + "images/error.jpg\" alt=\"error\" />",
                email: "<img src=\"" + SiteUrl + "images/error.jpg\" alt=\"Email is niet geldig.\" />"
            }
        },

        errorPlacement: function(error, element) {
            element.parent().children("em").html(error);
            element.parent().children("input").attr("class", "TextBoxError");
        },

        success: function(label) {
            label.html("<img src=\"" + SiteUrl + "images/ok.jpg\" alt=\"ok\" />");
            var bijhorendeElement = "#" + $(label).attr("htmlFor");
            if (($(bijhorendeElement).attr("class") == "TextBoxError") || ($(bijhorendeElement).attr("class") == "TextBox")) {
                $(bijhorendeElement).attr("class", "TextBox");
            }
            else {
                $(bijhorendeElement).attr("class", "TextBoxLarge");
            }
        },

        highlight: function(element, errorClass) {
        }
    });
}
