function nameCFocus()
{
	document.userprofile.name.focus();
	
}

function nameCFocus1()
{
	document.userprofile.last_name.focus();
}

function call()
{
var dat=document.userprofile.year.value;
var check = dat.match("yyyy");
if(check!=null)
{
document.userprofile.year.value="";
document.userprofile.year.focus();
}
else
{
document.userprofile.year.focus();
}
}

function profile(form)
{
	
	var value=form.nickname.value
	var valid=/^[0-9a-zA-Z_]*$/;
	if(form.nickname.value=="")
	{
		form.nickname.style.background = "#FFCCCC";
		alert("Please enter the Nickname");
		form.nickname.focus();
		return false;
	}
	else if(value!="" && !valid.test(value))
     {
      			form.nickname.style.background = "#FFCCCC";
		       	alert("Nickname should contain only alphabets,digits and underscore without embedded spaces.\n");
				form.nickname.focus();
				return false;
     }
    else
    {
    	form.nickname.style.background = "#FFFFFF";
    }
	
	
	
	if(form.member_id.value == "")
	{
		form.member_id.style.background = "#FFCCCC";
		alert("Email is required to process request");
		form.member_id.focus();
		return false;
	}
	else if(!echeck(form.member_id.value))
	{
			form.member_id.style.background = "#FFCCCC";
			form.member_id.focus();
			return false;
	}
	else
	{
		form.member_id.style.background = "#FFFFFF";
	}
	
	if(form.remail.value == "")
	{
		form.remail.style.background = "#FFCCCC";
		alert("Please ReType Email");
		form.remail.focus();
		return false;
	}
	else if(!echeck(form.remail.value))
	{
			form.remail.style.background = "#FFCCCC";
			form.remail.focus();
			return false;
	}
	else
	{
		form.remail.style.background = "#FFFFFF";
	}
	
	if(form.member_id.value != form.remail.value)
	{
		form.member_id.style.background = "#FFCCCC";
		form.remail.style.background = "#FFCCCC";
		alert("Emails are not matching");
		form.member_id.focus();
		return false;
	}
	else
	{
		form.member_id.style.background = "#FFFFFF";
		form.remail.style.background = "#FFFFFF";
	}
	
	if(form.date.value==0)
    {
     form.date.style.background = "#FFCCCC";
     alert("Please select the date.");
     form.date.focus();
      return false;
    }
   
    if(form.month.value==0)
    {
     form.month.style.background = "#FFCCCC";
     alert("Please select the month.");
     form.month.focus();
      return false;
    }
    
    if(form.year.value=="yyyy" || form.year.value=="")
	{
		form.year.style.background = "#FFCCCC";
		alert("Please enter the year");
		form.year.focus();
		return false;
	}
	else
	{
		form.year.style.background = "#FFFFFF";
		
	}
	
	var rad = false;
	for(i=0;i<form.gender.length;i++)
	{
		if (form.gender[i].checked)
			rad = true; 
	}

	if (!rad)
	{
		alert("Please select a gender.")
		return (false);
	}
	
	var str = form.name.value;
	if(str == "")
	{
		form.name.style.background = "#FFCCCC";
		alert("FirstName Field is required to process the form");
		nameCFocus();
		return false;
	}
	else
	{
		//var str=document.comments.name.value;
		var first_char = str.charAt(0);
		var last_char = str.charAt(str.length-1);
	   if(!isContainsSpecialChars(str))
	   {
	   		form.name.style.background = "#FFCCCC";
		   	alert("FirstName should contains only characters,space and '.'");
		   	nameCFocus();
			return false;
	   } 
		/*if((str.charAt(str.length-1) == ".")||(str.charAt(0) == ".") ||(first_char==" ") || (last_char==" "))
		{
			form.name.style.background = "#FFCCCC";
			nameCFocus();
		   	alert("FirstName should not contain '.' or space at Start OR End");
		   	return false;
		}
		var dotindex = str.indexOf('.');
		if(dotindex != -1)
		{
			var substr = str.substr(dotindex+1);
			if(substr.indexOf('.') != -1)
			{
				form.name.style.background = "#FFCCCC";
				alert("FirstName Should not contain two or more dots");
				nameCFocus();
			    return false;
			}
		}*/
	}
	
	var str1 = form.last_name.value;
	if(str1 == "")
	{
		form.last_name.style.background = "#FFCCCC";
		alert("Last Name Field is required to process the form");
		nameCFocus1();
		return false;
	}
	else
	{
		//var str=document.comments.name.value;
		var first_char1 = str1.charAt(0);
		var last_char1 = str1.charAt(str1.length-1);
	   if(!isContainsSpecialChars(str1))
	   {
	   		form.last_name.style.background = "#FFCCCC";
		   	alert("Last Name should contains only characters,space and '.'");
		    nameCFocus1();
			return false;
	   } 
		/*if((str1.charAt(str1.length-1) == ".")||(str1.charAt(0) == ".") ||(first_char1==" ") || (last_char1==" "))
		{
			form.last_name.style.background = "#FFCCCC";
			nameCFocus1();
		   	alert("Last Name should not contain '.' or space at Start OR End");
		   	return false;
		}
		var dotindex1 = str1.indexOf('.');
		if(dotindex1 != -1)
		{
			var substr1 = str1.substr(dotindex+1);
			if(substr1.indexOf('.') != -1)
			{
				form.last_name.style.background = "#FFCCCC";
				alert("Last Name Should not contain two or more dots");
				nameCFocus1();
			    return false;
			}
		}*/
	}
	
	if(form.occupation.value==0)
    {
     form.occupation.style.background = "#FFCCCC";
     alert("Please select the occupation.");
     form.occupation.focus();
      return false;
    }

	if(form.occu.value.length>20)
    {
     form.occu.style.background = "#FFCCCC";
     alert("Proffession not more than 20 characters.");
     form.occu.focus();
      return false;
    }
    
    if(form.scity.value=="" && form.city.value=="" )
	{
		form.scity.style.background = "#FFCCCC";
		alert("Please select a city ");
		form.scity.focus();
		return false;
	}
	else
	{
		form.scity.style.background = "#FFFFFF";
	}

	if(form.city.value != "")
	{
		if(!isContainsSpecialChars(form.city.value))
		{
			form.city.style.background = "#FFCCCC";
			alert("City should contains only characters and spaces");
			form.city.focus();
			return false;
		}
	    var str=form.city.value;
		var dotindex = str.indexOf('.');
		if(dotindex != -1)
		{
			var substr = str.substr(dotindex+1);
			if(substr.indexOf('.') != -1)
			{
				form.city.style.background = "#FFCCCC";
				alert("City Should not contain two or more dots");
				form.city.focus();
			    return false;
			}
		}
	}
	else
	{
		form.city.style.background = "#FFFFFF";
		
	}

	if(form.img_loc.value!="")
	{
		
		var str = form.img_loc.value;
		if(str.lastIndexOf('.')!=-1)
		{
			
			var index = str.lastIndexOf('.');
			str = str.substr(index);
			if(!(str.match("jpeg")!=null || str.match("jpg")!=null || str.match("gif")!=null || str.match("png")))
			{
				form.img_loc.style.background = "#FFCCCC";
				alert("please Upload jpeg or gif Format images only");
				form.img_loc.focus();
				return false;
			}
		}
		else
		{
			form.img_loc.style.background = "#FFCCCC";
			alert("Invalid File Name");
			form.img_loc.focus();
			return false;
		}
	}

	
	
	
	
	if(form.password.value=="")
	{
		form.password.style.background = "#FFCCCC";
		alert("Enter password");
		form.password.focus();
		return false;
	}
		else if(form.password.value.length<6)
	{
		alert("Password should be atleast 6 characters");
		
	}
	else if(form.password.value.length>15)
	{
		alert("Password should not be more than 15 characters");
		form.password.focus();
		return false;
		
	}
		
	else
	{
		form.password.style.background = "#FFFFFF";
		
	}
	
	if(form.repass.value=="")
	{
		form.repass.style.background = "#FFCCCC";
		alert("Retype the password");
		form.repass.focus();
		return false;
	}
	else
	{
		form.repass.style.background = "#FFFFFF";
		
	}
	
	if(form.password.value != form.repass.value)
	{
		form.password.style.background = "#FFCCCC";
		form.repass.style.background = "#FFCCCC";
		alert("Make sure passwords are matched");
		form.password.focus();
		return false;
	}
	
	
		
		
	else
	{
		form.password.style.background = "#FFFFFF";
		form.repass.style.background = "#FFFFFF";
		
	}
	/*if(form.agree.value!="Y")
	{
		form.agree.style.background = "#FFCCCC";
		alert("Please check Admanya User Agreement and Terms & conditions.");
		form.agree.focus();
		return false;
	}*/
	if ( form.agree.checked == false )
    {
    	form.agree.style.background = "#FFCCCC";
        alert ( "Please check the Terms & Conditions box." );
        form.agree.focus();
		return false;
    }
    
}