	var STYLE_STATIC = 1;
	var STYLE_EDITABLE = 2;
	var STYLE_MULTI_LINE_EDITABLE = 3;
	var STYLE_PASSWORD = 4;    
	var STYLE_SINGLE_CHOICE_LIST = 11;
	var STYLE_MULTI_CHOICE_LIST = 12;
	var STYLE_DROPDOWN_LIST = 13;
	var STYLE_EDITABLE_DROPDOWN = 14;
	var STYLE_RADIO_CHOICE = 15;
	var STYLE_BUTTON_CHOICE = 16;

	var isFormError = false;
	var isGoodUsername = false;
	var isGoodNickname = false;
	var profileList = new Array();
	var isFirstError = true;
	
	function Profile(){
		this.properties = new Array();
		this.name;
	}
	
	function Property(){
		this.type = 0;
		this.name = '';
		this.uuid = '';
		this.mandatory = false;
		this.hasNormalAnswer = true;
	}
	
	function errorOn(obj){
		//error.style.display='block';
		//error.style.backgroundColor = 'red';		

		if(obj.length){
			for(var i=0; i < obj.length; i++){				
				obj[i].className = 'signuperroron';
			}
		}else{
			obj.className = 'signuperroron';
		}		
		if(isFirstError){
			isFirstError = false;
			obj.focus();
		}
		isFormError = true;
	}
	
	function errorOff(obj){
		//error.style.display='signuperroroff';
		//error.style.backgroundColor = 'white';
	
		if(obj.length){
			for(var i=0; i < obj.length; i++){
				//obj[i].style.backgroundColor = errorOffColor;
				obj[i].className = 'signuperroroff';
			}
		}else{
			obj.style.backgroundColor = errorOffColor;
			obj.className = 'signuperroroff';
		}				
	}
	
	function errorOn(obj, name){

		//var row = eval('row_'+name);
		var row = document.getElementById('row_'+name);
		if(row){
			row.className = 'signuperroron';
		}
		if(isFirstError){
			isFirstError = false;
			obj.focus();
		}
		isFormError = true;
	}
	
	function errorOff(obj, name){
		var row = document.getElementById('row_'+name);
		if(row){
			row.className = 'signuperroroff';
		}
	}
	
	function funVerifyAccountInfo(obj){	

		switch(obj.name){			
			case 'accountForm.category1Id':
				if(obj.options && obj.selectedIndex == 0 && document.frmSignup['accountForm.category1Name'].value.length == 0){
					errorOn(obj, obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj, obj.name.replace('accountForm.',''));
				}
				break;			
			case 'accountForm.username':
				if(!checkEmail(obj.value)){
					errorOn(obj, obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj, obj.name.replace('accountForm.',''));
				}
				break;
			case 'accountForm.password':
				if(obj.value.length < 4){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else if(document.frmSignup['accountForm.rePassword'].value.length > 3 && obj.value != document.frmSignup['accountForm.rePassword'].value){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;
			case 'accountForm.rePassword':
				if(obj.value.length < 4){
					errorOn(obj,'password');
				}else if(document.frmSignup['accountForm.password'].value.length > 3 && obj.value != document.frmSignup['accountForm.password'].value){
					errorOn(obj,'password');
				}else{
					errorOff(obj,'password');
				}
				break;
			case 'accountForm.nickname':
				if(obj.value.length == 0){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;
			case 'accountForm.mediaId':
				if(obj.selectedIndex == 0){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;			
			case 'accountForm.firstName':			
				if(obj.value.length < 2){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;
			case 'accountForm.lastName':
				if(obj.value.length < 2){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;
			case 'accountForm.city':
				if(obj.value.length == 0){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;
			case 'accountForm.stateId':			
				if(obj.selectedIndex == 0 && (document.frmSignup['accountForm.countryId'].selectedIndex <= 6)){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{								
					errorOff(obj,obj.name.replace('accountForm.',''));					
				}
				break;
			case 'accountForm.countryId':				
				var stateObj = document.frmSignup['accountForm.stateId'];
				var stateId = stateObj.options[stateObj.selectedIndex].value;
				var countryId = obj.options[obj.selectedIndex].value;
				
				if(obj.selectedIndex == 0){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else if(obj.selectedIndex <= 6){
					if(stateId == 0){
		            	errorOn(obj,obj.name.replace('accountForm.',''));
		            }
		            else{
						errorOff(obj,obj.name.replace('accountForm.',''));
					}
				}else if(stateObj.selectedIndex > 0 && (obj.selectedIndex > 6)){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;
			case 'accountForm.zipcode':
				var countryObj = document.frmSignup['accountForm.countryId'];
				var countryId = countryObj.options[countryObj.selectedIndex].value;
				
				if(obj.value.length == 0 && (countryId == 1220 || countryId == 9000)){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;
			/*case 'accountForm.gender':
				if(obj.checked == false){
					errorOn(obj,obj.name.replace('accountForm.',''));
				}else{
					errorOff(obj,obj.name.replace('accountForm.',''));
				}
				break;*/
			case 'accountForm.birthMonth':
				if(obj.selectedIndex == 0){
					errorOn(obj,'dob');
				}else{
					errorOff(obj,'dob');
				}
				break;
			case 'accountForm.birthDay':
				if(obj.selectedIndex == 0){
					errorOn(obj,'dob');
				}else{
					errorOff(obj,'dob');
				}
				break;
			case 'accountForm.birthYear':
				if(obj.selectedIndex == 0){
					errorOn(obj,'dob');
				}else{
					errorOff(obj,'dob');
				}
				break;
		}		
	}
	
	function funVerifyProfile(obj){
		var field = eval('document.frmSignup.field_'+obj.uuid);
		var rowName = 'field_'+obj.uuid;

		if(!field) return false;
		
		if(obj.type == STYLE_EDITABLE){
			if(field.value.length == 0){
				errorOn(field, rowName);
			}else{				
				errorOff(field, rowName);
			}
		}else if(obj.type == STYLE_MULTI_LINE_EDITABLE){
			if(field.value.length == 0){
				errorOn(field, rowName);
			}else{				
				errorOff(field, rowName);
			}
		}else if(obj.type == STYLE_PASSWORD){
			if(field.value.length == 0){
				errorOn(field, rowName);
			}else{				
				errorOff(field, rowName);
			}
		}else if(obj.type == STYLE_SINGLE_CHOICE_LIST){
			if(!obj.hasNormalAnswer){
				if(field[field.length-1].selectedIndex < 1){
					errorOn(field[field.length-1], rowName);
				}else{
					errorOff(field[field.length-1], rowName);
				}
			}else{		
				if(field.selectedIndex < 1){
					errorOn(field, rowName);
				}else{
					errorOff(field, rowName);
				}
			}
		}else if(obj.type == STYLE_MULTI_CHOICE_LIST){
			if(!obj.hasNormalAnswer){
				if(field[field.length-1].selectedIndex < 1){
					errorOn(field[field.length-1], rowName);
				}else{
					errorOff(field[field.length-1], rowName);
				}
			}else{
				if(field.selectedIndex < 1){
					errorOn(field, rowName);
				}else{
					errorOff(field, rowName);
				}
			}
		}else if(obj.type == STYLE_DROPDOWN_LIST){		
			if(!obj.hasNormalAnswer){
				if(field[field.length-1].selectedIndex < 1){
					errorOn(field[field.length-1], rowName);
				}else{
					errorOff(field[field.length-1], rowName);
				}
			}else{
				if(field.selectedIndex < 1){
					errorOn(field, rowName);
				}else{
					errorOff(field, rowName);
				}
			}
		}else if(obj.type == STYLE_EDITABLE_DROPDOWN){
			if(!obj.hasNormalAnswer){
				if(field[field.length-1].selectedIndex < 1){
					errorOn(field[field.length-1], rowName);
				}else{
					errorOff(field[field.length-1], rowName);
				}
			}else{
				if(field.selectedIndex < 1){
					errorOn(field, rowName);
				}else{
					errorOff(field, rowName);
				}
			}
		}else if(obj.type == STYLE_RADIO_CHOICE){
			var isOk = false;
			
			if(field.length){
				for(var i=0; i < field.length; i++){
					if(field[i].checked == true){
						isOk = true;
						break;
					}
				}
				
				if(!isOk){
					errorOn(field, rowName);
				}else{
					errorOff(field, rowName);
				}
			}else{
				if(!field.checked){
					errorOn(field, rowName);
				}else{
					errorOff(field, rowName);
				}
			}
		}else if(obj.type == STYLE_BUTTON_CHOICE){
			var isOk = false;
			
			if(field.length){			
				for(var i=0; i < field.length; i++){				
					if(field[i].checked == true){
						isOk = true;
						break;
					}
				}
				
				if(!isOk){
					errorOn(field, rowName);
				}else{				
					errorOff(field, rowName);					
				}				
			}else{
				if(!field.checked){
					errorOn(field, rowName);
				}else{
					errorOff(field, rowName);
				}
			}
		}
	}
	
	function funHideCommunity(index, className){	
		//var thisCommunityTitle = eval('CommunityTitle'+index);
		var thisCommunityTitle = document.getElementById('CommunityTitle'+index);
		if(thisCommunityTitle){
			thisCommunityTitle.className = className;
			//thisCommunityTitle.style.fontWeight = 'normal';
		}
		
		thisCommunityBody = document.getElementById('CommunityBody'+index);
		if(thisCommunityBody){		
			thisCommunityBody.style.display='none';
		}
		
	}
	
	function funShowCommunity(index, className){
		var thisCommunityTitle = document.getElementById('CommunityTitle'+index);
		
		if(thisCommunityTitle){
			thisCommunityTitle.className = className;
			//thisCommunityTitle.style.fontWeight = 'bold';
		}
		
		var thisCommunityBody = document.getElementById('CommunityBody'+index);
		if(thisCommunityBody){
			thisCommunityBody.style.display='block';
		}
	}
	
	function funHideProfile(comIndex, proIndex, className){
		var thisProfileTitle = document.getElementById('ProfileTitle_'+comIndex+'_'+proIndex);
		if(thisProfileTitle){
			thisProfileTitle.className = className;
			//thisProfileTitle.style.fontWeight = 'normal';
		}
		
		var thisProfileBody = document.getElementById('ProfileBody_'+comIndex+'_'+proIndex);
		if(thisProfileBody){
			thisProfileBody.style.display='none';
		}
	}
	
	function funShowProfile(comIndex, proIndex, className){
		var thisProfileTitle = document.getElementById('ProfileTitle_'+comIndex+'_'+proIndex);
		
		if(thisProfileTitle){
			thisProfileTitle.className = className;
			//thisProfileTitle.style.fontWeight = 'bold';
		}
		
		var thisProfileBody = document.getElementById('ProfileBody_'+comIndex+'_'+proIndex);
		if(thisProfileBody){
			thisProfileBody.style.display='block';
		}
	}
		
	/*function funHideRide(comIndex, proIndex, className, className2){
		var thisRideTitle = document.getElementById('RideTitle_'+comIndex+'_'+proIndex);
		var thisRideFont = document.getElementById('RideFont_'+comIndex+'_'+proIndex);
		
		if(thisRideTitle) thisRideTitle.className = className2;
		if(thisRideFont) thisRideFont.className = className;
		
		var thisProfileBody = document.getElementById('ProfileBody_'+comIndex+'_'+proIndex);
		if(thisProfileBody){
			thisProfileBody.style.display='none';
		}
	}
	
	function funShowRide(comIndex, proIndex, className, className2){
		var thisRideTitle = document.getElementById('RideTitle_'+comIndex+'_'+proIndex);
		var thisRideFont = document.getElementById('RideFont_'+comIndex+'_'+proIndex);
		
		if(thisRideTitle) thisRideTitle.className = className2;
		if(thisRideFont) thisRideFont.className = className;
		
		var thisProfileBody = document.getElementById('ProfileBody_'+comIndex+'_'+proIndex);
		if(thisProfileBody){
			thisProfileBody.style.display='block';
		}
	}*/
	
	function funCreateProfile(index, inName){
		profileList[index] = new Profile();	
		profileList[index].name = inName
	}
	
	function funCreateProperty(profileIdex, index, uuid, type, mandatory, hasNormalAnswer){
		profileList[profileIdex].properties[index] = new Property();		
		profileList[profileIdex].properties[index].uuid = uuid;
		profileList[profileIdex].properties[index].type = type;
		profileList[profileIdex].properties[index].mandatory = mandatory;
		profileList[profileIdex].properties[index].hasNormalAnswer = hasNormalAnswer;
	}
	
