﻿/// <reference path="../../libs/jquery/jquery-1.3.2-vsdoc2.js" />
function rgoster(resim) {
 document.images["rbolge"].src = resim;	
}

function initMenu(el) {
    $(el + ' div').hide();
    $(el + ' div:first').show();
    $(el + ' li a').click(function() {
        var checkElement = $(this).next();
        if ((checkElement.is('div')) && (checkElement.is(':visible'))) {
            return false;
        }
        if ((checkElement.is('div')) && (!checkElement.is(':visible'))) {
            $(el + ' div:visible').slideUp(0);
            checkElement.slideDown(0);
            return false;
        }
    }
);
}
$(document).ready(function() {

    validateEmail = function(value, onFailure) {
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (!filter.test(value)) {
            onFailure();
        }
    }
    $('#newstellerForm').ajaxForm({
        beforeSubmit: function(formData, jqForm, options) {
            var isValid = true;
            for (var i = 0; i < formData.length; i++) {
                if (formData[i].name == 'userEmail') {
                    validateEmail(formData[i].value, function() {
                        isValid = false;
                    });

                }
            }
            if (!isValid) {
                $('.newstellerForm-output').slideUp('normal', function() {
                    $('.newstellerForm-output').html('Geçerli bir email adresi girin!');
                    $('.newstellerForm-output').slideDown('normal', function() {
                    });
                });

                return false;
            }
        },
        success: function() {
            $('.newstellerForm-output').slideUp('normal', function() {
                $('.newstellerForm-output').html('Kaydedildi!');
                $('.newstellerForm-output').slideDown('normal', function() {
                });
            });

            // alert('sdds');
        },
        error: function() {
            $('.newstellerForm-output').slideUp('normal', function() {
                $('.newstellerForm-output').html('Hata!');
                $('.newstellerForm-output').slideDown('normal', function() {
                });
            });
        }
    });
});
