// commission calc zero check
function checkZero()
{
   if (document.commcalc.saleprice.value == '')
   {
      alert ("please enter a sale price value");
      return false;
   }
   else
   {
      return true;
   }
}

// exclusive/listing signup date copier
function calcDates(s)
{
   var d = s.options[s.selectedIndex].value;
   if (s.selectedIndex == 1)
   {
      document.all['exclusive_start'].value = document.all['datelisted'].value;
   }
}


// open listing print window
function openListingDetails(d)
{
   window.open("./includes/listing_printout.php?ag="+d);//,"listingwindow","scrollbars=yes,menubar=0,resizable=1,width=1024,height=768;");
}
// open listing print window
function openListingDetailsTMP()
{
   window.open("./includes/tmp_listing_printout.php","listingwindow"); // ,"scrollbars=yes,menubar=1,resizable=1,width=1024,height=768;");
}

// print page...minus selected DIV tags  : )
function printPage()
{
   var numDivs = 20;
   for(i=1;i<numDivs;i++) {
     if(document.all['divNoPrint'+i]){
       document.all['divNoPrint'+i].style.display = 'none'; }
    }
   window.print();
   for(i=1;i<numDivs;i++) {
     if(document.all['divNoPrint'+i]){
       document.all['divNoPrint'+i].style.display = ''; }
    } 
}

// function for redirect on dropdown change
function GoDropDown(s)
{
   var d = s.options[s.selectedIndex].value;
   window.location.href = d;
   s.selectedIndex=0;
}

// integer only input
function intOnly(i)
{
   if(i.value.length>0)
   {
      i.value = i.value.replace(/[^\d]+/g,''); 
   }
}

// copy address details between form fields
function clickIfSame()
{
   // copy property details to vendor address if required
   document.addlisting.vendoraddress01.value = document.addlisting.address01.value
   document.addlisting.vendoraddress02.value = document.addlisting.address02.value
   document.addlisting.vendorsuburb.value = document.addlisting.suburb.value
   document.addlisting.vendorpostcode.value = document.addlisting.postcode.value
}

function checkForm()
{
   err = 0;
   errmsg = '';
   if (document.addlisting.agencytype.value == 'null')
   {
      err = 1;
      errmsg = errmsg + "please select an agency type\r\n";
   }
   if (document.addlisting.sales_agent.value == 'null')
   {
      err = 1;
      errmsg = errmsg + "please select a sales agent\r\n";
   }
   if (document.addlisting.listingprice.value == '')
   {
      err = 1;
      errmsg = errmsg + "please insert a listing price";
   }
   if (err == 1)
   {
      alert(errmsg);
      return false;
   }
   else
   {
      return true;
   }
}
function popUp(strURL,strType,strHeight,strWidth,starRating)
{
	var strOptions="";
	if (strType=="console") strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth;
	if (strType=="fixedconsole") strOptions="height="+strHeight+",width="+strWidth;
	if (strType=="fixed") strOptions="status,scrollbars,top=100,left=250,height="+strHeight+",width="+strWidth+",star_rating="+starRating;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,top=80,left=200,resizable,location,height="+strHeight+",width="+strWidth;
	window.open(strURL, 'newWin', strOptions);
}
// ---------------------------------
// ---- Flip Navigation Buttons ----
// ---------------------------------
function flipButtons(flipID,flipImage)
{
	if (flipID == 0)
	{
		if (flipImage == 'On')
		{
			document.getElementById("startHere").className = 'clickHereToStartOn';
		}
		else
		{
			document.getElementById("startHere").className = 'clickHereToStartOff';
		}
	}
}