
function Pay_onkeypress() 	{
	if (window.event.keyCode < 48 || window.event.keyCode > 57)		return false;		
}

function Amount_onkeypress() {	
	if (window.event.keyCode<48 || window.event.keyCode>57){
	return false;}
}

function Allowed_Inputs(e,truechars){	
	var whichCode = (window.Event) ? e.which : e.keyCode;
	//alert(whichCode);
	for (i=0; i<truechars.length; i++)
	{
		if (whichCode==truechars.charCodeAt(i)) {
			return true;
		}
	}
	return false;
	
}

function not_Allowed_Inputs(e,falsechars){	
	var whichCode = (window.Event) ? e.which : e.keyCode;
	//alert(whichCode);
	for (i=0; i<falsechars.length; i++)
	{	
		if (whichCode==falsechars.charCodeAt(i) || whichCode==34 || whichCode==39) {
			return false;
		}
	}
	return true;
	
}

function Amount_onkeyup(thisis,digit,decimal) {	
	var tempstr,newstr,str,i,str2 ;
	var commapos,aftercomma,commacount;
	//Nusret
	var tempaftercomma;
	//
	
	i=0;
	str = thisis.value;
	decimal=parseFloat(decimal);
	digit=parseFloat(digit);
	
	while ( 15 > i) 
	{
		str = str.replace(".","");
		i=i+1;
	}
	commacount=0;
	commapos=str.indexOf(",");
	
	if (commapos>=0)
	{
		aftercomma=str.substr(commapos);
		str=str.substr(0,commapos);
	}
	else
		aftercomma="";
	
	
	if(str.length>=digit)
	{
		str=str.substr(0,digit);
	}
	if(aftercomma.length>decimal+1)
	{
		if (decimal<=0)
			aftercomma="";
		else
			aftercomma=aftercomma.substr(0,decimal+1);
	}else
	{
		if (decimal<=0)
			aftercomma="";
	}
	
	/*Nusret*/
	if (commapos>=0) 
	{
		tempaftercomma = aftercomma.substr(1,decimal);
		
		//alert(tempaftercomma);	
			
		if (tempaftercomma.indexOf(",")>=0)
			aftercomma = ","
			
	}
	/**/
	if (str.length > 3) 
	{
		tempstr=str;
		newstr="";
		while (tempstr.length>3)
		{
			newstr="."+tempstr.substr(tempstr.length-3)+newstr; 
			tempstr=tempstr.substr(0,tempstr.length-3);
		}
		str=tempstr+newstr+aftercomma;
	}
	else
	{
		if(commapos>=0)
		{
			str=str+aftercomma;
		}
	}

	
	thisis.value= str;
}

/* Orginal
function Amount_onkeyup(thisis) {
	//alert(thisis.value);
	var tempstr,newstr,str,i,str2 ;
	var commapos,aftercomma,commacount;
	i=0;
	str = thisis.value;
	if (str.indexOf(",")<0)
	{	// çalışma
		//alert(str);
		//str = str.replace(".","");
		//alert(str);
	
		while ( 15 > i) 
		{
			str = str.replace(".","");
			i=i+1;
		}
		commacount=0;
		commapos=str.indexOf(";");
	
		if (commapos>=0) 
		{
			aftercomma=str.substr(commapos);
			str=str.substr(0,commapos);
		}
		else
			aftercomma="";
	
		if (str.length > 3) 
		{
			tempstr=str;
			newstr="";
			while (tempstr.length>3)
			{
				newstr="."+tempstr.substr(tempstr.length-3)+newstr; 
				tempstr=tempstr.substr(0,tempstr.length-3);
			}
			thisis.value = tempstr+newstr+aftercomma;
		}
		else //Aysun
		{
			str = str.replace(".","");
			thisis.value=str
		}
	}//indexOf
	return true;
}
*/
function limitSize(thisis,maxLength)
{
var str, re;

str = thisis.value;
re = /\./g;
			
str = str.replace(re, "");

if (str.length>maxLength)
{
	str=str.substring(0,maxLength);
}

thisis.value=str;
return true;
}


function Name_onkeypress() {	
	if (window.event.keyCode<65 && window.event.keyCode!=32){
	return false;}
}
//Alias tanımlamada space girişinin engellenmesi 
function Alias_onkeypress_wospace() {	
	if (window.event.keyCode==32){
	return false;}
}
//Aysun
function Name_onkeypressTR() {	
	if (window.event.keyCode<65 && window.event.keyCode!=32){
	return false;}
		
	var validChars="üÜğĞışŞİçÇöÖQqXxWw ";
	for (i=0; i<validChars.length; i++)
	{
		if (window.event.keyCode==validChars.charCodeAt(i)) {
			return false;
		}
	}
}
function Comma(number) {
	number = '' + number;
	if (number.length > 3) {
		var mod = number.length % 3;
		var output = (mod > 0 ? (number.substring(0,mod)) : '');
		for (i=0 ; i < Math.floor(number.length / 3); i++) {
			if ((mod == 0) && (i == 0))
				output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
			else
				output+= '.' + number.substring(mod + 3 * i, mod + 3 * i + 3);
		}
		return (output);
	}
	else return number;
}

function Numeric_Control(e) {	
	//alert(window.event.srcElement.value);
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if (whichCode == 13) return true;  // Enter
	if (whichCode == 0) return true;
	if (whichCode == 8) return true;
	if (whichCode == 32) return true;  
	if (whichCode > 57 ){
	return false;}
	if (whichCode < 48){
	return false;}
}

function Only_Numeric(e) {	
	//alert(window.event.srcElement.value);
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if (whichCode == 13) return true;  // Enter
	if (whichCode == 44) return true;  // Comma
	if (whichCode > 57 ){
	return false;}
	if (whichCode < 48 && whichCode > 13){
	return false;}
}

function Only_Character(e) {	
	//alert(window.event.srcElement.value);
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if (whichCode == 13) return true;  // Enter
	if (whichCode == 44) return true;  // Enter
	if (whichCode > 47 && whichCode < 58){
	return false;}
}

function Only_LetterANDDigit(e) {	
	//alert(window.event.srcElement.value);
	var whichCode = (window.Event) ? e.which : e.keyCode;
	//alert(whichCode);
	if (whichCode > 47 && whichCode < 58){
	return true;}
	if (whichCode > 96 && whichCode < 123){
	return true;}	
	if (whichCode > 64 && whichCode < 91){
	return true;}	
	if (whichCode == 13) return true;  // Enter
	if (whichCode == 0) return true;  //Delete etc.
	if (whichCode == 8) return true;
	if (whichCode == 32) return true;  
	return false;

}



function Only_Digit(e) {	
	//alert(window.event.srcElement.value);
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if (whichCode == 13) return true;  // Enter
	if (whichCode > 57 ){
	return false;}
	if (whichCode < 48 && whichCode > 13){ 
	return false;}
}

function Only_Letter(e) {	

	var whichCode = (window.Event) ? e.which : e.keyCode;

	if (whichCode == 13) return true;  // Enter
	if (whichCode == 0) return true;  //Delete etc.
	if (whichCode == 8) return true; 
	
	if ((whichCode >=97 && whichCode <=122) || (whichCode <=90 && whichCode >=65)){
	return true;}
	
	var validChars="üÜğĞışŞİçÇöÖ ";

	for (i=0; i<validChars.length; i++)
	{
		if (whichCode==validChars.charCodeAt(i)) {
			return true;
		}
	}
	
	return false;
	
}		

	
function Open(message,titletxt){

var msgWindow; 

	msgWindow=window.open("","Ornek","toolbar=0,top=50,left=50,width=300,height=80,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0"); 
	msgWindow.document.close(); 
	msgWindow.document.open();
	msgWindow.document.write("<html><head><meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-9'>");
	msgWindow.document.write("<meta http-equiv='Content-Type' content='text/html; charset=windows-1254'>");
	msgWindow.document.write("<title>" + titletxt + "</title></head><body>");
	msgWindow.document.write("<table  width=250 ><tr><td style='FONT: 10px Helvetica, sans-serif, Arial;HEIGHT: 20px'>" + message + "</td></tr></table>");
	msgWindow.document.write("</body>");
	msgWindow.focus();
}	
	
function PadField(thisis, other, len) {
	var	str = thisis.value;
  var i, l = str.length;
  for (i=0; i<len - l; i++)	{
  	str = "0" + str;
  }
	other.value = str;
  return true;
}

function ToUCase(thisis, other) {
	var	str = thisis.value;
	var chr, recStr;
	var i, l = str.length;
	recStr = "";
	for (i=0; i<l; i++)	{
		chr = str.charCodeAt(i);		
		if (chr > 96 && chr < 123){
			chr = chr - 32;
		}
		recStr = recStr + String.fromCharCode(chr);	
	}	
	thisis.value = recStr;
	return true;
}

function AutoTab(fld,n) {
	var f = eval("document.mainform.x_param" + n);
	if (f !=null)	{
		if(fld.value.length==fld.maxLength)	{
			f.focus();
		}
	}	else	{
  	f = eval("document.mainform.input_param" + n);
		if (f != null)	{
			if(fld.value.length==fld.maxLength)	{
				f.focus();
			}
		}
	}
}

function Only_LetterTR(e) {	

	var whichCode = (window.Event) ? e.which : e.keyCode;

	if (whichCode == 13) return true;  // Enter
	if (whichCode == 0) return true;  //Delete etc.
	if (whichCode == 8) return true; 	
	
	var validChars="üÜğĞışŞİçÇöÖQqXxWw ";

	for (i=0; i<validChars.length; i++)
	{		
		if (whichCode==validChars.charCodeAt(i)) {
			return false;
		}		
	}
	
	if ((whichCode >=97 && whichCode <=122) || (whichCode <=90 && whichCode >=65)){
	return true;}
	
	return false;
	
}
		
function CheckTCKimlikNo(tcKimlikNo){
	var tckimlikno_str;
	
	tckimlikno_str=tcKimlikNo;
	
	if ((tcKimlikNo!="") && (tcKimlikNo.length!=11)){
		alert("TC Kimlik Numaranız 11 haneli rakam olmalıdır.");
		return false;
	}
		
	if (tcKimlikNo!="") 
	{
		Tmp   = Math.floor(parseInt(tckimlikno_str)/100);
		Tmp1  = Math.floor(parseInt(tckimlikno_str)/100);
		

		int1=parseInt(tckimlikno_str.substring(0, 1));
		int2=parseInt(tckimlikno_str.substring(1, 2));
		int3=parseInt(tckimlikno_str.substring(2, 3));
		int4=parseInt(tckimlikno_str.substring(3, 4));
		int5=parseInt(tckimlikno_str.substring(4, 5));
		int6=parseInt(tckimlikno_str.substring(5, 6));
		int7=parseInt(tckimlikno_str.substring(6, 7));
		int8=parseInt(tckimlikno_str.substring(7, 8));
		int9=parseInt(tckimlikno_str.substring(8, 9));
		
		odd_sum=int9+int7+int5+int3+int1;
		even_sum=int8+int6+int4+int2;
		total = odd_sum*3+even_sum;
		
		ChkDigit1 = (10-(total % 10)) % 10;
		odd_sum = ChkDigit1+int8+int6+int4+int2;
		even_sum  = int9+int7+int5+int3+int1;
		total = odd_sum*3+even_sum;
		ChkDigit2 = (10-(total % 10)) % 10;
		Tmp=Tmp*100+ChkDigit1*10+ChkDigit2;
        
		if (Tmp!=tckimlikno_str) {
			alert("Girmiş olduğunuz TC Kimlik Numarası Yanlıştır, lütfen tekrar giriniz.");
			return false;
		}
	}
	else{
		alert("Lütfen Türkiye Cumhuriyeti Kimlik Numaranızı giriniz.");
		return false;
	}
		
    return true;
}
