function setFocus(Ctrl) {
	Ctrl.focus();
	return false;
}
//trims leading and trailing spaces
function trimSpaces(temp)
{
  //trailing
  while(''+temp.value.charAt(temp.value.length-1)==' ')
  temp.value=temp.value.substring(0,temp.value.length-1);
 
  //leading
  while(''+temp.value.charAt(0)==' ')
   temp.value=temp.value.substring(1,temp.value.length);
}


//trims all spaces PARAMETER IS OBJ
function trimAllSpaces(temp)
{

	tempstring = temp.value;   
	tempstr = "";
	for (var i = 0; i < tempstring.length; i++){      
		var ch = tempstring.substring(i, i + 1);      
		if (ch == ' '){         
		}
        else
        {
        tempstr = tempstr + ch; 
          }
                
	}   

     temp.value = tempstr;

}

// textbox'a girilen TÜRKÇE karakteri kabul etmiyor 
function noTurkishCharacters(temp){   

	 tempstring = temp.value;
         ch = tempstring.substring(tempstring.length -1 ,tempstring.length);
        
         if (ch == 'Ý' || ch == 'Þ' || ch == 'þ' || ch == 'Ð' || ch == 'ð' 
            || ch == 'Ç' || ch == 'ç' || ch == 'Ü' || ch == 'ü' || ch == 'Ö' || ch == 'ö')
            temp.value = tempstring.substring(0 ,tempstring.length-1);

}


// türkçe karakterleri eng yapýyo. 
function convertToEnglish(tStr){   

	tempstring = tStr;   
	tempstr = "";
    tempch = '';
	for (var i = 0; i < tempstring.length; i++){      
	
		var ch = tempstring.substring(i, i + 1);      
        tempch = ch; 
		if (ch == 'Ý') {tempch = 'i';}
		if (ch == 'I') {tempch = 'i';}
        if (ch == 'ý') {tempch = 'i';}
        if (ch == 'Þ') {tempch = 's';}
        if (ch == 'þ') {tempch = 's';}
        if (ch == 'Ð') {tempch = 'g';}
        if (ch == 'ð') {tempch = 'g';}
        if (ch == 'Ç') {tempch = 'c';}
        if (ch == 'ç') {tempch = 'c';}
        if (ch == 'Ü') {tempch = 'u';}
        if (ch == 'ü') {tempch = 'u';}
        if (ch == 'Ö') {tempch = 'o';}
        if (ch == 'ö') {tempch = 'o';}

      	tempstr = tempstr + tempch; 
      
     }
    

    return tempstr;

}

// türkçe karakterleri eng yapýyo. 
function convertToStickerPrint(tStr){   

	tempstring = tStr;   
	tempstr = "";
    tempch = '';
	for (var i = 0; i < tempstring.length; i++){      
	
		var ch = tempstring.substring(i, i + 1);      
        tempch = ch; 
        if (ch == 'Ç') {tempch = '€';}
        if (ch == 'Ý') {tempch = '˜';}
        if (ch == 'Ð') {tempch = '¦';}
        if (ch == 'Ö') {tempch = '™';}
	    if (ch == 'Þ') {tempch = 'ž';}
        if (ch == 'Ü') {tempch = 'š';}


      	tempstr = tempstr + tempch; 
      
     }

 	return tempstr;

}



//türkçe karakterleri cut ediyo...
function cutTurkishCharacters(temp)
{

	tempstring = temp.value;   
	tempstr = "";
	for (var i = 0; i < tempstring.length; i++){      
		var ch = tempstring.substring(i, i + 1);      
		if (ch != 'Ý' && ch != 'ý' && ch != 'Þ' && ch != 'þ' && ch != 'Ð' && ch != 'ð' 
            && ch != 'Ç' && ch != 'ç' && ch != 'Ü' && ch != 'ü' && ch != 'Ö' && ch != 'ö')         
	tempstr = tempstr + ch; 
          }
                
	

     temp.value = tempstr;
}



//EMail alanýný kontrol ediyor

function isEMail(temp)
{
   
        if(temp.value.length != 0){
        cutTurkishCharacters(temp);
        trimAllSpaces(temp);
	if (temp.value.indexOf ('@',0) == -1 || temp.value.indexOf ('.',0) == -1){      
		alert("E-MAIL must have  \"@\" and \".\" ")      
		temp.select();      
		temp.focus();      
	}   }
} 

// girilen string'in uzunluðunu kontrol ediyor!
 
function contWord(temp,strlen){   

	tempstring = temp.value;
        if(tempstring.length != strlen && tempstring.length != 0){
    	alert(strlen + " haneden az giriþ yapýlamaz.");
        temp.focus();
    }
}


// girilen string'in uzunluðu strlen'den fazla ise string'i cut ediyor.!
 
function cutWord(temp,strlen){   

	tempstring = temp.value;
    if(tempstring.length > strlen ){
        temp.value = tempstring.substr(0,strlen);
        alert("Girilen deðer " + strlen + " haneden fazla olduðu için \'" + temp.value + "\' olarak deðiþtirilmiþtir!");
    }
}



// girilen string'in uzunluðu strlen'den fazla ise string'i cut ediyor.!
 
function yildizNoktaSil(tempStr){   

   if(tempStr == '.' || tempStr == '*') 
     return ' ';
   else
     return tempStr;
	 
}



function replaceAll(text, strA, strB) { 
 
   return text.replace( new RegExp(strA,"g"), strB );

}




function checkNewMemberForm(form)
{
	if(form.user_name.value == "" ) 
	{
	  alert("Please enter your username!");
	  return false;
	}

	if(form.user_name.value.length < 4) 
	{
	  alert("Your username must be at least 4 characters!");
	  return false;
	}

	if(form.pass_word.value == "" ) 
	{
	  alert("Please enter your password!");
	  return false;
	}

	if(form.pass_word.value.length < 4) 
	{
	  alert("Your password must be at least 4 characters!");
	  return false;
	}
	
	if(form.pass_word.value != form.pass_word2.value ) 
	{
	  alert("Please enter the same password to 'Password Again' field!");
	  form.pass_word.value ="";
	  form.pass_word2.value = ""; 
	  return false;
	}
	
	if(form.email.value == "" ) 
	{
	  alert("Please enter your e-mail!");
	  return false;
	}

}

function autoFormatDate(obj){

	var len = obj.value.length;
	if(len==0){
		return;
	}
	if ((len < 8) || (len > 10) || (len == 9)){
		alert('wrong date format');
		obj.focus();
		return false;
	}
	if (len == 8){
		obj.value = obj.value.substring(0,2) + '/' + obj.value.substring(2,4) + '/' + obj.value.substring(4,8);

	}

	 
}
