// *****************************************************************************************************************************************
// ******************************************************** FORMCHECK  FUNCTIONS ***********************************************************
// *****************************************************************************************************************************************
function chkBlank(obj,message) {
	if (isBlank(obj)) {		
		alert(message);
		obj.focus();
		obj.select();
		return false;
	}
	else {
		return true;
	}
}
// -----------------------------------------------------------------------------------
function chkBlank2(obj) {
	if (obj.value=="")
		return false;
	else
		return true;
}
// -----------------------------------------------------------------------------------
// checks for the same value of 2 objects
// obj1,obj2: the input objects to check
// message: message to be displayed in case of failure
function chkSameValue(obj1,obj2,message) {
	obj1Value=obj1.value;	
	obj1Value=obj1Value.replace(/ /g,"");
	obj2Value=obj2.value;	
	obj2Value=obj2Value.replace(/ /g,"");

	if (obj1Value!=obj2Value) {
		alert(message);
		obj2.focus();
		obj2.select();
		return false;
	}
	else
		return true;
}
// -----------------------------------------------------------------------------------
// checks for a valid e-mail
// obj: the input object to check
// message: message to be displayed in case of failure
function chkEmail(obj,message) {
	objValue=obj.value;
	var chkemail= /^.+\@.+\..+$/;
	var emailchk=objValue.match(chkemail);
	if (emailchk==null) {
		alert(message);
		obj.focus();
		obj.select();
		return false;
	}
	else {
		var checkOK = "ÇĞİÖŞÜçğıöşü ";
		var myStr = obj.value;
	
		var allValid = true;
		for (i = 0;  i < myStr.length;  i++) {
			ch = myStr.charAt(i);
		
			for (j = 0;  j < checkOK.length;  j++) {
				if (ch == checkOK.charAt(j)) {
					allValid = false;
				}
			}
		}
		
		if (!allValid) {
			alert("Lütfen e-posta adresinizde Türkçe karakter kullanmayınız ve boşluk bırakmayınız!");
			obj.focus();
			obj.select();
			return false;
		}
		else {
			if (myStr.charAt(myStr.length-1)=="." || myStr.charAt(myStr.length-1)==",") {
				alert(message);
				obj.focus();
				obj.select();
				return false;
			}
			else
				return true;
		}
	}
}
// -----------------------------------------------------------------------------------
// checks an object's value for blank and whitespace
// obj: input object for checking
function isBlank(obj) {
	objValue=obj.value;
	objValue=objValue.replace(/ /g,"")

	return (objValue=="") ? true : false;
}
// -----------------------------------------------------------------------------------
function chkDate(obj,message) {
	return true;
}
// -----------------------------------------------------------------------------------
function chkSomeValue(obj,theValue,message) {
	objValue=obj.value;

	if (objValue==theValue) {
		alert(message);
		obj.focus();
		return false;
	}
	else
		return true;
}
// -----------------------------------------------------------------------------------
// belirtilen degerden buyuk/kucuk/esit degilse uyar
function chkSomeValue2(obj,theValue,message,tip) {
	objValue=obj.value;
	switch (tip) {
		case "e" :
			if (objValue!=theValue) {
				alert(message);
				obj.focus();
				obj.select();
				return false;
			}
			else
				return true;
			break;
		case "b" :
			if (objValue>theValue) {
				alert(message);
				obj.focus();
				obj.select();
				return false;
			}
			else
				return true;
			break;
		case "be" :
			if (objValue>=theValue) {
				alert(message);
				obj.focus();
				obj.select();
				return false;
			}
			else
				return true;
			break;
		case "k" :
			if (objValue<theValue) {
				alert(message);
				obj.focus();
				obj.select();
				return false;
			}
			else
				return true;
			break;
		case "ke" :
			if (objValue<=theValue) {
				alert(message);
				obj.focus();
				obj.select();
				return false;
			}
			else
				return true;
			break;
	}
}
// -----------------------------------------------------------------------------------
function chkNumeric(objName,message) {
	var checkOK = "0123456789";
	var checkStr = objName;
	var allValid = true;

	for (i = 0;  i < checkStr.value.length;  i++) {
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++) {
			if (ch == checkOK.charAt(j))
				break;
		}
		if (j == checkOK.length) {
			allValid = false;
			break;
		}				
	}
	if (!allValid) {
		alert(message);
		objName.select();
		objName.focus();
		return false;
	}
	else {
		return true;
	}
}
// -----------------------------------------------------------------------------------
function chkNumeric0(objName,message) {
	var checkOK = "0123456789";
	var checkStr = objName;
	var allValid = true;

	for (i = 0;  i < checkStr.value.length;  i++) {
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++) {
			if (ch == checkOK.charAt(j))
				break;
		}
		if (j == checkOK.length) {
			allValid = false;
			break;
		}				
	}
	if (!allValid) {
		alert(message);
		objName.select();
		objName.focus();
		return false;
	}
	else {
		if (checkStr.value<=0) {
			alert(message);
			objName.select();
			objName.focus();
			return false;
		}
		else
			return true;
	}
}
// -----------------------------------------------------------------------------------
function checkNumeric(objName) {
	if (chkNumeric(objName) == false) {
		objName.select();
		objName.focus();
		return false;
	}
	else {
		return true;
	}
}
// -----------------------------------------------------------------------------------
function checkLength(obj,length,message) {
	if (obj.value.length<length) {
		alert(message);
		obj.select();
		obj.focus();
		return false;
	}
	else
		return true;
}
// -----------------------------------------------------------------------------------
function checkLength2(obj,length,message) {
	if (obj.value.length!=length) {
		alert(message);
		obj.select();
		obj.focus();
		return false;
	}
	else
		return true;
}
// -----------------------------------------------------------------------------------