function input_validator_change(element, checked){
	if(checked == 'none')
	{
		document.getElementById(element).style.backgroundImage = 'url(/images/empty.png)';
	}
	else {
		if(checked){
			document.getElementById(element).style.backgroundImage = 'url(/images/accept.png)';
		}
		else{
			document.getElementById(element).style.backgroundImage = 'url(/images/cancel.png)';
		}
	}
}

// Nederland
function NLVATCheckDigit (vatnumber) {
	
	var str = "B";
	
	if(vatnumber.charAt(9) != str.toUpperCase()){
		return false;
	}
	
	var total = 0; 
	total = total + (9 * vatnumber.charAt(0));
	total = total + (8 * vatnumber.charAt(1));
	total = total + (7 * vatnumber.charAt(2));
	total = total + (6 * vatnumber.charAt(3));
	total = total + (5 * vatnumber.charAt(4));
	total = total + (4 * vatnumber.charAt(5));
	total = total + (3 * vatnumber.charAt(6));
	total = total + (2 * vatnumber.charAt(7));
	total = total % 11;
	
	return total == vatnumber.charAt(8);
}

// België
function BEVATCheckDigit (vatnumber) {
	if(vatnumber.length != 9){
		return false;
	}
	
	if(vatnumber.charAt(0) == 0 || vatnumber.charAt(0) == 1 || vatnumber.charAt(0) == 8){
		return false;
	}
	
	var temp = vatnumber.substring(0, 8);
	temp = 97 - (temp % 97);
	var ctemp = vatnumber.substring(7, 10);
	
	return temp == ctemp;
}

// Duitsland
function DEVATCheckDigit (vatnumber) {
  
	var product = 10;
	var sum = 0;     
	var checkdigit = 0; 
	
	for (var i = 0; i < 8; i++) {
		sum = (Number(vatnumber.charAt(i)) + product) % 10;
		if (sum === 0) {
			sum = 10;
		}
		product = (2 * sum) % 11;
	}
  
	if (11 - product == 10) {
		checkdigit = 0;
	} 
	else {
		checkdigit = 11 - product;
	}
  
	return checkdigit == vatnumber.slice (8,9);
}

function LUVATCheckDigit (vatnumber) {
	return vatnumber.slice (0,6) % 89 == vatnumber.slice (6,8);
}

function trim_field(element){
	element.value = (element.value).replace(/^\s*|\s*$/g, '');
}

function checkBTW(vatnumber){
	var check = false;
	vatnumber = vatnumber.replace(/^\s+|\s+$/g,"");
	
	if(vatnumber.length < 1){
		return false;
	}
	
	if(NLVATCheckDigit (vatnumber)){
		check = true;
	}
	if(BEVATCheckDigit (vatnumber)){
		check = true;
	}
	if(DEVATCheckDigit (vatnumber)){
		//check = true;
	}
	if(LUVATCheckDigit (vatnumber)){
		//check = true;
	}
	
	return check;
}

function check_mailform_subject(mailform_subject){
	return mailform_subject.length > 0;
}

function check_group_name(group_name){
	return group_name.length > 0;
}

function check_group_description(group_description){
	return group_description.length > 0;
}

function check_sector_description(sector_description){
	return sector_description.length > 0;
}

function check_bug_description(bug_description){
	return bug_description.length > 0;
}

function check_bug_page(bug_page){
	return bug_page.length > 0;
}

function check_user_credits(user_credits){
	return user_credits.length > 0;
}

function check_companies_name(companies_name){
	return companies_name.length > 0;
}

function check_companies_kvk(companies_kvk){
	return companies_kvk.length == 8 && !isNaN(companies_kvk);
}

function check_logininfo_loginname(logininfo_loginname){
	return logininfo_loginname.length > 3;
}

function check_logininfo_email(logininfo_email){
	var filter = /^[\.\_\-A-Za-z0-9]+[@][A-Za-z0-9]+\.[\.A-Za-z]{2,4}/;
	return filter.test(logininfo_email);
}

function check_customer_zipcode(customer_zipcode){
	if(customer_zipcode.length != 6){
		return false;
	}
	var filter = /^\d{4}[\s-]?[a-zA-Z]{2}$/;
	return filter.test(customer_zipcode);
}

function check_customer_zipcode_not_required(customer_zipcode){
	if(customer_zipcode.length > 0){
		var filter = /^\d{4}[\s-]?[a-zA-Z]{2}$/;
		return filter.test(customer_zipcode);
	}
	return 'none';
}

function check_logininfo_password(logininfo_password){
	return logininfo_password.length > 5 && logininfo_password.length <= 10;
}

function check_customer_lastname(customer_lastname){
	return customer_lastname.length > 0;
}

function check_customer_surname(customer_surname){
	return customer_surname.length > 0;
}

function check_customer_address(customer_address){
	return customer_address.length > 0;
}

function check_customer_city(customer_city){
	return customer_city.length > 0;
}

function check_customer_phone(customer_phone){
	var filter = /^(^\+[0-9])|([0-9])+$/;
	return filter.test(customer_phone);
}

function check_support_phone(support_phone){
	var filter = /^(^\+[0-9])|([0-9])+$/;
	return filter.test(support_phone);
}

function check_customer_mobile_phone(customer_mobile_phone){
	if(customer_mobile_phone.match(/^(\+316|00316|06)[0-9]{8}$/)){
		return true;
	}
	else if(customer_mobile_phone.match(/^(\+324|00324|04)[0-9]{8}$/)){
		return true;
	}
	else if(customer_mobile_phone.match(/^(\+491|00491|01)[0-9]{9}$/)){
		return true;
	}
	else if(customer_mobile_phone.match(/^(\+234|00234|0234)[0-9]{10}$/)){
		return true;
	}
	else{
		return false;
	}
}

function check_customer_sendsms_mobile_phone(customer_sendsms_mobile_phone){	
	if(customer_sendsms_mobile_phone.length > 0){	
		if(customer_sendsms_mobile_phone.match(/^(\+316|00316|06)[0-9]{8}$/)){
			return true;
		}
		else if(customer_sendsms_mobile_phone.match(/^(\+324|00324|04)[0-9]{8}$/)){
			return true;
		}
		else if(customer_sendsms_mobile_phone.match(/^(\+491|00491|01)[0-9]{9}$/)){
			return true;
		}
		else if(customer_sendsms_mobile_phone.match(/^(\+234|00234|0234)[0-9]{10}$/)){
			return true;
		}
		else{
			return false;
		}
	}
	return 'none';
}

function check_bill_num_of_sms(bill_num_of_sms, min_credits, max_credits){
	return bill_num_of_sms >= min_credits && bill_num_of_sms <= max_credits;
}

function check_sms_originator(message_originator){
	if(message_originator.length <= 0){ 
		return false;
	}
	if(!isNaN(message_originator)){
		return message_originator.length <= 16;
	}
	else {
		return message_originator.length <= 11;
	}
}

function check_email_originator(message_originator){
	return message_originator.length <= 50 && message_originator.length > 0;
}

function check_email_subject(email_subject){
	return email_subject.length <= 50 && email_subject.length > 0;
}

function check_email_message(message_message){
	return message_message.length > 0;
}

function check_sms_originator_setting(message_originator){
	if(!isNaN(message_originator)){
		return message_originator.length <= 16;
	}
	else {
		return message_originator.length <= 11;
	}
}

function check_setting_warning(setting_warning){
	return setting_warning.length > 0 && !isNaN(setting_warning);
}

function check_setting_alert(setting_alert){
	return setting_alert.length > 0 && !isNaN(setting_alert);
}

function check_infosms_campaign_name(infosms_campaign_name){
	return infosms_campaign_name.length > 0;
}

function check_template_name(template_name){
	return template_name.length > 0;
}

function check_template_message(template_message){
	return template_message.length > 0;
}

function check_max_messages_on_page(max_messages_on_page){
	return max_messages_on_page.length > 0;
}

function check_pro_own_keyword_price(pro_own_keyword_price){
	return pro_own_keyword_price.length > 0;
}

function check_lite_messages_older_than(lite_messages_older_than){
	return lite_messages_older_than.length > 0;
}

function check_pro_messages_older_than(pro_messages_older_than){
	return pro_messages_older_than.length > 0;
}

function check_admin_messages_older_than(admin_messages_older_than){
	return admin_messages_older_than.length > 0;
}

function check_pro_sub_keyword_price(pro_sub_keyword_price){
	return pro_sub_keyword_price.length > 0;
}

function check_lite_own_keyword_price(lite_own_keyword_price){
	return lite_own_keyword_price.length > 0;
}

function check_lite_sub_keyword_price(lite_sub_keyword_price){
	return lite_sub_keyword_price.length > 0;
}

function check_sms_username(sms_username){
	return sms_username.length > 0;
}

function check_sms_password(sms_password){
	return sms_password.length > 0;
}

function check_price_per_month_pro(price_per_month_pro){
	return price_per_month_pro.length > 0;
}

function check_max_recipients(max_recipients){
	return max_recipients.length >= 0;
}

function check_max_messages(max_messages){
	return max_messages.length >= 0;
}

function check_max_groups(max_groups){
	return max_groups.length >= 0;
}

function check_max_templates(max_templates){
	return max_templates.length >= 0;
}

function check_sitename(sitename){
	return sitename.length > 0;
}

function check_month_to_plan_lite(month_to_plan_lite){
	return month_to_plan_lite.length >= 0;
}

function check_month_to_downgrade(month_to_downgrade){
	return month_to_downgrade.length >= 0;
}


function check_min_month_pro_keyword(min_month_pro_keyword){
	return min_month_pro_keyword.length > 0;
}

function check_min_month_lite_keyword(min_month_lite_keyword){
	return min_month_lite_keyword.length > 0;
}

function check_min_month_level(min_month_level){
	return min_month_level.length > 0;
}



function check_delete_users_after(delete_users_after){
	return delete_users_after.length > 0;
}

function check_mail_users_expired(mail_users_expired){
	return mail_users_expired.length > 0;
}
