
function delProjectPhoto1(imageno)
{
  if(confirm("Are you sure sure want to delete this photo?"))
  {
  	document.frmClassified.act.value="delPhoto";
	document.frmClassified.imageno.value=imageno;
  	document.frmClassified.submit();
  }
}


function trimSpaces(stringValue) {
	// Checks the first occurance of spaces and removes them
	for(i = 0; i < stringValue.length; i++) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i > 0) {
		stringValue = stringValue.substring(i);
	}
	
	// Checks the last occurance of spaces and removes them
	strLength = stringValue.length - 1;
	for(i = strLength; i >= 0; i--) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i < strLength) {
		stringValue = stringValue.substring(0, i + 1);
	}
	
	// Returns the string after removing leading and trailing spaces.
	return stringValue;
}

function checkEmail(emailString) {
	splitVal = emailString.split('@');
	if(splitVal.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitVal[0].length <= 0 || splitVal[1].length <= 0) {
		alert("Please enter a valid email address");
		return false;
	}
	
	splitDomain = splitVal[1].split('.');
	if(splitDomain.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitDomain[0].length <= 0 || splitDomain[1].length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	return true;
}

//---------------------From Prasanth----------------------------//

function siteName()
{
document.forms[0].sitename.focus();
if(document.forms[0].sitename.value.length<=0)
{
alert("Please enter your sitename");
(document.forms[0].sitename.focus());
return false;
}
return true;
}

//-personal Information-//

//--------------------------------------------------------
function chkAbt()
{
confirm("Are you sure");
return true;
}
function chkCnt()
{
return true;
}
function checkuser()
{
builduname = trimSpaces(document.login.username.value);
buildpword = trimSpaces(document.login.password.value);
if(builduname.length<=0)
 {
 alert("Please enter the userID");
 document.login.username.focus();
 return false;
 }
  if(buildpword.length<=0)
  {
	alert("Please enter the password");
	document.login.password.focus();
  return false;
  }
	return true;
}



function user()
{
builduname = trimSpaces(document.form1.username.value);
buildpword = trimSpaces(document.form1.password.value);
if(builduname.length<=0)
 {
 alert("Please enter the userID");
 document.form1.username.focus();
 return false;
 }
  if(buildpword.length<=0)
  {
	alert("Please enter the password");
	document.form1.password.focus();
  return false;
  }
	return true;
}


function chksearch()
{
if(document.qsearch.pin.value!="")
{
if(isNaN(document.qsearch.pin.value))
{
alert("Please enter a valid number for the price"); 
//document.forms[0].lprice.value="";
document.qsearch.pin.value = "";
document.qsearch.pin.focus();
return false;
}
}

//window.location.href="../php/searchResult.php";
//return true;
}

function chkkeysearch()
{
if(document.keysearch.keyword.value=="")
{
	alert("Please enter a keyword for the search"); 
//document.forms[0].lprice.value="";
document.keysearch.keyword.focus();
return false;
}
}
//-------------------------------------------------------------//


								//Functions by AJU on 26/08/2005//

function addProject()
{
	document.location.href="displayAddProject.php";
}

function gotoprojectlist(projectTypeID)
{
	document.location.href="listProjects.php?selectProject="+projectTypeID;
}

function gotoprojectlist1()
{
	document.location.href="listProjects1.php";
}
function gotoprojectdetails(prid)
{
	document.location.href="projectDetails.php?pro_id="+prid;
}

function editPrjRedirect(prid)
{
	document.location.href="editProject.php?pro_id="+prid;
}

function modifyPrjRedirect()
{
	document.frmModify.act.value="modify";
	document.frmModify.submit();
}

function delProject(prid)
{
	if(confirm("Do you want to remove the porject?"))
	{
		document.location.href="deleteProject.php?pro_id="+prid;
	}
}

function showProjectPhoto(photoname) 
{ 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 450;
	winHeight = 400;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2; 
	window.open("showProjectPhoto.php?photoname=" + photoname,"ProjectPhoto","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function showProjectPhoto1(photoname) 
{ 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 450;
	winHeight = 400;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2; 
	window.open("showProjectPhoto1.php?photoname=" + photoname,"ProjectPhoto","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function delProjectPhoto(imageno)
{
  if(confirm("Are you sure sure want to delete this photo?"))
  {
  	document.frmModify.act.value="delPhoto";
	document.frmModify.imageno.value=imageno;
  	document.frmModify.submit();
  }
}

function deleteprojectlist(prid)
{
	if(confirm("Do you want to remove the porject?"))
	{
		document.frmListProjects.action.value="deleteprojects";
		document.frmListProjects.submit();
	}
}

function gotolistdistrict(distId)
{
	document.location.href="listDistrict.php?selectDistrict="+distId;
}

function advsearch(proid)
{
	document.forms[0].pro_id.value=proid;
	document.forms[0].submit();	
}

function delclassified()
{
	document.form1.del.value="delete";
	document.form1.submit();
}
function classiSearchresult()
{
	document.frmClassicSearch.action="classiSearchresult.php";
	document.frmClassicSearch.submit();
}


/////////////////////
function chkSubmit1()
{
	document.contact.email.value=trimSpaces(document.contact.email.value);
	
	if(document.contact.email.value.length<=0)
	 {
	 	alert("Enter Email Id");
		document.contact.email.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.contact.email.value))
	   {
		document.contact.email.focus();
	    return false;
	   }
	 }  
	 
	 
	
	
}


function openDynWindow(url) { 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 700;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open(url, "Reviews", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}


function showFloorPhoto(photoname) 
{ 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 600;
	winHeight = 600;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2; 
	window.open("showFloorPlanPhoto.php?photoname=" + photoname,"ProjectPhoto","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}



function showClassiPhoto(photoname) 
{ 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 600;
	winHeight = 600;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2; 
	window.open("showClassiPhoto.php?photoname=" + photoname,"ProjectPhoto","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}

function editClsRedirect(clid)
{
	document.location.href="editBuildClassi.php?pro_id="+classid;
}

function modifyClsRedirect()
{
	document.form1.act.value="modify";
	document.form1.submit();
}

function delClassiPhoto($classid)
{
 // if(confirm("Are you sure sure want to delete this photo?"))
 // {
		//document.location.href="editBuildClassi.php?classid="+$classid;
  //}
}