// JavaScript Document
//---------------------Real Estate Validation
function real_estate_validation()
{
	if(frm.reference_number.value=="")
	{
		alert("Please enter the REFERENCE NUMBER");
		frm.reference_number.focus();
		return false;
	}
	
	if(frm.title.value=="")
	{
		alert("Please enter the TITLE");
		frm.title.focus();
		return false;
	}
	
	if(frm.thumb_image.value=="" || frm.delete_thumb_image.checked==1)
	 {
		if(frm.thumbnail_image.value=="")
		{
			alert("Please select the THUMBNAIL IMAGE");
			frm.thumbnail_image.focus();
			return false;
		}
	 }
	
	if(frm.address.value=="")
	{
		alert("Please enter the ADDRESS");
		frm.address.focus();
		return false;
	}
	
	if(frm.city.value=="")
	{
		alert("Please Select the CITY");
		frm.city.focus();
		return false;
	}
	
	if(frm.state.value=="")
	{
		alert("Please Select the STATE");
		frm.state.focus();
		return false;
	}
	
	if(frm.zip_code.value=="")
	{
		alert("Please enter the ZIP CODE");
		frm.zip_code.focus();
		return false;
	}
	
	if(frm.status.value=="")
	{
		alert("Please select the STATUS");
		frm.status.focus();
		return false;
	}
	
	if(frm.price.value=="")
	{
		alert("Please enter the PRICE");
		frm.price.focus();
		return false;
	}
	
	buffer="";
			for (var i=1; i < frm.inside_features.length-1; i++)
				{ 	
					if (frm.inside_features.options[i].selected)
	
						buffer=buffer+frm.inside_features.options[i].value+"_";			
				}
		frm.collect_inside_features.value=buffer;
		
	buffer="";
			for (var i=1; i < frm.outside_features.length-1; i++)
				{ 	
					if (frm.outside_features.options[i].selected)
	
						buffer=buffer+frm.outside_features.options[i].value+"_";			
				}
		frm.collect_outside_features.value=buffer;
		
	buffer="";
			for (var i=1; i < frm.other_features.length-1; i++)
				{ 	
					if (frm.other_features.options[i].selected)
	
						buffer=buffer+frm.other_features.options[i].value+"_";			
				}
		frm.collect_other_features.value=buffer;

}


function calendar_validation()
{
date=new Date();
month=date.getMonth()+1;
day=date.getDate();
year=date.getFullYear();

if(frm.title.value=="")
{
alert("Please enter the TITLE of event");
frm.title.focus();
return false;
}
if(frm.place.value=="")
{
alert("Please enter the PLACE of event");
frm.place.focus();
return false;
}
if(frm.start_date.value=="")
{
alert("Please enter the START DATE of event");
frm.start_date.focus();
return false;
}
if(frm.end_date.value=="")
{
alert("Please enter the END DATE of event");
frm.end_date.focus();
return false;
}
{
split_start_date=frm.start_date.value.split("-");
split_end_date=frm.end_date.value.split("-");

if(isNaN(split_start_date[2]) || isNaN(split_start_date[1]) || isNaN(split_start_date[0]))
{
alert("Invalid START DATE of event");
frm.start_date.focus();
return false;
}

if(isNaN(split_end_date[2]) || isNaN(split_end_date[1]) || isNaN(split_end_date[0]))
{
alert("Invalid END DATE of event");
frm.end_date.focus();
return false;
}

if(split_start_date[2]<year)
{
alert("Invalid START DATE of event");
frm.start_date.focus();
return false;
}

if(split_start_date[0]<month && split_start_date[2]==year)
{
alert("Invalid START DATE of event");
frm.start_date.focus();
return false;
}

if(split_start_date[1]<day && split_start_date[0]==month && split_start_date[2]==year)
{
alert("Invalid START DATE of event");
frm.start_date.focus();
return false;
}

if(split_end_date[2]<year)
{
alert("Invalid END DATE of event");
frm.end_date.focus();
return false;
}

if(split_end_date[0]<month && split_end_date[2]==year)
{
alert("Invalid END DATE of event");
frm.end_date.focus();
return false;
}

if(split_end_date[1]<day && split_end_date[0]==month && split_end_date[2]==year)
{
alert("Invalid END DATE of event");
frm.end_date.focus();
return false;
}

if(split_end_date[2]<split_start_date[2])
{
alert("Invalid PERIOD of event");
frm.end_date.focus();
return false;
}

if(split_end_date[0]<split_start_date[0] && split_end_date[2]==split_start_date[2])
{
alert("Invalid PERIOD of event");
frm.end_date.focus();
return false;
}

if(split_end_date[1]<split_start_date[1] && split_end_date[0]==split_start_date[0] && split_end_date[2]==split_start_date[2])
{
alert("Invalid PERIOD of event");
frm.end_date.focus();
return false;
}

}
if(frm.repeat.value=="Week")
{
i=0;
buffer="";
for(i=0;i<frm.period_week_name.length;i++)
	{
		if(frm.period_week_name.options[i].selected)
		buffer=buffer+frm.period_week_name.options[i].value+",";
	}
frm.collect_days_name.value=buffer;
}

}


function edit_calendar_validation()
{
date=new Date();
month=date.getMonth()+1;
day=date.getDate();
year=date.getFullYear();

if(frm.title.value=="")
{
alert("Please enter the TITLE of event");
frm.title.focus();
return false;
}
if(frm.place.value=="")
{
alert("Please enter the PLACE of event");
frm.place.focus();
return false;
}

if(frm.start_date.value=="")
{
alert("Please enter the START DATE of event");
frm.start_date.focus();
return false;
}
if(frm.end_date.value=="")
{
alert("Please enter the END DATE of event");
frm.end_date.focus();
return false;
}
{
split_start_date=frm.start_date.value.split("-");
split_end_date=frm.end_date.value.split("-");


	if(isNaN(split_start_date[2]) || isNaN(split_start_date[1]) || isNaN(split_start_date[0]))
	{
	alert("Invalid START DATE of event");
	frm.start_date.focus();
	return false;
	}

	if(isNaN(split_end_date[2]) || isNaN(split_end_date[1]) || isNaN(split_end_date[0]))
	{
	alert("Invalid END DATE of event");
	frm.end_date.focus();
	return false;
	}

if(frm.initial_start_date.value!=split_start_date[2]+"-"+split_start_date[0]+"-"+split_start_date[1])
{

		if(split_start_date[2]<year)
		{
		alert("Invalid START DATE of event");
		frm.start_date.focus();
		return false;
		}
		
		if(split_start_date[0]<month && split_start_date[2]==year)
		{
		alert("Invalid START DATE of event");
		frm.start_date.focus();
		return false;
		}
		
		if(split_start_date[1]<day && split_start_date[0]==month && split_start_date[2]==year)
		{
		alert("Invalid START DATE of event");
		frm.start_date.focus();
		return false;
		}


		if(split_end_date[0]<split_start_date[0])
		{
		alert("Invalid PERIOD of event");
		frm.end_date.focus();
		return false;
		}

		if(split_end_date[1]<split_start_date[1] && split_end_date[0]==split_start_date[0])
		{
		alert("Invalid PERIOD of event");
		frm.end_date.focus();
		return false;
		}

		if(split_end_date[2]<split_start_date[2] && split_end_date[1]==split_start_date[1] && split_end_date[0]==split_start_date[0])
		{
		alert("Invalid PERIOD of event");
		frm.end_date.focus();
		return false;
		}
}

}
if(frm.repeat.value=="Week")
{
i=0;
buffer="";
for(i=0;i<frm.period_week_name.length;i++)
	{
		if(frm.period_week_name.options[i].selected)
		buffer=buffer+frm.period_week_name.options[i].value+",";
	}
frm.collect_days_name.value=buffer;
}

}


function valid_administrator()
{
if(admin_frm.username.value=="")
{
alert("Please enter the USERNAME");
admin_frm.username.focus();
return false;
}
else

if(admin_frm.password.value=="")
{
alert("Please enter the PASSWORD");
admin_frm.password.focus();
return false;
}

else
if(admin_frm.re_type_password.value=="")
{
alert("Please retype your PASSWORD");
admin_frm.re_type_password.focus();
return false;
}

else
if(admin_frm.re_type_password.value!=admin_frm.password.value)
{
alert("The confirmation PASSWORD doesn't match the origin one");
admin_frm.re_type_password.value="";
admin_frm.re_type_password.focus();
return false;
}
}

function valid_contact_us()
{
if(contact_us_frm.main_name.value=="")
	{
		alert("Please enter the MAIN NAME");
		contact_us_frm.main_name.focus();
		return false;
	}
if(contact_us_frm.telephone1.value=="")
	{
		alert("Please enter the TELEPHONE");
		contact_us_frm.telephone1.focus();
		return false;
	}
if(contact_us_frm.zip.value=="")
	{
		alert("Please enter the ZIP CODE");
		contact_us_frm.zip.focus();
		return false;
	}
if(contact_us_frm.address.value=="")
	{
		alert("Please enter the ADDRESS");
		contact_us_frm.address.focus();
		return false;
	}
if(contact_us_frm.city.value=="")
	{
		alert("Please enter the CITY");
		contact_us_frm.city.focus();
		return false;
	}
if(contact_us_frm.contact_email.value=="")
	{
		alert("Please enter the CONTACT EMAIL");
		contact_us_frm.contact_email.focus();
		return false;
	}
}

function valid_config_infomation()
{
if(config_frm.site_url.value=="")
	{
		alert("Please enter the URL");
		config_frm.site_url.focus();
		return false;
	}
if(config_frm.site_name.value=="")
	{
		alert("Please enter the Site Name");
		config_frm.site_name.focus();
		return false;
	}	
if(config_frm.title_bar.value=="")
	{
		alert("Please enter the TITLE of WEBSITE");
		config_frm.title_bar.focus();
		return false;
	}
if(config_frm.administrator_email.value=="")
	{
		alert("Please enter the Administrator Email");
		config_frm.administrator_email.focus();
		return false;
	}
if(config_frm.max_file_size.value=="")
	{
		alert("Please enter the MAXIMUM FILE SIZE");
		config_frm.max_file_size.focus();
		return false;
	}
if(isNaN(config_frm.max_file_size.value))
	{
		alert("Invalid MAXIMUM FILE SIZE");
		config_frm.max_file_size.focus();
		return false;
	}
if(config_frm.main_result_per_page.value=="")
	{
		alert("Please enter the Main Result Per Page");
		config_frm.main_result_per_page.focus();
		return false;
	}
if(isNaN(config_frm.main_result_per_page.value))
	{
		alert("Invalid Main Result Per Page");
		config_frm.main_result_per_page.focus();
		return false;
	}
if(config_frm.main_result_per_box.value=="")
	{
		alert("Please enter the Main Result Per Box");
		config_frm.main_result_per_box.focus();
		return false;
	}
if(isNaN(config_frm.main_result_per_box.value))
	{
		alert("Invalid Main Result Per Box");
		config_frm.main_result_per_box.focus();
		return false;
	}
}

function valid_about_us()
{

 if(frm.title.value=="")
	 {
		alert("Please enter the title");
		frm.title.focus();
		return false;
     }
}


function valid_photo_infomation()
{

if(frm.max_photo_size.value=="")
	{
		alert("Please enter the MAXIMUM PHOTO SIZE");
		frm.max_photo_size.focus();
		return false;
	}
if(isNaN(frm.max_photo_size.value))
	{
		alert("Invalid MAXIMUM PHOTO SIZE");
		frm.max_photo_size.focus();
		return false;
	}
if(frm.thumbnail_width.value=="")
	{
		alert("Please enter the IMAGE THUMBNAIL WIDTH");
		frm.thumbnail_width.focus();
		return false;
	}
if(isNaN(frm.thumbnail_width.value))
	{
		alert("Invalid IMAGE THUMBNAIL WIDTH");
		frm.thumbnail_width.focus();
		return false;
	}
if(frm.thumbnail_height.value=="")
	{
		alert("Please enter the IMAGE THUMBNAIL HEIGHT");
		frm.thumbnail_height.focus();
		return false;
	}
if(isNaN(frm.thumbnail_height.value))
	{
		alert("Invalid IMAGE THUMBNAIL HEIGHT");
		frm.thumbnail_height.focus();
		return false;
	}
if(frm.image_width.value=="")
	{
		alert("Please enter the IMAGE WIDTH");
		frm.image_width.focus();
		return false;
	}
if(isNaN(frm.image_width.value))
	{
		alert("Invalid IMAGE WIDTH");
		frm.image_width.focus();
		return false;
	}
if(frm.image_height.value=="")
	{
		alert("Please enter the IMAGE HEIGHT");
		frm.image_height.focus();
		return false;
	}
if(isNaN(frm.image_height.value))
	{
		alert("Invalid IMAGE HEIGHT");
		frm.image_height.focus();
		return false;
	}
if(frm.main_photos_per_page.value=="")
	{
		alert("Please enter the NUMBER OF IMAGES PER ROW");
		frm.main_photos_per_page.focus();
		return false;
	}
if(isNaN(frm.main_photos_per_page.value))
	{
		alert("Invalid NUMBER OF IMAGES PER ROW");
		frm.main_photos_per_page.focus();
		return false;
	}
}


function client_contact_us_validation()
 {
  if(frm.name.value=="")
   {
     alert("please enter First NAME");
	 frm.name.focus();
	 return false;
   }
   if(frm.phone.value=="")
   {
     alert("please enter PHONE Number");
	 frm.phone.focus();
	 return false;
   }
   if(frm.email.value=="")
   {
     alert("please enter YOUR EMAIL");
	 frm.email.focus();
	 return false;
   }
 }

function dream_home_validation()
{
	if(frm.name.value=="")
   	{
     alert("please enter Your Name");
	 frm.name.focus();
	 return false;
    }
	if(frm.e_mail.value=="")
   	{
     alert("please enter Email Address");
	 frm.e_mail.focus();
	 return false;
    }
	if(frm.mail_address.value=="")
   	{
     alert("please enter Your Mail Address");
	 frm.mail_address.focus();
	 return false;
    }
	if(frm.city.value=="")
   	{
     alert("please enter the City");
	 frm.city.focus();
	 return false;
    }
	if(frm.state.value=="")
   	{
     alert("please select the State");
	 frm.state.focus();
	 return false;
    }
	if(frm.home_telephone.value=="")
   	{
     alert("please enter Home Telephone");
	 frm.home_telephone.focus();
	 return false;
    }
}

function home_mortgage_validation()
{
	if(frm.name.value=="")
   	{
     alert("please enter Your Name");
	 frm.name.focus();
	 return false;
    }
	if(frm.e_mail.value=="")
   	{
     alert("please enter Email Address");
	 frm.e_mail.focus();
	 return false;
    }
		if(frm.home_telephone.value=="")
   	{
     alert("please enter Home Telephone");
	 frm.home_telephone.focus();
	 return false;
    }
	if(frm.home_address.value=="")
   	{
     alert("please enter Your Home Address");
	 frm.home_address.focus();
	 return false;
    }
	if(frm.city.value=="")
   	{
     alert("please enter the City");
	 frm.city.focus();
	 return false;
    }
	if(frm.state.value=="")
   	{
     alert("please select the State");
	 frm.state.focus();
	 return false;
    }
}