// JavaScript Document
	$(document).ready(function() {

        //if mask is clicked
		$('#mask').live("click",function () {
    		$(this).hide();
    		$('.window').hide();
    		$('#dialog').html('');
    	});

        //if close button is clicked
        $('.window .close').live("click",function (e) {
            //Cancel the link behavior
            e.preventDefault();
            
            $('#mask').hide();
            $('.window').hide();
            $('#dialog').html('');
        });
		
        //select all the a tag with name equal to SatinAl
        $('a[name=SatinAl]').live("click",function(e) {
            //Cancel the link behavior
            e.preventDefault();
            $.ajax({
                type: 'POST',
                url: '/inc/islemler/add_basket.asp',
                data: $('#formBuyDeal').serialize(),
                success: function(ajaxCevap) {
					if (ajaxCevap == "Hata:2")
					{
						return false;
					}
					else if (ajaxCevap == "Hata:1")
					{
						return false;
					}
					else if (ajaxCevap == "OK")
					{
						window.location.href = $('#formBuyDeal').attr('action');
					}
                }
            });
    
        });
		
        //select all the a tag with name equal to modal
        $('a[name=modal]').live("click",function(e) {
            //Cancel the link behavior
            e.preventDefault();
 
			$('#mask').hide();
			$('.window').hide();
			$('#dialog').html('');
 
            //Get the Modal Popup
            var id = $('#dialog');
            $('#dialog').load('/inc/'+$(this).attr('href')+'.asp');
	
            //Get the screen height and width
            var maskHeight = $(document).height();
            var maskWidth = $(window).width();
            
            //Set heigth and width to mask to fill up the whole screen
            $('#mask').css({'width':maskWidth,'height':maskHeight});
            
            //transition effect		
            $('#mask').fadeIn(100);	
            $('#mask').fadeTo("slow",0.5);	
        
            //Get the window height and width
            var winH = $(window).height();
            var winW = $(window).width();
                  
            //Set the popup window to center
            $(id).css('top',  132);
            $(id).css('left', winW/2-$(id).width()/2);
    
            //transition effect
            $(id).fadeIn(1000);	
        });

		//if tab button is clicked
		$('.tabs .tab').live("click",function (e) {
			//Cancel the link behavior
			e.preventDefault();
			
			$('.tab_icerik').hide();
			$('.tabs .tab').removeClass("tab_aktif");
			$(this).addClass("tab_aktif");
			$('.tab_aktif span').addClass("aktif");
	
			var index = $(".tabs .tab").index(this);
			
			var itemId = $('.tab_icerik').eq(index).attr("id");
			if ( itemId == "firma_firsatlari"){			
				$('#firma_firsatlari').load('/inc/firma_kampanyalari.asp');
			}
			
			$('.tab_icerik').eq(index).fadeIn(500);
			
		});


		//Tüm firsatlardaki üzerine gelince efekti
		$(".tum_firsat").mouseenter(function () {
			$(this).find(".summary").hide();
			$(this).find(".kazanc").show();	
		});

		//Tüm firsatlardaki üzerinden ayrilinca efekti
		$(".tum_firsat").mouseleave(function () {
			$(this).find(".summary").show();
			$(this).find(".kazanc").hide();	
		});

		// area height control
		if ($('#Middle .area').height() < $(window).height() - 328)
		{
			$('#Middle .area').height($(window).height() - 328);
		}
		
		// area height control when window resize
		$(window).resize(function() {
								  
			$('#Middle .area').css({'height':'auto'});
			
			if ($('#Middle .area').height() < $(window).height() - 328)
			{
				$('#Middle .area').height($(window).height() - 328);
			}
		});
	});
