﻿function ajaxGonder(nesne,urlx,datax){

	var loader = jQuery('<div id="loader"><img src="images/ajax-loader.gif" alt="Bekleyiniz..." /></div>')
			.css({position: "relative", top: "1em", left: "25em",display:'block'})
			.appendTo("body")
			.hide();
	jQuery().ajaxStart(function() {
			loader.show();
	}).ajaxStop(function() {
			loader.hide();
	}).ajaxError(function(a, b, e) {
		throw e;
	});
	$.ajax({
		type: 'POST',
		url: urlx,
		dataType: "html",
		async:false,
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
		data: datax,
		success: function(ajaxCevap,status) {
				$(nesne).html(ajaxCevap);
				$("div#loader").remove();
		}					
	});
}
/*jquery ajax form gonderme fonksiyonu*/
function ajaxFormGonder(urlx,datax,hedef){ //validate olayinda calistigi icin, validate olmayan formlarda calismaz. form ismi yok! __mt, maverabilisim.com
		// show a simple loading indicator
	
	var loader = jQuery('<div id="loader"><img src="images/loading.gif" alt="Bekleyiniz..." /></div>')
			.css({position: "relative", top: "1em", left: "25em",display:'block'})
			.appendTo("body")
			.hide();
	jQuery().ajaxStart(function() {
			loader.show();
	}).ajaxStop(function() {
			loader.hide();
	}).ajaxError(function(a, b, e) {
		throw e;
	});

	$.ajax({
		type : "POST",
		cache	: false,
		url		: urlx,
		data		: datax,
		dataType: "html",
		async: false,
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",		
		success: function(data) {
			$(hedef).html(data);
			//alert(data);
			
		}
	}); //ajax 
	


}//ajaxFormGonder() func
function ajax(sayfa,datax,success){
	$.ajax({
		type		: "POST",
		cache	: false,
		url		: sayfa,
		data		: datax,
		success: function(data) {
			$.fancybox(data); // buraya ne yazilmak isteniyorsa artik.
		}
	});


}
function gizliAjax(nesne,urlx,datax,sGoster){
	//sGoster: bu degisken 1 ise; bu durumda sonuc herhangi bir element icerisinde gosterilir.2 olursa gizli calisir.reklam tiklamalari gibi.
	$(nesne).ajaxStart(function(){
		if (sGoster==1)
			$(this).html('Yükleniyor, bekleyiniz.');
	});

	$.ajax({
		type: 'POST',
		url: urlx,
		dataType: "html",
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
		data: datax,		
		success: function(ajaxCevap,status) {
				if (sGoster==1)
					$(nesne).html(ajaxCevap);
		}					
	});
}

function addslashes(str) {
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\0/g,'\\0');
	return str;
}
	function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\0/g,'\0');
	str=str.replace(/\\\\/g,'\\');
	return str;
} 





function onayla(msj)
{
	cvp=confirm(msj);
	if (cvp) 	
	    return true;	
	else 
	    return false;
}



//checkboxların tümünü isaretle class: class'a gore isaretler. jQuery ister
function tumunuIsaretle(nesne,obj){

	if ($("input[name="+obj+"]").is(":checked"))
		$(nesne).each(function(index) {
			this.checked=true;
			
		});
	else
		$(nesne).each(function(index) {
			this.checked=false;
		});
}

