// JavaScript Document

function checkPhoto_1(picField) {
 var picFile = picField;
 var imagePath = document.FormTwo.picFile.value;
 var pathLength = imagePath.length;
 var lastDot = imagePath.lastIndexOf(".");
 var fileType = imagePath.substring(lastDot,pathLength);
 if((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG")) {
  return true;
 } else {
  return false;
 }
}

function field_validation()
{
	var contact_email=document.getElementById("contact_email").value;
	var contact_mobile_phone=document.getElementById("contact_mobile").value;
	var contact_home_phone=document.getElementById("contact_phone").value;
	//var contact_office_phone=document.getElementById("contact_office_phone").value;
	
	if(validateMailId(contact_email) || validatePhone(contact_mobile_phone) || validatePhone(contact_home_phone))
	{
		if((document.getElementById("np_builder_logo"))&&(document.getElementById("np_builder_logo").value!=""))
		{
			
				 var imagePath = document.getElementById("np_builder_logo").value;
				 var pathLength = imagePath.length;
				 var lastDot = imagePath.lastIndexOf(".");
				 var fileType = imagePath.substring(lastDot,pathLength);
				 if(!((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))) {
				  alert("Please upload .JPG, .PNG, and .GIF image formats in Builder Logo");
				return false;
				 } 
		}
		if((document.getElementById("layout_plan_1"))&&(document.getElementById("layout_plan_1").value!=""))
		{
			
				 var imagePath = document.getElementById("layout_plan_1").value;
				 var pathLength = imagePath.length;
				 var lastDot = imagePath.lastIndexOf(".");
				 var fileType = imagePath.substring(lastDot,pathLength);
				 if(!((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))) {
				  alert("Please upload .JPG, .PNG, and .GIF image formats in Layout Plan");
				return false;
				 } 
		}
		if((document.getElementById("layout_plan_2"))&&(document.getElementById("layout_plan_2").value!=""))
		{
			
				 var imagePath = document.getElementById("layout_plan_2").value;
				 var pathLength = imagePath.length;
				 var lastDot = imagePath.lastIndexOf(".");
				 var fileType = imagePath.substring(lastDot,pathLength);
				 if(!((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))) {
				  alert("Please upload .JPG, .PNG, and .GIF image formats in Location Plan");
				return false;
				 } 
		}
		if((document.getElementById("layout_plan_3"))&&(document.getElementById("layout_plan_3").value!=""))
		{
			
				 var imagePath = document.getElementById("layout_plan_3").value;
				 var pathLength = imagePath.length;
				 var lastDot = imagePath.lastIndexOf(".");
				 var fileType = imagePath.substring(lastDot,pathLength);
				 if(!((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))) {
				  alert("Please upload .JPG, .PNG, and .GIF image formats in Master Plan");
				return false;
				 } 
		}
		
		if((document.getElementById("layout_plan_4"))&&(document.getElementById("layout_plan_4").value!=""))
		{
			
				 var imagePath = document.getElementById("layout_plan_4").value;
				 var pathLength = imagePath.length;
				 var lastDot = imagePath.lastIndexOf(".");
				 var fileType = imagePath.substring(lastDot,pathLength);
				 if(!((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))) {
				  alert("Please upload .JPG, .PNG, and .GIF image formats in Site Plan");
				return false;
				 } 
		}
		
		
		
		var Tot_Property = document.getElementById("total_property_no").value;
		for(var i=1; i<=Tot_Property; i++)
		{
			if((document.getElementById("floor_plan"+i))&&(document.getElementById("floor_plan"+i).value!=""))
				{
					
						 var imagePath = document.getElementById("floor_plan"+i).value;
						 var pathLength = imagePath.length;
						 var lastDot = imagePath.lastIndexOf(".");
						 var fileType = imagePath.substring(lastDot,pathLength);
						 if(!((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))) {
						  alert("Please upload .JPG, .PNG, and .GIF image formats in Floor Plan in Property# "+i);
						return false;
						 } 
				}
			if((document.getElementById("image_upload"+i))&&(document.getElementById("image_upload"+i).value!=""))
				{
					
						 var imagePath = document.getElementById("image_upload"+i).value;
						 var pathLength = imagePath.length;
						 var lastDot = imagePath.lastIndexOf(".");
						 var fileType = imagePath.substring(lastDot,pathLength);
						 if(!((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))) {
						  alert("Please upload .JPG, .PNG, and .GIF image formats in Image Upload in Property# "+i);
						return false;
						 } 
				}
			if((document.getElementById("specification"+i))&&(document.getElementById("specification"+i).value!=""))
				{
					
						 var imagePath = document.getElementById("specification"+i).value;
						 var pathLength = imagePath.length;
						 var lastDot = imagePath.lastIndexOf(".");
						 var fileType = imagePath.substring(lastDot,pathLength);
						 if(!((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG"))) {
						  alert("Please upload .JPG, .PNG, and .GIF image formats in Specification in Property# "+i);
						return false;
						 } 
				}
		}
		
		return true;
	}
	else
	{
		alert("We need valid contact Email or Mobile/Phone no.");
		return false;
	}
}
