﻿// JavaScript Document

function flushCache(){
		cache = {};
		cache.data = {};
		cache.length = 0;
};
function kutuyuyoket(kutuid){
	$("#"+kutuid).parents(".kutu3-1").effect("highlight", {}, 400).animate({
		opacity: 0    
		},function () {
	$("#"+kutuid).parent(".kutu3-1-islemler").parent(".kutu3-1").remove();
	});
};
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
};
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
};
/*
•” ” (ASCII 32 (0×20)), an ordinary space.
•“\t” (ASCII 9 (0×09)), a tab.
•“\n” (ASCII 10 (0×0A)), a new line (line feed).
•“\r” (ASCII 13 (0×0D)), a carriage return.
•“\0″ (ASCII 0 (0×00)), the NUL-byte.
•“\x0B” (ASCII 11 (0×0B)), a vertical tab.
*/
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
};
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
};
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
};
function trim2(str){    
if(!str || typeof str != 'string')        return null;    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
};
function dataisle(data){
	var dizim = data.split("_",3);
	$.ajax({
	   type: 'POST',
	   url: 'islemler/'+dizim[1]+'.asp'+'?i='+dizim[0]+'&id='+dizim[2],
	   data: 'data='+Url.encode($('#'+dizim[1]+'_'+dizim[2]).html()),
	   cache:function(){
	   flushCache();
	   }, 
	   success: function(ajaxCevap) {
		  $("#mesaj").hide();
		  $("#hatali").hide();
		  $("#mesaj").show();
		  $("#basarili").show();
		  $("#basarimesaji").html(ajaxCevap);
		  $('#'+dizim[1]+'_'+dizim[2]).unblock();
	   },
	   error:function(xhr) {
		   $('#'+dizim[1]+'_'+dizim[2]).unblock(); 
			var msg = "Üzgünüz Hata Oluştu: ";
			alert(msg + xhr.status + " " + xhr.statusText);
		  }
	});
};
function dataekle(formidsi){
	var dizim=formidsi.split("_",2);									
    $("#"+formidsi).ajaxForm({
    url: 'islemler/'+dizim[1]+'.asp'+'?i='+dizim[0]+'&MM_insert='+formidsi,
	type: 'POST',
	resetForm: true,
	cache:function(){
	   flushCache();
	   }, 
    beforeSubmit: function(formData, jqForm, options){
        if (Spry) { // checks if Spry is used in your page
            var r = Spry.Widget.Form.validate(jqForm[0]); // validates the form
            if (!r)
                return r;
        }
    },
    success: function(ajaxCevap) {
			  $("#basarimesaji").html(ajaxCevap);
			  hs.close('yenieklemehs');
			  $("#mesaj").hide();
			  $("#hatali").hide();
			  $("#mesaj").show();
			  $("#basarili").show();
			  $('#'+dizim[1]+'_'+dizim[2]).unblock();
	},
    error:function(xhr) {
				var msg = "Üzgünüz Hata Oluştu: ";
				alert(msg + xhr.status + " " + xhr.statusText);
	}
});
};
function dataguncelle(formidsi){
	var dizim=formidsi.split("_",3);
	var uri='islemler/'+dizim[1]+'.asp'+'?i='+dizim[0]+'&id='+dizim[2]+'&MM_update='+formidsi;
    $("#"+formidsi).ajaxForm({
    url: uri,
	type: 'POST',
	resetForm: false,
	cache:function(){
	   flushCache();
	   }, 
    beforeSubmit: function(formData, jqForm, options){
        if (Spry) { // checks if Spry is used in your page
            var r = Spry.Widget.Form.validate(jqForm[0]); // validates the form
            if (!r){
				$("#resimpanelformu").prepend($("#resimpaneli"));
			    $("#resimpaneli").show();
                return r;
			}else{
				$("#"+formidsi).block({ message: '<p>İşlem Yapılıyor</p>', css: { border: '3px solid #a00' } });
			}
        }
    },
    success: function(ajaxCevap) {
			  $("#mesaj").hide();
			  $("#hatali").hide();
			  $("#mesaj").show();
			  $("#basarili").show();
			  $("#basarimesaji").html(ajaxCevap);
			  $('#'+dizim[0]+'_'+dizim[1]+'_'+dizim[2]).unblock();
			  $("#resimpanelformu").prepend($("#resimpaneli"));
			  $("#resimpaneli").show();
	},
    error:function(xhr) {
				var msg = "Üzgünüz Hata Oluştu: ";
				alert(msg + xhr.status + " " + xhr.statusText);
				$('#'+dizim[0]+'_'+dizim[1]+'_'+dizim[2]).unblock();
				$("#resimpanelformu").prepend($("#resimpaneli"));
			    $("#resimpaneli").show();
	}
});
};
$(document).ready(function(){
			   
	$('#map_canvas').googleMaps({
    scroll:false,
	disablezoom:true,
	depth:11,
	controls:{
				hide:true
			},
	latitude: 	41.0001,
    longitude:  29.1516,
	tekyermi:{
				dragfnk:function(pnt){
				alert(pnt.lat()+'  burada  '+pnt.lng());
				$('#lat').val(pnt.lat());
				$('#lng').val(pnt.lng());
				}
			}
	});
	/*$('#map_canvas').googleMaps({
    scroll:false,
	latitude: 	41.4416,
    longitude: -112.1516,
	disabledubklik:true,
	tekyermi:{
				opta:true,
				dragfnk:function(pnt){
				alert(pnt.lat()+'  burada  '+pnt.lng());
				}
			},
	markers: {
			latitude: 	41.4416,
			longitude: -112.1516,
			draggable: true,
			dragendfnk:function(pnt){
			alert(pnt.lat()+'  ilk burada '+pnt.lng());
			}
        }
	});*/
	var cache = {};
	$('#e_ilislemleri').submit(function() {
        return false; 
    }); 
	$(".ileklemesubmit").click(function() {
		dataekle('e_ilislemleri');
    }); 
	$('#e_ilceislemleri').submit(function() {
        return false; 
    }); 
	$(".ilceeklemesubmit").click(function() {
		dataekle('e_ilceislemleri');
    }); 
	$('#e_semtislemleri').submit(function() {
        return false; 
    }); 
	$(".semteklemesubmit").click(function() {
		dataekle('e_semtislemleri');
    });
	$('#e_detayislemleri').submit(function() {
        return false; 
    }); 
	$(".detayeklemesubmit").click(function() {
		dataekle('e_detayislemleri');
    });
	$('#e_kisiislemleri').submit(function() {
        return false; 
    }); 
	$(".kisieklemesubmit").click(function() {
		dataekle('e_kisiislemleri');
    });
	$('.g_kisiislemleri').submit(function() {
        return false; 
    }); 
	$(".kisiguncellesubmit").click(function() {
		var idsi=$(".g_kisiislemleri").attr('id');
		$("#resimpaneli").hide();
		$("#gkpasif").prepend($("#resimpaneli"));
		dataguncelle(idsi);
    });
	$(".mapdegis").click(function() {
		$('#map_canvas').googleMaps({depth:11});	   
    });
	$(".akt").click(function() {
		var idsi=$(this).attr('id');
		$(this).parent(".kutu3-1-islemler").parent(".kutu3-1").block({ message: '<p>İşlem Yapılıyor</p>', css: { border: '3px solid #a00' } });
		dataisle(idsi);
	  });  
	$(".kduzenlemeislemi").click(function() {
		var idsi=$(this).attr('id');
		var datam=idsi.split("_",3);
		window.location="kisi.asp?id="+datam[2];
	  }); 
	$(".silmeislemi").click(function() {								
		if(confirm('Silmek istediğinizden emin misiniz?')) {
			var idsi=$(this).attr('id');
			$(this).parent(".kutu3-1-islemler").parent(".kutu3-1").block({ message: '<p>Siliniyor</p>', css: { border: '3px solid #a00' } });
			dataisle(idsi);
		}return false;});
		
   /*  new cycle, more info @ http://malsup.com/jquery/cycle/  */
   $('.cycle-1').cycle({ 
       fx:     'fade', 
       speed:   200, 
       timeout: 10000, 
       clip:   'zoom' 
	 });
   
	$(".kutu3-1").mouseover(function () {
      $(this).css("background-color",'#e9e9e9');
	});
	$(".kutu3-1").mouseout(function () {
      $(this).css("background-color",'#FFF');
	});

  settings = {
          tl: { radius: 10 },
          tr: { radius: 10 },
          bl: { radius: 10 },
          br: { radius: 10 },
          autoPad: true,
          validTags: ["div"]
      }

  <!--$('.kutu3-1').corner(settings);-->

	/* succes */
	$(".del-x").click(function () {
					$(this).parents('.dialog-box-succes').hide();
				});
	/* error */
	$(".del-x").click(function() {
				$(this).parents('.dialog-box-error').hide();
				});
	/* warning */
	$(".del-x").click(function() {
				$(this).parents('.dialog-box-warning').effect("highlight", {}, 400).animate({
					opacity: 0    
				},function () {
					$(this).remove();
				});
		return false;
	  });
	/* information */
	
	$(".del-x").click(function() {
				$(this).parents('.dialog-box-information').effect("highlight", {}, 400).animate({
					opacity: 0    
				},function () {
					$(this).remove();
				});
		return false;
	  });

    /* toggle selected box */
	/*pasifleri kapatıyoruz...*/
	
	$(".toggle").click(function(){
	   var id = $(this).attr('id');
		  $("#tog"+ id).slideToggle("slow");
			 if ($('#'+ id + ' img.close').is(":hidden")){
				 $('#'+ id +' img.close').show();
				 $('#'+ id +' img.open').hide();
			  } else {
				 $('#'+ id + ' img.open').show();
				 $('#'+ id + ' img.close').hide();
			  }
	});
	if ($("#toogle")){
		var id="gle"
				$("#tog"+ id).slideToggle("slow");
			 if ($('#'+ id + ' img.close').is(":hidden")){
				 $('#'+ id +' img.close').show();
				 $('#'+ id +' img.open').hide();
			  } else {
				 $('#'+ id + ' img.open').show();
				 $('#'+ id + ' img.close').hide();
			  }
	};
				
				
    /* This will give every even tr(row) a backgroundcolor */
    /* When hover a row it will light up */
	$("#tb-1 tr, #tb-2 tr").mouseover(function() {
		$(this).addClass("row-over");}).mouseout(function() {
			$(this).removeClass("row-over");
			});
	
           $("#tb-1 tr:even, #tb-2 tr:even").addClass("row"); 
		   
		   
    /* Code for the sortables more info @ http://jqueryui.com/demos/sortable/ */	
	$('#sortable').sortable({ 
				handle:      '.box-780-head',
				//placeholder: 'sortHelper', (css not working correct)
				delay:        250,
				cursor:      'move',
				scroll:       true,
				revert:       true, 
				opacity:      0.7
	});

    /* Code for the sortables more info @ http://jqueryui.com/demos/sortable/ */	
	$('#sortable2').sortable({ 
				handle:      '.box-1000-head',
				//placeholder: 'sortHelper', (css not working correct)
				delay:        250,
				cursor:      'move',
				scroll:       true,
				revert:       true, 
				opacity:      0.7
	});
	
	/* more info about the jQuerydatepicker @ http://jqueryui.com/demos/datepicker/ */
	$("#datepicker").datepicker({
		nextText: '',
		prevText: ''
	});	
	
	// searchfield value more info @ http://mucur.name/system/jquery_example/
	$('#s').example('Search here');
	
	/* lightbox more info @ http://colorpowered.com/colorbox/ */					   
	$("a.lightbox, a.lightbox2").colorbox({transition:"none"});
	
   <!-- /* remove/switch to simple mode SmartMarkUp Universal Markup Editor */ -->
	<!--var remove = document.getElementById('remove'); -->
	<!--remove.onclick = function() { -->
	<!--	if (this.rel == 'on') { -->
	<!--		this.innerHTML = 'Switch to advance mode'; -->
	<!--		this.rel = 'off'; -->
	<!--		$.sMarkUpRemove('#html'); -->
	<!--	} else { -->
	<!--		this.innerHTML = 'Switch to simple mode'; -->
	<!--		this.rel = 'on'; -->
	<!--		$('#html').sMarkUp('html', 300); -->
	<!--	} -->
	<!--	return false; -->
	<!--}; -->
    
	/* pngfix, supersleight the jQuery version more info @ http://allinthehead.com/retro/338/supersleight-jquery-plugin */
	$('#userid, .dialog-left, #tb-1, #tb-2').supersleight();
    
	<!--// tabs-->
	<!--$("#tabs").tabs();-->

});