﻿
	function KrokiGetir(p_kroki_id) {
			AjaxIcerik("#KrokiBody","kroki.asp","pathgizle=true&kid="+p_kroki_id);
			$("#KrokiTabs div").css({
				"background":"#f3f3f3",
				"font-weight":"normal"
			});
			$("#KrokiTab"+p_kroki_id).css({
				"background":"#5b5b5b",
				"color":"#fff",
				"font-weight":"bold"
			});
		}
	function AjaxMenuGetPath(p_param) {
		$("#MenuPath").css('display','block');
			$("#MenuPath").html('');
			$.ajax({
				  type: "GET",
				  url: '/Ajax/AJX_Getpath.asp',
				  data: p_param,
				  success: function(data) {
					$("#MenuPath").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 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());
			if($("#MenuIcerik").height()< $(".Box").height()) $("#MenuIcerik").height($(".Box").height());
			
			
		
		}

	function ToggleTarih() {
			if($('#chkZaman').is(':checked')) {
					$('#srcTarih').show('slow');	
				} else {
					$('#srcTarih').hide('slow');
					}
		}
	
	$().ready(function()  {
					
		//$(".CB_icerik").colorbox();
		
		/*$(".Box .BoxDesc .Desc ul li ul").each(function(key) { $(this).toggle(); });
		$(".Box .BoxDesc .Desc ul li").each(function(key) {    
							var strAltUl = $(this).children('ul');
							if(strAltUl.length>0) { 
								$(this).children('a:first').click(function (event)  
									{  
										 strAltUl.toggle();
										 event.preventDefault();  
									});
							}
				});	
		$(".Box .BoxDesc .Desc ul li .aktif").each(function(key) {    
							$(".Box .BoxDesc .Desc ul").show();
				});*/
		FixPage();
		
		//$('#KampanyaIcerik').jScrollPane();
				 
		
		
		
		// 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();  
								});
						});

	});
