function PopUp(id){
	if(id!=""){
		var strURL = "/photo.asp?id=" + id
		var objPhotoWindow = window.open(strURL,'photo','height=500,width=550,left=10,top=10,directories=0,fullscreen=0,location=0,menubar=0,scrollbars=1,resizable=0,status=0,toolbar=0');
	}

}


function SetOther(){
	for (var i=0; i < document.climateform.Climate.length; i++){
	   if (document.climateform.Climate[i].value=="Other"){
		  	document.climateform.Climate[i].checked=true
	  	}
	}
}


function strTrim(strText) {
		for (i=0; i<strText.length; ++i) {
			if (strText.charAt(i) != ' ') break;
		}
		if (i >= strText.length) return ('');
		if (i > 0) strText = strText.substring(i, strText.length);
		for (j=strText.length-1; j > i; --j) {
			if (strText.charAt(j) != ' ') break;
		}
		if (j < strText.length -1)
			strText = strText.substring(0, j+1);
		return strText;

}

function ValidEmail(email)
{
	  var result = false
	  var theStr = new String(email)
	  var index = theStr.indexOf("@");
	  if (index > 0)
	  {
	    var pindex = theStr.indexOf(".",index);
	    if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	  }
	  if (theStr.indexOf(" ") > 0 )  return false;  
	  if (theStr.indexOf("@", index + 1) > 0 ) return false;
	  return result;
}

function ValidateForm(obj){

	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;

	// trim the values of white space

	var strContactName = strTrim(obj.ContactName.value);
	var strBusinessName = strTrim(obj.BusinessName.value);
	var strTelephone = strTrim(obj.Telephone.value);
	var strEmail = strTrim(obj.Email.value);
	var strLocation = strTrim(obj.Location.value);


	if (strContactName==""){
		strAlert += "- Enter your name\n";
		isAlert = true;
	}
	if (strBusinessName==""){
		strAlert += "- Enter your Business name or type\n";
		isAlert = true;
	}
	if (strTelephone==""){
		strAlert += "- Enter your phone number\n";
		isAlert = true;
	}
	if (!ValidEmail(strEmail)){
		strAlert += "- Enter a valid email address\n";
		isAlert = true;
	}
	if (obj.OrnamentalPlants.checked || obj.Flowers.checked || obj.Vegetables.checked){
		//OK
	}else if(obj.Other.checked && strTrim(obj.OtherPlants.value)==""){
		strAlert += "- Specify what 'Other' plants you grow\n";
		isAlert = true;	
	}else{
		strAlert += "- Select what plants you grow\n";
		isAlert = true;		
	
	}
	if (obj.RainandWind.checked || obj.Ventilation.checked || obj.OptimumLight.checked || obj.HighTemperatures.checked || obj.LowTemperatures.checked || obj.HumidityControl.checked || obj.AirCirculation.checked || obj.InsectProtection.checked || obj.WaterAndNutrientSavings.checked || obj.ControlSystems.checked) {
		// OK
	}else{
		strAlert += "- Select at least one concern\n";
		isAlert = true;	
	}		

	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}	
}