﻿$().ready(function() {
    // validate signup form on keyup and submit
    $("#ctl00_MainContent_btnSend").click(function() {
        $("#aspnetForm").validate({
            rules: {
                ctl00$MainContent$txtSenderName: "required",
                captcha: "required",
                ctl00$MainContent$txtSenderEmail: {
                    required: true,
                    email: true
                },
                //ctl00$MainContent$txtRecipientName: "required",
                ctl00$MainContent$txtCardTitle: "required",
		ctl00$MainContent$txtRecipientEmail: "required"
            },
            messages: {
                captcha: "prepiši varnostno kodo",
                ctl00$MainContent$txtSenderName: "vnesi svoje ime",
                ctl00$MainContent$txtSenderEmail: "vnesi veljaven e-mail",
                ctl00$MainContent$txtRecipientName: "vnesi ime prejemnika",
                ctl00$MainContent$txtRecipientEmail: "vnesi vsaj enega prajemnika",
                ctl00$MainContent$txtCardTitle: "vnesi naslov voščilnice"
            }
        });
    });

    //refresh captcha image
    var origsrc = "";
    $("#captchareloadimg").click(function() {
        var imgel = $("#captchaimage");
        //first time click - set original src
        origsrc = origsrc == "" ? imgel.attr('src') : origsrc;
        //set "new" src, append time so browser will not load image from cache
        imgel.attr('src', origsrc + (origsrc.indexOf("?") < 0 ? "?" : "&") + (new Date()).getTime());
    });
    //pointer on mouseover - css doesn't work in opera (?)
    $("#captchareloadimg").hover(
        function() { $("body").css({ 'cursor': 'pointer' }); },
        function() { $("body").css({ 'cursor': 'default' }); }
    );


    var offset = $('#kategorije-ozadje').offset();
    var offset_sv = $('.content-seznam-voscilnic').offset();

    $('#kategorije-ozadje').css({ 'position': 'absolute',  'left': (offset_sv.left + $('.content-seznam-voscilnic').width() - $('#kategorije-ozadje').width()) + 'px', 'top': (offset_sv.top  ) + 'px' });
    $('#kategorije-ozadje').bind('drag', function(event) {
        $(this).css({ top: event.offsetY, left: event.offsetX });
    }).hover(
        function() { $('body').css('cursor', 'move') },
        function() { $('body').css('cursor', 'default') }
    );


});

