(function($) {
    var originalLive = jQuery.fn.live;
    jQuery.fn.live = function(types) {
        var self = this;
        var args = arguments;
        if (types == 'click') {
            setTimeout(function() {
                originalLive.apply(self, args);
            }, 0);
        } else {
            originalLive.apply(self, args);
        }
    };
})(jQuery);

$(document).ready(function(){
	$('input').attr('autocomplete','off');
	$('a.boxy').boxy();
	$(".telefon").mask("(999) 999-9999");
	$(".posta_kodu").mask("99999");
	$(".select , #kategori").msDropDown({showIcon:false , zIndex:9999999 , visibleRows : ($('option',this).length)});
	$(window).bind("scroll",scrollMe);
	$(".zoom").jqzoom({ zoomWidth: 300 , zoomHeight: 376 , zoomType:'standart' , showEffect:'show' , hideEffect:'fadeout' , fadeoutSpeed: 'slow' , title :false });
	/*$("img.lazy").lazyload({
		placeholder: "http://www.alamarka.com/images/kampanya/urun/liste/alamarka.jpg"
	});*/
});

$('#tumunu_sec').live('click',function(){
	$("INPUT[type='checkbox']").attr('checked', $('#tumunu_sec').is(':checked'));   
});

$('#bildirimler').live('click',function(){
	$('#bildirimlerBox').animate({top:0},{queue:false, duration:100});
});

$('#adres-ekle').live('click',function(){
	$.fancybox({
		'type'		: 'iframe',
		'href'		: 'ajax/adresEkle' ,
		'padding'	: 0 ,
		'margin'	: 0 ,
		'width'		: 400 ,
		'height'	: 380 ,
		'onClosed'	: function(){
			$.post('ajax/adresTable',{},function(e){
				$('#adres-table').html(e);
			});
		}
	});
});

$('.adres-duzenle').live('click',function(){
	var id = $(this).attr('rel');
	$.fancybox({
		'type'		: 'iframe',
		'href'		: 'ajax/adresDuzenle/'+id ,
		'padding'	: 0 ,
		'margin'	: 0 ,
		'width'		: 400 ,
		'height'	: 380 ,
		'onClosed'	: function(){
			$.post('ajax/adresTable/',{},function(e){
				$('#adres-table').html(e);
			});
		}
	});
});

function mesaj(mesaj){
	new Boxy("<p>"+mesaj+"</p>");
}

function scrollMe() {
	var position = $("#akin").position();
	var windowPos = $(window).scrollTop();
	$("#akin").animate({top:(windowPos)}, {queue:false, duration:100});
}

