/* document.getElementById("first_name").maxLength = 130;
document.getElementById("last_name").maxLength = 130;
document.getElementById("email_address").maxLength = 64;
document.getElementById("email_address_verify").maxLength = 64;
document.getElementById("address1").maxLength = 600;
document.getElementById("address2").maxLength = 600;
if(typeof(eval(document.getElementById("city")))!= "undefined"){
	document.getElementById("city").maxLength = 80;
}
document.getElementById("country").maxLength = 40;
document.getElementById("postal_code").maxLength = 20;
document.getElementById("phone2").maxLength = 30;
*/
var title = document.signup.title;
var first_name = document.signup.first_name;
var last_name = document.signup.last_name;
var email_address = document.signup.email_address;
var email_address_verify = document.signup.email_address_verify;
var address1 = document.signup.address1;
var address2 = document.signup.address2;
var city = document.signup.city;
var country = document.signup.country;
var postal_code = document.signup.postal_code;
var phone2 = document.signup.phone2;
var checkId;

function display(obj,maxlength){
	var txt = obj.value;
	
	
	s = txt;
	if(s.length == 0) obj.maxLength = 1000;
	var totalLength = 0;
	var i;
	var charCode;
	for (i = 0; i < s.length; i++) {
	charCode = s.charCodeAt(i);
	if (charCode < 0x007f) {
	totalLength = totalLength + 1;
	
	} else if ((0x0080 <= charCode) && (charCode <= 0x07ff)) {
	totalLength += 2;
	
	} else if ((0x0800 <= charCode) && (charCode <= 0xffff)) {
	totalLength += 3;

	}
	
	if(totalLength > maxlength){
		obj.maxLength = i;
		obj.value = obj.value.substring(0,i);
		obj.focus();
		return;
	}
	}
}

if(typeof(eval(document.signup.title))!= "undefined"){

title.onchange = function(){
	display(title,30);
	clearInterval(checkId);
}
title.onfocus = function(){ 
	checkId = setInterval(function(){display(title,30);},200);	
}

}

if(typeof(eval(document.signup.first_name))!= "undefined"){

first_name.onchange = function(){
	display(first_name,130);
	clearInterval(checkId);
}
first_name.onfocus = function(){ 
	checkId = setInterval(function(){display(first_name,130);},200);	
}

}

if(typeof(eval(document.signup.last_name))!= "undefined"){
last_name.onchange = function(){
	display(last_name,130);
	clearInterval(checkId);
}
last_name.onfocus = function(){ 
	checkId = setInterval(function(){display(last_name,130);},200);	
}

}

if(typeof(eval(document.signup.email_address))!= "undefined"){
email_address.onchange = function(){
	display(email_address,64);
	clearInterval(checkId);
}
email_address.onfocus = function(){ 
	checkId = setInterval(function(){display(email_address,64);},200);	
}
}



if(typeof(eval(document.signup.email_address_verify))!= "undefined"){
email_address_verify.onchange = function(){
	display(email_address_verify,64);
	clearInterval(checkId);
}
email_address_verify.onfocus = function(){ 
	checkId = setInterval(function(){display(email_address_verify,64);},200);	
}

}


if(typeof(eval(document.signup.address1))!= "undefined"){

address1.onchange = function(){
	display(address1,600);
	clearInterval(checkId);
}
address1.onfocus = function(){ 
	checkId = setInterval(function(){display(address1,600);},200);	
}

}
if(typeof(eval(document.signup.address2))!= "undefined"){

address2.onchange = function(){
	display(address2,600);
	clearInterval(checkId);
}
address2.onfocus = function(){ 
	checkId = setInterval(function(){display(address2,600);},200);	
}

}
if(typeof(eval(document.signup.city))!= "undefined"){
city.onchange = function(){
	display(city,80);
	clearInterval(checkId);
}
city.onfocus = function(){ 
	checkId = setInterval(function(){display(city,80);},200);	
}
}
if(typeof(eval(document.signup.country))!= "undefined"){

country.onchange = function(){
	display(country,40);
	clearInterval(checkId);
}
country.onfocus = function(){ 
	checkId = setInterval(function(){display(country,40);},200);	
}
}
if(typeof(eval(document.signup.postal_code))!= "undefined"){

postal_code.onchange = function(){
	display(postal_code,20);
	clearInterval(checkId);
}
postal_code.onfocus = function(){ 
	checkId = setInterval(function(){display(postal_code,20);},200);	
}

}
if(typeof(eval(document.signup.phone2))!= "undefined"){

phone2.onchange = function(){
	display(phone2,30);
	clearInterval(checkId);
}
phone2.onfocus = function(){ 
	checkId = setInterval(function(){display(phone2,30);},200);	
}
}

