﻿

(function($) {

 

    $(window).load(function() {

    $(".style_holder a[href='#']").css({ cursor: "default" }).click(function() { return false; }).parent().addClass("noLink");

        //Hide signup forms.
        $('#signup_pop').hide();
        $('#thankyou_content').hide();


        $(".starsOff").each(function() {
            if ($(this).hasClass("edit"))
                $(this).prepend('<div class="buttons"><a class="1"></a><a class="2"></a><a class="3"></a><a class="4"></a><a class="5"></a></div>');
            var width = (100 / 5) * $(this).find("input:hidden").val();
            $(this).find(".starsOn").css({ width: width + "%" });
        });

        $(".starsOff").each(function() {
        if ($(this).find("input:hidden").length > 0) {
            if ($(this).hasClass("edit"))
                $(this).prepend('<div class="buttons"><a class="1"></a><a class="2"></a><a class="3"></a><a class="4"></a><a class="5"></a></div>');
            var width = (100 / 5) * $(this).find("input:hidden").val() + "%";
            $(this).find(".starsOn").css({ width: width });
        }
    });

        
    });


})(jQuery);



    //Popop signup script from Effect
    function showForm() {
        $('#signup_pop').fadeIn(500);
    }
    function closeForm() {
        $('#signup_pop').fadeOut(500);
        $('#signup_content').fadeIn(750);
        $('#signup_footer').fadeIn(750);
        $('#thankyou_content').hide();
        resetFields();
    }
    function submitForm() {
        if ($("#signup_name").val() == $("#signup_name").get(0).emptyValue) {
            alert("Please enter your name");
            return;
        } if ($("#signup_braSize").val() == $("#signup_braSize").get(0).emptyValue) {
            alert("Please enter your bra size");
            return;
        }

        Masquerade.Signup(
        $("#signup_mail").val(),
        $("#signup_name").val(),
        $("#signup_braSize").val(), function(results) {
            if (results == "OK") {
                $('#signup_content').hide();
                $('#signup_footer').hide();
                $('#thankyou_content').fadeIn(500);
                resetFields();
            } else {
                alert(results);
            }
        });
        
    }
    function resetFields() {
        document.forms[0].reset();
    }
 


var $gluubF = {};


//jQuery extentsion to create the modals used by this site and all full sizable.  Its more complex than I had antisipated !!!
jQuery.fn.modal = function () {

    var modalElement = this[0];

    if (modalElement.modal)
        return modalElement.modal;

    var modalObject = new $gluubF.modal(modalElement, arguments[0] || {});

    return $(modalElement);
};

$gluubF.modal = function (modalElement, args) {
    var width = args.width;
    var height = args.height;
    var closeClickedCallback = args.closeClickedCallback;
    var showClose = args.showClose || true;
    var dims = { tl: { w: 31, h: 31 }, tr: { w: 31, h: 31 }, bl: { w: 31, h: 31 }, br: { w: 31, h: 31 }, t: { h: 15 }, b: { h: 23 }, l: { w: 16 }, r: { w: 22 }, inPad: { t: 15, r: 22, b: 23, l: 16} };
    var newModal = $('<div class="modal_greyOut"></div><div class="modal"><div class="b"></div><div class="t"></div><div class="l"></div><div class="r"></div><div class="tl"></div><div class="tr"></div><div class="br"></div><div class="bl"></div><div class="modal_cont"><div class="modal_head"><h3>Title</h3><a href="#" class="modal_close" title="Close">Close</a></div><div class="modal_body"></div></div></div>');

    newModal.find(".modal_body").append($(">*", modalElement));
    $(modalElement).append(newModal);
    //$(document.body).prepend(modalElement);
    newModal = $(modalElement);
    newModal.hide();
    newModal.find(".tl").css({ width: dims.tl.w + "px", height: dims.tl.h + "px" });
    newModal.find(".tr").css({ width: dims.tr.w + "px", height: dims.tr.h + "px", marginLeft: (width - dims.tr.w) + "px" });
    newModal.find(".br").css({ width: dims.br.w + "px", height: dims.br.h + "px", marginLeft: (width - dims.tr.w) + "px", marginTop: (height - dims.br.h) + "px" });
    newModal.find(".bl").css({ width: dims.bl.w + "px", height: dims.bl.h + "px", marginTop: (height - dims.br.h) + "px" });
    newModal.find(".t").css({ marginLeft: (dims.tl.w) + "px", width: (width - dims.tl.w - dims.tr.w) + "px", height: dims.t.h + "px" });
    newModal.find(".b").css({ marginLeft: (dims.tl.w) + "px", width: (width - dims.tl.w - dims.tr.w) + "px", marginTop: (height - dims.b.h) + "px", height: dims.b.h + "px" });
    newModal.find(".l").css({ marginTop: (dims.tl.h) + "px", height: (height - dims.tl.h - dims.bl.h) + "px", width: dims.l.w + "px" });
    newModal.find(".r").css({ marginTop: (dims.tl.h) + "px", height: (height - dims.tl.h - dims.bl.h) + "px", marginLeft: (width - dims.r.w) + "px", width: dims.r.w + "px" });
    newModal.find(".modal_cont").css({
        marginLeft: dims.inPad.l + "px",
        marginTop: (dims.inPad.t) + "px",
        width: (width - dims.inPad.l - dims.inPad.r) + "px",
        height: (height - dims.inPad.t - dims.inPad.b) + "px",
        backgroundColor: "#1e1e1e",
        position: "absolute"
    });

    /* Buttons placing script */
    var modalButtons = newModal.find(".modal_buttons");
    newModal.find(".modal_head").before();
    var modalButtonsInner = $('<div class="inner1"><div class="inner2"></div></div>');
    modalButtonsInner.find(".inner2").append(modalButtons.find(">*"));
    modalButtons.append(modalButtonsInner);
    modalButtons.css({ height: "50px", position: "absolute", top: "0px", width: (width - dims.r.w - dims.l.w) + "px", marginTop: (height - dims.b.h - dims.t.h - 50) + "px" });
    modalButtons.find(".buttonEngraved:last").css({ marginRight: "0px" });

    newModal.find(".modal_greyOut").css({ position: "fixed", top: "0px", left: "0px", width: "100%", height: "100%", backgroundColor: "black", opacity: 0.5 });
    newModal.find(".modal_greyOut").click( function() { if (closeClickedCallback != null) closeClickedCallback();
        return false; } );
    //$(document.body).prepend(this.find(".modal_greyOut"));

    if (!browser.isIE6x)
        newModal.find(".modal").css({ width: width + "px", marginLeft: -(width / 2) + "px", marginTop: -(height / 2) + "px", position: "fixed" });
    else
        newModal.find(".modal").css({ width: width + "px", marginLeft: (width / 2) + "px", marginTop: (height / 2) + "px", position: "fixed" });
    newModal.find(".modal_head h3").text($(modalElement).attr("title"));
    if ($("dfn", modalElement).length > 0)
        newModal.find(".modal_head h3").html($("dfn", modalElement).html());
    $("dfn", modalElement).remove();
    newModal.find(".modal_close").click(function () {

        if (closeClickedCallback != null) closeClickedCallback();
        return false;
    });
    if (!showClose) $(modalElement).find(".modal_close").hide();

    //        this.sayHi = function () {
    //            alert("hi");
    //        };
    modalElement.modal = newModal;
    this.modalElement = modalElement;
    this.jqModalElement = $(modalElement);

};

$gluubF.modal.prototype = {
    open: function () {
        if (!$gluubF.modal.modalOpen) {
            $gluubF.modal.modalOpen = true;
            this.jqModalElement.show();
            //IE6 fix
            this.jqModalElement.find(".inner2").css({ width: this.jqModalElement.find(".inner1").outerWidth() + "px" });
        }
    },
    close: function () { this.jqModalElement.hide(); $gluubF.modal.modalOpen = false; },
    lock: function () { this.jqModalElement.find(".modal_body,modal_buttons").hide(); },
    unlock: function () { this.jqModalElement.find(".modal_body,modal_buttons").show(); },
    find: function (query) { return this.jqModalElement.find(query); }
};
$gluubF.modal.modalOpen = false;
$gluubF.modal.openModalName = "";
 
