function validChars(string) 
{

    var valid="  0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-?!*(),£/"
    var blnValid

    blnValid = true;

    for (var i=0; i<string.length; i++) {
        if (valid.indexOf(string.charAt(i)) < 0) {
            
            blnValid = false;
        }
    }

    return blnValid;
}

function validNumber(string) 
{

    var valid="0123456789"
    var blnValid

    blnValid = true;

    for (var i=0; i<string.length; i++) {
        if (valid.indexOf(string.charAt(i)) < 0) {
            
            blnValid = false;
        }
    }

    return blnValid;
}



function AddContent()
{
    if(document.ADDCONTENT.DESCRIPTION.value=='')
    
    {
      alert("No text entered.");
      document.ADDCONTENT.DESCRIPTION.focus();
    }
    
	else
    
	{
	 	document.ADDCONTENT.submit();
    }
}



function AddPty()

{
    if(document.ADDPTY.Reference.value=='')

	{
		alert("You must enter a property reference.");
		document.ADDPTY.Reference.focus();
	}

	else
	
	{
        if(document.ADDPTY.Location.value=='')

        {
    		alert("You must enter a property location.");
    		document.ADDPTY.Location.focus();
        }
	   
        else
        
        {
            if(document.ADDPTY.PropertyType.value=='')

            {
        		alert("You must enter a property type.");
        		document.ADDPTY.PropertyType.focus();
            }

            else
            
            {
                if(document.ADDPTY.DisplayPrice.value=='')

        		{
        			alert("Please enter a Property Price.");
        			document.ADDPTY.DisplayPrice.focus();
        		}

                else
                
                {
                    (validNumber(document.ADDPTY.DisplayPrice.value));
                    if(validNumber(document.ADDPTY.DisplayPrice.value)==false)

                    {
                      alert('Price contains non-numeric characters');
                      document.ADDPTY.DisplayPrice.focus();
                    }

                    else
                    
                    {
                        if(document.ADDPTY.SellerPrice.value=='')
                            {
                                alert("Please enter the Sellers Price.");
                                document.ADDPTY.SellerPrice.focus();
                            }

                            else
                      
                            {
                                (validNumber(document.ADDPTY.SellerPrice.value));
                                if(validNumber(document.ADDPTY.SellerPrice.value)==false)

                                    {
                                        alert('Sellers Price contains non-numeric characters');
                                        document.ADDPTY.SellerPrice.focus();
                                    }

                                    else
                        
                                    {
                                        if(document.ADDPTY.ShortDescription.value=='')
                                            {
                                                alert("Please enter a Short Description.");
                                                document.ADDPTY.ShortDescription.focus();
                                            }

                                            else

                                            {
                                                document.ADDPTY.submit();
                                            }
                                    }
                            }
                    }
                }
            }
 	  	}
    }
}


function SendEmail()

{
	if(document.CONTACT.Enq_Name.value=='')

	{	
	 	alert("Please enter your name.");
		document.CONTACT.Enq_Name.focus();
	}

	else

	{
		if(document.CONTACT.Description.value=='')

		{	
		 	alert("Please type your message in the box provided.");
			document.CONTACT.Description.focus();
		}

		else

		{	

        valid = true;
    	var newemail = new String(document.CONTACT.Enq_Email.value);

		if (newemail.length < 5)

    		{
				valid = false;
			}

			else
				    
			{
				if(newemail.indexOf('@')<2)
					
				{
					valid = false;
				}
                        
				else
					
				{
					if(newemail.indexOf(' ')!=-1)
						
					{
						valid = false;
					}
					    
					else
                        
					{
						if(newemail.lastIndexOf('.')<newemail.indexOf('@')+2)
							
						{
							valid = false;
						}
                    }
				}
			}

			if (valid == false)

			{
    			alert("Email address in either blank or invalid.\n Please check the details and try again.");
    			document.CONTACT.Enq_Email.focus();
			}
                
			else

			{
				document.CONTACT.submit();
			}
  		}
	}
}


function Promo()

{
	if(document.PROMO.Enq_Name.value=='')

	{	
	 	alert("Please enter your name.");
		document.PROMO.Enq_Name.focus();
	}

	else

	{
		if(document.PROMO.Description.value=='')

		{	
		 	alert("Please type your message in the box provided.");
			document.PROMO.Description.focus();
		}

		else

		{	

        valid = true;
    	var newemail = new String(document.PROMO.Enq_Email.value);

		if (newemail.length < 5)

    		{
				valid = false;
			}

			else
				    
			{
				if(newemail.indexOf('@')<2)
					
				{
					valid = false;
				}
                        
				else
					
				{
					if(newemail.indexOf(' ')!=-1)
						
					{
						valid = false;
					}
					    
					else
                        
					{
						if(newemail.lastIndexOf('.')<newemail.indexOf('@')+2)
							
						{
							valid = false;
						}
                    }
				}
			}

			if (valid == false)

			{
    			alert("Email address in either blank or invalid.\n Please check the details and try again.");
    			document.PROMO.Enq_Email.focus();
			}

			else

			{
				document.PROMO.submit();
			}
		}
   }
}

function EditContent()
{
    if(document.EDITCONTENT.DESCRIPTION.value=='')
    
    {
      alert("Please enter some text.");
      document.EDITCONTENT.DESCRIPTION.focus();
    }
    
	else
    
	{
	 	document.EDITCONTENT.submit();
    }
}


function UserLogin()

{
	if (document.USER.User.value =="")
	{	alert("Please enter your Username");
		document.USER.User.focus();
	}
	else
	{	if (document.USER.Password.value =="")
		{	alert("Please enter your Password");
			document.USER.Password.focus();
		}
		else
		{
			document.USER.submit();
		}
	}
}