function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}//end function removeSpaces()

/**
* email kontrol eder. doðru bir giriþse true, yanlýþsa false döner
*/

function isValidEmail(emailAdayi){
	
	var reg_email = /^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@.+\..+$/;
	
	if(emailAdayi.value == ''){
		return false;
	}
	
	if(!reg_email.test(emailAdayi)){
		return false;
	}
	
	if(emailAdayi.charAt(emailAdayi.length-1)=='.'){
		return false;
	}
	
	return true;
}//end function isValidEmail()


/**
form elemanlarýný disabled yapar
*/
function disableForm(form_id){
	var form = document.getElementById(form_id);
	var i=0;
	
	for(i = 0; i<form.length; i++){
		
		form[i].disabled = true;
	}
}//end function disableForm()

/**
form elemanlarýný enabled yapar
*/
function enableForm(form_id){
	var form = document.getElementById(form_id);
	var i=0;
	
	for(i = 0; i<form.length; i++){
		
		form[i].disabled = false;
	}
}//end function enableForm()

function resetForm(form_id){
	var form = document.getElementById(form_id);
	var len = form.length;
	var i=0;
	
	for(i=0; i<len; i++){
		if(form[i].type != 'submit'){
			form[i].value = '';
		}
	}
}



/**
*
* Javascript trim, ltrim, rtrim
* http://www.webtoolkit.info/
*
*
**/

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


function box_isEmpty(box_id,message){
	var box = document.getElementById(box_id);
	if(trim(box.value) == ''){
		alert(message);
		box.focus();
		return true;
	}
	
	return false;
}//end function box_isEmpty();

function box_isNumeric(box_id,message_ifempty,message_ifnotnumeric){
	var box = document.getElementById(box_id);
	
	if(box.value == ''){
		alert(message_ifempty);
		box.focus();
		return false;
	}
	
	if(box.value.replace(/0/g,'') != parseInt(box.value.replace(/0/g,''))){
		alert(message_ifnotnumeric);
		box.focus();
		return false;
	}
	
	return true;
}//end function box_isNumeric();

function box_isNumericIdentity(box_id,message, defaultLength, defaultLength_message){
	var box = document.getElementById(box_id);
	
	if(box.value.replace(/0/g,'') != parseInt(box.value.replace(/0/g,''))){
		alert(message);
		box.focus();
		return false;
	}
	
	if(defaultLength){
		if(trim(box.value).length != defaultLength){
			alert(defaultLength_message);
			box.focus();
			return false;
		}
	}
	
	return true;
}//end function box_isNumericIdentity()


function box_isValidPassword(passBox_id, passRepeatBox_id, message_1, message_2){
	var box1 = document.getElementById(passBox_id);
	
	if(trim(box1.value) == ''){
		alert(message_1);
		box1.focus();
		return false;
	}
	
	if(box1.value != document.getElementById(passRepeatBox_id).value){
		alert(message_2);
		document.getElementById(passRepeatBox_id).focus();
		return false;
	}
	
	return true;
}//end function box_isValidPassword()


function box_isEmail(box_id, message){
	var box = document.getElementById(box_id);
	
	if(!isValidEmail(box.value)){
		alert(message);
		box.focus();
		return false;
	}
	
	return true;
}//end function box_isEmail();


var charset = "ABCÇDEFGÐHIÝJKLMNOÖPQRSÞTUÜVWXYZabcçdefgðhiýjklmnoöpqrsþtuüvwxyz ,.";
var ad_charset = "ABCÇDEFGÐHIÝJKLMNOÖPQRSÞTUÜVWXYZabcçdefgðhiýjklmnoöpqrsþtuüvwxyz ";

var numcharset = "0123456789";
var tel_charset = "0123456789 ";

function kontrol(target) {
	oldvalue = target.value;
	StrLen = oldvalue.length;
	var tempy = '';
	
	for (a=0; a < StrLen; a++) {
	
	if (charset.indexOf(oldvalue.charAt(a)) != -1) tempy += oldvalue.charAt(a);
	}
	if (oldvalue != tempy) target.value = tempy;
}


function num_kontrol(target) {
	oldvalue = target.value;
	StrLen = oldvalue.length;
	var tempy = '';
	
	for (a=0; a < StrLen; a++) {
	if (numcharset.indexOf(oldvalue.charAt(a)) != -1) tempy += oldvalue.charAt(a);
	}
	if (oldvalue != tempy) target.value = tempy;
}

function tel_kontrol(target) {
	oldvalue = target.value;
	StrLen = oldvalue.length;
	var tempy = '';
	
	for (a=0; a < StrLen; a++) {
	if (tel_charset.indexOf(oldvalue.charAt(a)) != -1) tempy += oldvalue.charAt(a);
	}
	if (oldvalue != tempy) target.value = tempy;
}

function ad_kontrol(target){
	var oldvalue = target.value;
	var StrLen = oldvalue.length;
	var tempy = '';
	
	for (a=0; a < StrLen; a++) {
	
	if (ad_charset.indexOf(oldvalue.charAt(a)) != -1) tempy += oldvalue.charAt(a);
	}
	if (oldvalue != tempy) target.value = tempy;
}//end function ad_kontrol()