function check(which) {
//colorize
var highlightcolor="#FFCCFF";
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if(tempobj.name.substring(0,8)=="required" || tempobj.name.substring(0,4)=="mail" || tempobj.type=="password"){
	if (((tempobj.type=="text"||tempobj.type=="textarea")&& tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&& tempobj.selectedIndex==0)) {
	tempobj.style.backgroundColor =highlightcolor; 
	}else if(( (tempobj.name.substring(0,4)=="mail") && tempobj.value!='') && ((tempobj.value.indexOf('.')<1) || (tempobj.value.indexOf('@')<1))){
    tempobj.style.backgroundColor =highlightcolor;
	}else if(tempobj.type=="password" && tempobj.value==''){
	tempobj.style.backgroundColor =highlightcolor;
	}else if(tempobj.type=="password" && tempobj.value!='' && (which.rePassword.value!=tempobj.value)){
	tempobj.style.backgroundColor =highlightcolor;		
	}else{
	tempobj.style.backgroundColor = '';
	}
	
}
	
	
}

//validation	
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];

if(tempobj.name.substring(0,8)=="required" || tempobj.name.substring(0,4)=="mail" || tempobj.type=="password"){
	if (((tempobj.type=="text"||tempobj.type=="textarea")&& tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&& tempobj.selectedIndex==0)) {
	alert('please complete all required fields');
	return false;
	}else if(( (tempobj.name.substring(0,4)=="mail") && tempobj.value!='') && ((tempobj.value.indexOf('.')<1) || (tempobj.value.indexOf('@')<1))){
	alert('Incorrect email address.');
	return false;
	}else if(tempobj.type=="password" && tempobj.value.length<5){
		alert('your passwored shuoled be at least 5 character long.');
		return false;
	}else if(tempobj.type=="password" && tempobj.value!='' && (which.rePassword.value!=tempobj.value)){
			alert('please retype Password.');
		return false;
	}
	
}
	
	
}

}
