// JavaScript Document

$(document).ready(function () {
    $('.drop').each(function (i) {
        $(this).sSelect();
    });

    setTooltips();

    $(".shadow").each(function (i) {
        var text = $(this).html();
        $(this).html("");
        $(this).append("<i>" + text + "</i>");
        $(this).append("<i>" + text + "</i>");
        $(this).children("i").each(function (i) {
            if (i == 0) {
                $(this).addClass("innerText")
            }
            if (i == 1) {
                $(this).addClass("shadowText")
            }
        });
    });


});

function setTooltips() {
    $(".formUnswerArea").each(function (i) {
        var topCord = $(this).offset().top;
        var height = $(this).height();
        var newTop = topCord - height;
        var newLeft = $(this).offset().left;
        var thisNode = $(this);
        var unsId = thisNode.parent(".formQuest").prev().prev().attr("name");
        var unsAreaId = "uns_" + unsId;
        $(this).css({ top: newTop, left: newLeft });
        $(this).clone().appendTo("body").attr("id", unsAreaId);
        $(this).parent(".formQuest").click(function () {
            $(".formUnswerArea").css({ visibility: "hidden" });
            $(".formQuest").removeClass("activeQuest");
            $(this).addClass("activeQuest");
            $("#" + unsAreaId).css({ visibility: "visible" });
        });
        $(this).css({ display: "none" });
    });
    $(".unswerClose").click(function () {
        $(".formUnswerArea").css({ visibility: "hidden" });
        $(".formQuest").removeClass("activeQuest");
    });
}

function setFormat(e, f) {
    if (!$(e).val() | $(e).val() == f) {
        $(e).addClass('format');
        $(e).val(f);
        $(e).focus(function () {
            $(e).val('');
            $(e).removeClass('format');
        });
    }
         }


         function popup(url,w,h) {
         	var width = w;
         	var height = h;
         	var left = (screen.width - width) / 2;
         	var top = (screen.height - height) / 2;
         	var params = 'width=' + width + ', height=' + height;
         	params += ', top=' + top + ', left=' + left;
         	params += ', directories=no';
         	params += ', location=no';
         	params += ', menubar=no';
         	params += ', resizable=no';
         	params += ', scrollbars=no';
         	params += ', status=no';
         	params += ', toolbar=no';
         	newwin = window.open(url, 'windowname5', params);
         	if (window.focus) { newwin.focus() }
         }


