function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1) {
		   alert("Geçerli bir email adresi yazmadınız.");
		   return (false);
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
		   alert("Geçerli bir email adresi yazmadınız.");
		   return (false);
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
		   alert("Geçerli bir email adresi yazmadınız.");
		   return (false);
		}
		if (str.indexOf(at,(lat+1))!=-1) {
		   alert("Geçerli bir email adresi yazmadınız.");
		   return (false);
		}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {
		   alert("Geçerli bir email adresi yazmadınız.");
		   return (false);
		}
		if (str.indexOf(dot,(lat+2))==-1) {
		   alert("Geçerli bir email adresi yazmadınız.");
		   return (false);
		}		
		if (str.indexOf(" ")!=-1) {
		   alert("Geçerli bir email adresi yazmadınız.");
		   return (false);
		}
 		return (true);
}

function numaraYapma(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}	
	textBox.value = trim(textBox.value);
}

function secBirak(grpStr, button) {
 var form, el, e, f = 0;
 var unbuttoned = (button.value.substring(0,2).toLowerCase() == 'un');
 while (form = document.forms[f++]) {
   e = 0;
   while (el = form.elements[e++])
   if (el.type == 'checkbox' && el.name.indexOf(grpStr) != -1)
      el.checked = !unbuttoned;
 }
 button.value = unbuttoned ? button.value.substring(2) : 'un' + button.value;
}

function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

function setSelect(listElement, listValue)
{
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue)	{
			listElement.selectedIndex = i;
		}
	}	
}

function acPencereyi(sayfa,gen,uz,x,y) {
	x = (640 - gen)/2, y = (480 - uz)/2;

    if (screen) {
        y = (screen.availHeight - uz)/2;
        x = (screen.availWidth - gen)/2;
    }

    pencerem = window.open(sayfa,'windowRef','width=' + gen + ',height=' + uz +'scrollbars=1,status=1,top='+ y +',left='+ x +',screenX='+ x +',screenY='+ y);
    if (!pencerem.opener) pencerem.opener = self;
}

function fiyt() {;}

function gostertBunu(e){
	if (e.style.display=='none'){
			e.style.display='block';
			}
		else {
			e.style.display='none';
			}
		}
	
/* Win IE 5.5 & 6 için png düzeltmesi */
function correctPNG() 
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
function change() {
    var color1 = '#ccffff';
    var color2 = '#dd00ff';
    if (document.layers)
        window.document.layers[i].bgColor = color1;
    else if (document.all)
        window.document.all[i].style.background = color2;
}
	function findValueCallback(event, data, formatted) {
		$("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
	}
	
	function formatItem(row) {
		return row[0];
	}
	function formatResult(row) {
		return row[0].replace(/(<.+?>)/gi, '');
	}
	
	
	    function mailwind(ad)
		{
			var ea = 'mai' + 'lto:' + ad + '@' + 'nisan' + 'yan.c' + 'om';
			window.open(ea, 'windowname', 'width=500,height=300,scrollbars=yes');
			return false;
		}
		
function trKey(text) {
		var obj = document.xaraForm.xarama;
		if(document.selection) {
			obj.focus();
			var orig = obj.value.replace(/\r\n/g, "\n");
			var range = document.selection.createRange();

			if(range.parentElement() != obj) {
				return false;
			}

			range.text = text;

			var actual = tmp = obj.value.replace(/\r\n/g, "\n");

			for(var diff = 0; diff < orig.length; diff++) {
				if(orig.charAt(diff) != actual.charAt(diff)) break;
			}

			for(var index = 0, start = 0;
				tmp.match(text)
					&& (tmp = tmp.replace(text, ""))
					&& index <= diff;
				index = start + text.length
			) {
				start = actual.indexOf(text, index);
			}
		} else if(obj.selectionStart) {
			var start = obj.selectionStart;
			var end   = obj.selectionEnd;

			obj.value = obj.value.substr(0, start)
				+ text
				+ obj.value.substr(end, obj.value.length);
		}

		if(start != null) {
			setCaretTo(obj, start + text.length);
		} else {
			obj.value += text;
		}
	}

	function setCaretTo(obj, pos) {
		if(obj.createTextRange) {
			var range = obj.createTextRange();
			range.move('character', pos);
			range.select();
		} else if(obj.selectionStart) {
			obj.focus();
			obj.setSelectionRange(pos, pos);
		}
	}

function derTat(e) {
	if(e==0) {
		document.getElementById("uyar1").style.display='block';
		document.getElementById("uyar2").style.display='none';
		document.getElementById("uyar3").style.display='none';
		document.getElementById("uyar4").style.display='none';
	} else {
		document.getElementById("uyar1").style.display='none';
	}
}
function degGor(e) {
	if(e==0) {
		document.getElementById("te").style.display='block';
		document.getElementById("la").style.display='none';
		document.getElementById("uyar1").style.display='block';
		document.getElementById("uyar2").style.display='none';
		document.getElementById("uyar3").style.display='none';
		document.getElementById("uyar4").style.display='none';
		document.detay.dd.value='';
		document.detay.dq.focus();
	} else if(e==1) {
		document.getElementById("te").style.display='block';
		document.getElementById("la").style.display='none';
		document.getElementById("uyar1").style.display='none';
		document.getElementById("uyar2").style.display='block';
		document.getElementById("uyar3").style.display='none';
		document.getElementById("uyar4").style.display='none';
		document.detay.dd.value='';
		document.detay.dq.focus();
	} else if(e==2) {
		document.getElementById("la").style.display='block';
		document.getElementById("te").style.display='none';
		document.getElementById("uyar1").style.display='none';
		document.getElementById("uyar2").style.display='none';
		document.getElementById("uyar3").style.display='block';
		document.getElementById("uyar4").style.display='none';
		document.detay.dq.value='';
		document.detay.dd.focus();
	} else {
		document.getElementById("te").style.display='block';
		document.getElementById("la").style.display='none';
		document.getElementById("uyar1").style.display='none';
		document.getElementById("uyar2").style.display='none';
		document.getElementById("uyar3").style.display='none';
		document.getElementById("uyar4").style.display='block';
		document.detay.dd.value='';
		document.detay.dq.focus();
	}
}
   //$("#girdi").load("sag.php?s= #jq-p-Getting-Started li");
function ajax_update()
{
	var wrapperId 	=	'#yenid';
	var postFile	=	'yyeni.php';

	$.post(postFile, {}, function(data){  
		
		$(wrapperId).slideUp('2000',function(){

			$(this).html(data).slideDown();
			
			}).html();});
}

$(function() {
	$(".delbutton").click(function(){
		var element = $(this); 
		var del_id = element.attr("id");
		var info = 'id=' + del_id;
			$.ajax({
				type: "POST",
				url: "searchsil.php",
				data: info,
				cache: false,
				success: function(){
					$("#si"+del_id).slideUp("slow"),
					document.location.reload(true);
				}
			});
			return false;
	});
});

function arFrKontrol(theForm) {
	if (theForm.dn.value==2&&theForm.dd.value=="") {
		alert("Lütfen dil seçiniz!");
		theForm.dd.focus();
		return (false);
	} else if(theForm.dn.value!= 2&&theForm.dq.value=="") {
		alert("Lütfen aranacak terimi yazınız!");
		theForm.dq.focus();
		return (false);
	}
	return (true);
}
function yorKontrol(theForm,keli) {
	if (theForm.comment.value==""||theForm.comment.value==keli) {
		alert("Yorum yazmadınız.");
		theForm.comment.focus();
		return (false);
	} else if(theForm.isim.value=="") {
		alert("İsim yazmadınız.");
		theForm.isim.focus();
		return (false);
	} else if(theForm.email.value=="") {
		alert("Email yazmadınız.");
		theForm.email.focus();
		return (false);
	} else if(echeck(theForm.email.value)==false) {
		//alert("Geçerli bir email yazmadınız.");
		theForm.email.focus();
		return (false);
	}
	return (true);
}
	
var Url = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
 
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}


