function validate_quick(thisform)
{
	if(thisform.txtName.value == '' || thisform.txtName.value == 'Your name')	
		{
			alert("Woops! You forgot to fill in your Name");
			thisform.txtName.focus();
			return false;
		}
	
	if(thisform.txtEmail.value == '' || thisform.txtEmail.value == 'Your email address')	
		{
			alert("Woops! You forgot to fill in your Email");
			thisform.txtEmail.focus();
			return false;
		}
		
	if(validate_email(thisform.txtEmail,"Woops! You have entered an invalid Email Address")==false)
		{
			thisform.txtEmail.select();
			thisform.txtEmail.focus();
			return false;
		}

	if(thisform.txtPhone.value == '' || thisform.txtPhone.value == 'Your phone number')	
		{
			alert("Woops! You forgot to fill in your Phone");
			thisform.txtPhone.focus();
			return false;
		}
		
	if(IsNumeric(thisform.txtPhone.value)==false)
		{
			alert("Woops! You have entered an invalid Phone Number");
			thisform.txtPhone.select();
			thisform.txtPhone.focus();
			return false;
		}
		
	if(thisform.country.value == '' || thisform.country.value == 'Your Country')	
		{
			alert("Woops! You forgot to fill in your Country");
			thisform.country.focus();
			return false;
		}	
	
	
	if(thisform.txtComments.value == '' || thisform.txtComments.value == 'Questions or Comments')	
		{
			alert("Woops! You forgot to fill in your Questions or Comments");
			thisform.txtComments.focus();
			return false;
		}	
	thisform.submit();
	return true;
}

function validate_contactus(thisform)
{
	if(thisform.txtName.value == '')	
		{
			alert("Woops! You forgot to fill in your Name");
			thisform.txtName.focus();
			return false;
		}
	if(thisform.txtEmail.value == '')	
		{
			alert("Woops! You forgot to fill in your Email");
			thisform.txtEmail.focus();
			return false;
		}
	if(validate_email(thisform.txtEmail,"Woops! You have entered an invalid Email Address")==false)
		{
			thisform.txtEmail.select();
			thisform.txtEmail.focus();
			return false;
		}

	if(thisform.txtAddress.value == '')	
		{
			alert("Woops! You forgot to fill in your Address");
			thisform.txtAddress.focus();
			return false;
		}
	
	if(thisform.txtPhone.value == '')	
		{
			alert("Woops! You forgot to fill in your Phone");
			thisform.txtPhone.focus();
			return false;
		}
	if(IsNumeric(thisform.txtPhone.value)==false)
		{
			alert("Woops! You have entered an invalid Phone Number");
			thisform.txtPhone.select();
			thisform.txtPhone.focus();
			return false;
		}
		
	/*if(thisform.txtFax.value == '')	
		{
			alert("Woops! You forgot to fill in your Fax");
			thisform.txtFax.focus();
			return false;
		}
	
	if(IsNumeric(thisform.txtFax.value)==false)
		{
			alert("Woops! You have entered an invalid Fax Number");
			thisform.txtFax.select();
			thisform.txtFax.focus();
			return false;
		}
		
		
	if(thisform.txtComments.value == '')	
		{
			alert("Woops! You forgot to fill in your Comments");
			thisform.txtComments.focus();
			return false;
		}	*/
	thisform.submit();
	return true;
}

function validate_form_login(thisform)
{
	if(thisform.username.value == '' || thisform.username.value == 'User name')	
		{
			alert("Woops! You forgot to fill in your User Name");
			thisform.username.focus();
			return false;
		}	
		
	if(thisform.password.value == '' || thisform.password.value == 'Password' )	
		{
			alert("Woops! You forgot to fill in your Password");
			thisform.password.focus();
			return false;
		}	
		
		authenticate_login(thisform.username.value,thisform.password.value)
	    return true;
}

function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
function authenticate_login(thisVal1,thisVal2) {		
		
		var strURL="http://www.apollobuildtec.com/_Admin_Online/login-client.php?uname="+thisVal1+"&psw="+thisVal2;
		//alert(strURL)
		var req = getXMLHTTP();
		//alert(thisVal)
			if (req) {
				//document.getElementById('listClientDetails').style.display='block';
				req.onreadystatechange = function() {
					if (req.readyState == 4) {
						// only if "OK"
						if (req.status == 200) {	
						//alert(req.responseText)
						    if(req.responseText!=''){
							//document.getElementById('auth_msg').style.display='block';
							//document.getElementById('result').style.display='none';
							///cument.getElementById('auth_msg').innerHTML=req.responseText;
							alert(req.responseText);
							}else{
								//alert("Login success")
								window.location ='http://www.apollobuildtec.com/_Admin_Online/index.php';}
														
						} else {
							alert("There was a problem while using XMLHTTP:\n" + req.statusText);
						}
					}				
				}			
				req.open("POST", strURL, true);
				//req.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
				req.send(null);
			}			
		
	}
	
function validate_email(entered,alertbox) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = entered.value;
   if(reg.test(address) == false) {
     if (alertbox!="") alert(alertbox,entered);
      return false;
   }
}

function IsNumeric(strString)
{
   var strValidChars = "0123456789-(). ";
   var strChar;
   var blnResult = true;
   if (strString.length == 0) return false;

   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         	{
        	 blnResult = false;
         	}
      }
   return blnResult;
}