function validatePostBasic()
{
	var myName = 			$("#postyourownform input#invoice_name").val();
	var myEmailAddress =	$("#postyourownform input#invoice_email").val();
	var myContactName = 	$("#postyourownform input#contact_name").val();
	var myContactPhone = 	$("#postyourownform input#contact_phone").val();
	var myContactEmail = 	$("#postyourownform input#contact_email").val();
	var myLocation       =	$("#location option:selected").val();
	var myLocalarea = 	    $("#locationDetailPost option:selected").val();
	var myStreet = 		    $("#postyourownform input#street").val();
	var myPostcode = 		$("#postyourownform input#postcode").val();
	var myType = 		    $("#type option:selected").val(); 
	var myBedrooms = 		$("#bedrooms option:selected").val(); 
	var myPrice = 		    $("#price option:selected").val(); 
	var myDescription = 	$("#postyourownform input#property_description").val();
	
	if ( (myName == "") || (myEmailAddress == "") || ( myContactName == "") ||  (myLocation == "" || myLocalarea==""  ) || (myStreet == "") || (myPostcode == "") || (myType == "") || (myBedrooms == "") || (myBedrooms == "") ||  (myPrice == "") ||  (myDescription == "") )
	{
		$("#postahome_errors").show();
		
		if (myName == "")
		{
			$("#post_premier_ul .invoice_name").show();
			$("#post_premier_ul .invoice_name span").show();
		}else{
			$("#post_premier_ul .invoice_name").hide();
			$("#post_premier_ul .invoice_name span").hide();
		}
		if (myEmailAddress == "")
		{
			$("#post_premier_ul .invoice_email").show();
			$("#post_premier_ul .invoice_email span").show();
		}else{
			$("#post_premier_ul .invoice_email").hide();
			$("#post_premier_ul .invoice_email span").hide();
		}
		if (myContactName == "")
		{
			$("#post_premier_ul .contact_name").show();
			$("#post_premier_ul .contact_name span").show();
		}else{
			$("#post_premier_ul .contact_name").hide();
			$("#post_premier_ul .contact_name span").hide();
		}
		
		/*
		if (myContactPhone == "")
		{
			$("#post_premier_ul .contact_phone").show();
			$("#post_premier_ul .contact_phone span").show();
		}else{
			$("#post_premier_ul .contact_phone").hide();
			$("#post_premier_ul .contact_phone span").hide();
		}
		
		if (myContactEmail == "")
		{
			$("#post_premier_ul .contact_email").show();
			$("#post_premier_ul .contact_email span").show();
		}else{
			$("#post_premier_ul .contact_email").hide();
			$("#post_premier_ul .contact_email span").hide();
		}
		*/
		
		
		if((myContactPhone == "") && (myContactEmail == ""))
		{
			$("#post_premier_ul .contact_phone").show();
            $("#post_premier_ul .contact_phone span").show();
            //$("#post_premier_ul .contact_phone span").text("Phone or email required");
			
			$("#post_premier_ul .contact_email").show();
            $("#post_premier_ul .contact_email span").show();
            //$("#post_premier_ul .contact_email span").text("Phone or email required");
		}
		else
		{
			$("#post_premier_ul .contact_phone").hide();
            $("#post_premier_ul .contact_phone span").hide();
			$("#post_premier_ul .contact_email").hide();
            $("#post_premier_ul .contact_email span").hide();
		}
		
		
		
		
		if (myLocation == "")
		{
			$("#post_premier_ul .location").show();
			$("#post_premier_ul .location span").show();
		}else{
			$("#post_premier_ul .location").hide();
			$("#post_premier_ul .location span").hide();
		}
		if (myLocalarea == "")
		{
			$("#post_premier_ul .location").show();
			$("#post_premier_ul .location span").show();
		}else{
			$("#post_premier_ul .location").hide();
			$("#post_premier_ul .location span").hide();
		}
		if (myStreet == "")
		{
			$("#post_premier_ul .street").show();
			$("#post_premier_ul .street span").show();
		}else{
			$("#post_premier_ul .street").hide();
			$("#post_premier_ul .street span").hide();
		}
		if (myPostcode == "")
		{
			$("#post_premier_ul .postcode").show();
			$("#post_premier_ul .postcode span").show();
		}else{
			$("#post_premier_ul .postcode").hide();
			$("#post_premier_ul .postcode span").hide();
		}
		if (myType == "")
		{
			$("#post_premier_ul .type").show();
			$("#post_premier_ul .type span").show();
		}else{
			$("#post_premier_ul .type").hide();
			$("#post_premier_ul .type span").hide();
		}
		if (myBedrooms == "")
		{
			$("#post_premier_ul .bedrooms").show();
			$("#post_premier_ul .bedrooms span").show();
		}else{
			$("#post_premier_ul .bedrooms").hide();
			$("#post_premier_ul .bedrooms span").hide();
		}
		if (myPrice == "")
		{
			$("#post_premier_ul .price").show();
			$("#post_premier_ul .price span").show();
		}else{
			$("#post_premier_ul .price").hide();
			$("#post_premier_ul .price span").hide();
		}
		if (myDescription == "")
		{
			$("#post_premier_ul .property_description").show();
			$("#post_premier_ul .property_description span").show();
		}else{
			$("#post_premier_ul .property_description").hide();
			$("#post_premier_ul .property_description span").hide();
		}
		return false;
	}
	else
	{
		return true;
	}
}

function status_change()
{
    if(document.getElementById('select_status'))
    {
        var select_status =document.getElementById('select_status');
        var closing_date = document.getElementById('closing_date');
        //alert (closing_date.type);
            
        if(select_status.value == 'closing_date_set')
        {
            closing_date.style.visibility="visible";
        }
        else
        {
            closing_date.style.visibility="hidden";
        }
    }
}


function validatePostPremier()
{
    var isLoggedIn =        $("#postyourownform input#login").val();
    var myName =            $("#postyourownform input#invoice_name").val();
    var myEmailAddress =    $("#postyourownform input#invoice_email").val();
    var myContactName =     $("#postyourownform input#contact_name").val();
    var myContactPhone =    $("#postyourownform input#contact_phone").val();
    var myContactEmail =    $("#postyourownform input#contact_email").val();
    var myLocation       =  $("#postyourownform input#location").val() || $("#location option:selected").val();
    var myLocalarea =       $("#postyourownform input#locationDetailPost").val() || $("#locationDetailPost option:selected").val();
    var myStreet =          $("#postyourownform input#street").val();
    var myPostcode =        $("#postyourownform input#postcode").val();
    var myType =            $("#type option:selected").val(); 
    var myBedrooms =        $("#bedrooms option:selected").val(); 
    var myPrice =           $("#price option:selected").val(); 
    var myDescription =     $("#postyourownform input#property_description").val();
    
    if ( (isLoggedIn == 0) || (myName == "") || (myEmailAddress == "") || ( myContactName == "") || (myContactPhone == "" && myContactEmail == "") || (myLocation == "" || myLocalarea==""  ) || (myStreet == "") || (myPostcode == "") || (myType == "") || (myBedrooms == "") || (myBedrooms == "") ||  (myPrice == "") ||  (myDescription == "") )
    {
        returnVal = 1;
        if(isLoggedIn == 0)
        {
            myPassword1 = $("#postyourownformpassword input#password").val();
            myPassword2 = $("#postyourownformpassword input#password2").val();
            if   ( myPassword1 == "" || myPassword2 =="" )
            {            
                var pMessesage = "";
                if(myPassword1 == ""){ pMessage = "Password one is empty"; }
                if(myPassword2 == "" ){ pMessage = "Password two is empty"; }
                if(myPassword1 == "" && myPassword2 == ""  ){ pMessage = "Both passwords are empty"; }
                $("#post_premier_ul .password_fail").show();
                $("#post_premier_ul .password_fail span").text(pMessage);
                $("#post_premier_ul .password_fail span").show();
                $("#postahome_errors").show();
                returnVal = 'false';
            }else{
                $("#post_premier_ul .password_fail").hide();
                $("#post_premier_ul .password_fail span").hide();
            }
            if ( myPassword1 !== myPassword2  ) 
            {
                $("#post_premier_ul .password_mismatch").show();
                $("#post_premier_ul .password_mismatch span").show();
                $("#postahome_errors").show();
                returnVal = 'false';
            }else{
                $("#post_premier_ul .password_mismatch").show();
                $("#post_premier_ul .password_mismatch span").show();
            }
        }

        if (myName == "")
        {
            $("#post_premier_ul .invoice_name").show();
            $("#post_premier_ul .invoice_name span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .invoice_name").hide();
            $("#post_premier_ul .invoice_name span").hide();
        }
        if (myEmailAddress == "")
        {
            $("#post_premier_ul .invoice_email").show();
            $("#post_premier_ul .invoice_email span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .invoice_email").hide();
            $("#post_premier_ul .invoice_email span").hide();
        }
        if (myContactName == "" )
        {
            $("#post_premier_ul .contact_name").show();
            $("#post_premier_ul .contact_name span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .contact_name").hide();
            $("#post_premier_ul .contact_name span").hide();
        }
        if (myContactPhone == "" && myContactEmail == "")
        {
            $("#post_premier_ul .contact_phone").show();
            $("#post_premier_ul .contact_phone span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .contact_phone").hide();
            $("#post_premier_ul .contact_phone span").hide();
        }
        if (myLocation == "")
        {
            $("#post_premier_ul .location").show();
            $("#post_premier_ul .location span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .location").hide();
            $("#post_premier_ul .location span").hide();
        }
        if (myLocalarea == "")
        {
            $("#post_premier_ul .location").show();
            $("#post_premier_ul .location span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .location").hide();
            $("#post_premier_ul .location span").hide();
        }
        if (myStreet == "")
        {
            $("#post_premier_ul .street").show();
            $("#post_premier_ul .street span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .street").hide();
            $("#post_premier_ul .street span").hide();
        }
        if (myPostcode == "")
        {
            $("#post_premier_ul .postcode").show();
            $("#post_premier_ul .postcode span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .postcode").hide();
            $("#post_premier_ul .postcode span").hide();
        }
        if (myType == "")
        {
            $("#post_premier_ul .type").show();
            $("#post_premier_ul .type span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .type").hide();
            $("#post_premier_ul .type span").hide();
        }
        if (myBedrooms == "")
        {
            $("#post_premier_ul .bedrooms").show();
            $("#post_premier_ul .bedrooms span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .bedrooms").hide();
            $("#post_premier_ul .bedrooms span").hide();
        }
        if (myPrice == "")
        {
            $("#post_premier_ul .price").show();
            $("#post_premier_ul .price span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .price").hide();
            $("#post_premier_ul .price span").hide();
        }
        if (myDescription == "")
        {
            $("#post_premier_ul .property_description").show();
            $("#post_premier_ul .property_description span").show();
            returnVal = 'false';
        }else{
            $("#post_premier_ul .property_description").hide();
            $("#post_premier_ul .property_description span").hide();
        }
        if (returnVal =='false'){$("#postahome_errors").show(); return false;}
    }
    else
    {
        return true;
    }
}


function modifyProperty (misc)
{

	if(misc == 'extend')
	{
		document.location.href = "post-your-own-premier.html?extend=1&prop_id=" + document.form1.propid.value;
	}
	else if(document.form1.premier && document.form1.premier.value == 1 )
	{
		document.location.href = "post-your-own-premier.html?modify=1&prop_id=" + document.form1.propid.value;
	}
	else
	{
		document.location.href = "post-your-own.html?modify=1&prop_id=" + document.form1.propid.value;
	}
}


function sendEmail (cphone, cemail, iemail, iname)
{
	if ( window.ActiveXObject ) // if it's ie
	{
		xmlObjPostahome = new ActiveXObject("Microsoft.XMLHTTP"); // xmlObjPostahome is global
		xmlObjPostahome.onreadystatechange = function ()
		{
			if(xmlObjPostahome.readyState == 4) process(xmlObjPostahome.responseText);
		};
	}
	else
	{
		if (window.XMLHttpRequest) // if it's firefox etc.
		{
			xmlObjPostahome        = new XMLHttpRequest() // xmlObjPostahome is global
				xmlObjPostahome.onload = function () { process(xmlObjPostahome.responseText) };
		}
		else return; //
	}


	var url = "http://" + document.location.hostname + "/post/send_premium_number_alert.cgi";
	var params = "cphone=" + cphone + '&cemail=' + cemail + '&iemail=' + iemail + '&iname=' + iname;
	xmlObjPostahome.open("POST", url, true);
	//Send the proper header information along with the request
	xmlObjPostahome.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlObjPostahome.setRequestHeader("Content-length", params.length);
	xmlObjPostahome.setRequestHeader("Connection", "close");
	xmlObjPostahome.send(params);
}

function process()
{
	//dont need to do anything here
}


function getOtherLocationAreas ()
{
	if ( window.ActiveXObject ) // if it's ie
	{
		xmlObjPostahome = new ActiveXObject("Microsoft.XMLHTTP"); // xmlObjPostahome is global
		xmlObjPostahome.onreadystatechange = function ()
		{
			if(xmlObjPostahome.readyState == 4) writecontentPostOwn(xmlObjPostahome.responseText, 'locationSelect');
		};
	}
	else
	{
		if (window.XMLHttpRequest) // if it's firefox etc.
		{
			xmlObjPostahome        = new XMLHttpRequest() // xmlObjPostahome is global
			xmlObjPostahome.onload = function () { writecontentPostOwn(xmlObjPostahome.responseText, 'locationSelect') };
		}
		else return; //
	}

	if(document.postyourownform && (document.postyourownform.loggedin || document.postyourownform.password) )
	{
		if(!document.postyourownform.password)
		{
			alert('Please enter your password');
		}
	}

	var locationid="";
	if(document.postyourownform)
	{
		if(document.postyourownform.location.options)
		{
			var locationid = document.postyourownform.location.options[document.postyourownform.location.selectedIndex].value;
			var localareaid = document.postyourownform.localareaid.value;
		}
	}

	var targ = document.getElementById('locationHeader').style.display = 'block';
//	var targ = $("#locationHeader").text("Local area");
	
	if(locationid.match(/[0-9]/))
	{
		var url = "http://" + document.location.hostname + "/post/get_local_locations.cgi?locationid=" + locationid + '&localarea=' + localareaid;
		xmlObjPostahome.open("GET", url , true);
		xmlObjPostahome.send(null);
	}
	else
	{   
        //document.getElementById('locationHeader').style.display = 'none';
		//$("#locationHeader").text("Local area");
	}
}

function writecontentPostOwn (contentPostOwn, targetDiv )
{
    var targDivId = document.getElementById(targetDiv);
    if(targDivId){
		targDivId.innerHTML = contentPostOwn;
    }
}
