var logindialog = {
    bgiframe: true,
    autoOpen: false,
    height: 200,
    width: 300,
    modal: true,
    buttons: {
        'Giriş': function (){
            $('#login_form').submit();
        }
    }
}
$(function(){
        $(document).pngFix();
        $("ul.sf-menu").superfish({
            speed: 'fast',
            animation: {height:'show'},   // slide-down effect without fade-in 
            delay:     1200,              // 1.2 second delay on mouseout
            dropShadows: false,
            autoArrows: false
        });
        $("ul.menu li a").mouseover( function(e){
            $(this).parent().addClass('hover');
        });
        $("ul.menu li a").mouseout( function(e){
            $(this).parent().removeClass('hover');
        });
        $("#login_modal").dialog(logindialog);
        var isCtrl;
        $(document).keyup(function (e) { 
                if(e.which == 18) isCtrl=false;
        }).keydown(function (e) {
                if(e.which == 18) isCtrl=true; 
                if(e.which == 76 && isCtrl) {
                    $("#login_modal").dialog('open');
                }
        });
        if ($('#user_message').length > 0){
            alert($('#user_message').text());
        }
        
        $('ul.leftmenu li ul.menu').prev().click(function(e){
                if ($(this).next().css("display") == "none"){
                    $(this).next().stop().show();
                } else {
                    $(this).next().stop().hide();
                }
                return false;
        });
        
        $('.footlink').mouseover(function(e){
                $(this).find('img').attr("src","media/image/footlinks/"+$(this).attr("id")+"_b.jpg");
        })
        $('.footlink').mouseout(function(e){
                $(this).find('img').attr("src","media/image/footlinks/"+$(this).attr("id")+".jpg");
        })
        
        var moving = false;
        $('.carousel .next').click(function(e){
            if (!moving) {
                var pos = $('.carousel_canvas').css('left');
                pos = parseInt(pos.substr(0,pos.indexOf('px')));
                var wid = $('.carousel_canvas').css('width');
                wid = parseInt(wid.substr(0,wid.indexOf('px')));
                if (pos - 400 > -1*wid) {
                    moving = true;
                    $('.carousel_canvas').animate({left: (pos-80)+'px'},500,null,function(e){moving=false;});
                }
            }
        });
        $('.carousel .prev').click(function(e){
            if (!moving) {
                var pos = $('.carousel_canvas').css('left');
                pos = parseInt(pos.substr(0,pos.indexOf('px')));
                if (pos < 0) {
                    moving = true;
                    $('.carousel_canvas').animate({left: (pos+80)+'px'},500,null,function(e){moving=false;});
                }
            }
        });
        $('a.lighten').lightBox({fixedNavigation: true});
        $('.largefoto_image:first').show();
        $('#sonuclar').click(function(){
            $.post('anket.php',{sonuc_goster:true},function(data){
                $('.anket_area').html(data);
            }); 
        });
        function oy(){
            alert('a');
            $.post('anket.php',function(data){
                $('.anket_area').html(data);
            }); 
        } 
});

function validateMail(mail) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(mail) == false) {
      alert('Lütfen Geçerli Bir Mail Adresi Giriniz');
      return false;
   }
   return true;
}
