function isEmpty(s){
  return ((s == null)||(s.length == 0))
}

function rtrim(text){
  var lastChar=text.substring(text.length-1, text.length);
  while(lastChar==" "){
    text=text.substring(0, text.length-1);
    lastChar=text.substring(text.length-1, text.length);}
  return text;	
}

function checkString(f,fieldname,l){
  var value=f.value;
  if(value!=''){
  var result=!isEmpty(rtrim(value));
  if(!result)alert("Zorunlu giriş alanı : Lütfen "+fieldname+" giriniz.");
  if(result){
    result=(value.length>=l)
    if(!result)alert("Lütfen en az " + l + " karakter giriniz.");}
  if(!result)f.focus();
  return(result);
  }
}

function checkNumeric(f,fieldname,l){
var valuee=f.value;
if(valuee!=''){
  var result=checkString(f,fieldname,l);
  
  if(result){
    for(i=0;(i<l)&&result;i++){
      c=parseInt(f.value.substring(i,i+1),10);
      result=result&&(c==c);}
    if(!result)alert("Lütfen SAYISAL bir değer olarak giriniz.");}
    if(!result)f.focus();
  return(result);
}}


function checkEmail(f){
var x=f.value;
var result=(x.search(new RegExp("^\\S+@\\S+\\.\\S+$")));
if(result!=0){
if(x!=''){
    alert("Lütfen e-mail adresinizi  isim@alanadı.com  gibi bir formatta giriniz.");
    f.focus();
	}
    return false}
else
    return true;
}

function checkUrl(f){
var x=f.value;
var result=(x.search(new RegExp("^\\S+\\S+\\.\\S+$")));
if(result!=0){
if(x!=''){
    alert("Lütfen web adresinizi - alanadı.com - veya - www.alanadı.com - gibi bir formatta giriniz.");
    f.focus();
	}
    return false}
else
    return true;
}

function activate(field,getnum,bgcolor,color) {


if (getnum==1){
	if (bgcolor==null || bgcolor==""){
	  bgcolor= "f3f3f3"
	}
	if (color==null || color==""){
	  color= "000000"
	}
    field.style.backgroundColor = bgcolor
    field.style.color = color
}
else
{
	if (bgcolor==null || bgcolor==""){
	  bgcolor= "WhiteSmoke"
	}
	if (color==null || color==""){
	  color= "black"
	}    
    field.style.backgroundColor =bgcolor
    field.style.color =color
}
}
