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 li a").mouseover( function(e){
            $(this).parent().addClass('hover');
        });
        $("ul 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());
        }
        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 - 392 > -1*wid) {
                    moving = true;
                    $('.carousel_canvas').animate({left: (pos-98)+'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+98)+'px'},500,null,function(e){moving=false;});
                }
            }
        });
        $('.carouselfoto_mask').click(function(e){
                $('.largefoto_image').hide();
                //alert('#la_'+$(this).parent().attr("id"));
                $('#la_'+$(this).parent().attr("id")).css('display','block');
                /*var impath = $(this).parent().css('backgroundImage').replace('/XS/','/L/');
                impath = impath.substr(4,impath.length-5);
                var repath = impath.replace('/T/L','');
                $('#largeimage').css('backgroundImage',"url('"+impath+"')").attr('href',repath);*/
        });
        $('a.lighten').lightBox({fixedNavigation: true});
        $('.largefoto_image:first').show();
        $('a[href=#]').click(function(e){return false;})
        
});

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;
}

