function popup(filename)
{
           ridwindow=window.open(filename,"ridwindow","resize=no,toolbar=no,scrollbars=no,width=500,height=450")
       }
	function validate()
	{
		if (document.theForm.userID.value=="")
		{
			alert("Please enter Username");
			document.theForm.userID.focus();
			return false;
		}
		var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-";
		var checkOK1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
		var checkStr = document.theForm.userID.value;
		 
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
		{
		    	ch = checkStr.charAt(i);
		    	ch1 = checkStr.charAt(0);
		 	for (k=0; k < checkOK1.length; k++)
		  		if (ch1 == checkOK1.charAt(k))
		    			break;
				if (k == checkOK.length)
				{ 
				     allValid = false;
				     break;
				}
		    	for (j = 0;  j < checkOK.length;  j++)
		      		if (ch == checkOK.charAt(j))
		        		break;
			    	if (j == checkOK.length)
			    	{
			      		allValid = false;
			      		break;
			    	}
		}
		if (!allValid)
		{
		    alert("Use only letters, numbers, dot(.), minus(-) or the underscore (_) in User-ID field.No spaces or special characters please.");
		    document.theForm.userID.focus();
		    return (false);
		} 
		if ((document.theForm.password.value == ""))
		{
			alert("\nThe PASSWORD field is empty.\n\nPlease re-enter your Password.")
			document.theForm.password.focus();
			return false;
		}
		if (document.theForm.password.value != document.theForm.confirmPassword.value)
		{
			alert("Passwords typed do not match, please re-enter your passwords.\n");
			document.theForm.confirmPassword.value="";
			document.theForm.password.focus();
			document.theForm.password.value="";
			return false;
		}
		if (document.theForm.FName.value=="")
                {
                        alert('Please enter a EMail');
                        document.theForm.altEmail.focus();
                        return false;
                }	
		if ((document.theForm.altEmail.value!="") &&((document.theForm.altEmail.value.indexOf('@', 0) == -1) || (document.theForm.altEmail.value.indexOf('.', 0) == -1 )))
                {
                        alert('Please enter a valid EMail');
                        document.theForm.altEmail.focus();
                        return false;
                }	
		if (document.theForm.FName.value=="")
		{
			alert("Please enter First Name ");
			document.theForm.FName.focus();
			return false;
		}
		if (document.theForm.MName.value=="")
		{
			alert("Please enter Middle Name");
			document.theForm.MName.focus();
			return false;
		}
		if (document.theForm.lastName.value=="")
		{
			alert("Please enter Last Name");
			document.theForm.lastName.focus();
			return false;
		}
		if ( document.theForm.date.selectedIndex == 0)
		{
			alert("Please enter your Date of birth");
		    	document.theForm.date.focus();
			return false;
		}
		if ( document.theForm.month.selectedIndex == 0)
		{
			alert("Please enter your Month of birth");
		    	document.theForm.month.focus();
			return false;
		}
		if ( document.theForm.year.selectedIndex == 0)
		{
			alert("Please enter your Year of birth");
            		document.theForm.year.focus();
			return false;
		}
		if (document.theForm.maritalStatus.selectedIndex == 0)
		{
			alert("Please choose your Marital Status");
	        	document.theForm.maritalStatus.focus();
			return false;
		}
		if (document.theForm.gender.selectedIndex == 0)
		{
			alert("Please choose your Gender");
	        	document.theForm.gender.focus();
			return false;
		}
		if (document.theForm.pincode.value=="")
		{
			alert("Please enter Pin Code");
			document.theForm.pincode.focus();
			return false;
		}
		
		if (document.theForm.country.selectedIndex ==0)
		{
			alert("Please choose your Country");
			document.theForm.country.focus();
			return false;
		}
		if (document.theForm.education.selectedIndex ==0)
		{
			alert("Please choose your Education");
			document.theForm.education.focus();
			return false;
		}
		if (document.theForm.incomeGroup.selectedIndex ==0)
		{
			alert("Please choose your Income Group");
			document.theForm.incomeGroup.focus();
			return false;
		}
		if ((document.theForm.city[0].selectedIndex ==0)&(document.theForm.city[1].value==""))
		{
			alert("\nThe City field is empty.\n\nPlease re-enter the city name.")
			document.theForm.city[0].focus();
			return false;
		}
		if ((document.theForm.city[0].selectedIndex !=0)&(document.theForm.city[1].value!=""))
		{
			alert("\nPlease choose city either from the list or specify the city if its not in the list.\n\nYou can't choose both. Please Re-enter the city name.")
			document.theForm.city[1].focus();
			return false;
		}
		if (document.theForm.state.value=="")
		{
			alert("Please choose your State");
			document.theForm.state.focus();
			return false;
		}
		if (document.theForm.occupation.selectedIndex ==0)
				{
					alert("Please choose your occupation");
					document.theForm.occupation.focus();
					return false;
		}
		if (document.theForm.industry.selectedIndex ==0)
						{
							alert("Please choose your occupation");
							document.theForm.industry.focus();
							return false;
		}
  	   				
		
		//if (document.theForm.MaritalStatus.selectedIndex == 0)
		//{
		//	alert("Please choose your Marital Status");
	   //     	document.theForm.MaritalStatus.focus();
		//	return false;
		//}
		
		
  	   	//if (document.theForm.Education.selectedIndex ==0)
		//{
			//alert("Please choose your Education");
		     //   document.theForm.Education.focus();
			//return false;
		//}
  	   	//if (document.theForm.IncomeGroup.selectedIndex ==0)
		//{
		//	alert("Please choose your Annual Income");
		 //       document.theForm.IncomeGroup.focus();
		//	return false;
		//}
		
		
		if(document.theForm.city[0].selectedIndex ==0)
		{
			document.theForm.city[0].value=document.theForm.city[1].value;
		}
		
		
      		return true;
	}
	function isDate()
	{
		var yy,mm,dd;
		var im,id,iy;
		var present_date = new Date();
		yy = present_date.getYear();
		mm = present_date.getMonth();
		dd = present_date.getDate();
		im = document.theForm.month.selectedIndex;
		id = document.theForm.day.selectedIndex;
		iy = document.theForm.year.selectedIndex;
		var entered_month = document.theForm.month.options[im].value;
		var invalid_month = document.theForm.month.options[im].value - 1;
		var entered_day = document.theForm.day.options[id].value;
		var entered_year = document.theForm.year.options[iy].value;
		if ( (entered_day == 0) || (entered_month == 0) || (entered_year == 0) )
		{
			alert("Please enter your birthday");
			return false;
		}
		if ( is_greater_date(entered_year,entered_month,entered_day,yy,mm,dd) && is_valid_day(invalid_month,entered_day,entered_year) )
		{
			return true;
		}
		return false;
	}
	function is_greater_date(entered_year,entered_month,entered_day,yy,mm,dd)
	{
		if (entered_year > yy)
		{
			alert("The birthday field is entered incorrectly. The year entered exceeds the current year.");
			return false;
		}
		if (entered_year == yy)
		{
			if (entered_month > mm)
			{
				alert("The birthday field is entered incorrectly.");
				return false;
			}
			if (entered_month == mm)
			{
				if (entered_day > dd)
				{
					alert("The birthday field is entered incorrectly.");
					return false;
				}
			}
		}
		return true;
	}
	function is_valid_day(entered_month,entered_day,entered_year)
	{
		if ((entered_year % 4) == 0)
		{
			var days_in_month = "312931303130313130313031";
 		}
 		else
		{
			var days_in_month = "312831303130313130313031";
	 	}
		var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
		if (entered_month != -1)
		{
			if (entered_day > days_in_month.substring(2*entered_month,2*entered_month+2))
			{
				alert ("The birthday field is entered wrongly (the day field value exceeds the number of days for the month entered).");
				return false;
			}
		}
		return true;
	}
