// JavaScript Document

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function verifyIt() {
	var form = document.forms[0]
	for (i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "text" && form.elements[i].value == ""){
			alert("Please fill out all fields.")
			form.elements[i].focus()
			break
		}
		// more tests
	}
	// more statements
}


function textCounter( field, countfield, maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
    alert( 'You have reached the character limit' );
    return false;
  }
  else
  {
    countfield.value = maxlimit - field.value.length;
  }
}

function tmt_confirm(msg){
	document.MM_returnValue=(confirm(unescape('Please review your submission information now! If correct, press "ok".%0D%0ATo edit your submission, click cancel and make any needed changes.%0D%0A')));
}
function confirmDelete(msg){
	document.MM_returnValue=(confirm(unescape('Deleting cannot be undone!%0D%0AIf you dont want it displayed on your listings, click cancel and change the status to "hold".\nIf you are sure you want this property deleted, press "ok".%0D%0A')));
}
function confirmDeleteOne(msg){
	document.MM_returnValue=(confirm(unescape('Deleting cannot be undone!%0D%0AAre you sure you want this item deleted?%0D%0A')));
}
function verifyNewListings(){
if (document.NewListings.MLSNo.value=="")
		{
	alert("MLS No is Required.");
	document.NewListings.MLSNo.focus();
	return false;
		}
if (!IsNumeric(document.NewListings.MLSNo.value)) 
   { 
      alert('Please enter only numbers in the MLS Number field') 
      document.NewListings.MLSNo.focus(); 
      return false; 
      }
if (document.NewListings.City.value=="")
		{
	alert("City is Required.");
	document.NewListings.City.focus();
	return false;
		}

if (document.NewListings.Remarks.value=="")
		{
	alert("Property Remarks are Required.");
	document.NewListings.Remarks.focus();
	return false;
		}
   if (document.NewListings.price.value=="")
		{
	alert("Property price is Required.");
	document.NewListings.price.focus();
	return false;
		}
if (!IsNumeric(document.NewListings.price.value)) 
      { 
      alert('Please enter only numbers in the Price field') 
      document.NewListings.price.focus(); 
      return false; 
      }
if (document.NewListings.PropertyType.value=="")
		{
	alert("Property type is Required.");
	document.NewListings.PropertyType.focus();
	return false;
		}
if (document.NewListings.BedRooms.value=="")
		{
	alert("Number of Bedrooms is Required.");
	document.NewListings.BedRooms.focus();
	return false;
		}
if (!IsNumeric(document.NewListings.BedRooms.value)) 
   { 
      alert('Please enter only numbers in the Bedrooms field') 
      document.NewListings.BedRooms.focus(); 
      return false; 
      }
if (document.NewListings.FullBaths.value=="")
		{
	alert("Number of fullbaths is Required.");
	document.NewListings.FullBaths.focus();
	return false;
		}
if (!IsNumeric(document.NewListings.FullBaths.value)) 
   { 
      alert('Please enter only numbers in the FullBaths field') 
      document.NewListings.FullBaths.focus(); 
      return false; 
      }
if (document.NewListings.HalfBaths.value=="")
		{
	alert("Number of halfbaths is Required.");
	document.NewListings.HalfBaths.focus();
	return false;
		}
if (!IsNumeric(document.NewListings.HalfBaths.value)) 
   { 
      alert('Please enter only numbers in the Halfbaths field') 
      document.NewListings.HalfBaths.focus(); 
      return false; 
      }
if (document.NewListings.County.value=="")
		{
	alert("Property's County is Required.");
	document.NewListings.County.focus();
	return false;
		}
if (!IsNumeric(document.NewListings.Acres.value)) 
   { 
      alert('Please enter only numbers in the Acres field') 
      document.NewListings.Acres.focus(); 
      return false; 
      }
	document.NewListings.submit();
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char; 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
   }
   
function ReqPDFField(){
if (document.PDFUP.Brochure.value=="")
		{
	alert("Brochure is Required.");
	document.PDFUP.Brochure.focus();
	return false;
		}
		document.PDFUP.submit();
	}
	
function ReqVideoField(){
if (document.VideoUP.Video.value=="")
		{
	alert("Video Field is Required.");
	document.VideoUP.Video.focus();
	return false;
		}
		document.VideoUP.submit();
	}
function printDate()  {
dayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); 
monthNames = new Array('January','February','March','April','May','June',
'July','August','September','October','November','December');
  
today = new Date();
k = today.getDate();
while(k>10)
k=k-10;
  switch(k)  
  {
  case 1:
  suffix="st"; break;
  case 2:
  suffix="nd"; break;
  case 3:
  suffix="rd"; break;
  default:
  suffix="th";
  }
return dayNames[today.getDay()]+',  '+monthNames[today.getMonth()]+' '+today.getDate()+suffix;
}

function evalSelection(){
var anyOneIsChecked=false;
	for(var i=0; i<document.massLbl.Label.length; i++){
		if(document.massLbl.Label[i].checked){
			anyOneIsChecked=true;
		}
	}
	if(anyOneIsChecked) {
		document.massLbl.submit()
	}else{
		alert("You must select at least one")
	}
}


function evalSelectionEnv(){
var anyOneIsChecked=false;
	for(var i=0; i<document.massEnv.Envelope.length; i++){
		if(document.massEnv.Envelope[i].checked){
			anyOneIsChecked=true;
		}
	}
	if(anyOneIsChecked) {
		document.massEnv.submit()
	}else{
		alert("You must select at least one")
	}
}