function validateRegisterCourse()
{
/////////////////////////////Course & Individual Validation///////////////////////////
	var course=document.getElementById('course');
	var country=document.getElementById('country');
	var city=document.getElementById('city');
	var dates=document.getElementById('dates');
	
	var mode=document.getElementById('mode').value;
	var name=document.getElementById('name');
	var telephone=document.getElementById('telephone');
	var fax=document.getElementById('fax');
	var mobile=document.getElementById('mobile');
	var email=document.getElementById('email');
	var address=document.getElementById('address');
	
	
		
	if(course.selectedIndex==0)
	{
	    alert('Please Select a course');
		course.focus();
		return false;	
	}
	
	if(country.selectedIndex==0)
	{
	    alert('Please Select a country');
		country.focus();
		return false;	
	}
	
	if(city.selectedIndex==0)
	{
	    alert('Please Select a city');
		city.focus();
		return false;	
	}
	
	if(dates.selectedIndex==0)
	{
	    alert('Please Select a date');
		dates.focus();
		return false;	
	}
	
	if(mode=='individual')
	{
		
		if(name.value.length==0)
		{			
			alert('Please Enter name');
			name.focus();
			return false;
		}
					
		if(email.value=='')
		{
	           alert('Please Enter Email Address.');
	           email.focus();
			   return false;
	    }
		
	    if(!email.value.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/)) 
		{
	           alert('Please Enter a valid Email Address.');
	           email.focus();
			   return false;
	    }
		
	   
	    if(address.value.length==0)
		{			
			alert('Please Enter your Address');
			address.focus();
			return false;
		}
	   		
		if(telephone.value.length==0)
		{			
			alert('Please Enter your Telephone Number');
			telephone.focus();
			return false;
		}
			
			if(mobile.value.length==0)
			{			
			alert('Please Enter your Mobile Number');
			address.focus();
			return false;
			}
			if(telephone.value.match(/[&--]+/) || telephone.value.match(/[a-zA-Z]/)) 
			{
				alert("Telephone may contain only numeric values");
				telephone.focus();
				return false;
			}
			
			if(mobile.value.match(/[&--]+/) || mobile.value.match(/[a-zA-Z]/)) 
			{
				alert("Mobile may contain only numeric values");
				mobile.focus();
				return false;
			}
			
			if(fax.value.match(/[&--]+/) || fax.value.match(/[a-zA-Z]/)) 
			{
				alert("Fax may contain only numeric values");
				fax.focus();
				return false;
			}
	}
		
////////////////////////////////////Company Validation///////////////////////////////////
	
	if(mode=='company')
	{

		var company_sector=document.getElementById('company_sector');
		var company_name=document.getElementById('company_name');
		var contact_person=document.getElementById('contact_person');
		var contact_position=document.getElementById('contact_position');
		var contact_email=document.getElementById('contact_email');
		var contact_telephone=document.getElementById('contact_telephone');
		var contact_mobile=document.getElementById('contact_mobile');
		var contact_address=document.getElementById('contact_address');
		var no_parts=document.getElementById('no_parts').value;
		
		var username=document.getElementById('username');
		var password=document.getElementById('password');
		var rpassword=document.getElementById('rpassword');		
		var part_flag=0;
		
		if(username)
		{
			
			if(username.value.length==0)
			{		
				alert('Please Enter Username');
				username.focus();
				return false;
			}
			
			if(username_message.innerHTML!='')
			{
				alert('Please Check Username');
				username.focus();
				return false;
			}
			
			
			if(password.value.length==0)
			{		
				alert('Please Enter Password');
				password.focus();
				return false;
			}
		
			if(password.value.length < 6)
			{		
				alert('Password must not be less than 6 characters');
				password.focus();
				return false;
			}
			
			if(password.value != rpassword.value)
			{		
				alert('Password Does Not Match!');
				password.focus();
				return false;
			}
		}
			
		if(company_sector.selectedIndex==0)
		{
			alert("Please Select Company Sector");
			company_sector.focus();
			return false;	
		}
			
		if(company_name.value=='')
		{
			alert("Please Enter Company Name");
			company_name.focus();
			return false;
		}
		
		if(contact_person.value=='')
		{
			alert("Please Enter Contact Person Name");
			contact_person.focus();
			return false;
		}
		
		if(contact_position.value=='')
		{
			alert("Please Enter Contact Person Position");
			contact_position.focus();
			return false;
		}
		
		
		if(contact_email.value=='')
		{
			alert("Please Enter Contact Email");
			contact_email.focus();
			return false;
		}
		
		if(!contact_email.value.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/)) 
		{
	        alert('Please Enter a valid Email Address.');
	        email.focus();
			return false;
	    }
		
		if(contact_telephone.value=='')
		{
			alert("Please Enter Contact Telephone");
			contact_telephone.focus();
			return false;
		}
		
		if(contact_mobile.value=='')
		{
			alert("Please Enter Contact Mobile");
			contact_mobile.focus();
			return false;
		}	
		
		if(contact_address.value=='')
		{
			alert("Please Enter Contact Address");
			contact_address.focus();
			return false;
		}	

		
		
			
		for(var i=1;i<=no_parts;i++)
		{
			
			var participant_name='participant_name'+i;
			var participant_mobile='participant_mobile'+i;
			var participant_email='participant_email'+i;

								
			if(document.getElementById(participant_name).value=='')
			{
				alert("Please Enter Participant "+i+" Name");
				document.getElementByID(participant_name).focus();
				part_flag++;
				return false;
				break;
			}
			
			
			if(document.getElementById(participant_mobile).value=='')
			{
				alert("Please Enter Participant "+i+" Mobile");
				document.getElementByID(participant_mobile).focus();
				part_flag++;
				return false;
				break;
			}
			
			if(document.getElementById(participant_email).value=='')
			{
				alert("Please Enter Participant "+i+" Email");
				document.getElementByID(participant_email).focus();
				part_flag++;
				return false;
				break;
			}
							
		}
			
	
	}
		
				
    if(part_flag>0)
    {
    return false;
    }
	
   	else
    {
    document.getElementById('register_course_form').submit();  
    return true;
    }
}
////////////////////////////////////////////////////////////////////////////////////////////////
function showLoginForm()
{
document.getElementById('form_td').innerHTML="<table cellspacing=2 cellpadding=2 border=0>"
+"<tr><td colspan=2><b>Login</b></td></tr>"
+"<tr><td>Username</td><td><input type='text' name='username' id='username'></td></tr>"
+"<tr><td>Password</td><td><input type='password' name='password' id='password'></td></tr>"
+"<tr><td colspan=2 id='login_message'></td></tr>"	
+"<tr><td></td><td><input type='button' name='submit_login' id='submit_login' value='Login' onclick='companyLogin()'></td></tr></table>";
}


function showSelectType()
{
document.getElementById('mode').value='company';
	
document.getElementById('form_td').innerHTML='';
document.getElementById('select_type_td').innerHTML="<select name='company_type' id='company_type' onchange='companyAction()'><option value=''>--Select Type--</option><option value='reg'>Registered Company</option><option value='new'>New Company</option></select>";

}

function companyAction()
{

	var select_type=document.getElementById('company_type').selectedIndex;
	
	if(select_type==1)
	{
	document.getElementById('ctype').value='reg';
	showLoginForm();
	}
	else if(select_type==2)
	{
	document.getElementById('ctype').value='new';
	showRegistration(0);
	}	
	else
	{
	alert("Please Select your type");
	document.getElementById('company_type').focus();
	}
	
}




