﻿//Version 1.0
$(document).ready(function () {
    var findstring1 = "%20";
    var findstring2 = "%0d";
    var findstring3 = "%0a";



    $(".skycar-login-box").css({ opacity: 0.8 });


    $('a').each(function () {
        $.trim($(this).attr('href'));
        $(this).attr('href', $(this).attr('href').replace(new RegExp(findstring1, 'g'), ''));
        $(this).attr('href', $(this).attr('href').replace(new RegExp(findstring2, 'g'), ''));
        $(this).attr('href', $(this).attr('href').replace(new RegExp(findstring3, 'g'), ''));
        $(this).attr('href', $(this).attr('href').replace(/ /g,''));



    });

    //    $('#').attr('href', function (i, val) {
    //        return val.replace('20', 'asd');
    //    }); 




    // if the function argument is given to overlay,
    // it is assumed to be the onBeforeLoad event listener
    $(".skycar-award a[rel]").overlay({

        color: '#ccc',
        mask: '#000',

        closeOnClick: true,
        closeOnEsc: true,
        //        fixed: false,


        onBeforeLoad: function () {
            //  $('#overlay_iframe').attr('src', 'http://212.202.148.171/de-de/dynamics/skycar/eform.aspx#CRM Now! Workshop Anmeldung');

            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");

            // load the page specified in the trigger
            wrap.load(this.getTrigger().attr("href"));
        },

        onBeforeClose: function () {
            $("#exposeMask").hide();
            this.getOverlay().hide();

        }
    });

    $(".skycar-productdemo a[rel]").overlay({

        color: '#ccc',
        mask: '#000',

        closeOnClick: true,
        closeOnEsc: true,
        //        fixed: false,

        onBeforeLoad: function () {
            //  $('#overlay_iframe').attr('src', 'http://212.202.148.171/de-de/dynamics/skycar/eform.aspx#CRM Now! Workshop Anmeldung');

            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");

            // load the page specified in the trigger
            wrap.load(this.getTrigger().attr("href"));
        },


        onBeforeClose: function () {
            $("#exposeMask").hide();
            this.getOverlay().hide();

        }
    });


    /*Validator Temp*/
    $.getScript("http://www.microsoft.com/germany/library/eform/dynamics/skycar/validator.js", function () {
        $("form").attr("novalidate", "novalidate").validator({ lang: "de", inputEvent: "blur" });
        $.tools.validator.fn("[placeholder][required]", "*", function (input, value) {
            var placeholder = input.attr("placeholder");
            if (placeholder) {
                if (placeholder == value) {
                    return false;
                }
            }
            return true;
        });
        $("form button").fadeIn();
    });
    $("*[placeholder]").each(function (i, e) {
        e = $(e);
        var placeholderValue = e.attr("placeholder");
        if (!placeholderValue) { return }
        e.attr("value", placeholderValue);
        e.focus(function (ee) {
            if (e.val() == placeholderValue) {
                e.addClass("active");
                e.attr("value", "");
            }
        });
        e.blur(function (ee) {
            if ($.trim(e.val()) == "") {
                e.removeClass("active");
                e.attr("value", placeholderValue);
            }
        });
    });
    



});
 
