﻿
	function KrokiGetir(p_kroki_id) {
			AjaxIcerik("#KrokiBody","kroki.asp","pathgizle=true&kid="+p_kroki_id);
			$("#KrokiTabs div").css({
				"background":"#c9c9c9",
				"font-weight":"normal",
				"color":"#515151"
			});
			$("#KrokiTab"+p_kroki_id).css({
				"background":"#6480ba",
				"color":"#fff",
				"font-weight":"bold"
			});
		}
	function AjaxMenuGetPath(p_param) {
		$("#MenuPath #MenuPathIcerik").css('display','block');
			$("#MenuPath #MenuPathIcerik").html('');
			$.ajax({
				  type: "GET",
				  url: '/Ajax/AJX_Getpath.asp',
				  data: encodeURI(p_param),
				  success: function(data) {
					$("#MenuPath #MenuPathIcerik").html(data);
					}
				});
		}
	function AjaxMenuIcerikAnimate(p_Type,p_url,p_param,p_li) {
			switch (p_Type)
  			{
    			case "Kayarak": { 
					var strW = $(window).width();
					$("#MainDisBody").animate({
								"left": "-" + strW +"px"}, 500,function() {
								$("#MainDisBody").css({"display":"block"});
								//$("#MenuIcerik").css({opacity:0});
								$("#MenuIcerik").html('<img src="/images/yukleniyor.gif" style="margin:35px">');
								$.ajax({
									  type: "GET",
									  url: '/Ajax/AJX_icerik.asp',
									  data: 'ajxsayfa='+ p_url + '&' + p_param,
									  global:false,
									  success: function(data) {
										$("#MenuIcerik").html(data);
										FixPage();
										$("#MainDisBody").animate({
											"left": "0px"}, 1000,function() {
													//$("#MenuIcerik").animate({opacity:1});
												});
										}
								});
					});			
					break 
				}
    			case "Fade": { 
					$("#MainDisBody").animate({
								opacity:0}, 500,function() {
								$("#MainDisBody").css({"display":"block"});
								$("#MenuIcerik").html('<img src="/images/yukleniyor.gif" style="margin:35px">');
								$.ajax({
									  type: "GET",
									  url: '/Ajax/AJX_icerik.asp',
									  data: 'ajxsayfa='+ p_url + '&' + p_param,
									  global:false,
									  success: function(data) {
										$("#MenuIcerik").html(data);
										FixPage();
										$("#MainDisBody").animate({
											opacity:1}, 1000);
										}
								});
					});	
					break 
				}
			}
		}
	
	function AjaxMenuIcerik(p_url,p_param,p_li) {
			// Bg Olaylari Bas
			$("#nav li").removeClass("aktif");
			$("#"+p_li).removeClass().addClass("aktif");
			// Bg Olaylari Son
			$("#MenuIcerik").removeClass().addClass("content KenardanBosluk");
			AjaxMenuIcerikAnimate("Kayarak",p_url,p_param,p_li);
			//AjaxMenuIcerikAnimate("Fade",p_url,p_param,p_li);
		}
	
	function AjaxIcerik(p_body,p_url,p_param) {
			$(p_body).html('<img src="/images/yukleniyor.gif" style="margin:35px">');
			$.ajax({
				  type: "GET",
				  url: '/Ajax/AJX_icerik.asp',
				  data: 'ajxsayfa='+ p_url + '&' + p_param,
       		      global:false,
				  success: function(data) {
					$(p_body).html(data);
					FixPage();
					}
				});
		}
	
	function AjaxUrunIcerik(p_body,p_url,p_param) {
			var strLoding = '<div class="UrunLoading"><img src="/images/yukleniyor.gif" style="margin:35px"></div>';
			$("#UrunMenuIcerik").html($("#UrunMenuIcerik").html()+strLoding);
			UrunlerIE7Fix();
			$.ajax({
				  type: "GET",
				  url: '/Ajax/AJX_icerik.asp',
				  data: 'ajxsayfa='+ p_url + '&' + p_param,
       		      global:false,
				  success: function(data) {
					$('.UrunLoading').remove();
					$(p_body).html(data+$(p_body).html());
					// Animate Baş
					var strW = $(".SonEklenenBlok ul").width();
					$(".SonEklenenBlok ul").css({"position":"absolite","display":"block","left":"-" + strW + "px"});
					$(".SonEklenenBlok ul").animate(
								{"left":"0px"},{
											specialEasing: {
											width: ['toggle', 'swing'],
											height: ['toggle', 'swing'],
											opacity: 'toggle'

											}});
					// Animate Son
					UrunLinklerAjx();
					UrunlerIE7Fix();
					}
				});
		}
	function UrunLinklerAjx() {
		$(".UrunAjax").each(function(key) {    
							 var strLink = $(this).attr("href").replace("http://"+HostAdi,"");	
							 var strParam = $(this).attr("rel");							 
							 var strBlokId = $(".UrunKatBlok").index($(this).parent("h3").parent("li").parent("ul").parent(".UrunKatBlok"));
							 $(this).click(function (event)  
								{  
									$(".UrunBanner").html("");
							 		$(".UrunBanner").hide();
									$(".SonEklenenBlok").removeClass("SonEklenenBlok");
									var ToplamBlok = $(".UrunKatBlok").length;
									$(".UrunKatBlok").each(function(key) {    
										if(key<strBlokId)
											if(key<ToplamBlok) $(this).remove();
									});
									 
									 $(".UrunKatBlok li").removeClass("Aktif");
									 $(this).parent("h3").parent("li").addClass("Aktif");
									 location.hash = strLink;
									 AjaxUrunIcerik(".UrunKatBlokBody","products.asp","MenuGalerigizle=true&strAction=Ajx&"+strParam);
									 event.preventDefault();  
								});
						});	
		}
	
	function LiveSearchForm() {
			$(".LiveSearch").each(function(key) {    
							strAction = $(this).attr('action');
							$(this).attr('action','javascript:{void(0);}');
							strResultDiv = "#"+$(this).children('#ResultDiv').val();
							$(this).children('#srcText').keyup(function(){
								if($(this).val().length>1) AjaxIcerik(strResultDiv,strAction,"MenuGalerigizle=true&pathgizle=true&srct="+$(this).val());
								});
							});	
		}
	function ObjClassDegistir(p_obje,p_class) {
			$(p_obje).removeClass().addClass(p_class);
		}
	
	function FormUyariKutusuOlustur(caller, p_ana_obje, p_text) {
			var divFormError = document.createElement('div');
			var formErrorContent = document.createElement('div');		
			$(divFormError).addClass("formError");
			$(formErrorContent).addClass("formErrorContent");
			
			$(p_ana_obje).append(divFormError);
			$(divFormError).append(formErrorContent);
			
			var arrow = document.createElement('div');
			$(arrow).addClass("formErrorArrow");
			$(divFormError).append(arrow);
			$(arrow).addClass("formErrorArrowBottom")
			$(arrow).html('<div class="line10"><!-- --></div><div class="line9"><!-- --></div><div class="line8"><!-- --></div><div class="line7"><!-- --></div><div class="line6"><!-- --></div><div class="line5"><!-- --></div><div class="line4"><!-- --></div><div class="line3"><!-- --></div><div class="line2"><!-- --></div><div class="line1"><!-- --></div>');
			
			$(formErrorContent).html(p_text);
			
			callerTopPosition = $(caller).position().top;
			callerleftPosition = $(caller).position().left;
			callerWidth =  $(caller).width();
			inputHeight = $(divFormError).height();
			arrowHeight = $(arrow).height();
		
			/* POSITIONNING */		
					
			callerHeight =  $(caller).height();
			callerleftPosition +=  callerWidth -30; 
			callerTopPosition = callerTopPosition - (callerHeight - arrowHeight) - inputHeight;
			
			$(divFormError).css({
				top:callerTopPosition+"px",
				left:callerleftPosition+"px",
				opacity:0
			});
			
			ArroWTop = inputHeight+4;
			
			$(arrow).css({
				top:ArroWTop
			});
			
			$(divFormError).animate({opacity:0.75});
			
			$(".formError").live("click",function(){	 // REMOVE BOX ON CLICK
				$(this).fadeOut(150,function(){
					$(this).remove();
				}) 
			});
		}
	

	function TitleHareketEt(speed) {
			$("#MenuPathIcerik").css({"margin-left": "-" + ($("#MenuPathIcerik").width()-$("#MenuPath").width()) +"px"});
			myInterval = setInterval("TitleHareket()",speed);
		}
	function TitleHareket() {
		$("#MenuPathIcerik").animate({
								"margin-left": "0px"}, 1000,function() { 
										$("#MenuPathIcerik").animate({"margin-left": "-" + ($("#MenuPathIcerik").width()-$("#MenuPath").width()) +"px"}, 1000,function() {});
								});
		}
	
	function FixPage() {
			$('#frmIletisim').ajaxForm({ 
				target: '#FormSonuc', 
		 		beforeSubmit: function() { 
					$('.IletisimFormErr').removeClass();
					$('#FormSonuc').html('<img src="/images/loading.gif" style="margin:5px">');
					$('#gonder').attr('disabled', 'disabled');
					$('.formError').remove();
				},
				success: function() { 
					$('#gonder').removeAttr("disabled");
				} 
			});
			
			$('#frmIK').ajaxForm({ 
				target: '#FormSonuc', 
		 		beforeSubmit: function() { 
					$('.IletisimFormErr').removeClass();
					$('#FormSonuc').html('<img src="/images/loading.gif" style="margin:5px">');
					$('#gonder').attr('disabled', 'disabled');
					$('.formError').remove();
				},
				success: function() { 
					$('#gonder').removeAttr("disabled");
				} 
			});
			
			$('#frmEbulten').ajaxForm({ 
				target: '#FormSonuc', 
		 		beforeSubmit: function() { 
					$('.IletisimFormErr').removeClass();
					$('#gonder').attr('disabled', 'disabled');
					$('.formError').remove();
				},
				success: function() { 
					$('#gonder').removeAttr("disabled");
				} 
			});
			
			if($('#BaglantiliMenuler .Box .BoxDesc .Desc').html()=="") {
					$('#BaglantiliMenuler').css({"display":"none"});
					$('#UrunKategorileriList').css({"display":"block"});
				}
			
			if($("#MenuPathIcerik").width()>$("#MenuPath").width()) TitleHareketEt(3000);
			
			if($("#MenuIcerik").height()> $(".Box").height()) $(".Box").height($("#MenuIcerik").height());
		
		}
	
	function UrunlerIE7Fix() {
		var IntBlokGenislik = 0;
				$(".UrunKatBlok").each(function(key) {    
										IntBlokGenislik+=$(this).width();
										});
				$(".UrunKatBlokBody").css({"width":IntBlokGenislik+"px"});
	}

	function ToggleTarih() {
			if($('#chkZaman').is(':checked')) {
					$('#srcTarih').show('slow');	
				} else {
					$('#srcTarih').hide('slow');
					}
		}
	
	$().ready(function()  {
					
		$(".CB_icerik").colorbox();

		FixPage();
		
		//$('#KampanyaIcerik').jScrollPane();
				 
		$('#HaberSilde').codaSlider({     
			autoSlide: true, 
			autoSlideInterval: 3500, 
			dynamicTabs:false,
			dynamicArrows:false,
			slideEaseFunction: "easeInOutElastic",
			autoSlideStopWhenClicked: true
			});
		
		
		// PopUpKontrol Bas
		$.ajax({
				  type: "GET",
				  url: '/PopUpKontrol.asp',
				  data: InsertParam,
				  dataType: "script"
				});
	   // PopUpKontrol Son
		
		LiveSearchForm();
		
		$('#frmSrc').ajaxForm({ 
				target: '#AramaSonuclari', 
		 		beforeSubmit: function() { 
					$('.IletisimFormErr').removeClass();
					$('#AramaSonuclari').html('<img src="/images/loading.gif" style="margin:5px">');
					$('#btnSubmit').attr('disabled', 'disabled');
					$('.formError').remove();
				},
				success: function() { 
					$('#btnSubmit').removeAttr("disabled");
				} 
			});
		
		
		
		$(".AjaxIcerik").each(function(key) {    
							 var strLink = $(this).attr("href").replace("/Ajax/AJX_icerik.asp?ajxsayfa=","");
							 var strBody = "#"+$(this).attr("rel");							 
							 $(this).click(function (event)  
								{  
									 AjaxIcerik(strBody,strLink,'');
									 event.preventDefault();  
								});
						});
		
		UrunLinklerAjx();
		UrunlerIE7Fix();
		
		if ( $.browser.msie ) {
		   if($.browser.version<7) {
				alert("Tarayıcınız bu web sayfasını düzgün görüntüleyemeyecek kadar eski. Lütfen tarayıcınızı güncelleyiniz.");
		   } 
		}
			
	});
