<!--  copyright 2007 Gurg Consulting Ltd, All rights reserved  -->

// JavaScript Document
function validate()
{
	var ph =/^[0-9\()\#\+\-\" "]+$/;
	var emailval=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var reWhiteSpace =/^\s+$/;

	if(document.frmregistration.username.value=="")
	{
		alert("Please enter User Name");
		document.frmregistration.username.focus();
		return false;
	}
	
	
	if(document.frmregistration.password.value=="")
	{
		alert("Please enter Password");
		document.frmregistration.password.focus();
		return false;
	}
	if(document.frmregistration.password.value.length<5)
	{
		alert("Password atleast five(5) characters length");
		document.frmregistration.password.focus();
		return false;
	}
	if(document.frmregistration.conpassword.value=="")
	{
		alert("Please enter Confirm Password");
		document.frmregistration.conpassword.focus();
		return false;
	}
	if(document.frmregistration.conpassword.value!=document.frmregistration.password.value)
	{
		alert("Confirm password must be same with password");
		document.frmregistration.conpassword.focus();
		return false;
	}
	if(document.frmregistration.fname.value=="")
	{
		alert("Please enter Your First Name");
		document.frmregistration.fname.focus();
		return false;
	}	
	if(document.frmregistration.lname.value=="")
	{
		alert("Please enter Your Last Name");
		document.frmregistration.lname.focus();
		return false;
	}
	if(document.frmregistration.email.value=="")
	{
		alert("Please enter Your email.");
		document.frmregistration.email.focus();
		return false;
	}
	if(!emailval.test(document.frmregistration.email.value))
	{
		 alert("Please Enter a valid email.");
		 document.frmregistration.email.select();
		 return false;
	}
	if(document.frmregistration.age.checked==false)
	{
		alert("Check the box if your age is more than 16");
		return false;
	}
	if(document.frmregistration.country.value=="")
	{
		alert("Please select country.");
		document.frmregistration.country.focus();
		return false;
	}	
		
}

<!-- Validation for Company   -->


function validateCompany()
{
	var ph =/^[0-9\()\#\+\-\" "]+$/;
	var emailval=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var reWhiteSpace =/^\s+$/;

/*	if(document.frmCompany.username.value=="")
	{
		alert("Please enter User Name.");
		document.frmCompany.username.focus();
		return false;
	}
	
	if(document.frmCompany.password.value=="")
	{
		alert("Please enter Password.");
		document.frmCompany.password.focus();
		return false;
	}
	if(document.frmCompany.password.value.length<5)
	{
		alert("Password atleast five(5) characters length.");
		document.frmCompany.password.focus();
		return false;
	}
	if(document.frmCompany.conpassword.value=="")
	{
		alert("Please enter Confirm Password.");
		document.frmCompany.conpassword.focus();
		return false;
	}
	if(document.frmCompany.conpassword.value!=document.frmCompany.password.value)
	{
		alert("Confirm password must be same with password.");
		document.frmCompany.conpassword.focus();
		return false;
	}
	
	
	
	if(document.frmCompany.CompanyName.value=="")
	{
		alert("Please enter Your Company Name.");
		document.frmCompany.CompanyName.focus();
		return false;
	}
	
	if(document.frmCompany.CompanyStreet.value=="")
	{
		alert("Please enter Your Street Name.");
		document.frmCompany.CompanyStreet.focus();
		return false;
	}
	
	if(document.frmCompany.CompanyPostCode.value=="")
	{
		alert("Please enter Your Post Code.");
		document.frmCompany.CompanyPostCode.focus();
		return false;
	}
	
	
	if(document.frmCompany.CCountry.value=="")
	{
		alert("Please select country.");
		document.frmCompany.CCountry.focus();
		return false;
	}
	
	if(document.frmCompany.CompanyEmail.value=="")
	{
		alert("Please enter Company Email Address.");
		document.frmCompany.CompanyEmail.focus();
		return false;
	}
	if(!emailval.test(document.frmCompany.CompanyEmail.value))
	{
		 alert("Please Enter a valid Company Email Address.");
		 document.frmCompany.CompanyEmail.select();
		 return false;
	}*/
	
	
	if(document.getElementById("MyDestination").length==0)
		{
		alert("Please select atleast one Company Category");
		document.getElementById("MyContacts").focus();
		return false;
		}
		
	//----------------
	
	
	if(document.getElementById("MyDestination").length!=0)
	{
	var SelectedList = "";
	
	//alert(document.getElementById("MyDestination").length);
	
	for(var i = 0; i < document.getElementById("MyDestination").length; i++) 
	{
		SelectedList += (document.getElementById("MyDestination").options[i].value + ",");		
	}
	SelectedList = SelectedList.substring(0, SelectedList.length-1);
	document.getElementById("SelectedContactsList").value = SelectedList;
	//alert(SelectedList);
	}
	
	
	//----------
	
	
	
	
	//-------------------------------------------------------------
	/*if(document.frmCompany.ContactName1.value=="")
	{
		alert("Please Enter a Contact Person Name.");
		document.frmCompany.ContactName1.focus();
		return false;
	}
	
	if(document.frmCompany.JobTitle1.value=="")
	{
		alert("Please Enter a Contact Person job Title");
		document.frmCompany.JobTitle1.select();
		return false;
	}
	if(document.frmCompany.Telephone1.value=="")
	{
		alert("Please Enter a Contact Person Phone Number");
		document.frmCompany.Telephone1.select();
		return false;
	}
	if(document.frmCompany.Telephone1.value!="")
	{
		if(!ph.test(document.frmCompany.Telephone1.value))
		{
			 alert("Please Enter a valid Contact Person Phone Number");
			 document.frmCompany.Telephone1.select();
			 return false;
		}
	}
	if(document.frmCompany.Email1.value=="")
	{
		alert("Please Enter a Contact Person Email");
		document.frmCompany.Email1.select();
		return false;
	}
	if(document.frmCompany.Email1.value!="")
	{
		if(!emailval.test(document.frmCompany.Email1.value))
		{
			 alert("Please Enter a valid Contact Person Email Address.");
			 document.frmCompany.Email1.select();
			 return false;
		}
	}
	
	
	
	//----------------------------------------------------------
	
	if(document.frmCompany.CompanyNPhone.value=="")
	{
		alert("Please enter Your Company Phone No.");
		document.frmCompany.CompanyNPhone.focus();
		return false;
	}
		
	if(document.frmCompany.CompanySalesNPhone.value=="")
	{
		alert("Please enter Your Sales Enquiry Phone No.");
		document.frmCompany.CompanySalesNPhone.focus();
		return false;
	}
	
	if(document.frmCompany.CompanyScPhone.value=="")
	{
		alert("Please enter Your Support Contact Phone No.");
		document.frmCompany.CompanyScPhone.focus();
		return false;
	}
	
	
	if(document.frmCompany.CompanyScEmail.value=="")
	{
		alert("Please enter Your Support Contact email.");
		document.frmCompany.CompanyScEmail.focus();
		return false;
	}
	if(!emailval.test(document.frmCompany.CompanyScEmail.value))
	{
		 alert("Please Enter a valid Support Contact email.");
		 document.frmCompany.CompanyScEmail.select();
		 return false;
	}
	
	if(document.frmCompany.SendmeMsg.value=="")
	{
		alert("Please Enter Your Mobile Number To send Message.");
		document.frmCompany.SendmeMsg.focus();
		return false;
	}
	if(document.frmCompany.SendmeMsg.value!="")
	{
		if(!ph.test(document.frmCompany.SendmeMsg.value))
		{
			 alert("Please Enter a valid Mobile Number");
			 document.frmCompany.SendmeMsg.select();
			 return false;
		}
		
	}
*/	
	
}

function stop_keypress_whitespace(evt)
	{
	 evt = (evt) ? evt : ((window.event) ? event : null);
		if (evt) {
		   var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
		   if (elem) {
			   var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
				 if (charCode == 32 ) 
				 {
				   alert("Please Enter Mobile Number Without Space");
				   return false;
			   	 } 
		   }
		} 
	}

<!-- Validation for Service Provider   -->

function validateService()
{
	//alert("kkkkkkk");
	
	var ph =/^[0-9\()\#\+\-\" "]+$/;
	var emailval=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

	if(document.frmService.susername.value=="")
	{
		alert("Please enter User Name.");
		document.frmService.susername.focus();
		return false;
	}
	
	if(document.frmService.password.value=="")
	{
		alert("Please enter Password.");
		document.frmService.password.focus();
		return false;
	}
	if(document.frmService.password.value.length<5)
	{
		alert("Password atleast five(5) characters length.");
		document.frmService.password.focus();
		return false;
	}
	if(document.frmService.conpassword.value=="")
	{
		alert("Please enter Confirm Password.");
		document.frmService.conpassword.focus();
		return false;
	}
	if(document.frmService.conpassword.value!=document.frmService.password.value)
	{
		alert("Confirm password must be same with password.");
		document.frmService.conpassword.focus();
		return false;
	}
	
	
	
	if(document.frmService.ServiceName.value=="")
	{
		alert("Please enter Your Company Name.");
		document.frmService.ServiceName.focus();
		return false;
	}
	
	if(document.frmService.ServiceStreet.value=="")
	{
		alert("Please enter Your Street Name.");
		document.frmService.ServiceStreet.focus();
		return false;
	}
	
	if(document.frmService.ServicePostCode.value=="")
	{
		alert("Please enter Your Post Code.");
		document.frmService.ServicePostCode.focus();
		return false;
	}
	
	
	if(document.frmService.ServiceEmail.value=="")
	{
		alert("Please enter Service Provider Email Address.");
		document.frmService.ServiceEmail.focus();
		return false;
	}
	if(!emailval.test(document.frmService.ServiceEmail.value))
	{
		 alert("Please Enter a valid Service Provider Email Address.");
		 document.frmService.ServiceEmail.select();
		 return false;
	}
	
	
	
	
	
	if(document.frmService.ServiceNPhone.value=="")
	{
		alert("Please enter Your Company Phone No.");
		document.frmService.ServiceNPhone.focus();
		return false;
	}
	
	
	
	if(document.frmService.ServiceNEmail.value=="")
	{
		alert("Please enter Your email.");
		document.frmService.ServiceNEmail.focus();
		return false;
	}
	if(!emailval.test(document.frmService.ServiceNEmail.value))
	{
		 alert("Please Enter a valid email.");
		 document.frmService.ServiceNEmail.select();
		 return false;
	}
	
	
	if(document.frmService.ServiceSalesNPhone.value=="")
	{
		alert("Please enter Your Sales Enquiry Phone No.");
		document.frmService.ServiceSalesNPhone.focus();
		return false;
	}
	
	if(document.frmService.ServiceScPhone.value=="")
	{
		alert("Please enter Your Support Contact Phone No.");
		document.frmService.ServiceScPhone.focus();
		return false;
	}
	
	
	if(document.frmService.ServiceScEmail.value=="")
	{
		alert("Please enter Your Support Contact email.");
		document.frmService.ServiceScEmail.focus();
		return false;
	}
	if(!emailval.test(document.frmService.ServiceScEmail.value))
	{
		 alert("Please Enter a valid Support Contact email.");
		 document.frmService.ServiceScEmail.select();
		 return false;
	}
}

<!--  Company subscription validate -->

function CsubValidate(){	

	if(document.cSub.CompanySubFrom.value=="")
	{
		alert("Please enter Date From.");
		document.cSub.CompanySubFrom.focus();
		return false;
	}
	
	if(document.cSub.CompanySubTo.value=="")
	{
		alert("Please enter Date To.");
		document.cSub.CompanySubTo.focus();
		return false;
	}
	
	
	if(document.cSub.CompanySubName.value=="")
	{
		alert("Please enter Paid By Name.");
		document.cSub.CompanySubName.focus();
		return false;
	}

}

//=================================================================================


function IsIDAdded(ID)
	{
		var ret=false;
		for (var i=0;i<document.getElementById("MyDestination").length;i++)
		{
			if (ID==document.getElementById("MyDestination").options[i].value)
			ret=true;
		}
		return ret;
	}
	
function AddToTheList() 
	{
		if(document.getElementById("MyDestination").length==5)
		{
		alert("You Can't Add more than 5 Category");
		return;
		}
		
		if ( (document.getElementById("MyContacts").selectedIndex < 0)  )
		{
			alert("Please select at least one contact from left list to add");
			
		}
		else
		{
		if (!IsIDAdded(document.getElementById("MyContacts").options[document.getElementById("MyContacts").selectedIndex].value))
		{
			document.getElementById("MyDestination").options[document.getElementById("MyDestination").length] = new Option(document.getElementById("MyContacts").options[document.getElementById("MyContacts").selectedIndex].text,document.getElementById("MyContacts").options[document.getElementById("MyContacts").selectedIndex].value);
		}
		}		
	}
function RemoveFromTheList() 
	{
		if ( document.getElementById("MyDestination").selectedIndex < 0)
		{
			alert("Please select at least one contact from right list to remove");
		}
		else
		{
			document.getElementById("MyDestination").options[document.getElementById("MyDestination").selectedIndex] = null;
		}
	}
	
function HandleSubmit(S)
{
	
	var SelectedList = "";
	for(var i = 0; i < document.getElementById("MyDestination").length; i++) 
	{
		SelectedList += (document.getElementById("MyDestination").options[i].value + ",");		
	}
	SelectedList = SelectedList.substring(0, SelectedList.length-1);
	document.getElementById("SelectedContactsList").value = SelectedList;
	//alert(SelectedList);
	if (S!=1)
	{
		document.getElementById("fs").value="Submit";
		document.getElementById("contact").submit();
	}
}

//==================================================================