//PROD
//var secureURLStart = "https://www.reservationsoftwareonline.com/";
//var URLStart = "http://www.reservationsoftwareonline.com/";

//CHADS LOCAL PC
var secureURLStart = "http://localhost:8080/ressoft/";
var URLStart = "http://localhost:8080/ressoft/";


var monthF = null;
var dayF = null;
var yearF = null;
var monthT = null;
var dayT = null;
var yearT = null;
var fromDateMySQL = null;
var toDateMySQL = null;
var todayDateMySQL = null;
var todayDateMySQLPlusOne = null;
var todayDateMySQLEnd = null;

/* Current selected List row.*/
var selectedRow = null;

/* Current table List row.*/
var selectedTableRow = null;

/* variable for state/province code */
var stateProvCode = 99;

/* MultiUnit Rates Subwindow */
var ratesSubWin = null;
var popupWin = null;

/* MultiUnit RoomNames Subwindow */
var roomNamesSubWin = null; 

/* Hold the current listing ID */
var listingID = 0;
   
/* Hold the curretn Subunit ID */
var subUnitID = 0;

/* Hold the Current Room ID */
var roomId = 0;

/* Hold the owner ID */
var ownerId = 0;

var curTarget = null;

var oldTableRow = 0;

var submitOnLoadTarget = null;

var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

/**
 * Extend the String object with a trim() function.
 */
String.prototype.trim = new Function("return this.replace(/^\\s+|\\s+$/,'')");

/**
 * Framework Module JavaScript Library
 */
 
function doOnLoad()
{
  doCommonOnLoad();
}

function onLoad()
{
  doCommonOnLoad();
}



/**
 * Process the passwordDefault onKeyPress event.
 * This function is IE specific.
 */
function doPasswordOnKeyPress(argLogonType)
{
   if (navigator.appName == "Microsoft Internet Explorer")
   {
	var currKeyCode = window.event.keyCode;

	  /* Key code for Enter is 13.*/
	  if (currKeyCode == 13)
	  {
	    if(argLogonType == "M")
	    {
	      maintenanceLogon();
	    }
	    else
	    {
	      logon();
	    }
	  }//if (currKeyCode == 13)
   }
}//function doPasswordOnKeyPress()

function doPasswordOnKeyPressRA()
{
  var currKeyCode = window.event.keyCode;

  /* Key code for Enter is 13.*/
  if (currKeyCode == 13)
  {
    logonReservationAcceptance();
  }//if (currKeyCode == 13)
}//function doPasswordOnKeyPress()

function dofindResNbrOnKeyPressRA()
{
  var currKeyCode = window.event.keyCode;

  /* Key code for Enter is 13.*/
  if (currKeyCode == 13)
  {
    findCCRecord('extResNo');
  }//if (currKeyCode == 13)
}//function dofindResNbrOnKeyPressRA()

function doNameSearchOnKeyPressRA()
{
  var currKeyCode = window.event.keyCode;

  /* Key code for Enter is 13.*/
  if (currKeyCode == 13)
  {
    findCCRecord('extFullName');
  }//if (currKeyCode == 13)
}//function doNameSearchOnKeyPressRA()

function formatNewDate(targetDate) {

  var mm, dd, yyyy;
  // Return the target date in "mm/dd/yyyy" format.

  mm = String(targetDate.getMonth() + 1);
  while (mm.length < 2)
    mm = "0" + mm;
  dd = String(targetDate.getDate());
  while (dd.length < 2)
    dd = "0" + dd;
  yyyy = String(targetDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;

  //return mm + "/" + dd + "/" + yyyy;
  return yyyy + "-" + mm + "-" + dd;
}
function formatNewDateMMDDYYYY(targetDate) {

  var mm, dd, yyyy;
  // Return the target date in "mm/dd/yyyy" format.
  mm = String(targetDate.getMonth() + 1);
  while (mm.length < 2)
    mm = "0" + mm;
  dd = String(targetDate.getDate());
  while (dd.length < 2)
    dd = "0" + dd;
  yyyy = String(targetDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;

  return mm + "/" + dd + "/" + yyyy;
  //return yyyy + "-" + mm + "-" + dd;
}

function onlineDemo()
{
  var pb = window.open("onlineDemoPage1.htm",'','toolbar=no,location=yes,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=560,width=792');
  if(!pb){
     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
  }
}

function openDemoPage2()
{
  setResponseURL("onlineDemoPage2.jsp");

  /* Run the query.*/
  saveDataSet("dsLeads"); 
  
  submitForm(window, "fwForm");
}
//new2
function openTestCalendar()
{
  setResponseURL("testCalendar.jsp");

  /* Run the query.*/
		setQueryParam("dsListingAvailability", "argListingId", "22000");
		/* query param should be 0 for non multiunit rentals */
		setQueryParam("dsListingAvailability", "argSubUnitId", 0); 
		setQueryParam("dsListingAvailability", "argRoomId", 0);   
		/* Run the query for next page.*/
		executeQuery("dsListingAvailability");
		appendIfNoRow("dsListingAvailability"); 
  
  submitForm(window, "fwForm");
}
//chad march 7th
function openCleaningSchedule()
{
  setQueryParam("dsCleaningSchedule","argOwnerId","109")
  executeQuery("dsCleaningSchedule");
  setResponseURL("cleaningScheduleList.jsp");
   
  submitForm(window, "fwForm");
}

function loadAllAvail2(fromDate,toDate,ownerId,noOfBedrooms)
{
      setQueryParam("dsAmenities", "argRentalTypeNo", "1");      
      executeQuery("dsAmenities"); 
   fromDateD = new Date(fromDate);
   toDateD = new Date(toDate);
  fromDateNorm = formatNewDateMMDDYYYY(fromDateD);
  toDateNorm = formatNewDateMMDDYYYY(toDateD);
  fromDate = "'" +formatNewDate(fromDateD)+"'";
  toDate = "'" +formatNewDate(toDateD) + "'";
  //alert("toDate = " + toDate);
 
  setResponseURL("availableListings.jsp?extFromDate="+fromDateNorm+"&extToDate="+toDateNorm+"&extOwnId="+ownerId+"&extBedrooms="+noOfBedrooms);
  var segment = 'MultiUnitAdmin.loadAllAvailByMonth("F","'+fromDate+'","'+toDate+'","'+ownerId+'","'+noOfBedrooms+'")';
  
  buildScriptSegment(segment);
  submitForm(window, "fwForm");
}

function loadAllAvailByMonth()
{
//CHAD NEW MONTH
noOfBedrooms = ">= 0";
  var selIndex1 = fwForm.extGridDate2.selectedIndex;
  var dateSelected = "'"+fwForm.extGridDate2.options[selIndex1].value+"'";
  var argOwnID = document.getElementById("extOwnId").value;
      setQueryParam("dsAmenities", "argRentalTypeNo", "1");      
      executeQuery("dsAmenities"); 

  setResponseURL("managersAvailableListings.jsp?extDateSelected="+dateSelected+"&extOwnId="+argOwnID);
  //var segment = 'MultiUnitAdmin.loadAllAvailByMonthStartDate("F","'+dateSelected+'","'+argOwnID+'","'+noOfBedrooms+'")';
  
  //buildScriptSegment(segment);
  submitForm(window, "fwForm");
}
function loadAllAvailByMonthCROG()
{
//CHAD NEW MONTH
noOfBedrooms = ">= 0";
  var selIndex1 = fwForm.extGridDate2.selectedIndex;
  var dateSelected = "'"+fwForm.extGridDate2.options[selIndex1].value+"'";
  var argOwnID = document.getElementById("extOwnId").value;
      setQueryParam("dsAmenities", "argRentalTypeNo", "1");      
      executeQuery("dsAmenities"); 

  setResponseURL("managersAvailableListingsCROG.jsp?extDateSelected="+dateSelected+"&extOwnId="+argOwnID);
  //var segment = 'MultiUnitAdmin.loadAllAvailByMonthStartDate("F","'+dateSelected+'","'+argOwnID+'","'+noOfBedrooms+'")';
  
  //buildScriptSegment(segment);
  submitForm(window, "fwForm");
}
function loadAllAvailByMonthCROG2()
{
//CHAD NEW MONTH
noOfBedrooms = ">= 0";
  var selIndex1 = fwForm.extGridDate2.selectedIndex;
  var dateSelected = "'"+fwForm.extGridDate2.options[selIndex1].value+"'";
  var argOwnID = document.getElementById("extOwnId").value;
      setQueryParam("dsAmenities", "argRentalTypeNo", "1");      
      executeQuery("dsAmenities"); 

  setResponseURL("managersAvailableListingsCROG2.jsp?extDateSelected="+dateSelected+"&extOwnId="+argOwnID);
  //var segment = 'MultiUnitAdmin.loadAllAvailByMonthStartDateGaryCustom("F","'+dateSelected+'","'+argOwnID+'","'+noOfBedrooms+'")';
  
  //buildScriptSegment(segment);
  submitForm(window, "fwForm");
}

function loadAllAvailByMonthBLR()
{
//CHAD NEW MONTH
noOfBedrooms = ">= 0";
  var selIndex1 = document.fwForm.extGridDate2.selectedIndex;
  var dateSelected = "'"+document.fwForm.extGridDate2.options[selIndex1].value+"'";
  var argOwnID = document.getElementById("extOwnId").value;
      setQueryParam("dsAmenities", "argRentalTypeNo", "1");      
      executeQuery("dsAmenities"); 
  setResponseURL("managersAvailableListingsBLR.jsp?extDateSelected="+dateSelected+"&extOwnId="+argOwnID);
  submitForm(window, "fwForm");
}
function reservePMBO(listingId)
{ 
subUnitId= "0";
arriveDate = document.all["extFromDate"].value.substring(1,document.all["extToDate"].value.length - 1);
departDate = document.all["extToDate"].value.substring(1,document.all["extToDate"].value.length - 1);
	setQueryParam("dsCheckDateRangesNonMulti", "argListingId", listingId);
	setQueryParam("dsCheckDateRangesNonMulti", "argSubUnitId", subUnitId);
	//dsRatesDetailByRange??
	setQueryParam("dsListingFeeSetup", "argListingId", listingId);	
	setQueryParam("dsRatesDetail", "argListingId", listingId);
	setQueryParam("dsRatesDetail", "argSubUnitId", subUnitId);
	setQueryParam("dsPropertyListingByListingId", "argListingId", listingId);	

	executeQuery("dsCheckDateRangesNonMulti");
	executeQuery("dsRatesDetail");
	executeQuery("dsListingFeeSetup");
	executeQuery("dsPropertyListingByListingId");
    

  setResponseURL("MyAvailableDatesPMBO.jsp?fwModuleName=genKfrent&extArriveDate="+arriveDate+"&extDepartDate="+departDate);
  submitForm(window, "fwForm");
}

function loadAllAvailDetailed()
{
  fromDate = "'"+document.getElementById("extFromDate").value+"'";
  toDate = "'"+document.getElementById("extToDate").value+"'";
  ownerId = document.getElementById("extOwnId").value;
  noOfBedrooms = document.getElementById("extBedrooms").value;
  setQueryParam("dsAmenities", "argRentalTypeNo", "1");

   fromDateD = new Date(fromDate.substring(1,fromDate.length-1));
   toDateD = new Date(toDate.substring(1,toDate.length-1));
  fromDateNorm = formatNewDateMMDDYYYY(fromDateD);
  toDateNorm = formatNewDateMMDDYYYY(toDateD);
  fromDate = "'" +formatNewDate(fromDateD)+"'";
  toDate = "'" +formatNewDate(toDateD) + "'";
  //KILMER
      
  executeQuery("dsAmenities");  
  setResponseURL("availableListings.jsp?extFromDate="+fromDateNorm+"&extToDate="+toDateNorm+"&extOwnId="+ownerId+"&extBedrooms="+noOfBedrooms);
  var segment = 'MultiUnitAdmin.loadAllAvailByMonth("T","'+fromDate+'","'+toDate+'","'+ownerId+'","'+noOfBedrooms+'")';
  
  buildScriptSegment(segment);
  submitForm(window, "fwForm");
}

/* CKC Function */
function loadCKC()
{
  targetDate = new Date();
  mm = String(targetDate.getMonth() + 1);
  while (mm.length < 2)
    mm = "0" + mm;
  dd = String(targetDate.getDate());
  while (dd.length < 2)
    dd = "0" + dd;
  yyyy = String(targetDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;

  stringDate =  mm + "/" + dd + "/" + yyyy;
  dateSt = '"' + stringDate + '"';
  //alert("date = " + dateSt);
  setResponseURL("_CKC_ccb.jsp");
  var segment1 = 'MultiUnitAdmin.getCCBatchByDate('+dateSt+')';
  buildScriptSegment(segment1);;
  
  
  submitForm(window, "fwForm");
}

/* CKC Function */
function loadCKCDenied()
{
  targetDate = new Date();
  mm = String(targetDate.getMonth() + 1);
  while (mm.length < 2)
    mm = "0" + mm;
  dd = String(targetDate.getDate());
  while (dd.length < 2)
    dd = "0" + dd;
  yyyy = String(targetDate.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;

  stringDate =  mm + "/" + dd + "/" + yyyy;
  dateSt = '"' + stringDate + '"';
  //alert("date = " + dateSt);
  setResponseURL("_CKC_ccbD.jsp");
  var segment1 = 'MultiUnitAdmin.getCCBatchByDateDenied('+dateSt+')';
  buildScriptSegment(segment1);;
  
  
  submitForm(window, "fwForm");
}
function registerUser()
{
  insertRow()
}

function insertRow()
{
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("Register.jsp?fwModuleName=genKfrent");
  
 
  /* If the query returns no rows, then append a row.*/
  appendIfNoRow("dsPropertyOwner");
  
  submitForm(window, "fwForm");
}
function logon1()
{
  setResponseURL("SecureLogin.jsp");
  submitForm(window, "fwForm"); 
}
function logon()
{
   logonpage() 
}

function logon_CCNS()
{
   logonpage_CCNS() 
}

function logonpage()
{
  	/* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  	setResponseURL("Welcome.jsp");
  	setQueryParam("dsLogon", "argUserName", document.fwForm.extUserName2.value);
  	setQueryParam("dsLogon", "argPassword", document.fwForm.extPassword2.value);
  	setQueryParam("dsOwnerListingCount", "argUserName", document.fwForm.extUserName2.value);
  	setQueryParam("dsOwnerListingCount", "argPassword", document.fwForm.extPassword2.value);  
  	setQueryParam("dsHouseKeepingLogin", "argUserName", document.fwForm.extUserName2.value);
  	setQueryParam("dsHouseKeepingLogin", "argPassword", document.fwForm.extPassword2.value);  
  	setQueryParam("dsOwnerListingCountMU", "argUserName", document.fwForm.extUserName2.value);
  	setQueryParam("dsOwnerListingCountMU", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid", "argBed1", 0);
        setQueryParam("dsPropertyListingByOwnerMUuserid", "argBed2", 20); 
        //alert("logging in");
  	setQueryParam("dsPropertyListingByOwnerMUuserid0TO1", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid0TO1", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid2", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid2", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid3", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid3", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid4", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid4", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid5plus", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid5plus", "argPassword", document.fwForm.extPassword2.value);
       
  	/* Save the buffer.*/
  	executeQuery("dsLogon");
  	executeQuery("dsHouseKeepingLogin");
  	executeQuery("dsOwnerListingCount"); 
  	executeQuery("dsOwnerListingCountMU");  
  	executeQuery("dsPropertyListingByOwnerMUuserid");
  	executeQuery("dsPropertyListingByOwnerMUuserid0TO1");
  	executeQuery("dsPropertyListingByOwnerMUuserid2");
  	executeQuery("dsPropertyListingByOwnerMUuserid3");
  	executeQuery("dsPropertyListingByOwnerMUuserid4");
  	executeQuery("dsPropertyListingByOwnerMUuserid5plus");
  	var segment1 = 'checkSessionTimeout.setSessionApp()';
        buildScriptSegment(segment1);
        submitForm(window, "fwForm"); 
}

function logonpage_CCNS()
{
  	/* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  	setResponseURL("Welcome_CCNS.jsp");
  	setQueryParam("dsLogon", "argUserName", document.fwForm.extUserName2.value);
  	setQueryParam("dsLogon", "argPassword", document.fwForm.extPassword2.value);
  	setQueryParam("dsOwnerListingCount", "argUserName", document.fwForm.extUserName2.value);
  	setQueryParam("dsOwnerListingCount", "argPassword", document.fwForm.extPassword2.value);  
  	setQueryParam("dsHouseKeepingLogin", "argUserName", document.fwForm.extUserName2.value);
  	setQueryParam("dsHouseKeepingLogin", "argPassword", document.fwForm.extPassword2.value);  
  	setQueryParam("dsOwnerListingCountMU", "argUserName", document.fwForm.extUserName2.value);
  	setQueryParam("dsOwnerListingCountMU", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid", "argBed1", 0);
        setQueryParam("dsPropertyListingByOwnerMUuserid", "argBed2", 20); 
        //alert("logging in");
  	setQueryParam("dsPropertyListingByOwnerMUuserid0TO1", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid0TO1", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid2", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid2", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid3", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid3", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid4", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid4", "argPassword", document.fwForm.extPassword2.value); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid5plus", "argUserId", document.fwForm.extUserName2.value);
        setQueryParam("dsPropertyListingByOwnerMUuserid5plus", "argPassword", document.fwForm.extPassword2.value);
       
  	/* Save the buffer.*/
  	executeQuery("dsLogon");
  	executeQuery("dsHouseKeepingLogin");
  	executeQuery("dsOwnerListingCount"); 
  	executeQuery("dsOwnerListingCountMU");  
  	executeQuery("dsPropertyListingByOwnerMUuserid");
  	executeQuery("dsPropertyListingByOwnerMUuserid0TO1");
  	executeQuery("dsPropertyListingByOwnerMUuserid2");
  	executeQuery("dsPropertyListingByOwnerMUuserid3");
  	executeQuery("dsPropertyListingByOwnerMUuserid4");
  	executeQuery("dsPropertyListingByOwnerMUuserid5plus");
        submitForm(window, "fwForm"); 
}
function maintenanceLogon()
{
    var segment1 = 'doSetQueryParam("dsMechanicsLogin", "argUserName","' + document.fwForm.extUserName2.value + '")';
    buildScriptSegment(segment1);
    
    var segment1 = 'doSetQueryParam("dsMechanicsLogin", "argPassword","' + document.fwForm.extPassword2.value + '")';
    buildScriptSegment(segment1); 

  	var segment1 = 'doExecuteQuery("dsMechanicsLogin")';
  	buildScriptSegment(segment1);
  	
  	var segment = 'doExecuteQuery("dsWorkOrderStatus")';
    buildScriptSegment(segment);

   	var segment1 = 'doCheckSession()';
    buildScriptSegment(segment1);
    
    setResponseURL("maintenanceWorkOrderList.jsp?extFilterStatus=all&extFilter=N");
    
    submitForm(window, "fwForm"); 
}
function filterListingToBedrooms(argBeds)
{

  if(argBeds==1)
  { 
    arg3 = 1;
    arg4 = 1;
    extFilterVal = 1;
  }
  else if (argBeds==2)
  {
    arg3 = 2;
    arg4 = 2;
    extFilterVal = 2;
  }
  else if (argBeds==3)
  {
    arg3 = 3;
    arg4 = 3;
    extFilterVal = 3;
  }
  else if (argBeds==4)
  {
    arg3 = 4;
    arg4 = 4;
    extFilterVal = 4;
  }
  else if (argBeds==5)
  {
    arg3 = 5;
    arg4 = 20; 
    extFilterVal = 5;
  }
  else if (argBeds=99)
  {
    arg3 = 1;
    arg4 = 20;
    extFilterVal = 99;
  }  
  var segment13 = 'MultiUnitAdmin.filterMgmtListingsByBedrooms("'+arg3+'","'+arg4+'")';
  buildScriptSegment(segment13); 
  setResponseURL("Welcome.jsp?extFilter="+extFilterVal);
  submitForm(window,"fwForm");
}

function filterStatus(extFilterVal)
{
  setResponseURL("Welcome.jsp?extFilter="+extFilterVal);
  submitForm(window,"fwForm");
}

function loadPIS(argStatus)
{
  setResponseURL("_CKC_vis.jsp");
  setQueryParam("dsPropertyImagesByStatus", "argImageStatus", argStatus);

  /* Run the query.*/
  executeQuery("dsPropertyImagesByStatus"); 
  
  submitForm(window, "fwForm")
}


function getDetailRecord(argListingId, argBatchID, argValue, argShowAgree, argShowNotes)
{
var n0=""; 
var n1="One"; 
var n2="Two"; 
var n3="Three"; 
var n4="Four"; 
var n5="Five"; 
var n6="Six"; 
var n7="Seven"; 
var n8="Eight"; 
var n9="Nine"; 
var n10="Ten"; 
var n11="Eleven"; 
var n12="Twelve"; 
var n13="Thirteen"; 
var n14="Fourteen"; 
var n15="Fifteen"; 
var n16="Sixteen"; 
var n17="Seventeen"; 
var n18="Eighteen"; 
var n19="Nineteen"; 
var n20="Twenty"; 
var n30="Thirty"; 
var n40="Forty"; 
var n50="Fifty"; 
var n60="Sixty"; 
var n70="Seventy"; 
var n80="Eighty"; 
var n90="Ninety";

//Word numbers are really expressed for 1 to 999.
//We process only one 3-digit part of a number and need "aType" to say what part.
//Call this function four times to get billions, millions, thousands and dollars/cents.
//(i.e see function "wordAmount(a)" below which calls our wordamount999(a,t) four times.)
//This function accomodates forms with no cents or billions and millions on a separate line.

var typeFlag="none";
var typeWord="";
var centsvar = "";
var centsWord = "";
var amtCents = 0;
var amtWhole = 0;
var amtOnes = 0;
var amtCentsTxt = "";
var amtCentsTxt2 = "";
var txtOnes = "";
var spc = "";
var amtWholeTxt = "";
var amtWholeTxt2 = "";
var amtOnesTxt = "";
var amtHundredsTxt="";
var dollarWords = "";
	 var part1S = ""; //thousands
	 var part2S = ""; //dollars
	 var part3S = ""; //cents

//argValue = "1234.01";
argValue=parseInt(parseFloat(argValue)*100);
var amtWholeTxt=""+argValue;
//amtWholeTxt = xmlds.getColumnValue("dsCCBatchByBatchId", "RENTAL_CHARGE");

//alert("amount in = " + amtWholeTxt);
amtWholeTxt2 = amtWholeTxt;
var lengthN = 0;
var length = 0;
lengthN = amtWholeTxt.length - 2;
length = amtWholeTxt.length;

amtWholeTxt=amtWholeTxt.substring(0,lengthN);
  //amount without cents
amtCentsTxt=amtWholeTxt2.substring(lengthN,length);
  //amount of cents
//amtWholeTxt=amtWholeTxt.substring(lengthN,length);
  //amount without cents
//amtCentsTxt=amtWholeTxt2.substring(2,3);
  //amount of cents  
amtCents=parseInt(amtCentsTxt);
amtCentsTxt2=amtCentsTxt;

if (amtCents < 1){amtCentsTxt2="no";}
txtOnes="";
spc=" ";
var amtCentsTxt2 = " cents";
var amtWholeTxtCpy = "";

//amtWhole=parseInt(amtWholeTxt);
amtWhole=0;

while(amtWholeTxt.length > 0)
{
  //alert("loop");
  amtWholeTxtCpy = amtWholeTxt;
  //alert(" amtWholeTxtCpy = " + amtWholeTxtCpy);

	if (amtWholeTxt.length <= 3){
		amtWhole=parseInt(amtWholeTxt);
		if (amtWhole > 0){typeWord=" Dollar";}
		if (amtWhole > 1){typeWord=" Dollars";}
		//alert("typeWord = " + typeWord);

	}
	else if (amtWholeTxt.length > 3)
	{
	   lengthN = amtWholeTxt.length - 3;
	   amtWholeTxt=amtWholeTxt.substring(0,lengthN);
	   amtWhole=parseInt(amtWholeTxt);
	   if (amtWhole % 100 > 0)
	   {
	    typeWord=" Thousand ";
	    }
	 } 	 


        
	amtOnes=amtWhole % 100;
	amtOnesTxt="";
	if (amtOnes < 21){
	   eval("amtOnesTxt="+"n"+amtOnes);
	   //amtOnesTxt="n"+amtOnes;
	   }
	if (amtOnes > 20){
	  //amtOnesTxt = "n"+ String.valueOf(amtOnes / 10)+"0";
	    eval("amtOnesTxt="+"n"+ parseInt(amtOnes / 10)+"0");
	    //
	  //amtOnesTxt=amtOnesTxt+spc+"n"+ String.valueOf(amtOnes % 10);
	    eval("amtOnesTxt=amtOnesTxt+spc+"+"n"+ parseInt(amtOnes % 10));
	}


	amtHundredsTxt="";

	if (amtWhole % 1000 > 99){
	eval("amtHundredsTxt="+"n"+parseInt((amtWhole % 1000)/100));
	//amtHundredsTxt="n"+ String.valueOf((amtWhole % 1000)/100);
	amtHundredsTxt=amtHundredsTxt+" "+"Hundred ";
	}


	amtCentsTxt="";
	
	if (amtCents < 21){
	  if (amtCents == 1)
	  {
	    amtCentsTxt2 = " cent";
	  }
	  if (amtCents == 0)
	  {
	    amtCentsTxt2 = " no cents";
	  } 	
	   eval("amtCentsTxt="+"n"+amtCents);
	   //amtCentsTxt="n"+amtCents;
	   }
	if (amtCents > 20) {
 
	  //amtCentsTxt = "n"+ String.valueOf(amtCents / 10)+"0";
	    eval("amtCentsTxt="+"n"+parseInt(amtCents / 10)+"0");
	  //amtCentsTxt=amtCentsTxt+spc+"n"+ String.valueOf(amtCents % 10) + " cents";
	    eval("amtCentsTxt=amtCentsTxt+spc+"+"n"+parseInt(amtCents % 10));
	}


	 
	 if (amtWholeTxtCpy.length <= 3)
	 {
	  //alert("setting amtWholeTxt= blank");
	  amtWholeTxt= "";
	  part2S = amtHundredsTxt + amtOnesTxt + typeWord;
	  //alert("part 2 = " + part2S);
	 }
	  else if (amtWholeTxtCpy.length > 3){
	 	lengthN = amtWholeTxtCpy.length - 3;
	 	length = amtWholeTxtCpy.length;
	  	amtWholeTxt=amtWholeTxtCpy.substring(lengthN,length);
	  	part1S = amtHundredsTxt + amtOnesTxt + typeWord;
	  	//alert("part 1 = " + part1S);
	 }

	  part3S = amtCentsTxt;
	  //alert("amtWholeTxt.length before loop = " + amtWholeTxt.length);
}//loop
	 dollarWords = part1S + " " + part2S + " and " + amtCentsTxt + amtCentsTxt2;
	 //alert("dollar words = " + dollarWords);

 	 
      //var segment14a = 'MultiUnitAdmin.buildDetailedReceipt("'+ argListingId +'","'+ argBatchID +'","'+ dollarWords +'")';
      var segment14a = 'PDFgenerator.buildDetailedReceipt("'+ argListingId +'","'+ argBatchID +'","'+ dollarWords +'","'+ argShowAgree+'","'+ argShowNotes+'")';
      buildScriptSegment(segment14a);
      //setResponseURL(secureURLStart+"PDFs/detailReceipt"+argBatchID+".pdf");
      submitForm(window, "fwForm");
      showPDFDetailReceipt(argBatchID);


}


function updateOwnership()
{
  var listingId = document.getElementById("extListingId").value;
  var ownerId = document.getElementById("dsPropertyOwner-OWNER_ID").value;
  var multiUnitFlag = 0;
  var scanServ = 0;
  
  setQueryParam("dsPricingReference", "argListingId", listingId); 
  setQueryParam("dsPropertyListingByOwner", "argOwnerId", ownerId);
  //alert("opening up paymentFormA with listing id = " + listingID + " owner ID = " + ownerId + " multiUnitflag = " + multiUnitFlag);
  /* Run the query.*/
  executeQuery("dsPricingReference");
  executeQuery("dsPropertyListingByOwner");
  //saveDataSet("dsPropertyOwner");
  
    submitForm(window, "fwForm")
}


/* Function for update Registration for Keys For Rent */
function updateRegistrationForm()
{

  var dsOwnerId = document.getElementById("dsPropertyOwner-OWNER_ID").value;
  var pswd = document.getElementById("dsPropertyOwner-PASSWORD").value;
  var verifyPswd = document.getElementById("extverifyPassword").value;
  var userName = document.getElementById("dsPropertyOwner-USER_NAME").value;
 
  if (pswd != verifyPswd)
  {
    alert("Your Password does not match the verify password! Please re-enter.");
    return;
  }
  	
  //this function is called after a new user has signed up
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("Welcome.jsp?extFilter=");

 /* Save the buffer.*/
  saveDataSet("dsPropertyOwner");
  saveDataSet("dsOwnerCCMerch");
  setQueryParam("dsLogon", "argUserName", userName);
  setQueryParam("dsLogon", "argPassword", pswd);
  	setQueryParam("dsOwnerListingCount", "argUserName", userName);
  	setQueryParam("dsOwnerListingCount", "argPassword", pswd);  
  	setQueryParam("dsOwnerListingCountMU", "argUserName", userName);
  	setQueryParam("dsOwnerListingCountMU", "argPassword", pswd); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid", "argUserId", userName);
        setQueryParam("dsPropertyListingByOwnerMUuserid", "argPassword", pswd); 
  	setQueryParam("dsPropertyListingByOwnerMUuserid", "argBed1", "1");
        setQueryParam("dsPropertyListingByOwnerMUuserid", "argBed2", "1");
        arg3="";
        arg4="";
         
        /* Save the buffer.*/
  	executeQuery("dsLogon");
  	executeQuery("dsOwnerListingCount"); 
  	executeQuery("dsOwnerListingCountMU");  
  	executeQuery("dsPropertyListingByOwnerMUuserid");
  setQueryParam("dsPropertyOwner", "argOwnerId", dsOwnerId);

  /* Run the query.*/
  executeQuery("dsPropertyOwner");
  
  
  submitForm(window, "fwForm");

}


/* Function for add a new listing for Keys For Rent */
function addAnotherListing()
{

  var dsOwnerId = document.fwForm.extownId.value;

  //alert("Owner id = " + dsOwnerId);
  saveDataSet("dsPreferences");
  //this function is called after a user has logged in with a valid login
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("selectRentalType.jsp");

 /* Save the buffer.*/
  //saveDataSet("dsPropertyOwner");

  setQueryParam("dsPropertyOwner", "argOwnerId", dsOwnerId);
  
  /* Run the query.*/
  executeQuery("dsPropertyOwner");
  
 
  
  submitForm(window, "fwForm");

}


function getAccessLog()
{
      dateTodayD = new Date();
      monthT = String(dateTodayD.getMonth() + 1);
      while (monthT.length < 2)
        monthT = "0" + monthT;
      dayT = String(dateTodayD.getDate());
  	while (dayT.length < 2)
    	dayT = "0" + dayT;      
      yearT = dateTodayD.getFullYear();
      dateToday =  yearT + "-" + monthT + "-" + dayT;
      //alert("date to send = " + dateToday);
      setResponseURL("accessLog.jsp");
      
      var segment14a = 'MultiUnitAdmin.writeAccessLog("'+ dateToday +'")';
      buildScriptSegment(segment14a);      
      executeQuery("dsAccessLog");  
      
      submitForm(window, "fwForm");
      
}
      

function checkAvail(rowNo)
{
//************************************
//
listingId = document.getElementById("dsPropertyListingByListingId-LISTING_ID").value;
subUnitId = document.getElementById("dsMultiUnit-SUBUNIT_ID"+rowNo).value;

//alert("subunit selected = " + subUnitId);

	setResponseURL("MyAvailableDates.jsp?fwModuleName=genKfrent&extSubUnitId="+subUnitId);

	setQueryParam("dsCheckDateRanges", "argListingId", listingId);
	setQueryParam("dsCheckDateRanges", "argSubUnitId", subUnitId);
	setQueryParam("dsListingFeeSetup", "argListingId", listingId);
	setQueryParam("dsRatesDetail", "argListingId", listingId);
	setQueryParam("dsRatesDetail", "argSubUnitId", subUnitId);
	setQueryParam("dsRoomsBySubUnitID", "argListingId", listingId);
	setQueryParam("dsRoomsBySubUnitID", "argSubUnitId", subUnitId);

	executeQuery("dsCheckDateRanges");
	executeQuery("dsListingFeeSetup");
	executeQuery("dsRatesDetail");
	executeQuery("dsRoomsBySubUnitID");

submitForm(window, "fwForm");


//************************************
}



function getAvailableRooms(rowNo)
{
//************************************

  listingId = document.getElementById("dsCheckDateRanges-LISTING_ID").value;
  subUnitId = document.getElementById("dsCheckDateRanges-SUBUNIT_ID").value;
  roomId = document.getElementById("dsRoomsBySubUnitID-ROOM_NAME").value;

  extNoOfAdults = document.fwForm.extNoOfAdults.value;
  extNoOfChildren = document.fwForm.extNoOfChildren.value;
  noOfPeople = parseInt(extNoOfAdults) + parseInt(extNoOfChildren);
  extHandicapped = "no";
  extHearingImpaired = "no";
  if (document.fwForm.extHandicapped[0].checked)
  {
      extHandicapped = "yes";
  }
  if (document.fwForm.extHearingImpaired[0].checked)
  {
      extHearingImpaired = "yes";
  }

  needPetDep = "NO";
  //alert("room ID = " + roomId);
  fromDate = document.getElementById("extdateFrom").value;
  toDate = document.getElementById("extdateTo").value;
  if(document.fwForm.extgroup2[0].checked)
  { 
    needPetDep = "YES";
  }
  
  fromDateD = new Date(fromDate);
  toDateD = new Date(toDate);
  //we are colleting the depart date...so set it to day before
  toDateD.setDate(toDateD.getDate() - 1);  
  dateTodayD = new Date();
  difference = Math.abs(toDateD.getTime() - fromDateD.getTime());
  daysUntilReservation = Math.abs(dateTodayD.getTime() - fromDateD.getTime());
  daysDiff = (difference / (1000 * 60 * 60 * 24)) + 1;  
  daysUntilReservation = (daysUntilReservation / (1000 * 60 * 60 * 24)) + 1; 
  //make sure we are rounded
  daysDiff = Math.round(daysDiff);
  daysUntilReservation = Math.round(daysUntilReservation);
  //alert("new TO date = " + toDateD + " days difference = " + daysDiff);
  
  var day = toDateD.getDate();
  var month = toDateD.getMonth()  + 1;
  var year = toDateD.getFullYear();

  toDate = month + '/' + day + '/' + year;

  fromDate = "'" + fromDate + "'";
  toDate = "'" + toDate + "'";
  setResponseURL("MyAvailableDatesAR.jsp?fwModuleName=genKfrent&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"#entryPoint");
  
  //clearDataSet("dsGetAvailableRooms");
  /* Build the script segment.*/
  var segment13 = 'MultiUnitAdmin.getAvailableRooms2("'+listingId+'","'+subUnitId+'","'+fromDate+'","'+toDate+'","'+daysDiff+'","'+roomId+'","'+daysUntilReservation+'","'+needPetDep+'","'+noOfPeople+'")';
  buildScriptSegment(segment13); 

  setQueryParam("dsListingFeeSetup", "argListingId", listingId);
  setQueryParam("dsCheckDateRanges", "argListingId", listingId);
  setQueryParam("dsCheckDateRanges", "argSubUnitId", subUnitId);
  setQueryParam("dsRatesDetail", "argListingId", listingId);
  setQueryParam("dsRatesDetail", "argSubUnitId", subUnitId);
  setQueryParam("dsRoomsBySubUnitID", "argListingId", listingId);
  setQueryParam("dsRoomsBySubUnitID", "argSubUnitId", subUnitId);  

  executeQuery("dsListingFeeSetup");
  executeQuery("dsCheckDateRanges");
  executeQuery("dsRatesDetail");
  executeQuery("dsRoomsBySubUnitID");  

  submitForm(window, "fwForm");

}
function beginOwnerReservation(rowNo, authType)
{
  ownerId = document.getElementById("extOwnerID").value;
  listingId = document.getElementById("extListingID").value;
  subUnitId = document.getElementById("extSubUnitId").value;
  roomId = document.getElementById("extRoomId").value;
  lastFour = document.getElementById("extLastFourOfPhone").value;  

  todayDateFromS = document.getElementById("extCalendarFrom").value;
  todayDateFrom = "'" + todayDateFromS + "'";
  todayDateToS = document.getElementById("extCalendarTo").value;
  colorPref = document.getElementById("extBC").value;
  todayDateTo = "'" + todayDateToS + "'";
  fromDateD = new Date(todayDateFromS);
  toDateD = new Date(todayDateToS);

  //date and date of departure
  toDateD.setDate(toDateD.getDate() - 1);

  dateTodayD = new Date();

  difference = Math.abs(toDateD.getTime() - fromDateD.getTime());
  daysUntilReservation = Math.abs(dateTodayD.getTime() - fromDateD.getTime());
  daysDiff = (difference / (1000 * 60 * 60 * 24)) + 1;  
  daysUntilReservation = (daysUntilReservation / (1000 * 60 * 60 * 24)) + 1; 
  //make sure we are rounded
  daysDiff = Math.round(daysDiff);
  daysUntilReservation = Math.round(daysUntilReservation);

  fromDate = "'" + todayDateFromS + "'";
  toDate = "'" + todayDateToS + "'";

  setQueryParam("dsPreferences", "argOwnerId", ownerId);  
  executeQuery("dsPreferences");
  
  //** MYSQL CHANGES
  buildMySQL_TO_DATE(toDateD);
  buildMySQL_FROM_DATE(fromDateD); 
  
  setResponseURL("myAvailabilityWResPT2Owner.jsp?fwModuleName=genKfrent&extLID="+listingId+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID="+roomId+"&extBC="+colorPref);

  var segment13 = 'ProcessReservations.processOwnerRequestNormal("'+listingId+'","'+todayDateFrom+'","'+todayDateTo+'","'+daysDiff+'","'+daysUntilReservation+'","'+fromDateMySQL+'","'+toDateMySQL+'","'+lastFour+'")';

  buildScriptSegment(segment13); 

  submitForm(window, "fwForm");  
}

function formatToMySQL(targetDate) {
//alert("in formatNewDate function");
  var mm, dd, yyyy;
  // Return the target date in "mm/dd/yyyy" format.

  yyyy = targetDate.substring(6,10);
  dd = targetDate.substring(3,5);
  mm = targetDate.substring(0,2);

  return yyyy + "-" + mm + "-" + dd;
}
function beginOwnerInventorySearch(argURL, ownerId)
{
  selSort = "";
  selBeds = "";
  extCalendarFrom = ""; extCalendarTo = "";
  arg1="F";arg2="F";arg3="F";arg4="F";arg5="F";arg6="F";arg7="F";arg8="F";arg9="F";arg10="F";arg11="F";arg12="F";arg13="F";arg14="F";arg15="F";arg16="F";arg17="F";arg18="F";arg19="F";arg20="F";arg21="F";arg22="F";arg23="F";arg24="F";

  if(document.getElementById("extCalendarFrom2"))
  {
    extCalendarFrom = "";
    if(document.getElementById("extCalendarFrom2").value.length > 6)
    { 
      if(document.getElementById("extCalendarFrom2").value.indexOf("/") < 0)
      {
        alert("Please enter the departure date in the following format mm/dd/yyyy");
        return;
      }
       extCalendarFrom = document.getElementById("extCalendarFrom2").value;
       extCalendarFrom = formatToMySQL(extCalendarFrom);
    }

  }
  else
  {
   extCalendarFrom = "";
  }
  if(document.getElementById("extCalendarTo2"))
  {
    extCalendarTo = "";
    if(document.getElementById("extCalendarTo2").value.length > 6)
    {
      if(document.getElementById("extCalendarTo2").value.indexOf("/") < 0)
      {
        alert("Please enter the arrival date in the following format mm/dd/yyyy");
        return;
      }    
       extCalendarTo = document.getElementById("extCalendarTo2").value;
       extCalendarTo = formatToMySQL(extCalendarTo);
    }
  }
  else
  {
   extCalendarTo = "";
  } 
  if(document.getElementById("extCity"))
  {
    extCityIdx = document.fwForm.extCity.selectedIndex;
    extCity = document.fwForm.extCity.options[extCityIdx].value;
  }
  else
  {
    extCity="";
  }


  setResponseURL(argURL+".jsp?extOID="+ownerId+"&extPageNo=1&extSort="+selSort+"&extBeds="+selBeds+"&extCity="+extCity+"&extCalendarFrom="+extCalendarFrom+"&extCalendarTo="+extCalendarTo+"&ext1="+arg1+"&ext2="+arg2+"&ext3="+arg3+"&ext4="+arg4+"&ext5="+arg5+"&ext6="+arg6+"&ext7="+arg7+"&ext8="+arg8+"&ext9="+arg9+"&ext10="+arg10+"&ext11="+arg11+"&ext12="+arg12+"&ext13="+arg13+"&ext14="+arg14+"&ext15="+arg15+"&ext16="+arg16+"&ext17="+arg17+"&ext18="+arg18+"&ext19="+arg19+"&ext20="+arg20+"&ext21="+arg21+"&ext22="+arg22+"&ext23="+arg23+"&ext24="+arg24);
  submitForm(window, "fwForm");  
}

function beginReservation(rowNo,authType, winType)
{
//************************************
  argOwnerId = document.fwForm.extOwnerId.value;
  listingId = document.getElementById("extListingID").value;
  subUnitId = document.getElementById("extSubUnitId").value;
  roomId = document.getElementById("extRoomId").value;
  colorPref = document.getElementById("extBC").value;
  couponCode = document.getElementById("extCPN").value;
  if(document.getElementById("extNoOfBedrooms"))
  {
    noOfRooms = document.fwForm.extNoOfBedrooms.value;
    extNoOfAdults = document.fwForm.extNoOfAdults.value;
    extNoOfChildren = document.fwForm.extNoOfChildren.value;
    extNoOfChargeChildren = document.fwForm.extNoOfChargeChildren.value;  
    noOfPeople = parseInt(extNoOfAdults) + parseInt(extNoOfChargeChildren);
    noToCharge = noOfRooms;
  }
  else
  {
    extNoOfAdults = document.fwForm.extNoOfAdults.value;
    extNoOfChildren = document.fwForm.extNoOfChildren.value;
    extNoOfChargeChildren = document.fwForm.extNoOfChargeChildren.value;  
    noOfPeople = parseInt(extNoOfAdults) + parseInt(extNoOfChargeChildren);
    noToCharge = noOfPeople;
    noOfRooms = 0;
  }
  
  extHandicapped = "no";
  extHearingImpaired = "no";
  var opFee1 = "NO";
  var opFee2 = "NO";
  var opFee3 = "NO"; var opFee4 = "NO"; var opFee5 = "NO"; var opFee6 = "NO";
  var opFee7 = "NO"; var opFee8 = "NO"; var opFee9 = "NO"; var opFee10 = "NO";
  var opFee11 = "NO"; var opFee12 = "NO"; var opFee13 = "NO"; var opFee14 = "NO";
  var opFee15 = "NO"; var opFee16 = "NO"; var opFee17 = "NO"; var opFee18 = "NO";var opFee19 = "NO";
  var noOfUnits1 = "0";
  var noOfUnits2 = "0";
  var noOfUnits4 = "0"; var noOfUnits5 = "0"; var noOfUnits6 = "0";
  var noOfUnits7 = "0"; var noOfUnits8 = "0"; var noOfUnits9 = "0"; var noOfUnits10 = "0";
  var noOfUnits11 = "0"; var noOfUnits12 = "0"; var noOfUnits13 = "0"; var noOfUnits14 = "0";
  var noOfUnits15 = "0"; var noOfUnits16 = "0"; var noOfUnits17 = "0"; var noOfUnits18 = "0"; var noOfUnits19 = "0";
  var noOfPets = "0";
  var noOfPetsOverLbs = "0";
  var mop = "";
  var opFeeString = "";
  if(document.getElementById("extMOPequalsCC"))
  {
  //alert("MOP =" + document.getElementById("extMOPequalsCC"));
    if(document.getElementById("extMOPequalsCC").checked)
    {
      mop="CC";
    }
    //alert("MOP =" + document.getElementById("extMOPequalsCC").checked);
  }
  if(document.getElementById("extNoOfPets"))
  {
    noOfPets = document.getElementById("extNoOfPets").value;
  }
  if(document.getElementById("exttrRowNoPetsOverLbs"))
  {
    noOfPetsOverLbs = document.getElementById("exttrRowNoPetsOverLbs").value;
    //alert("petsOW = " + noOfPetsOverLbs);
  }  
  if (document.fwForm.extHandicapped.checked)
  {
      extHandicapped = "yes";
  }
  if (document.fwForm.extHearingImpaired.checked)
  {
      extHearingImpaired = "yes";
  }
  needPetDep = "NO";

  if(document.fwForm.extgroup2[0].checked)
  { 
    needPetDep = "YES";
  }
 if(document.getElementsByName("extgroupOF1").length > 0)
 {
  if (document.fwForm.extgroupOF1[0].checked)
  {   opFee1="YES"; opFeeString = 'Y';  } else {opFeeString = 'N'};
  if (document.getElementById("extNoOfUnits1"))
  {   noOfUnits1 = document.getElementById("extNoOfUnits1").value; if(noOfUnits1==""){noOfUnits1 = "0";} }
 }
 if(document.getElementsByName("extgroupOF2").length > 0)
 {
  if (document.fwForm.extgroupOF2[0].checked)
  {   opFee2="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits2"))
  {    noOfUnits2 = document.getElementById("extNoOfUnits2").value; if(noOfUnits2==""){noOfUnits2 = "0";} }  
 } 
 //need to set opFeeString for space 3
 opFeeString = opFeeString +'N'
 //dont remove line above..it is necessary for opFee3 since we dont use it correctly.
 if(document.getElementsByName("extgroupOF4").length > 0)
 {
  if (document.fwForm.extgroupOF4[0].checked)
  {   opFee4="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits4"))
  {    noOfUnits4 = document.getElementById("extNoOfUnits4").value; if(noOfUnits4==""){noOfUnits4 = "0";} }  
 } 
 if(document.getElementsByName("extgroupOF5").length > 0)
 {
  if (document.fwForm.extgroupOF5[0].checked)
  {   opFee5="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits5"))
  {    noOfUnits5 = document.getElementById("extNoOfUnits5").value; 
    if(noOfUnits5==""){noOfUnits5 = "0";}
  }  
 } 
 //alert("noOfUnits5 = " + noOfUnits5);
if(document.getElementsByName("extgroupOF6").length > 0)
 {
  if (document.fwForm.extgroupOF6[0].checked)
  {   opFee6="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits6"))
  {    noOfUnits6 = document.getElementById("extNoOfUnits6").value; if(noOfUnits6==""){noOfUnits6 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF7").length > 0)
 {
  if (document.fwForm.extgroupOF7[0].checked)
  {   opFee7="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits7"))
  {    noOfUnits7 = document.getElementById("extNoOfUnits7").value;  if(noOfUnits7==""){noOfUnits7 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF8").length > 0)
 {
  if (document.fwForm.extgroupOF8[0].checked)
  {   opFee8="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits8"))
  {    noOfUnits8 = document.getElementById("extNoOfUnits8").value; if(noOfUnits8==""){noOfUnits8 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF9").length > 0)
 {
  if (document.fwForm.extgroupOF9[0].checked)
  {   opFee9="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits9"))
  {    noOfUnits9 = document.getElementById("extNoOfUnits9").value; if(noOfUnits9==""){noOfUnits9 = "0";} }  
 } 
 if(document.getElementsByName("extgroupOF10").length > 0)
 {
  if (document.fwForm.extgroupOF10[0].checked)
  {   opFee10="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits10"))
  {    noOfUnits10 = document.getElementById("extNoOfUnits10").value; if(noOfUnits10==""){noOfUnits10 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF11").length > 0)
 {
  if (document.fwForm.extgroupOF11[0].checked)
  {   opFee11="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits11"))
  {    noOfUnits11 = document.getElementById("extNoOfUnits11").value; if(noOfUnits11==""){noOfUnits11 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF12").length > 0)
 {
  if (document.fwForm.extgroupOF12[0].checked)
  {   opFee12="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits12"))
  {    noOfUnits12 = document.getElementById("extNoOfUnits12").value; if(noOfUnits12==""){noOfUnits12 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF13").length > 0)
 {
  if (document.fwForm.extgroupOF13[0].checked)
  {   opFee13="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits13"))
  {    noOfUnits13 = document.getElementById("extNoOfUnits13").value; if(noOfUnits13==""){noOfUnits13 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF14").length > 0)
 {
  if (document.fwForm.extgroupOF14[0].checked)
  {   opFee14="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits14"))
  {    noOfUnits14 = document.getElementById("extNoOfUnits14").value; if(noOfUnits14==""){noOfUnits14 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF15").length > 0)
 {
  if (document.fwForm.extgroupOF15[0].checked)
  {   opFee15="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits15"))
  {    noOfUnits15 = document.getElementById("extNoOfUnits15").value; if(noOfUnits15==""){noOfUnits15 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF16").length > 0)
 {
  if (document.fwForm.extgroupOF16[0].checked)
  {   opFee16="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits16"))
  {    noOfUnits16 = document.getElementById("extNoOfUnits16").value;  if(noOfUnits16==""){noOfUnits16 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF17").length > 0)
 {
  if (document.fwForm.extgroupOF17[0].checked)
  {   opFee17="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits17"))
  {    noOfUnits17 = document.getElementById("extNoOfUnits17").value;  if(noOfUnits17==""){noOfUnits17 = "0";} }  
 }
 if(document.getElementsByName("extgroupOF18").length > 0)
 {
  if (document.fwForm.extgroupOF18[0].checked)
  {   opFee18="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
  if (document.getElementById("extNoOfUnits18"))
  {    noOfUnits18 = document.getElementById("extNoOfUnits18").value; if(noOfUnits18==""){noOfUnits18 = "0";} }  
 } 
  if(document.getElementsByName("extgroupOF19").length > 0)
  {
   if (document.fwForm.extgroupOF19[0].checked)
   {   opFee19="YES"; opFeeString = opFeeString +'Y'; } else { opFeeString = opFeeString +'N';}
   if (document.getElementById("extNoOfUnits19"))
   {    noOfUnits19 = document.getElementById("extNoOfUnits19").value; if(noOfUnits19==""){noOfUnits19 = "0";} }  
 }
 if(document.getElementById("extgroupOF3"))
 {
   if (document.fwForm.extgroupOF3[0].checked)
   {
     opFee3="YES";
   }  
 }

 //alert("sending optFeeString = " + opFeeString);

  todayDateFromS = document.getElementById("extCalendarFrom").value;
  todayDateFrom = "'" + todayDateFromS + "'";
  todayDateToS = document.getElementById("extCalendarTo").value;
  todayDateTo = "'" + todayDateToS + "'";
  //alert("todayDateTo = " + todayDateTo);
  
  fromDateD = new Date(todayDateFromS);
  toDateD = new Date(todayDateToS);
  
  //******************  CHAD CHANGE toDateD to day -1 because we capture this
  //date and date of departure
   toDateD.setDate(toDateD.getDate() - 1);

  dateTodayD = new Date();

  difference = Math.abs(toDateD.getTime() - fromDateD.getTime());
  //alert("difference = " + difference);
  daysUntilReservation = Math.abs(dateTodayD.getTime() - fromDateD.getTime());
  daysDiff = (difference / (1000 * 60 * 60 * 24)) + 1;  
  daysUntilReservation = (daysUntilReservation / (1000 * 60 * 60 * 24)) + 1; 
  //make sure we are rounded
  daysDiff = Math.round(daysDiff);
  daysUntilReservation = Math.round(daysUntilReservation);

  fromDate = "'" + todayDateFromS + "'";
  toDate = "'" + todayDateToS + "'";

  //** MYSQL CHANGES
  //alert("start To date = " + toDateD);
  buildMySQL_TO_DATE(toDateD);
  //alert("new To date = " + toDateMySQL);
  buildMySQL_FROM_DATE(fromDateD);

  if(authType != '1')
  {
    if((roomId > "") && (roomId != "0"))
    {
      setResponseURL("myAvailabilityWResPT2MU.jsp?fwModuleName=genKfrent&extLID="+listingId+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID="+roomId+"&extBC="+colorPref+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extNoOfPets="+noOfPets+"&extNoOfPetsOW="+noOfPetsOverLbs+"&extMOP="+mop+"&extOF1="+opFee1+"&extOF2="+opFee2+"&extOpFee3="+opFee3+"&extNoOfUnits1="+noOfUnits1+"&extNoOfUnits2="+noOfUnits2+"&extOF4="+opFee4+"&extOF4Q="+noOfUnits4+"&extOF5="+opFee5+"&extOF5Q="+noOfUnits5+"&extOF6="+opFee6+"&extOF6Q="+noOfUnits6+"&extOF7="+opFee7+"&extOF7Q="+noOfUnits7+"&extOF8="+opFee8+"&extOF8Q="+noOfUnits8+"&extOF9="+opFee9+"&extOF9Q="+noOfUnits9+"&extOF10="+opFee10+"&extOF10Q="+noOfUnits10+"&extOF11="+opFee11+"&extOF11Q="+noOfUnits11+"&extOF12="+opFee12+"&extOF12Q="+noOfUnits12+"&extOF13="+opFee13+"&extOF13Q="+noOfUnits13+"&extOF14="+opFee14+"&extOF14Q="+noOfUnits14+"&extOF15="+opFee15+"&extOF15Q="+noOfUnits15+"&extOF16="+opFee16+"&extOF16Q="+noOfUnits16+"&extOF17="+opFee17+"&extOF17Q="+noOfUnits17+"&extOF18="+opFee18+"&extOF18Q="+noOfUnits18+"&extOF19="+opFee19+"&extOF19Q="+noOfUnits19);
    }
    else
    {
      if(winType=="IFRAME")
      {
          setResponseURL("resPT2_IFRAME.jsp?fwModuleName=genKfrent&extDateFrame=1&extLID="+listingId+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID="+roomId+"&extBC="+colorPref+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extRms="+noOfRooms+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extNoOfPets="+noOfPets+"&extNoOfPetsOW="+noOfPetsOverLbs+"&extMOP="+mop+"&extOF1="+opFee1+"&extOF2="+opFee2+"&extOpFee3="+opFee3+"&extNoOfUnits1="+noOfUnits1+"&extNoOfUnits2="+noOfUnits2+"&extOF4="+opFee4+"&extOF4Q="+noOfUnits4+"&extOF5="+opFee5+"&extOF5Q="+noOfUnits5+"&extOF6="+opFee6+"&extOF6Q="+noOfUnits6+"&extOF7="+opFee7+"&extOF7Q="+noOfUnits7+"&extOF8="+opFee8+"&extOF8Q="+noOfUnits8+"&extOF9="+opFee9+"&extOF9Q="+noOfUnits9+"&extOF10="+opFee10+"&extOF10Q="+noOfUnits10+"&extOF11="+opFee11+"&extOF11Q="+noOfUnits11+"&extOF12="+opFee12+"&extOF12Q="+noOfUnits12+"&extOF13="+opFee13+"&extOF13Q="+noOfUnits13+"&extOF14="+opFee14+"&extOF14Q="+noOfUnits14+"&extOF15="+opFee15+"&extOF15Q="+noOfUnits15+"&extOF16="+opFee16+"&extOF16Q="+noOfUnits16+"&extOF17="+opFee17+"&extOF17Q="+noOfUnits17+"&extOF18="+opFee18+"&extOF18Q="+noOfUnits18+"&extOF19="+opFee19+"&extOF19Q="+noOfUnits19+"#DETAILS");
      }
      else
      {
          setResponseURL("resPT2.jsp?fwModuleName=genKfrent&extDateFrame=1&extLID="+listingId+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID="+roomId+"&extBC="+colorPref+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extRms="+noOfRooms+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extCPN="+couponCode+"&extHearingImpaired="+extHearingImpaired+"&extNoOfPets="+noOfPets+"&extNoOfPetsOW="+noOfPetsOverLbs+"&extMOP="+mop+"&extOF1="+opFee1+"&extOF2="+opFee2+"&extOpFee3="+opFee3+"&extNoOfUnits1="+noOfUnits1+"&extNoOfUnits2="+noOfUnits2+"&extOF4="+opFee4+"&extOF4Q="+noOfUnits4+"&extOF5="+opFee5+"&extOF5Q="+noOfUnits5+"&extOF6="+opFee6+"&extOF6Q="+noOfUnits6+"&extOF7="+opFee7+"&extOF7Q="+noOfUnits7+"&extOF8="+opFee8+"&extOF8Q="+noOfUnits8+"&extOF9="+opFee9+"&extOF9Q="+noOfUnits9+"&extOF10="+opFee10+"&extOF10Q="+noOfUnits10+"&extOF11="+opFee11+"&extOF11Q="+noOfUnits11+"&extOF12="+opFee12+"&extOF12Q="+noOfUnits12+"&extOF13="+opFee13+"&extOF13Q="+noOfUnits13+"&extOF14="+opFee14+"&extOF14Q="+noOfUnits14+"&extOF15="+opFee15+"&extOF15Q="+noOfUnits15+"&extOF16="+opFee16+"&extOF16Q="+noOfUnits16+"&extOF17="+opFee17+"&extOF17Q="+noOfUnits17+"&extOF18="+opFee18+"&extOF18Q="+noOfUnits18+"&extOF19="+opFee19+"&extOF19Q="+noOfUnits19+"#DETAILS");
      }
    }
  }
  else
  {
    if((roomId > "") && (roomId != "0"))
    {
      setResponseURL("myAvailabilityWResPT2ManOverMU.jsp?fwModuleName=genKfrent&extLID="+listingId+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID="+roomId+"&extBC="+colorPref+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extNoOfPets="+noOfPets+"&extNoOfPetsOW="+noOfPetsOverLbs+"&extMOP="+mop+"&extOF1="+opFee1+"&extOF2="+opFee2+"&extOpFee3="+opFee3+"&extNoOfUnits1="+noOfUnits1+"&extNoOfUnits2="+noOfUnits2+"&extOF4="+opFee4+"&extOF4Q="+noOfUnits4+"&extOF5="+opFee5+"&extOF5Q="+noOfUnits5+"&extOF6="+opFee6+"&extOF6Q="+noOfUnits6+"&extOF7="+opFee7+"&extOF7Q="+noOfUnits7+"&extOF8="+opFee8+"&extOF8Q="+noOfUnits8+"&extOF9="+opFee9+"&extOF9Q="+noOfUnits9+"&extOF10="+opFee10+"&extOF10Q="+noOfUnits10+"&extOF11="+opFee11+"&extOF11Q="+noOfUnits11+"&extOF12="+opFee12+"&extOF12Q="+noOfUnits12+"&extOF13="+opFee13+"&extOF13Q="+noOfUnits13+"&extOF14="+opFee14+"&extOF14Q="+noOfUnits14+"&extOF15="+opFee15+"&extOF15Q="+noOfUnits15+"&extOF16="+opFee16+"&extOF16Q="+noOfUnits16+"&extOF17="+opFee17+"&extOF17Q="+noOfUnits17+"&extOF18="+opFee18+"&extOF18Q="+noOfUnits18+"&extOF19="+opFee19+"&extOF19Q="+noOfUnits19);
    }
    else
    {
      //alert("clear datasets and recs");
      clearDataSet("dsCCBatchByBatchId");
      setQueryParam("dsCCBatchByBatchId","argBatchId","");
      executeQuery("dsCCBatchByBatchId");
      clearDataSet("dsPaymentSummary");
      //setQueryParam("dsPaymentSummary","argBatchId","");
      //executeQuery("dsPaymentSummary");      
      clearDataSet("dsPaymentsDetail");
      //setQueryParam("dsPaymentsDetail","argPaymentId","");
      //executeQuery("dsPaymentsDetail");       
      clearDataSet("dsMiscCharges");
      clearDataSet("dsContactDetail");
      //setQueryParam("dsMiscCharges","argBatchId","");
      //executeQuery("dsMiscCharges");       
      setResponseURL("resPT2ManOver.jsp?fwModuleName=genKfrent&extDateFrame=1&extLID="+listingId+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID="+roomId+"&extBC="+colorPref+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extRms="+noOfRooms+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extCPN="+couponCode+"&extHearingImpaired="+extHearingImpaired+"&extNoOfPets="+noOfPets+"&extNoOfPetsOW="+noOfPetsOverLbs+"&extMOP="+mop+"&extOF1="+opFee1+"&extOF2="+opFee2+"&extOpFee3="+opFee3+"&extNoOfUnits1="+noOfUnits1+"&extNoOfUnits2="+noOfUnits2+"&extOF4="+opFee4+"&extOF4Q="+noOfUnits4+"&extOF5="+opFee5+"&extOF5Q="+noOfUnits5+"&extOF6="+opFee6+"&extOF6Q="+noOfUnits6+"&extOF7="+opFee7+"&extOF7Q="+noOfUnits7+"&extOF8="+opFee8+"&extOF8Q="+noOfUnits8+"&extOF9="+opFee9+"&extOF9Q="+noOfUnits9+"&extOF10="+opFee10+"&extOF10Q="+noOfUnits10+"&extOF11="+opFee11+"&extOF11Q="+noOfUnits11+"&extOF12="+opFee12+"&extOF12Q="+noOfUnits12+"&extOF13="+opFee13+"&extOF13Q="+noOfUnits13+"&extOF14="+opFee14+"&extOF14Q="+noOfUnits14+"&extOF15="+opFee15+"&extOF15Q="+noOfUnits15+"&extOF16="+opFee16+"&extOF16Q="+noOfUnits16+"&extOF17="+opFee17+"&extOF17Q="+noOfUnits17+"&extOF18="+opFee18+"&extOF18Q="+noOfUnits18+"&extOF19="+opFee19+"&extOF19Q="+noOfUnits19);
    }
  }
  if(document.getElementById("extClient"))
  {
      setResponseURL("resPT2_AH.jsp?fwModuleName=genKfrent&extDateFrame=1&extLID="+listingId+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID="+roomId+"&extBC="+colorPref+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extRms="+noOfRooms+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extCPN="+couponCode+"&extHearingImpaired="+extHearingImpaired+"&extNoOfPets="+noOfPets+"&extNoOfPetsOW="+noOfPetsOverLbs+"&extMOP="+mop+"&extOF1="+opFee1+"&extOF2="+opFee2+"&extOpFee3="+opFee3+"&extNoOfUnits1="+noOfUnits1+"&extNoOfUnits2="+noOfUnits2+"&extOF4="+opFee4+"&extOF4Q="+noOfUnits4+"&extOF5="+opFee5+"&extOF5Q="+noOfUnits5+"&extOF6="+opFee6+"&extOF6Q="+noOfUnits6+"&extOF7="+opFee7+"&extOF7Q="+noOfUnits7+"&extOF8="+opFee8+"&extOF8Q="+noOfUnits8+"&extOF9="+opFee9+"&extOF9Q="+noOfUnits9+"&extOF10="+opFee10+"&extOF10Q="+noOfUnits10+"&extOF11="+opFee11+"&extOF11Q="+noOfUnits11+"&extOF12="+opFee12+"&extOF12Q="+noOfUnits12+"&extOF13="+opFee13+"&extOF13Q="+noOfUnits13+"&extOF14="+opFee14+"&extOF14Q="+noOfUnits14+"&extOF15="+opFee15+"&extOF15Q="+noOfUnits15+"&extOF16="+opFee16+"&extOF16Q="+noOfUnits16+"&extOF17="+opFee17+"&extOF17Q="+noOfUnits17+"&extOF18="+opFee18+"&extOF18Q="+noOfUnits18+"&extOF19="+opFee19+"&extOF19Q="+noOfUnits19+"#DETAILS");
  }
  
  //Trying to fix the rowNo is out of bounds error for dsContactDetail
  appendIfNoRow("dsContactDetail");
  
  //clearDataSet("dsGetAvailableRooms");
  /* Build the script segment.*/
  //var segment13 = 'MultiUnitAdmin.getAvailableRooms2("'+listingId+'","'+subUnitId+'","'+fromDateMySQL+'","'+toDateMySQL+'","'+daysDiff+'","'+roomId+'","'+daysUntilReservation+'","'+needPetDep+'","'+noOfPeople+'")';
  //var segment13 = 'MultiUnitAdmin.getAvailableRooms1("'+listingId+'","'+todayDateFrom+'","'+todayDateTo+'","'+daysDiff+'","'+daysUntilReservation+'","'+needPetDep+'","'+noOfPeople+'","'+fromDateMySQL+'","'+toDateMySQL+'")';
    if((roomId > "") && (roomId != "0"))
    {
      var segment13 = 'ProcessReservations.processRequestMultiUnit("'+listingId+'","'+subUnitId+'","'+todayDateFrom+'","'+todayDateTo+'","'+daysDiff+'","'+daysUntilReservation+'","'+needPetDep+'","'+noOfPeople+'","'+fromDateMySQL+'","'+toDateMySQL+'","'+opFee1+'","'+opFee2+'")';
    }
    else
    {
      var segment13 = 'ProcessReservations.processRequestNormal("'+listingId+'","'+todayDateFrom+'","'+todayDateTo+'","'+daysDiff+'","'+daysUntilReservation+'","'+needPetDep+'","'+noToCharge+'","'+fromDateMySQL+'","'+toDateMySQL+'","'+opFee1+'","'+opFee2+'","'+opFeeString+'")';
    }

  buildScriptSegment(segment13); 
  //may need to call this class
  //getAvailableRooms1(String listingID, String dateFrom, String dateTo, String daysDiff, String daysUntilReservation, String needPetDep, String noOfPeople, String dateToMySQL, String dateFromMySQL)
  

  setQueryParam("dsListingFeeSetup", "argListingId", listingId);
  setQueryParam("dsListingFeeSetupOptional", "argListingId", listingId);
  setQueryParam("dsCheckDateRanges", "argListingId", listingId);
  setQueryParam("dsCheckDateRanges", "argSubUnitId", subUnitId);
  setQueryParam("dsRatesDetail", "argListingId", listingId);
  setQueryParam("dsRatesDetail", "argSubUnitId", subUnitId);
  setQueryParam("dsOwnerAdChannelDropDown", "argOwnerId", argOwnerId);
  //setQueryParam("dsRoomsBySubUnitID", "argListingId", listingId);
  //setQueryParam("dsRoomsBySubUnitID", "argSubUnitId", subUnitId);  

  executeQuery("dsListingFeeSetup");
  executeQuery("dsListingFeeSetupOptional");
  executeQuery("dsCheckDateRanges");
  executeQuery("dsRatesDetail");
  executeQuery("dsOwnerAdChannelDropDown");
  //executeQuery("dsRoomsBySubUnitID");  

  submitForm(window, "fwForm");

}

function editCCRecordLite(argBatchId, argListingId)
{
  propOwnerId = document.getElementById("extOwnerId").value;
  setQueryParam("dsCCBatchByBatchId","argBatchId",argBatchId);
  executeQuery("dsCCBatchByBatchId");
  setQueryParam("dsCCBatchOptionalByBatchId","argBatchId",argBatchId);
  executeQuery("dsCCBatchOptionalByBatchId");  
  setQueryParam("dsListingFeeSetupOptional","argListingId",argListingId);
  executeQuery("dsListingFeeSetupOptional");    
  setQueryParam("dsOwnerListingCountByOwner","argOwnerId",propOwnerId);
  executeQuery("dsOwnerListingCountByOwner");
  setQueryParam("dsPaymentSummary","argBatchId",argBatchId);
  executeQuery("dsPaymentSummary");  
  setResponseURL("editCCRecordLite.jsp");
  submitForm(window, "fwForm");
}
function editBatchRecord(argListingId, argBatchId)
{
  setQueryParam("dsListingScheduleByBatchID","argBatchId",argBatchId);
  executeQuery("dsListingScheduleByBatchID");  
  //alert(""+document.getElementById('extOwnerId').value);
  setQueryParam("dsOwnerListingCountByOwner","argOwnerId",document.getElementById('extOwnerId').value);
  executeQuery("dsOwnerListingCountByOwner");    

  setQueryParam("dsCleaningScheduleByBatchID","argBatchId",argBatchId);
  executeQuery("dsCleaningScheduleByBatchID"); 
  appendIfNoRow("dsCleaningScheduleByBatchID");
  setQueryParam("dsCancellationSetup","argListingId",argListingId);
  executeQuery("dsCancellationSetup");
  setQueryParam("dsMiscCharges","argBatchId",argBatchId);
  executeQuery("dsMiscCharges");
  setQueryParam("dsPaymentSummary","argBatchId",argBatchId);
  executeQuery("dsPaymentSummary");  
  setQueryParam("dsListingFeeSetup","argListingId",argListingId);
  executeQuery("dsListingFeeSetup");
  setQueryParam("dsListingFeeSetupOptional","argListingId",argListingId);
  executeQuery("dsListingFeeSetupOptional");  
  setQueryParam("dsCCBatchByBatchId","argBatchId",argBatchId);
  executeQuery("dsCCBatchByBatchId");
  setQueryParam("dsCCBatchOptionalByBatchId","argBatchId",argBatchId);
  executeQuery("dsCCBatchOptionalByBatchId"); 
  setQueryParam("dsReservationNotes","argBatchId",argBatchId);
  executeQuery("dsReservationNotes");   
  //setQueryParam("dsContactDetail","argBatchId",argBatchId);
  //executeQuery("dsContactDetail"); 
  //appendIfNoRow("dsContactDetail");
  
  setResponseURL("editRecordFromOnlineRequest.jsp?fwModuleName=genKfrent&extListingId="+argListingId+"&extBatchId="+argBatchId+"&extRecordType=");
  submitForm(window, "fwForm");
}
function editBatchRecord2(argListingId, argBatchId, argType)
{
  setQueryParam("dsListingScheduleByBatchID","argBatchId",argBatchId);
  executeQuery("dsListingScheduleByBatchID");  
  setQueryParam("dsOwnerListingCountByOwner","argOwnerId",document.getElementById('extOwnerId').value);
  executeQuery("dsOwnerListingCountByOwner");    
  setQueryParam("dsCleaningScheduleByBatchID","argBatchId",argBatchId);
  executeQuery("dsCleaningScheduleByBatchID"); 
  appendIfNoRow("dsCleaningScheduleByBatchID");
  setQueryParam("dsReservationNotes","argBatchId",argBatchId);
  executeQuery("dsReservationNotes");  
  setQueryParam("dsCancellationSetup","argListingId",argListingId);
  executeQuery("dsCancellationSetup");
  setQueryParam("dsMiscCharges","argBatchId",argBatchId);
  executeQuery("dsMiscCharges");
  setQueryParam("dsPaymentSummary","argBatchId",argBatchId);
  executeQuery("dsPaymentSummary"); 
  setQueryParam("dsContactDetail","argBatchId",argBatchId);
//Kent 02-09-2011 commented out the line below
//  executeQuery("dsContactDetail"); 
  setQueryParam("dsPreferences","argOwnerId",document.getElementById('extOwnerId').value);
  executeQuery("dsPreferences");   
  appendIfNoRow("dsContactDetail");    
    setQueryParam("dsListingFeeSetup","argListingId",argListingId);
    executeQuery("dsListingFeeSetup");
    setQueryParam("dsListingFeeSetupOptional","argListingId",argListingId);
    executeQuery("dsListingFeeSetupOptional");    
    setQueryParam("dsCCBatchByBatchId","argBatchId",argBatchId);
    executeQuery("dsCCBatchByBatchId");  
  setQueryParam("dsCCBatchOptionalByBatchId","argBatchId",argBatchId);
  executeQuery("dsCCBatchOptionalByBatchId"); 
  //executeQuery("dsCleaningTypes");
    setResponseURL("editCCRecord_b.jsp?fwModuleName=genKfrent&extListingId="+argListingId+"&extBatchId="+argBatchId+"&extRecordType=");
  submitForm(window, "fwForm");
}
function enterPriorReservation(argOwnerId)
{
  clearDataSet("dsCCBatchByBatchId");
  clearDataSet("dsPaymentsDetail");
  clearDataSet("dsPaymentSummary");
  clearDataSet("dsContactDetail");
  setQueryParam("dsOwnerListingCountByOwner","argOwnerId",argOwnerId);
  executeQuery("dsOwnerListingCountByOwner");
  
  setResponseURL("enterPriorReservation.jsp");
  submitForm(window, "fwForm");
}

function buildSpaceAvailableRate(rowNo)
{
//************************************

  listingId = document.getElementById("extLISTING_ID").value;
  //alert("genKfrent - buildSpaceAvailableRate, listId from dsCheckDateRanges = " + listingId);

  extNoOfAdults = document.fwForm.extNoOfAdults.value;
  extNoOfChildren = document.fwForm.extNoOfChildren.value;

  var extHearingImpaired = "no";
  var extHandicapped = "no";
  noOfPeople = parseInt(extNoOfAdults) + parseInt(extNoOfChildren);
  //EVAL
  //alert("no of people = " + noOfPeople); 
  if (document.fwForm.extHandicapped[0].checked)
  {
      extHandicapped = "yes";
  }
  if (document.fwForm.extHearingImpaired[0].checked)
  {
      extHearingImpaired = "yes";
  }

  needPetDep = "NO";
  //alert("room ID = " + roomId);
  fromDate = document.getElementById("extdateFrom").value;
  toDate = document.getElementById("extdateTo").value;
  if(document.fwForm.extgroup2[0].checked)
  { 
    needPetDep = "YES";
  }
  
  fromDateD = new Date(fromDate);
  toDateD = new Date(toDate);
    var day = toDateD.getDate();
    var month = toDateD.getMonth()  + 1;
    var year = toDateD.getFullYear();
    rawToDate = "'"+month + '/' + day + '/' + year+"'";

  //we are colleting the depart date...so set it to day before
  toDateD.setDate(toDateD.getDate() - 1);
  dateTodayD = new Date();
  difference = Math.abs(toDateD.getTime() - fromDateD.getTime());
  daysUntilReservation = Math.abs(dateTodayD.getTime() - fromDateD.getTime());
  daysDiff = (difference / (1000 * 60 * 60 * 24)) + 1;  
  daysUntilReservation = (daysUntilReservation / (1000 * 60 * 60 * 24)) + 1; 
  //make sure we are rounded
  daysDiff = Math.round(daysDiff);
  daysUntilReservation = Math.round(daysUntilReservation);
  //alert("new TO date = " + toDateD + " days difference = " + daysDiff);
  
  var day = toDateD.getDate();
  var month = toDateD.getMonth()  + 1;
  var year = toDateD.getFullYear();
  toDate = month + '/' + day + '/' + year;
//*** NEW CODE FOR MY SQL
  var day = toDateD.getDate();
  if(String(day).length == 1){ day = '0'+day};
  var month = toDateD.getMonth()  + 1;
   if(String(month).length == 1){ month = '0'+month};
  var year = toDateD.getFullYear();
  toDate = year + '-' + month + '-' + day;
  day = fromDateD.getDate();
  if(String(day).length == 1){ day = '0'+day};
  month = fromDateD.getMonth()  + 1;
   if(String(month).length == 1){ month = '0'+month;};
  year = fromDateD.getFullYear();
  fromDate = year + '-' + month + '-' + day;
  //alert("genKfrent.js fromDate = " + fromDate);
  //**** END NEW CODE
   
  fromDate = "'" + fromDate + "'";
  toDate = "'" + toDate + "'";

  setResponseURL("MyAvailableDatesSpaceAvailAR.jsp?fwModuleName=genKfrent&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extHandicapped="+extHandicapped+"&extFromDate="+fromDate+"&extToDate="+rawToDate+"&extHearingImpaired="+extHearingImpaired+"#entryPoint");
  

  /* Build the script segment.*/
  var segment13 = 'MultiUnitAdmin.buildSpaceAvailableRate("'+listingId+'","'+fromDate+'","'+toDate+'","'+daysDiff+'","'+daysUntilReservation+'","'+needPetDep+'","'+noOfPeople+'")';
  buildScriptSegment(segment13); 

  setQueryParam("dsListingFeeSetup", "argListingId", listingId);
  setQueryParam("dsRatesDetail", "argListingId", listingId);
  setQueryParam("dsRatesDetail", "argSubUnitId", "0");

  executeQuery("dsListingFeeSetup");
  executeQuery("dsRatesDetail");
 

  submitForm(window, "fwForm");


}

function getAvailableRoomsPM(rowNo)
{
//************************************

  listingId = document.getElementById("dsCheckDateRangesNonMulti-LISTING_ID").value;
  //subUnitId = document.getElementById("dsCheckDateRanges-SUBUNIT_ID").value;
  //roomId = document.getElementById("dsRoomsBySubUnitID-ROOM_NAME").value;
  extNoOfAdults = document.fwForm.extNoOfAdults.value;
  extNoOfChildren = document.fwForm.extNoOfChildren.value;

  var extHearingImpaired = "no";
  var extHandicapped = "no";
  noOfPeople = parseInt(extNoOfAdults) + parseInt(extNoOfChildren);
  //EVAL
  //alert("no of people = " + noOfPeople); 
  if (document.fwForm.extHandicapped[0].checked)
  {
      extHandicapped = "yes";
  }
  if (document.fwForm.extHearingImpaired[0].checked)
  {
      extHearingImpaired = "yes";
  }

  needPetDep = "NO";
  //alert("room ID = " + roomId);
  fromDate = document.getElementById("extdateFrom").value;
  toDate = document.getElementById("extdateTo").value;
  if(document.fwForm.extgroup2[0].checked)
  { 
    needPetDep = "YES";
  }
  
  fromDateD = new Date(fromDate);
  toDateD = new Date(toDate);
  //we are colleting the depart date...so set it to day before
  toDateD.setDate(toDateD.getDate() - 1);
  dateTodayD = new Date();
  difference = Math.abs(toDateD.getTime() - fromDateD.getTime());
  daysUntilReservation = Math.abs(dateTodayD.getTime() - fromDateD.getTime());
  daysDiff = (difference / (1000 * 60 * 60 * 24)) + 1;  
  daysUntilReservation = (daysUntilReservation / (1000 * 60 * 60 * 24)) + 1; 
  //make sure we are rounded
  daysDiff = Math.round(daysDiff);
  daysUntilReservation = Math.round(daysUntilReservation);
  //alert("new TO date = " + toDateD + " days difference = " + daysDiff);
  
  var day = toDateD.getDate();
    if (day.length < 2)
    { day = "0"+day; }  
  var month = toDateD.getMonth()  + 1;
    if (month.length < 2)
    { month = "0"+month; }  
  var year = toDateD.getFullYear();

  toDate = month + '/' + day + '/' + year;
  //** MYSQL CHANGES
  //alert("start To date = " + toDateD);
  buildMySQL_TO_DATE(toDateD);
  //alert("new To date = " + toDateMySQL);
  buildMySQL_FROM_DATE(fromDateD);

  fromDate = "'" + fromDate + "'";
  toDate = "'" + toDate + "'";

  setResponseURL("MyAvailableDatesPMAR.jsp?fwModuleName=genKfrent&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"#entryPoint");
  
  //clearDataSet("dsGetAvailableRooms");
  /* Build the script segment.*/
  var segment13 = 'MultiUnitAdmin.getAvailableRooms1("'+listingId+'","'+fromDate+'","'+toDate+'","'+daysDiff+'","'+daysUntilReservation+'","'+needPetDep+'","'+noOfPeople+'","'+toDateMySQL+'","'+fromDateMySQL+'")';
  buildScriptSegment(segment13); 

setQueryParam("dsListingFeeSetup", "argListingId", listingId);
setQueryParam("dsCheckDateRangesNonMulti", "argListingId", listingId);
setQueryParam("dsCheckDateRangesNonMulti", "argSubUnitId", "0");
setQueryParam("dsRatesDetail", "argListingId", listingId);
setQueryParam("dsRatesDetail", "argSubUnitId", "0");

executeQuery("dsListingFeeSetup");
executeQuery("dsCheckDateRangesNonMulti");
executeQuery("dsRatesDetail");
//executeQuery("dsRoomsBySubUnitID"); 

submitForm(window, "fwForm");
}


function buildMySQL_TO_DATE(toDateD)
   {
       dayT = toDateD.getDate();
       if (dayT.length < 2)
       { dayT = "0"+dayT; }  
       monthT = toDateD.getMonth()  + 1;
       if (monthT.length < 2)
       { monthT = "0"+monthT; }  
       yearT = toDateD.getFullYear();
       //firefox fix
       if(yearT == 109) {yearT = "2009";}
       if(yearT == 110) {yearT = "2010";}
       if(yearT == 111) {yearT = "2011";}
       if(yearT == 112) {yearT = "2012";}
       if(yearT == 113) {yearT = "2013";}
       if(yearT == 114) {yearT = "2014";}
       if(yearT == 115) {yearT = "2015";}
       if(yearT == 116) {yearT = "2016";}
       if(yearT == 117) {yearT = "2017";}
       if(yearT == 118) {yearT = "2018";}
       if(yearT == 119) {yearT = "2019";}
       toDateMySQL = yearT + '-' + monthT + '-' + dayT;
    }

function buildMySQL_FROM_DATE(fromDateD)
   {
       dayF = fromDateD.getDate();
       if (dayF.length < 2)
       { dayF = "0"+dayF; }  
       monthF = fromDateD.getMonth()  + 1;
       if (monthF.length < 2)
       { monthF = "0"+monthF; }  
       yearF = fromDateD.getFullYear();
       //firefox fix
       if(yearF == 109) {yearF = "2009";}
       if(yearF == 110) {yearF = "2010";}
       if(yearF == 111) {yearF = "2011";}
       if(yearF == 112) {yearF = "2012";}
       if(yearF == 113) {yearF = "2013";}
       if(yearF == 114) {yearF = "2014";}
       if(yearF == 115) {yearF = "2015";}
       if(yearF == 116) {yearF = "2016";}
       if(yearF == 117) {yearF = "2017";}
       if(yearF == 118) {yearF = "2018";}
       if(yearF == 119) {yearF = "2019";}
       fromDateMySQL = yearF + '-' + monthF + '-' + dayF;
    }    

function buildMySQL_TODAY_DATE(todayDateD)
   {
       dayF = todayDateD.getDate();
       if (dayF.length < 2)
       { dayF = "0"+dayF; }  
       monthF = todayDateD.getMonth()  + 1;
       if (monthF.length < 2)
       { monthF = "0"+monthF; }  
       yearF = todayDateD.getFullYear();
       todayDateMySQL = yearF + '-' + monthF + '-' + dayF;
    } 
    
function reserveRoom(rowNo)
{
  listingId = document.getElementById("extdsGetAvailableRoomsByRoomId-LISTING_ID"+rowNo).value;
  subUnitId = document.getElementById("extdsGetAvailableRoomsByRoomId-SUBUNIT_ID"+rowNo).value;
  roomId = document.getElementById("extdsGetAvailableRoomsByRoomId-ROOM_ID"+rowNo).value;
  dateFrom = document.getElementById("extdateFrom"+rowNo).value;
  dateTo = document.getElementById("extdateTo"+rowNo).value;
  charge = document.getElementById("extcurrentcharge"+rowNo).value;
  balanceDue = document.getElementById("extbaldue"+rowNo).value;
  roomName = document.getElementById("extroomName"+rowNo).value;
  deposit = document.getElementById("extdeposit"+rowNo).value;
  tax = document.getElementById("exttax"+rowNo).value; 
  additionalPartyFee = document.getElementById("extadditionalPartyFee"+rowNo).value;
  
  extDepOnly  = document.getElementById("extDepOnly"+rowNo).value;
  extPetDep  = document.getElementById("extPetDep"+rowNo).value;
  extUtilityDep  = document.getElementById("extUtilityDep"+rowNo).value;
  extOtherFee1  = document.getElementById("extOtherFee1"+rowNo).value;
  extOtherFee2  = document.getElementById("extOtherFee2"+rowNo).value; 
  extOtherFee3  = document.getElementById("extOtherFee3"+rowNo).value;
  if(extOtherFee3 == "") { extOtherFee3=0;}
  extCleaningFee = document.getElementById("extCleaningFee"+rowNo).value;
  extTotalReservationTax  = document.getElementById("extTotalReservationTax"+rowNo).value;
  extApplicationFee = document.getElementById("extApplicationFee"+rowNo).value;
  extRentalTax = document.getElementById("extRentalTax"+rowNo).value;
  extRefAmt = document.getElementById("extRefAmt"+rowNo).value;
  extTotDisc = document.getElementById("extTotDisc"+rowNo).value;
  extNoOfAdults = document.getElementById("extNoOfAdults").value;
  extNoOfChildren = document.getElementById("extNoOfChildren").value;
  extHandicapped = 0;
  extHearingImpaired = 0;
  if (document.fwForm.extHandicapped[0].checked)
  {
      extHandicapped = 1;
  }
  if (document.fwForm.extHearingImpaired[0].checked)
  {
      extHearingImpaired = 1;
  }  

  
  
  rentalChargeType = "DEPOSIT";  
  if ((deposit == 0) || (deposit == '0.00'))
  {
     rentalChargeType = "BALANCE DUE";
     charge = balanceDue;
  } 

  dateFromMQ = dateFrom.substring(1,(dateFrom.length -1));
  //alert("date to with quotes = " + dateTo);
  dateToMQ = dateTo.substring(1,(dateTo.length -1));

  fromDateD = new Date(dateFromMQ);
  toDateD = new Date(dateToMQ);  
  fromDateD.setDate(fromDateD.getDate() - 1);
  //CHAD NEW DATE SETUP
  //toDateD.setDate(toDateD.getDate() + 1);
  toDateD.setDate(toDateD.getDate());
  //alert("new from date = " + fromDateD);
  fromDateS = formatNewDate(fromDateD);
  toDateS = formatNewDate(toDateD);
  fromDateMinusOne = "'" + fromDateS + "'";
  toDatePlusOne = "'" + toDateS + "'";  
  
 
//5-14-11   setResponseURL(secureURLStart+"MyReservationCCInfo.jsp?fwModuleName=genKfrent&extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRefAmt="+extRefAmt+"&extTotDisc="+extTotDisc);
   setResponseURL("MyReservationCCInfo.jsp?extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRefAmt="+extRefAmt+"&extTotDisc="+extTotDisc);

  
   setQueryParam("dsCCBatch", "argListingId", listingId);
   setQueryParam("dsCCBatch", "argSubUnitId", subUnitId);
   setQueryParam("dsCCBatch", "argRoomId", roomId);
 
   executeQuery("dsCCBatch");
   appendRow("dsCCBatch");

 
  /* Submit the Form */
  submitForm(window, "fwForm");
}

function findAvailableProperties()
{

  ownerId = document.getElementById("extOwnerId").value;
  todayDateFromS = document.getElementById("extCalendarFrom").value;
  todayDateFrom = "'" + todayDateFromS + "'";
  
  todayDateToS = document.getElementById("extCalendarTo").value;
  todayDateTo = "'" + todayDateToS + "'";
  
  fromDateD = new Date(todayDateFromS);
  toDateD = new Date(todayDateToS);
  dateTodayD = new Date();

  difference = Math.abs(toDateD.getTime() - fromDateD.getTime());
  daysUntilReservation = Math.abs(dateTodayD.getTime() - fromDateD.getTime());
  daysDiff = (difference / (1000 * 60 * 60 * 24)) + 1;  
  daysUntilReservation = (daysUntilReservation / (1000 * 60 * 60 * 24)) + 1; 
  //make sure we are rounded
  daysDiff = Math.round(daysDiff);
  daysUntilReservation = Math.round(daysUntilReservation);
  
  fromDate = "'" + todayDateFromS + "'";
  toDate = "'" + todayDateToS + "'";
  //** MYSQL CHANGES
  buildMySQL_TO_DATE(toDateD);
  buildMySQL_FROM_DATE(fromDateD);  
  //alert("From date = " + todayDateFromS + " and To date = " + todayDateToS);
  setResponseURL("findAvailProps.jsp?fwModuleName=genKfrent&extFromDate="+todayDateFromS+"&extToDate="+todayDateToS);
  
  /* Build the script segment.*/
  var segment13 = 'MultiUnitAdmin.findAvailableProps("'+fromDate+'","'+toDate+'","'+daysDiff+'","'+ownerId+'","'+fromDateMySQL+'","'+toDateMySQL+'")';
  buildScriptSegment(segment13); 

  submitForm(window, "fwForm");

}

function openAvailablePropertiesDetail()
{

  ownerId = document.getElementById("extOwnerId").value;
  //alert("owner id = " + ownerId);
  setResponseURL("openRentalSearch.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);

      setQueryParam("dsAmenities", "argRentalTypeNo", "1");      
      
      executeQuery("dsAmenities");
      //load the features
      executeQuery("dsPropertyListingByFeature");  

  submitForm(window, "fwForm");

}

function findAvailablePropertiesDetail()
{
 if(document.getElementById("extCalendarFrom").value == "")
 {
   alert("Please enter a valid date range to search by placing a curson in the from date field");
   return;
 }
 if(document.getElementById("extCalendarTo").value == "")
 {
   alert("Please enter a valid date range to search by placing a curson in the to date field");
   return;
 }
  noOfBedrooms = document.getElementById("dsPropertyListing-NUMBER_OF_BEDROOMS").value;
  
  if (noOfBedrooms == "ANY")
  { 
    noOfBedrooms = ">= 0";
  }
  
  ownerId = document.getElementById("extOwnerId").value;
  todayDateFromS = document.getElementById("extCalendarFrom").value;
  //todayDateFromMMDDYYYY = formatInputYYYYMMDD(todayDateFromS);
  //todayDateFromSMMDDYYYY = "'" + todayDateFromMMDDYYYY + "'";
  //todayDateFrom = "'" + todayDateFromS + "'";
  
  todayDateToS = document.getElementById("extCalendarTo").value;
  //todayDateToMMDDYYYY = formatInputYYYYMMDD(todayDateToS);
  //todayDateToSMMDDYYYY = "'" + todayDateToMMDDYYYY + "'";
  //todayDateTo = "'" + todayDateToS + "'";
  
  //fromDateD = new Date(todayDateFromMMDDYYYY);
  //toDateD = new Date(todayDateToMMDDYYYY);
   fromDateD = new Date(todayDateFromS);
   toDateD = new Date(todayDateToS);
  fromDateNorm = formatNewDateMMDDYYYY(fromDateD);
  toDateNorm = formatNewDateMMDDYYYY(toDateD);
  fromDate = "'" +formatNewDate(fromDateD)+"'";
  toDate = "'" +formatNewDate(toDateD) + "'";  
  
  dateTodayD = new Date();

  difference = Math.abs(toDateD.getTime() - fromDateD.getTime());
  daysUntilReservation = Math.abs(dateTodayD.getTime() - fromDateD.getTime());
  daysDiff = (difference / (1000 * 60 * 60 * 24)) + 1;  
  daysUntilReservation = (daysUntilReservation / (1000 * 60 * 60 * 24)) + 1; 
  //make sure we are rounded
  daysDiff = Math.round(daysDiff);
  daysUntilReservation = Math.round(daysUntilReservation);
  
  //fromDate = "'" + todayDateFromS + "'";
  //toDate = "'" + todayDateToS + "'";
  //alert("From date = " + todayDateFromS + " and To date = " + todayDateToS);
    if(document.getElementById("extCbx-calView").checked)
    {
       loadAllAvail2(fromDateNorm,toDateNorm,ownerId,noOfBedrooms); 
       return;
    }
    else
    {
     alert("Traditonal (non-grid view) is disabled. Please check back later");
     return;
    }
  setResponseURL("findAvailPropsDetail.jsp?fwModuleName=genKfrent&extFromDate="+todayDateFromS+"&extToDate="+todayDateToS);

      
  /* Build the script segment.*/
  var segment13 = 'MultiUnitAdmin.findAvailablePropsDetail("'+fromDate+'","'+toDate+'","'+daysDiff+'","'+ownerId+'","'+noOfBedrooms+'")';
  buildScriptSegment(segment13); 

  submitForm(window, "fwForm");

}

function reserveRoomPM(rowNo)
{
  listingId = document.getElementById("extdsGetAvailableRoomsByRoomId-LISTING_ID"+rowNo).value;
  subUnitId =  "0";
  roomId = "0";
  dateFrom = document.getElementById("extdateFrom"+rowNo).value;
  dateTo = document.getElementById("extdateTo"+rowNo).value;
  charge = document.getElementById("extcurrentcharge"+rowNo).value;
  balanceDue = document.getElementById("extbaldue"+rowNo).value;
  roomName = "not applicable";
  deposit = document.getElementById("extdeposit"+rowNo).value;
  tax = document.getElementById("exttax"+rowNo).value; 
  additionalPartyFee = document.getElementById("extadditionalPartyFee"+rowNo).value;
  
  extDepOnly  = document.getElementById("extDepOnly"+rowNo).value;
  extPetDep  = document.getElementById("extPetDep"+rowNo).value;
  extUtilityDep  = document.getElementById("extUtilityDep"+rowNo).value;
  extOtherFee1  = document.getElementById("extOtherFee1"+rowNo).value;
  extOtherFee2  = document.getElementById("extOtherFee2"+rowNo).value; 
  extOtherFee3  = document.getElementById("extOtherFee3"+rowNo).value;
  if(extOtherFee3 == "") { extOtherFee3=0;}
  extCleaningFee = document.getElementById("extCleaningFee"+rowNo).value;
  extTotalReservationTax  = document.getElementById("extTotalReservationTax"+rowNo).value;
  extApplicationFee = document.getElementById("extApplicationFee"+rowNo).value;
  extRentalTax = document.getElementById("extRentalTax"+rowNo).value;
  extNoOfAdults = document.fwForm.extNoOfAdults.value;
  extNoOfChildren = document.fwForm.extNoOfChildren.value;
  extHandicapped = 0;
  extHearingImpaired = 0;
  if (document.fwForm.extHandicapped[0].checked)
  {
      extHandicapped = 1;
  }
  if (document.fwForm.extHearingImpaired[0].checked)
  {
      extHearingImpaired = 1;
  }  

  
  
  rentalChargeType = "DEPOSIT";  
  if ((deposit == 0) || (deposit == '0.00'))
  {
     rentalChargeType = "BALANCE DUE";
     charge = balanceDue;
  } 

  dateFromMQ = dateFrom.substring(1,(dateFrom.length -1));
  //alert("date to with quotes = " + dateTo);
  dateToMQ = dateTo.substring(1,(dateTo.length -1));
  //alert("date to without quotes = " + dateToMQ);
  //alert("cleaning fee = " + extCleaningFee);
  fromDateD = new Date(dateFromMQ);
  toDateD = new Date(dateToMQ);  
  fromDateD.setDate(fromDateD.getDate() - 1);
  //CHAD NEW DATE SETUP
  //toDateD.setDate(toDateD.getDate() + 1);
  toDateD.setDate(toDateD.getDate());
  //alert("new from date = " + fromDateD);
  fromDateS = formatNewDate(fromDateD);
  toDateS = formatNewDate(toDateD);
  fromDateMinusOne = "'" + fromDateS + "'";
  toDatePlusOne = "'" + toDateS + "'";  
  

//5-14-11   setResponseURL(secureURLStart+"MyReservationCCInfo.jsp?fwModuleName=genKfrent&extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee);
   setResponseURL("MyReservationCCInfo.jsp?extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee);

   setQueryParam("dsCCBatch", "argListingId", listingId);
   setQueryParam("dsCCBatch", "argSubUnitId", subUnitId);
   setQueryParam("dsCCBatch", "argRoomId", roomId);
 
   executeQuery("dsCCBatch");
   appendRow("dsCCBatch");

 
  /* Submit the Form */
  submitForm(window, "fwForm");
}

function reserveRoomPMkfr(rowNo)
{ 
  listingId = document.getElementById("extdsGetAvailableRoomsByRoomId-LISTING_ID"+rowNo).value;
  subUnitId =  document.getElementById("extdsGetAvailableRoomsByRoomId-ROOM_ID"+rowNo).value;
  roomId = document.getElementById("extdsGetAvailableRoomsByRoomId-SUBUNIT_ID"+rowNo).value;

  extManOver = document.getElementById("extManOver").value;
  dateFrom = document.getElementById("extdateFrom"+rowNo).value;
  dateTo = document.getElementById("extdateTo"+rowNo).value;
  charge = document.getElementById("extcurrentcharge"+rowNo).value;
  realRentalCharge = document.getElementById("extcharge"+rowNo).value;
  //alert("realRentalCharge = " + realRentalCharge);
  balanceDue = document.getElementById("extbaldue"+rowNo).value;
  roomName = "not applicable";
  deposit = document.getElementById("extdeposit"+rowNo).value;
  tax = document.getElementById("exttax"+rowNo).value; 
  additionalPartyFee = document.getElementById("extadditionalPartyFee"+rowNo).value;
  noOfRooms = "";
  if(document.getElementById("extNoOfBedrooms"))
  {
    noOfRooms = document.getElementById("extNoOfBedrooms").value;
  }

  extDepOnly  = document.getElementById("extDepOnly"+rowNo).value;
  extPetDep  = document.getElementById("extPetDep"+rowNo).value;
      if(extPetDep=="0.0"){extPetDep="0.00"}
  extPetFee  = document.getElementById("extPetFee"+rowNo).value;
  //alert("petFee = " + extPetFee);
  extUtilityDep  = document.getElementById("extUtilityDep"+rowNo).value;
  extOtherFee1  = document.getElementById("extOtherFee1"+rowNo).value;
  extOtherFee2  = document.getElementById("extOtherFee2"+rowNo).value;
  extOtherFee3  = document.getElementById("extOtherFee3"+rowNo).value;
    if(extOtherFee3=="0"){extOtherFee3="0.00"}
  if(extOtherFee3 == "") { extOtherFee3="0.00";}
  if(extOtherFee1 == ".00") { extOtherFee1="0.00";}
  if(extOtherFee2 == ".00") { extOtherFee2="0.00";}
  if(additionalPartyFee == ".00") { additionalPartyFee="0.00";}
  extOptFee1  = document.getElementById("extOptFee1"+rowNo).value; extOF1Qty  = document.getElementById("extOptFee1Qty"+rowNo).value;
  extOptFee2  = document.getElementById("extOptFee2"+rowNo).value; extOF2Qty  = document.getElementById("extOptFee2Qty"+rowNo).value; 
  extOptFee3  = document.getElementById("extOptFee3"+rowNo).value;
  extOF4  = document.getElementById("extOptFee4"+rowNo).value; extOF4Qty  = document.getElementById("extOptFee4Qty"+rowNo).value;
  extOF5  = document.getElementById("extOptFee5"+rowNo).value; extOF5Qty  = document.getElementById("extOptFee5Qty"+rowNo).value;
  extOF6  = document.getElementById("extOptFee6"+rowNo).value; extOF6Qty  = document.getElementById("extOptFee6Qty"+rowNo).value;
  extOF7  = document.getElementById("extOptFee7"+rowNo).value; extOF7Qty  = document.getElementById("extOptFee7Qty"+rowNo).value;
  extOF8  = document.getElementById("extOptFee8"+rowNo).value; extOF8Qty  = document.getElementById("extOptFee8Qty"+rowNo).value;
  extOF9  = document.getElementById("extOptFee9"+rowNo).value; extOF9Qty  = document.getElementById("extOptFee9Qty"+rowNo).value;
  extOF10  = document.getElementById("extOptFee10"+rowNo).value; extOF10Qty  = document.getElementById("extOptFee10Qty"+rowNo).value;
  extOF11  = document.getElementById("extOptFee11"+rowNo).value; extOF11Qty  = document.getElementById("extOptFee11Qty"+rowNo).value;
  extOF12  = document.getElementById("extOptFee12"+rowNo).value; extOF12Qty  = document.getElementById("extOptFee12Qty"+rowNo).value;
  extOF13  = document.getElementById("extOptFee13"+rowNo).value; extOF13Qty  = document.getElementById("extOptFee13Qty"+rowNo).value;
  extOF14  = document.getElementById("extOptFee14"+rowNo).value; extOF14Qty  = document.getElementById("extOptFee14Qty"+rowNo).value;
  extOF15  = document.getElementById("extOptFee15"+rowNo).value; extOF15Qty  = document.getElementById("extOptFee15Qty"+rowNo).value;
  extOF16  = document.getElementById("extOptFee16"+rowNo).value; extOF16Qty  = document.getElementById("extOptFee16Qty"+rowNo).value;
  extOF17  = document.getElementById("extOptFee17"+rowNo).value; extOF17Qty  = document.getElementById("extOptFee17Qty"+rowNo).value;
  extOF18  = document.getElementById("extOptFee18"+rowNo).value; extOF18Qty  = document.getElementById("extOptFee18Qty"+rowNo).value;
  extOF19  = document.getElementById("extOptFee19"+rowNo).value; extOF19Qty  = document.getElementById("extOptFee19Qty"+rowNo).value;
  if(extOptFee3 == "") { extOptFee3=0;}
  extST  = document.getElementById("extStateTax"+rowNo).value; 
  extCT  = document.getElementById("extCountyTax"+rowNo).value;
  extLclT  = document.getElementById("extLocalTax"+rowNo).value;
  extLdgT  = document.getElementById("extLodgingTax"+rowNo).value;
  extTT  = document.getElementById("extTourismTax"+rowNo).value;
  extOthT  = document.getElementById("extOtherTax"+rowNo).value;
  extProcFee  = document.getElementById("extProcFee"+rowNo).value;
  extCDAmt = document.getElementById("extCDAmt"+rowNo).value;
  extCode = document.getElementById("extCode"+rowNo).value;
   if(extProcFee == "")
  { 
     extProcFee="0.00";
  }
  
  extCleaningFee = document.getElementById("extCleaningFee"+rowNo).value;
  extTotalReservationTax  = document.getElementById("extTotalReservationTax"+rowNo).value;
  extApplicationFee = document.getElementById("extApplicationFee"+rowNo).value;
  if(extApplicationFee=="0.0"){extApplicationFee="0.00"}
  extRentalTax = document.getElementById("extRentalTax"+rowNo).value;
  extUseTax = document.getElementById("extUseTax"+rowNo).value;
  extRealRentTotal = document.getElementById("extRealRentTotal"+rowNo).value;
  extNoOfAdults = document.fwForm.extNoOfAdults.value;
  extNoOfChildren = document.fwForm.extNoOfChildren.value;
  noOfPets = "0";
  noOfPetsOW = "0";
  if(document.getElementById("extNoOfPets"))
  {
    noOfPets = document.getElementById("extNoOfPets").value;
  }
  if(document.getElementById("exttrRowNoPetsOverLbs"))
  {
    noOfPetsOW = document.getElementById("exttrRowNoPetsOverLbs").value;
  } 
  if(noOfPets == "0")
  {
    if((extPetDep > 0) || (extPetFee > 0))
    {
      noOfPets = "1";
    }
  }
  //alert("noOfPets=" + noOfPets);
  extNoOfChargeChildren = document.fwForm.extNoOfChargeChildren.value;  
  extHandicapped = 0;
  extHearingImpaired = 0;
  if (document.fwForm.extHandicapped.checked)
  {
      extHandicapped = 1;
  }
  if (document.fwForm.extHearingImpaired.checked)
  {
      extHearingImpaired = 1;
  }  

  rentalChargeType = "BALANCE%20DUE";  
  if ((deposit == 0) || (deposit == '0.00'))
  {
     rentalChargeType = "BALANCE DUE";
     charge = balanceDue;
  } 

  dateFromMQ = dateFrom.substring(1,(dateFrom.length -1));
  dateToMQ = dateTo.substring(1,(dateTo.length -1));
  fromDateD = new Date(dateFromMQ);
  fromDateD1 = new Date(dateFromMQ);
  toDateD = new Date(dateToMQ);  

fromDateD1.setDate(fromDateD1.getDate());
fromDateS = formatNewDate(fromDateD1);
  enteredFromDate =  fromDateS ;
  fromDateD.setDate(fromDateD.getDate() - 1);
  //CHAD NEW DATE SETUP
  //toDateD.setDate(toDateD.getDate() + 1);
  toDateD.setDate(toDateD.getDate());
  //alert("new from date = " + fromDateD);
  fromDateS = formatNewDate(fromDateD);
  fromDateS1 = formatNewDate(fromDateD1);
  toDateS = formatNewDate(toDateD);
  fromDateMinusOne =  fromDateS ;

  toDatePlusOne =  toDateS ;  
  
  extReqCCInfo = document.getElementById("extReqCCInfo").value;
  
//CHAD NEED TO FIX ARRIVAL DATE(dateFromMQ) and DEPARTURE DATE(dateToMQ)
   if(extManOver == 1)
   {
     clearDataSet("dsCCBatchByBatchId");
     clearDataSet("dsCCBatchOptionalByBatchId");
     clearDataSet("dsContactDetail");  
     clearDataSet("dsErrors"); 
     appendIfNoRow("dsCCBatchByBatchId");
     appendIfNoRow("dsCCBatchOptionalByBatchId");
     appendIfNoRow("dsContactDetail");
     appendRow("dsPaymentsDetail");
     setQueryParam("dsOwnersTable", "argListingId", listingId);
     executeQuery("dsOwnersTable"); 
     setQueryParam("dsHouseKeepingUsers", "argOwnerId", document.getElementById("extOwnerId").value);
     executeQuery("dsHouseKeepingUsers"); 
     executeQuery("dsCleaningTypes"); 
  /* Build the script segment.*/
//5-14-11     setResponseURL(secureURLStart+"managerReservation.jsp?fwModuleName=genKfrent&extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extUseTax="+extUseTax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extEnteredFromDate="+enteredFromDate+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extPetFee="+extPetFee+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRentalChargeOnly="+realRentalCharge+"&extOptFee1="+extOptFee1+"&extOptFee2="+extOptFee2+"&extOptFee3="+extOptFee3+"&extManOver="+extManOver+"&extST="+extST+"&extCT="+extCT+"&extLclT="+extLclT+"&extLdgT="+extLdgT+"&extTT="+extTT+"&extOthT="+extOthT+"&extRecordType=NEW&extNoOfPets="+noOfPets+"&extNoOfPetsOW="+noOfPetsOW+"&extRRT="+extRealRentTotal+"&extProcFee="+extProcFee+"&extOF1Q="+extOF1Qty+"&extOF2Q="+extOF2Qty+"&extOF4="+extOF4+"&extOF4Q="+extOF4Qty+"&extOF5="+extOF5+"&extOF5Q="+extOF5Qty+"&extOF6="+extOF6+"&extOF6Q="+extOF6Qty+"&extOF7="+extOF7+"&extOF7Q="+extOF7Qty+"&extOF8="+extOF8+"&extOF8Q="+extOF8Qty+"&extOF9="+extOF9+"&extOF9Q="+extOF9Qty+"&extOF10="+extOF10+"&extOF10Q="+extOF10Qty+"&extOF11="+extOF11+"&extOF11Q="+extOF11Qty+"&extOF12="+extOF12+"&extOF12Q="+extOF12Qty+"&extOF13="+extOF13+"&extOF13Q="+extOF13Qty+"&extOF14="+extOF14+"&extOF14Q="+extOF14Qty+"&extOF15="+extOF15+"&extOF15Q="+extOF15Qty+"&extOF16="+extOF16+"&extOF16Q="+extOF16Qty+"&extOF17="+extOF17+"&extOF17Q="+extOF17Qty+"&extOF18="+extOF18+"&extOF18Q="+extOF18Qty+"&extOF19="+extOF19+"&extOF19Q="+extOF19Qty);
     setResponseURL("managerReservation.jsp?extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extUseTax="+extUseTax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extEnteredFromDate="+enteredFromDate+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extPetFee="+extPetFee+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRentalChargeOnly="+realRentalCharge+"&extOptFee1="+extOptFee1+"&extOptFee2="+extOptFee2+"&extOptFee3="+extOptFee3+"&extManOver="+extManOver+"&extST="+extST+"&extCT="+extCT+"&extLclT="+extLclT+"&extLdgT="+extLdgT+"&extTT="+extTT+"&extOthT="+extOthT+"&extRecordType=NEW&extNoOfPets="+noOfPets+"&extNoOfPetsOW="+noOfPetsOW+"&extRRT="+extRealRentTotal+"&extProcFee="+extProcFee+"&extOF1Q="+extOF1Qty+"&extOF2Q="+extOF2Qty+"&extOF4="+extOF4+"&extOF4Q="+extOF4Qty+"&extOF5="+extOF5+"&extOF5Q="+extOF5Qty+"&extOF6="+extOF6+"&extOF6Q="+extOF6Qty+"&extOF7="+extOF7+"&extOF7Q="+extOF7Qty+"&extOF8="+extOF8+"&extOF8Q="+extOF8Qty+"&extOF9="+extOF9+"&extOF9Q="+extOF9Qty+"&extOF10="+extOF10+"&extOF10Q="+extOF10Qty+"&extOF11="+extOF11+"&extOF11Q="+extOF11Qty+"&extOF12="+extOF12+"&extOF12Q="+extOF12Qty+"&extOF13="+extOF13+"&extOF13Q="+extOF13Qty+"&extOF14="+extOF14+"&extOF14Q="+extOF14Qty+"&extOF15="+extOF15+"&extOF15Q="+extOF15Qty+"&extOF16="+extOF16+"&extOF16Q="+extOF16Qty+"&extOF17="+extOF17+"&extOF17Q="+extOF17Qty+"&extOF18="+extOF18+"&extOF18Q="+extOF18Qty+"&extOF19="+extOF19+"&extOF19Q="+extOF19Qty);
   }
   else
   {
     clearDataSet("dsCCBatch");
     clearDataSet("dsContactDetail");
     clearDataSet("dsPaymentsDetail");
     appendIfNoRow("dsCCBatch");
     appendIfNoRow("dsPaymentsDetail");
     appendIfNoRow("dsContactDetail");
     if(extReqCCInfo == 1)
     {
       if(document.getElementById("extIFRAME"))
       {
//5-14-11           setResponseURL(secureURLStart+"MyReservationCCInfoKFRIFRAME.jsp?fwModuleName=genKfrent&extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extUseTax="+extUseTax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extEnteredFromDate="+enteredFromDate+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extPetFee="+extPetFee+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRentalChargeOnly="+realRentalCharge+"&extOptFee1="+extOptFee1+"&extOptFee2="+extOptFee2+"&extOptFee3="+extOptFee3+"&extManOver="+extManOver+"&extST="+extST+"&extCT="+extCT+"&extLclT="+extLclT+"&extLdgT="+extLdgT+"&extTT="+extTT+"&extOthT="+extOthT+"&extRRT="+extRealRentTotal+"&extProcFee="+extProcFee+"&extOF1Q="+extOF1Qty+"&extOF2Q="+extOF2Qty+"&extOF4="+extOF4+"&extOF4Q="+extOF4Qty+"&extOF5="+extOF5+"&extOF5Q="+extOF5Qty+"&extOF6="+extOF6+"&extOF6Q="+extOF6Qty+"&extOF7="+extOF7+"&extOF7Q="+extOF7Qty+"&extOF8="+extOF8+"&extOF8Q="+extOF8Qty+"&extOF9="+extOF9+"&extOF9Q="+extOF9Qty+"&extOF10="+extOF10+"&extOF10Q="+extOF10Qty+"&extOF11="+extOF11+"&extOF11Q="+extOF11Qty+"&extOF12="+extOF12+"&extOF12Q="+extOF12Qty+"&extOF13="+extOF13+"&extOF13Q="+extOF13Qty+"&extOF14="+extOF14+"&extOF14Q="+extOF14Qty+"&extOF15="+extOF15+"&extOF15Q="+extOF15Qty+"&extOF16="+extOF16+"&extOF16Q="+extOF16Qty+"&extOF17="+extOF17+"&extOF17Q="+extOF17Qty+"&extOF18="+extOF18+"&extOF18Q="+extOF18Qty+"&extOF19="+extOF19+"&extOF19Q="+extOF19Qty+"&extCDAmt="+extCDAmt+"&extCode="+extCode);
           setResponseURL("MyReservationCCInfoKFRIFRAME.jsp?extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extUseTax="+extUseTax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extEnteredFromDate="+enteredFromDate+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extPetFee="+extPetFee+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRentalChargeOnly="+realRentalCharge+"&extOptFee1="+extOptFee1+"&extOptFee2="+extOptFee2+"&extOptFee3="+extOptFee3+"&extManOver="+extManOver+"&extST="+extST+"&extCT="+extCT+"&extLclT="+extLclT+"&extLdgT="+extLdgT+"&extTT="+extTT+"&extOthT="+extOthT+"&extRRT="+extRealRentTotal+"&extProcFee="+extProcFee+"&extOF1Q="+extOF1Qty+"&extOF2Q="+extOF2Qty+"&extOF4="+extOF4+"&extOF4Q="+extOF4Qty+"&extOF5="+extOF5+"&extOF5Q="+extOF5Qty+"&extOF6="+extOF6+"&extOF6Q="+extOF6Qty+"&extOF7="+extOF7+"&extOF7Q="+extOF7Qty+"&extOF8="+extOF8+"&extOF8Q="+extOF8Qty+"&extOF9="+extOF9+"&extOF9Q="+extOF9Qty+"&extOF10="+extOF10+"&extOF10Q="+extOF10Qty+"&extOF11="+extOF11+"&extOF11Q="+extOF11Qty+"&extOF12="+extOF12+"&extOF12Q="+extOF12Qty+"&extOF13="+extOF13+"&extOF13Q="+extOF13Qty+"&extOF14="+extOF14+"&extOF14Q="+extOF14Qty+"&extOF15="+extOF15+"&extOF15Q="+extOF15Qty+"&extOF16="+extOF16+"&extOF16Q="+extOF16Qty+"&extOF17="+extOF17+"&extOF17Q="+extOF17Qty+"&extOF18="+extOF18+"&extOF18Q="+extOF18Qty+"&extOF19="+extOF19+"&extOF19Q="+extOF19Qty+"&extCDAmt="+extCDAmt+"&extCode="+extCode);
       }
       else
       {
//5-14-11           setResponseURL(secureURLStart+"MyReservationCCInfoKFR.jsp?fwModuleName=genKfrent&extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extRms="+noOfRooms+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extUseTax="+extUseTax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extEnteredFromDate="+enteredFromDate+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extPetFee="+extPetFee+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRentalChargeOnly="+realRentalCharge+"&extOptFee1="+extOptFee1+"&extOptFee2="+extOptFee2+"&extOptFee3="+extOptFee3+"&extManOver="+extManOver+"&extST="+extST+"&extCT="+extCT+"&extLclT="+extLclT+"&extLdgT="+extLdgT+"&extTT="+extTT+"&extOthT="+extOthT+"&extRRT="+extRealRentTotal+"&extProcFee="+extProcFee+"&extOF1Q="+extOF1Qty+"&extOF2Q="+extOF2Qty+"&extOF4="+extOF4+"&extOF4Q="+extOF4Qty+"&extOF5="+extOF5+"&extOF5Q="+extOF5Qty+"&extOF6="+extOF6+"&extOF6Q="+extOF6Qty+"&extOF7="+extOF7+"&extOF7Q="+extOF7Qty+"&extOF8="+extOF8+"&extOF8Q="+extOF8Qty+"&extOF9="+extOF9+"&extOF9Q="+extOF9Qty+"&extOF10="+extOF10+"&extOF10Q="+extOF10Qty+"&extOF11="+extOF11+"&extOF11Q="+extOF11Qty+"&extOF12="+extOF12+"&extOF12Q="+extOF12Qty+"&extOF13="+extOF13+"&extOF13Q="+extOF13Qty+"&extOF14="+extOF14+"&extOF14Q="+extOF14Qty+"&extOF15="+extOF15+"&extOF15Q="+extOF15Qty+"&extOF16="+extOF16+"&extOF16Q="+extOF16Qty+"&extOF17="+extOF17+"&extOF17Q="+extOF17Qty+"&extOF18="+extOF18+"&extOF18Q="+extOF18Qty+"&extOF19="+extOF19+"&extOF19Q="+extOF19Qty+"&extCDAmt="+extCDAmt+"&extCode="+extCode);
           setResponseURL("MyReservationCCInfoKFR.jsp?extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extRms="+noOfRooms+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extUseTax="+extUseTax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extEnteredFromDate="+enteredFromDate+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extPetFee="+extPetFee+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRentalChargeOnly="+realRentalCharge+"&extOptFee1="+extOptFee1+"&extOptFee2="+extOptFee2+"&extOptFee3="+extOptFee3+"&extManOver="+extManOver+"&extST="+extST+"&extCT="+extCT+"&extLclT="+extLclT+"&extLdgT="+extLdgT+"&extTT="+extTT+"&extOthT="+extOthT+"&extRRT="+extRealRentTotal+"&extProcFee="+extProcFee+"&extOF1Q="+extOF1Qty+"&extOF2Q="+extOF2Qty+"&extOF4="+extOF4+"&extOF4Q="+extOF4Qty+"&extOF5="+extOF5+"&extOF5Q="+extOF5Qty+"&extOF6="+extOF6+"&extOF6Q="+extOF6Qty+"&extOF7="+extOF7+"&extOF7Q="+extOF7Qty+"&extOF8="+extOF8+"&extOF8Q="+extOF8Qty+"&extOF9="+extOF9+"&extOF9Q="+extOF9Qty+"&extOF10="+extOF10+"&extOF10Q="+extOF10Qty+"&extOF11="+extOF11+"&extOF11Q="+extOF11Qty+"&extOF12="+extOF12+"&extOF12Q="+extOF12Qty+"&extOF13="+extOF13+"&extOF13Q="+extOF13Qty+"&extOF14="+extOF14+"&extOF14Q="+extOF14Qty+"&extOF15="+extOF15+"&extOF15Q="+extOF15Qty+"&extOF16="+extOF16+"&extOF16Q="+extOF16Qty+"&extOF17="+extOF17+"&extOF17Q="+extOF17Qty+"&extOF18="+extOF18+"&extOF18Q="+extOF18Qty+"&extOF19="+extOF19+"&extOF19Q="+extOF19Qty+"&extCDAmt="+extCDAmt+"&extCode="+extCode);
       }       
     }
     else
     {
//5-14-11       setResponseURL(secureURLStart+"MyReservationInfoKFR.jsp?fwModuleName=genKfrent&extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extRms="+noOfRooms+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extUseTax="+extUseTax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extEnteredFromDate="+enteredFromDate+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extPetFee="+extPetFee+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRentalChargeOnly="+realRentalCharge+"&extOptFee1="+extOptFee1+"&extOptFee2="+extOptFee2+"&extOptFee3="+extOptFee3+"&extManOver="+extManOver+"&extST="+extST+"&extCT="+extCT+"&extLclT="+extLclT+"&extLdgT="+extLdgT+"&extTT="+extTT+"&extOthT="+extOthT+"&extRRT="+extRealRentTotal+"&extProcFee="+extProcFee+"&extOF1Q="+extOF1Qty+"&extOF2Q="+extOF2Qty+"&extOF4="+extOF4+"&extOF4Q="+extOF4Qty+"&extOF5="+extOF5+"&extOF5Q="+extOF5Qty+"&extOF6="+extOF6+"&extOF6Q="+extOF6Qty+"&extOF7="+extOF7+"&extOF7Q="+extOF7Qty+"&extOF8="+extOF8+"&extOF8Q="+extOF8Qty+"&extOF9="+extOF9+"&extOF9Q="+extOF9Qty+"&extOF10="+extOF10+"&extOF10Q="+extOF10Qty+"&extOF11="+extOF11+"&extOF11Q="+extOF11Qty+"&extOF12="+extOF12+"&extOF12Q="+extOF12Qty+"&extOF13="+extOF13+"&extOF13Q="+extOF13Qty+"&extOF14="+extOF14+"&extOF14Q="+extOF14Qty+"&extOF15="+extOF15+"&extOF15Q="+extOF15Qty+"&extOF16="+extOF16+"&extOF16Q="+extOF16Qty+"&extOF17="+extOF17+"&extOF17Q="+extOF17Qty+"&extOF18="+extOF18+"&extOF18Q="+extOF18Qty+"&extOF19="+extOF19+"&extOF19Q="+extOF19Qty+"&extCDAmt="+extCDAmt+"&extCode="+extCode);
       setResponseURL("MyReservationInfoKFR.jsp?extListingId="+listingId+"&extSubUnitId="+subUnitId+"&extChargeType="+rentalChargeType+"&extRoomId="+roomId+"&extRms="+noOfRooms+"&extBalDue="+balanceDue+"&extCleaningFee="+extCleaningFee+"&extDeposit="+deposit+"&extTax="+tax+"&extUseTax="+extUseTax+"&extRentalCharge="+charge+"&extArrivalDate="+dateFromMQ+"&extDepartureDate="+dateToMQ+"&extRoomName="+roomName+"&extArrivalDateWQ="+dateFrom+"&extDepartDateWQ="+dateTo+"&extArrivalDateMO="+fromDateMinusOne+"&extEnteredFromDate="+enteredFromDate+"&extDepartDatePO="+toDatePlusOne+"&extDepOnly="+extDepOnly+"&extPetDep="+extPetDep+"&extPetFee="+extPetFee+"&extUtilityDep="+extUtilityDep+"&extOtherFee1="+extOtherFee1+"&extOtherFee2="+extOtherFee2+"&extOtherFee3="+extOtherFee3+"&extTotalReservationTax="+extTotalReservationTax+"&extApplicationFee="+extApplicationFee+"&extRentalTax="+extRentalTax+"&extNoOfAdults="+extNoOfAdults+"&extNoOfChildren="+extNoOfChildren+"&extNoOfChargeChildren="+extNoOfChargeChildren+"&extHandicapped="+extHandicapped+"&extHearingImpaired="+extHearingImpaired+"&extadditionalPartyFee="+additionalPartyFee+"&extRentalChargeOnly="+realRentalCharge+"&extOptFee1="+extOptFee1+"&extOptFee2="+extOptFee2+"&extOptFee3="+extOptFee3+"&extManOver="+extManOver+"&extST="+extST+"&extCT="+extCT+"&extLclT="+extLclT+"&extLdgT="+extLdgT+"&extTT="+extTT+"&extOthT="+extOthT+"&extRRT="+extRealRentTotal+"&extProcFee="+extProcFee+"&extOF1Q="+extOF1Qty+"&extOF2Q="+extOF2Qty+"&extOF4="+extOF4+"&extOF4Q="+extOF4Qty+"&extOF5="+extOF5+"&extOF5Q="+extOF5Qty+"&extOF6="+extOF6+"&extOF6Q="+extOF6Qty+"&extOF7="+extOF7+"&extOF7Q="+extOF7Qty+"&extOF8="+extOF8+"&extOF8Q="+extOF8Qty+"&extOF9="+extOF9+"&extOF9Q="+extOF9Qty+"&extOF10="+extOF10+"&extOF10Q="+extOF10Qty+"&extOF11="+extOF11+"&extOF11Q="+extOF11Qty+"&extOF12="+extOF12+"&extOF12Q="+extOF12Qty+"&extOF13="+extOF13+"&extOF13Q="+extOF13Qty+"&extOF14="+extOF14+"&extOF14Q="+extOF14Qty+"&extOF15="+extOF15+"&extOF15Q="+extOF15Qty+"&extOF16="+extOF16+"&extOF16Q="+extOF16Qty+"&extOF17="+extOF17+"&extOF17Q="+extOF17Qty+"&extOF18="+extOF18+"&extOF18Q="+extOF18Qty+"&extOF19="+extOF19+"&extOF19Q="+extOF19Qty+"&extCDAmt="+extCDAmt+"&extCode="+extCode);
     }
   }

setQueryParam("dsListingFeeSetup", "argListingId", listingId);
executeQuery("dsListingFeeSetup");

  /* Submit the Form */
  submitForm(window, "fwForm");
}

function openReports()
{
  argOwnerId = document.getElementById("extOwnerId").value;
  setResponseURL("earningsStatement.jsp?fwModuleName=genKfrentReports&extOwnerId="+argOwnerId+"&extListingId=ALL&extMoYr=default&extFrom= &extTo= ");
  submitForm(window, "fwForm");
}
function getEarningsStatement(rowNo)
{
  argOwnerId = document.getElementById("extOwnerId").value;
  argListingId = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
  argSubUnitId = document.getElementById("extdsPropertyListingByOwnerMUuserid-B.SUBUNIT_ID"+rowNo).value;
  argRoomId = "0";//need a way to get a room id someday
  argMUname = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.MULTIUNIT_NAME"+rowNo).value;
  argMUname = argMUname.replace("#","");
  setQueryParam("dsPreferences","argOwnerId",argOwnerId);
  executeQuery("dsPreferences");
  setQueryParam("dsOwnerAddEdit","argListingId",argListingId);
  executeQuery("dsOwnerAddEdit");  

  setResponseURL("earningsStatement.jsp?fwModuleName=genKfrentReports&extOwnerId="+argOwnerId+"&extListingId="+argListingId+"&extSubUnitId="+argSubUnitId+"&extRoomId="+argRoomId+"&extMoYr=default&extCO=0&extMUName="+argMUname+"&extFrom= &extTo= ");
  submitForm(window, "fwForm");
}
function getEarningsStatementBdrm(listdesc,listcode)
{
 if (document.getElementById("ext"+listcode).selectedIndex == 0)
 {
   alert("Please select a property from the " + listdesc+ " drop-down list first.");
 }
 else
 {
   list_idx = document.getElementById("ext"+listcode).selectedIndex;
   argListingId = document.getElementById("ext"+listcode).options[list_idx].value;
   argMUname = document.getElementById("ext"+listcode).options[list_idx].text;

  argOwnerId = document.getElementById("extOwnerId").value;
  argSubUnitId = "0";;
  argRoomId = "0";//need a way to get a room id someday
  
  setQueryParam("dsPreferences","argOwnerId",argOwnerId);
  executeQuery("dsPreferences");

  setResponseURL("earningsStatement.jsp?fwModuleName=genKfrentReports&extOwnerId="+argOwnerId+"&extListingId="+argListingId+"&extSubUnitId="+argSubUnitId+"&extRoomId="+argRoomId+"&extMoYr=default&extCO=0&extMUName="+argMUname+"&extFrom= &extTo= ");
  submitForm(window, "fwForm");
 }
}

function saveReservedDates(checkFlag)
{
  if((document.getElementById("dsCCBatch-LISTING_ID").value == "") || (document.getElementById("dsCCBatch-LISTING_ID").value == null))
  {
    alert("An error has occurred processing this reservation. This may be attributed to security settings and/or session timeout. Please begin the reservation process again by closing this window and clicking the 'reserve now' link again for this property.");
    return;
  }
 
 document.getElementById("dsCCBatch-EMAIL_ADDRESS").value = document.getElementById("dsPaymentsDetail-CARDHOLDER_EMAIL").value;
 document.getElementById("dsCCBatch-PHONE_NUMBER").value = document.getElementById("dsPaymentsDetail-CARDHOLDER_PHONE").value;
 document.getElementById("dsCCBatch-OPTIONAL_PHONE_NUMBER").value = document.getElementById("dsPaymentsDetail-CARDHOLDER_PHONE_CELL").value;
 if(checkFlag == "1")
 {
   if(document.getElementsByName("extMOP")[0].checked)
   {
     document.getElementById("dsPaymentsDetail-PAYMENT_AMT").value = document.getElementById("extCurrentDue").value;
   }
   else
   {
     document.getElementById("dsPaymentsDetail-CHECK_AMT").value = document.getElementById("extCurrentDue").value;
   }
 }
 else
 {
   document.getElementById("dsPaymentsDetail-PAYMENT_AMT").value = document.getElementById("extCurrentDue").value;
 }
 emailAddr=document.getElementById("dsCCBatch-EMAIL_ADDRESS").value;
 arrivalD=document.getElementById("dsCCBatch-ARRIVAL_DATE").value;
 departureD=document.getElementById("dsCCBatch-DEPARTURE_DATE").value;
 phoneNum=document.getElementById("dsCCBatch-PHONE_NUMBER").value;
 tenant=document.getElementById("dsCCBatch-NAME_ON_RESERVATION").value;
 
  dateTodayD = new Date(); 
  toDateNorm = formatNewDate(dateTodayD);
  //alert("arrivaldate = " + document.getElementById("dsCCBatch-ARRIVAL_DATE").value);
 document.getElementById("dsPaymentsDetail-PAYMENT_DATE").value = "" + toDateNorm;

  if(document.getElementById("agreeToTerms").checked == false)
  {
    alert("You must click the checkbox to agree to the terms of the agreement and fees calculated for the rental.");
    return;
  }
  if(document.getElementById("dsCCBatch-NAME_ON_RESERVATION").value == "")
  {
    alert("You must enter a guest name. Thank You.");
    return;
  }
  if(document.getElementById("dsPaymentsDetail-CARDHOLDER_EMAIL").value == "")
  {
    alert("You must enter an email address. Thank You.");
    return;
  }
   if(document.getElementsByName("extMOP")[0].checked)
   {
     if ((checkCreditCard('dsPaymentsDetail-CC_TYPE','dsPaymentsDetail-CC_NUMBER') != true) && (checkEmail('dsPaymentsDetail-CARDHOLDER_EMAIL',false) != true))
     {
       return;
     }
   }
   else
   {
     if(checkEmail('dsPaymentsDetail-CARDHOLDER_EMAIL',false) != true)
     {
       return;
     }
   }
     //alert("both checks = true");
     if(document.getElementById("dsPaymentsDetail-CARDHOLDER_EMAIL").value != document.getElementById("extComfirmEMAIL").value)
     {
       alert("Your email address does not match the confirm email address. Please verify.");
       return;     
     }
     if(document.getElementById("dsCCBatch-OPTIONAL_EMAIL_ADDRESS").value != document.getElementById("extComfirmEMAIL2").value)
     {
       alert("Your 2nd email address does not match the confirm email address. Please verify.");
       return;     
     }     
     if((document.getElementById("dsPaymentsDetail-CARDHOLDER_PHONE").value == "") && (document.getElementById("dsPaymentsDetail-CARDHOLDER_PHONE_CELL").value == ""))
     {
       alert("You must enter at least one contact number, Home or Cell. Thank You.");
       return;     
     }
     if(document.getElementsByName("extMOP")[0].checked)
     {
       if(document.getElementById("dsPaymentsDetail-CARDHOLDER_NAME").value == "") 
       {
         alert("You must enter the Cardholder's Name Thank You.");
         return;
       }     
     }     
     if(document.getElementById("dsCCBatch-TENANT_ADDRESS").value == "") 
     {
       alert("You must enter the address of your party. Thank You.");
       return;     
     }
     if(document.getElementById("dsCCBatch-TENANT_CITY").value == "") 
     {
       alert("You must enter the city of your party. Thank You.");
       return;     
     }
     if(document.getElementById("dsCCBatch-TENANT_STATE_PROV").value == "") 
     {
       alert("You must enter the state abbreviation of your party. Enter 'none' if you have no state. Thank You.");
       return;     
     }     
     if(document.getElementById("dsCCBatch-TENANT_ZIP_NATION_CODE").value == "") 
     {
       alert("You must enter the zipcode of your party. Thank You.");
       return;     
     }
     if(document.getElementsByName("extMOP")[0].checked)
     { 
       if(document.getElementById("dsPaymentsDetail-CARD_AUTHORIZATION_NUMBER").value == "")
       {
         alert("You must enter the card CVV/CCV (3 or 4 digit code). Thank You.");
         return;      
       }
     }
     else
     {
       if(document.getElementById("dsPaymentsDetail-BANKING_INSTITUTION").value == "") 
       {
         alert("You must enter the banking institution. Thank You.");
         return;     
       }
       if(document.getElementById("dsPaymentsDetail-ACCOUNT_NO").value == "") 
       {
         alert("You must enter the banking account number. Thank You.");
         return;     
       }
       if(document.getElementById("dsPaymentsDetail-ROUTING_NO").value == "") 
       {
         alert("You must enter the banking routing number. Thank You.");
         return;     
       }
     }
     if(document.getElementById("extRepeat"))
     {
       if(document.getElementById("extRepeat").checked == true)
       {
         document.getElementById("dsCCBatch-REPEAT_STAY").value = "1";
       }
     }
     
     //Set the address info for the payment to be used to process the ACH payment
     if(checkFlag == "1")
     {
       if(document.getElementsByName("extMOP")[1].checked)
       {
         //Enable the fileds to set the values to store on the payment
         document.getElementById("dsPaymentsDetail-CARDHOLDER_NAME").disabled = false;
         document.getElementById("dsPaymentsDetail-CARDHOLDER_ADDRESS").disabled = false;
	     document.getElementById("dsPaymentsDetail-CARDHOLDER_ADDRESS2").disabled = false;
	     document.getElementById("dsPaymentsDetail-CARDHOLDER_CITY").disabled = false;
	     document.getElementById("dsPaymentsDetail-CARDHOLDER_STATE_PROV").disabled = false;
	     document.getElementById("dsPaymentsDetail-CARDHOLDER_ZIP_NATION_CODE").disabled = false;
	     
         document.getElementById("dsPaymentsDetail-CHECK_NO").value = "0000";
         document.getElementById("dsPaymentsDetail-NAME_ON_CHECK").value = document.getElementById("dsCCBatch-NAME_ON_RESERVATION").value;
         document.getElementById("dsPaymentsDetail-CARDHOLDER_NAME").value = document.getElementById("dsCCBatch-NAME_ON_RESERVATION").value;
         document.getElementById("dsPaymentsDetail-CARDHOLDER_ADDRESS").value = document.getElementById("dsCCBatch-TENANT_ADDRESS").value;
         document.getElementById("dsPaymentsDetail-CARDHOLDER_ADDRESS2").value = document.getElementById("dsCCBatch-TENANT_ADDRESS2").value;
         document.getElementById("dsPaymentsDetail-CARDHOLDER_CITY").value = document.getElementById("dsCCBatch-TENANT_CITY").value;
         document.getElementById("dsPaymentsDetail-CARDHOLDER_STATE_PROV").value = document.getElementById("dsCCBatch-TENANT_STATE_PROV").value;
         document.getElementById("dsPaymentsDetail-CARDHOLDER_ZIP_NATION_CODE").value = document.getElementById("dsCCBatch-TENANT_ZIP_NATION_CODE").value;
         document.getElementById("dsPaymentsDetail-CARDHOLDER_NATION").value = document.getElementById("dsCCBatch-TENANT_NATION").value;
       }
     }
     //set fwModified for FIREFOX browser
     document.getElementById("fwModified").value = "true";
     
     gownerId = document.getElementById("dsCCBatch-OWNER_ID").value;
     glistingId = document.getElementById("dsCCBatch-LISTING_ID").value;
     gsubUnitId = document.getElementById("dsCCBatch-SUBUNIT_ID").value;
     gBATCHId = document.getElementById("dsCCBatch-BATCH_ID").value;
     groomId = document.getElementById("dsCCBatch-ROOM_ID").value;
     gcharge = document.getElementById("dsCCBatch-RENTAL_CHARGE").value;
     gfromDateMinusOne = document.getElementById("extarriveDateMO").value;
     gtoDatePlusOne = document.getElementById("extdepartDatePO").value;
     depositReq = document.getElementById("extdeposit").value;
     taxReq = document.getElementById("exttax").value;
     balanceDue = document.getElementById("extBalanceDue").value;
     manOveride = document.getElementById("extManOver").value;

     if(document.getElementById("extIFRAME"))
     {
//5-14-11       setResponseURL(secureURLStart+"myReservationThankYouIFRAME.jsp?fwModuleName=genKfrent&extListingId="+glistingId);
       setResponseURL("myReservationThankYouIFRAME.jsp?extListingId="+glistingId);
     }
     else
     {
//5-14-11       setResponseURL(secureURLStart+"myReservationThankYou.jsp?fwModuleName=genKfrent");
       setResponseURL("myReservationThankYou.jsp");
     }     
     var segment14a = 'ProcessReservations.createPendingRecord("'+gownerId+'","'+glistingId+'","'+gsubUnitId+'","'+groomId+'","'+balanceDue+'","'+gBATCHId+'","'+manOveride+'","")';
       buildScriptSegment(segment14a); 
     var segment14a = 'ProcessReservations.sendNoticeToKFRAdmin("'+gownerId+'","'+tenant+'","'+emailAddr+'","'+arrivalD+'","'+departureD+'","'+phoneNum+'","'+glistingId+'")';
       buildScriptSegment(segment14a);       
   
     submitForm(window, "fwForm");
}
function saveReservedDatesNoCC()
{
  if(document.getElementById("agreeToTerms").checked == false)
  {
    alert("You must click the checkbox to agree to the terms of the agreement and fees calculated for the rental.");
    return;
  }
   if ( (checkEmail('dsCCBatch-EMAIL_ADDRESS',false) == true))
   {
     //alert("both checks = true");
     if(document.getElementById("dsCCBatch-EMAIL_ADDRESS").value != document.getElementById("extComfirmEMAIL").value)
     {
       alert("Your email address does not match the confirm email address. Please verify.");
       return;     
     }
     if(document.getElementById("dsCCBatch-OPTIONAL_EMAIL_ADDRESS").value != document.getElementById("extComfirmEMAIL2").value)
     {
       alert("Your 2nd email address does not match the confirm email address. Please verify.");
       return;     
     }     
   
     if(document.getElementById("dsCCBatch-TENANT_ADDRESS").value == "") 
     {
       alert("You must enter the address of your party. Thank You.");
       return;     
     }
     if(document.getElementById("dsCCBatch-TENANT_CITY").value == "") 
     {
       alert("You must enter the city of your party. Thank You.");
       return;     
     }
     if(document.getElementById("dsCCBatch-TENANT_STATE_PROV").value == "") 
     {
       alert("You must enter the state abbreviation of your party. Enter 'none' if you have no state. Thank You.");
       return;     
     }     
     if(document.getElementById("dsCCBatch-TENANT_ZIP_NATION_CODE").value == "") 
     {
       alert("You must enter the zipcode of your party. Thank You.");
       return;     
     } 
     if(document.getElementById("extRepeat"))
     {
       if(document.getElementById("extRepeat").checked == true)
       {
         document.getElementById("dsCCBatch-REPEAT_STAY").value = "1";
       }
     }
     //set fwModified for FIREFOX browser
     document.getElementById("fwModified").value = "true";
     
     gownerId = document.getElementById("dsCCBatch-OWNER_ID").value;
     glistingId = document.getElementById("dsCCBatch-LISTING_ID").value;
     gsubUnitId = document.getElementById("dsCCBatch-SUBUNIT_ID").value;
     gBATCHId = document.getElementById("dsCCBatch-BATCH_ID").value;
     groomId = document.getElementById("dsCCBatch-ROOM_ID").value;
     gcharge = document.getElementById("dsCCBatch-RENTAL_CHARGE").value;
     gfromDateMinusOne = document.getElementById("extarriveDateMO").value;
     gtoDatePlusOne = document.getElementById("extdepartDatePO").value;
     depositReq = document.getElementById("extdeposit").value;
     taxReq = document.getElementById("exttax").value;
     balanceDue = document.getElementById("extBalanceDue").value;
     manOveride = document.getElementById("extManOver").value;
     
//5-14-11     setResponseURL(secureURLStart+"myReservationThankYou.jsp?fwModuleName=genKfrent");
     setResponseURL("myReservationThankYou.jsp");
     var segment14a = 'ProcessReservations.createBalanceDueBypass("'+gownerId+'","'+glistingId+'","'+gsubUnitId+'","'+groomId+'","'+balanceDue+'","'+gBATCHId+'","'+manOveride+'")';
     var segment14a = 'ProcessReservations.createPendingRecord("'+gownerId+'","'+glistingId+'","'+gsubUnitId+'","'+groomId+'","'+balanceDue+'","'+gBATCHId+'","'+manOveride+'","")';
       buildScriptSegment(segment14a); 
//Kent 01/25/2011 Get an error on reservation so I am commenting out the saves       saveDataSet("dsContactDetail");
     submitForm(window, "fwForm");
     
   }

}

function closeThankYou()
{
  window.close();
  opener.focus();
}


function viewCCBatchBalDue()
{
   ownerId = document.getElementById("extOwnerId").value;
   recType = "= 'BALANCE DUE'";
   
   //setResponseURL(secureURLStart+"secureCCBatchBalDue.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
//5-14-11   setResponseURL(secureURLStart+"finalConfirmationList.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
   setResponseURL("finalConfirmationList.jsp?extOwnerId="+ownerId);
   
    var segment14b = 'ReservationHandler.resetCCBatchDateSet("'+ownerId+'","'+recType+'")';
    buildScriptSegment(segment14b); 

   submitForm(window, "fwForm");   
}
function getPendingAuthList(argOwnerId)
{
//5-11-14   setResponseURL(secureURLStart+"pendingAuthorizationList.jsp?fwModuleName=genKfrent");
   setResponseURL("pendingAuthorizationList.jsp");
   setQueryParam("dsCCPaymentsPendingAuth","argOwnerId",argOwnerId);
   executeQuery("dsCCPaymentsPendingAuth");
   submitForm(window, "fwForm");   
}

function viewRentalSchedule(argOpt)
{
  showOwner = "Y";
  if(document.getElementById("extHideOwnerChkBox"))
  {
    if(document.getElementById("extHideOwnerChkBox").checked)
    {
      //alert("checked");
      showOwner = "N";
    }
  }
  todayDateD = new Date();

  todayDateS = formatNewDate(todayDateD);
  todayDate = "'" + todayDateS + "'";
 
  ownerId = document.getElementById("extOwnerId").value;

  toDateDWeek = new Date();
  toDateDWeek.setDate(todayDateD.getDate() + 7);

  buildMySQL_TODAY_DATE(toDateDWeek);
  todayDateMySQLWeek = todayDateMySQL;

  //** MYSQL CHANGES
  buildMySQL_TODAY_DATE(todayDateD);
  //alert("today date mySql = " + todayDateMySQL);
 
  argLength = "ALL";
  todayDateMySQLEnd = todayDateMySQLWeek;
  if(argOpt == "DAY")
  {
    todayDateMySQLEnd = todayDateMySQL;
  }
  setResponseURL("viewSchedule.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId+"&extArriveDate="+todayDateS+"&extShowOwner="+showOwner);
  if(document.getElementById("extFilterID").value != "-Select-")
  {
    var segment14b = 'MultiUnitAdmin.viewScheduleByID("'+ownerId+'","'+todayDateMySQL+'","'+argLength+'","'+document.getElementById("extFilterID").value+'")';
    buildScriptSegment(segment14b); 
  }
  else
  {
    var segment14b = 'MultiUnitAdmin.viewSchedule("'+ownerId+'","'+todayDateMySQL+'","'+argLength+'","'+todayDateMySQLEnd+'","'+showOwner+'")';
    buildScriptSegment(segment14b);  
  }

  submitForm(window, "fwForm");
}
function viewRentalScheduleByDate()
{
  showOwner = "Y";
  if(document.getElementById("extHideOwnerChkBox"))
  {
    if(document.getElementById("extHideOwnerChkBox").checked)
    {
      //alert("checked");
      showOwner = "N";
    }
  }
  todayDateS = document.getElementById("extCalendarArriveDate").value;
  
  todayDate = "'" + todayDateS + "'";
  ownerId = document.getElementById("extOwnerId").value;
   //REQUIRED MYSQL change
  toDateD = new Date(todayDateS);
  //** MYSQL CHANGES
  buildMySQL_TODAY_DATE(toDateD);
  var todayDateMySQLStart = todayDateMySQL;
  
  var todayToDateS = document.getElementById("extCalendarArriveToDate").value;
  toDateD = new Date(todayToDateS);
  //** MYSQL CHANGES
  buildMySQL_TODAY_DATE(toDateD);
  todayDateMySQLEnd = todayDateMySQL;
  argLength = "ALL";
  setResponseURL("viewSchedule.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId+"&extArriveDate="+todayDateS+"&extShowOwner="+showOwner);

    var segment14b = 'MultiUnitAdmin.viewSchedule("'+ownerId+'","'+todayDateMySQLStart+'","'+argLength+'","'+todayDateMySQLEnd+'","'+showOwner+'")';
    buildScriptSegment(segment14b); 

  submitForm(window, "fwForm");
}
function testFetch()
{
  host = "smtp1.1and1.com";
  var segment14b = 'MultiUnitAdmin.fetchEmailByHost("'+host+'")';
  buildScriptSegment(segment14b);   

  submitForm(window, "fwForm");
}
//CHAD 03/06/2004
//function setCleaningSchedule(rowNo)
//{

//  propListingId = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
//  propAddress = document.getElementById("extPropAddress"+rowNo).value;
//  extrentalTypeNo = 1;

//  todayDateD = new Date();
//
//  todayDateS = formatNewDate(todayDateD);
//  todayDate = "'" + todayDateS + "'";
// var subunitID = document.getElementById("extdsPropertyListingByOwnerMUuserid-B.SUBUNIT_ID"+rowNo).value;

// roomId = 0;
// if(subunitID == "")
// {
//   subunitID = 0;
// }
 //alert("subunitID = " + subunitID);
//  setQueryParam("dsListingScheduleByListingID","argListingId",propListingId);
//  executeQuery("dsListingScheduleByListingID");
//  setQueryParam("dsListingAvailability","argListingId",propListingId);
//  setQueryParam("dsListingAvailability","argSubUnitId",subunitID);
//  setQueryParam("dsListingAvailability","argRoomId",roomId);
//  executeQuery("dsListingAvailability");
 
//  ownerId = document.getElementById("extOwnerId").value;
//  listingID =  document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
// setRow("dsPropertyListingByOwnerMUuserid",rowNo);
//   if (subunitID > 0)
//   {
// 	setResponseURL("selectRoomForCleaning.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId+"&extListingID="+listingID+"&extStatus=0&extSubUnitId="+subunitID+"&extClassName="+className+"&extPropAddress="+propAddress);  
//      	setQueryParam("dsMultiUnitRoomDetail", "argListingId", listingID);
//      	setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subunitID);
    
      	/* Run the query for next page.*/
//     	executeQuery("dsMultiUnitRoomDetail");
//  }
//  else
//  {
//    setQueryParam("dsCleaningScheduleAR", "argListingId", listingID); 
//    setQueryParam("dsCleaningScheduleAR", "argSubUnitId", 0);
//    setQueryParam("dsCleaningScheduleAR", "argRoomId", 0);
//    executeQuery("dsCleaningScheduleAR");
//    //alert("extModdate = " + todayDateS);
//    setResponseURL("scheduleCleaningCalendar.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId+"&extListingId="+listingID+"&extSubUnitId="+subunitID+"&extRoomId="+roomId+"&extModDate="+todayDateS+"&extPropAddress="+propAddress);
//  var segment14b = 'MultiUnitAdmin.viewFullSchedule("'+ownerId+'","'+todayDate+'","'+listingID+'")';
//  buildScriptSegment(segment14b); 
//  }   
   
//  submitForm(window, "fwForm");    
//}
//CHAD 03/06/2004
function goToCleaningSchedule(rowNo)
{
  propListingId = document.getElementById("dsMultiUnitRoomDetail-LISTING_ID"+rowNo).value;
  propAddress = document.getElementById("extPropAddress").value;
  extrentalTypeNo = 1;

  var propOwnerId = document.fwForm.extOwnerId.value;
  todayDateD = new Date();

  todayDateS = formatNewDate(todayDateD);
  todayDate = "'" + todayDateS + "'";
  var subunitID = document.getElementById("dsMultiUnitRoomDetail-SUBUNIT_ID"+rowNo).value;
  roomId = document.getElementById("extdsMultiUnitRoomDetail-ROOM_ID"+rowNo).value;
 
  ownerId = document.getElementById("extOwnerId").value;
  //alert("extModdate = " + todayDateS);
  listingID =  document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
  setResponseURL("scheduleCleaningCalendar.jsp?fwModuleName=genKfrent&extOwnerId="+propOwnerId+"&extListingId="+listingID+"&extSubUnitId="+subunitID+"&extRoomId="+roomId+"&extModDate="+todayDateS+"&extPropAddress="+propAddress);
  
  var segment14b = 'MultiUnitAdmin.viewFullSchedule("'+propOwnerId+'","'+todayDate+'","'+listingID+'")';
  buildScriptSegment(segment14b);  
  
  submitForm(window, "fwForm"); 
}


function viewDepartures(argOpt)
{
  showOwner="Y";
  if(document.getElementById("extHideOwnerChkBox"))
  {
    if(document.getElementById("extHideOwnerChkBox").checked)
    {
      //alert("checked");
      showOwner = "N";
    }
  }
  todayDateD = new Date();

  todayDateS = formatNewDate(todayDateD);
  todayDate = "'" + todayDateS + "'";
 
  ownerId = document.getElementById("extOwnerId").value;

  toDateDWeek = new Date();
  toDateDWeek.setDate(todayDateD.getDate() + 7);

  buildMySQL_TODAY_DATE(toDateDWeek);
  todayDateMySQLWeek = todayDateMySQL;

  //** MYSQL CHANGES
  buildMySQL_TODAY_DATE(todayDateD);
  //alert("today date mySql = " + todayDateMySQL);
 
  argLength = "ALL";
  todayDateMySQLEnd = todayDateMySQLWeek;
  if(argOpt == "DAY")
  {
    todayDateMySQLEnd = todayDateMySQL;
  }
 
  setResponseURL("viewDepartures.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId+"&extStartDate="+todayDateS+"&extShowOwner="+showOwner);
 
     var segment14b = 'MultiUnitAdmin.viewDepartures("'+ownerId+'","'+todayDateMySQL+'" ,"'+todayDateMySQLEnd+'")';
     buildScriptSegment(segment14b);   
   submitForm(window, "fwForm");
}


function viewDeparturesByDate()
{
  showOwner = "Y";
  if(document.getElementById("extHideOwnerChkBox"))
  {
    if(document.getElementById("extHideOwnerChkBox").checked)
    {
      //alert("checked");
      showOwner = "N";
    }
  }
  todayDateS = document.getElementById("extCalendarDepartDate").value;
  todayDate = "'" + todayDateS + "'";
 
   ownerId = document.getElementById("extOwnerId").value;
   
   
   //REQUIRED MYSQL change
  toDateD = new Date(todayDateS);

  //** MYSQL CHANGES
  buildMySQL_TODAY_DATE(toDateD);
  var todayDateMySQLStart = todayDateMySQL;
  //alert("new date = " + todayDateMySQL);
   
  //End date
  todayToDateS = document.getElementById("extCalendarDepartToDate").value;
  todayDate = "'" + todayToDateS + "'";   
   
   //REQUIRED MYSQL change
  toDateD = new Date(todayToDateS);

  //** MYSQL CHANGES
  buildMySQL_TODAY_DATE(toDateD);
  todayDateMySQLEnd = todayDateMySQL;
  //alert("new date = " + todayDateMySQL);

   setResponseURL("viewDepartures.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId+"&extEndDate="+todayToDateS+"&extStartDate="+todayDateS+"&extShowOwner="+showOwner);
   
   var segment14b = 'MultiUnitAdmin.viewDepartures("'+ownerId+'","'+todayDateMySQLStart+'","'+todayDateMySQLEnd+'")';
   buildScriptSegment(segment14b);   
   submitForm(window, "fwForm");
}

function setKFRapproved(rowNo)
{
   paymentNo = document.getElementById("extdsOwnerBillingByDate-PAYMENT_NO"+rowNo).value;
   billingNo = document.getElementById("extdsOwnerBillingByDate-BILLING_NO"+rowNo).value;
   ownerId = document.getElementById("extdsOwnerBillingByDate-OWNER_ID"+rowNo).value;

   setResponseURL("_CKC_ccb.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
   
   /* Build the script segment.*/
   var segment24 = 'MultiUnitAdmin.setToKFRApproved('+paymentNo+','+billingNo+','+ownerId+')';
   buildScriptSegment(segment24);  
   
   loadCKC();

   submitForm(window, "fwForm");   
}

function setKFRDenied(rowNo)
{
   paymentNo = document.getElementById("dsOwnerBillingByDate-PAYMENT_NO"+rowNo).value;
   billingNo = document.getElementById("dsOwnerBillingByDate-BILLING_NO"+rowNo).value;
   ownerId = document.getElementById("dsOwnerBillingByDate-OWNER_ID"+rowNo).value;

   setResponseURL("_CKC_ccb.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
   
   /* Build the script segment.*/
   var segment24 = 'MultiUnitAdmin.setToKFRDenied('+paymentNo+','+billingNo+','+ownerId+')';
   buildScriptSegment(segment24);  
   
   loadCKC();

   submitForm(window, "fwForm");   
}
function reserveRoomForOwner(rowNo)
{
   if( document.getElementById("extEmailAddress").value == "")
   {
     alert("Please enter your email address to send confirmation to.");
     return;
   }
   
   if (document.getElementsByName("ext-OWNER_OR_FAMILY_RES")[0].checked)
   {
   	document.getElementById("ext-OWNER_OR_FAMILY_RES").value = 1;
   }
   else
   if (document.getElementsByName("ext-OWNER_OR_FAMILY_RES")[1].checked)
   {
    document.getElementById("ext-OWNER_OR_FAMILY_RES").value = 2;
   }

   if (document.getElementById("extDisDepartClean").value == "1")
   {
     if (document.getElementById("ext-OWNER_DEPARTURE_CLEANING").checked)
     {
       document.getElementById("ext-OWNER_DEPARTURE_CLEANING").value = "1";
     }
   }
   else
   {
     if (document.getElementById("ext-OWNER_DEPARTURE_CLEANING").checked)
     {
       document.getElementById("ext-OWNER_DEPARTURE_CLEANING").value = "1";
     }
   }   
   
   if (document.getElementById("ext-OWNER_SUPPLY_REFILL").checked)
   {
   	document.getElementById("ext-OWNER_SUPPLY_REFILL").value = "1";
   }
   
   ownerId = document.getElementById("extOwnerID").value;
   listingId = document.getElementById("extListingID").value;
   subUnitId = document.getElementById("extSubUnitId").value;
   roomId =  document.getElementById("extRoomId").value;
   rentalCharge = "0.0";

  gdateFrom = document.getElementById("extdateFrom"+rowNo).value.substring(1,document.getElementById("extdateFrom"+rowNo).value.length - 1);
  gdateTo = document.getElementById("extdateTo"+rowNo).value.substring(1,document.getElementById("extdateTo"+rowNo).value.length - 1);
  fromDateD = new Date(gdateFrom);
  toDateD = new Date(gdateTo);
  toDateDM1 = new Date(gdateTo);
  
  toDateD.setDate(toDateD.getDate() + 1);
  toDateDM1.setDate(toDateDM1.getDate() - 1);
  //alert("new from date = " + fromDateD);
  fromDateS = formatNewDate(fromDateD);
  toDateS = formatNewDate(toDateD);
  fromDateS2 = formatNewDateMMDDYYYY(fromDateD);
  toDateS2 = formatNewDateMMDDYYYY(toDateD); 
  toDateS2M1 = formatNewDateMMDDYYYY(toDateDM1);
  gfromDateMinusOne = "'" + fromDateS + "'";
  gtoDatePlusOne = "'" + toDateS + "'";  
  gfromDateMinusOneMMDDYYYY = "'" + fromDateS2 + "'";
  gtoDatePlusOneMMDDYYYY = "'" + toDateS2 + "'"; 
  gtoDateMinusOneMMDDYYYY = "'" + toDateS2M1 + "'";
  gdateFrom = "'" + gdateFrom + "'";
  gdateTo = "'" + gdateTo + "'";
  
  //******NEED TO FIGURE OUT FROM_DATE AND WHERE TO SEND THE DATE + 1??

  buildMySQL_TO_DATE(toDateD);
  buildMySQL_FROM_DATE(fromDateD);
/* DO NOT RESET DATE RANGES AUTOMATTICALLY ANYMORE   */
   //var segment14b = 'MultiUnitAdmin.resetDateRanges("'+ownerId+'","'+listingId+'","'+subUnitId+'","'+roomId+'","'+rentalCharge+'","'+gfromDateMinusOne+'","'+gtoDatePlusOne+'","'+gdateFrom+'","'+gdateTo+'","'+gfromDateMinusOneMMDDYYYY+'","'+gtoDateMinusOneMMDDYYYY+'","'+gtoDatePlusOneMMDDYYYY+'")';
   //buildScriptSegment(segment14b);    
 
    /* Build the script segment.*/
   var segment24 = 'MultiUnitAdmin.scheduleOwnerReservation("'+ownerId+'","'+listingId+'","'+subUnitId+'","'+roomId+'","'+gdateFrom+'","'+gdateTo+'")';
   buildScriptSegment(segment24);
   setResponseURL("myReservationOwnerConfirmed.jsp");

   submitForm(window, "fwForm");   
}//reserveRoomForOwner()

function setApproved(rowNo,argStatus)
{

   ownerId = document.getElementById("extOwnerId").value;
   listingId = document.getElementById("extListingId"+rowNo).value;
   subUnitId = document.getElementById("extSubUnitId"+rowNo).value;
   roomId =  document.getElementById("extRoomId"+rowNo).value;
   batchId = document.getElementById("extdsCCBatchByOwner-BATCH_ID"+rowNo).value;
   rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
   authNo = document.getElementById("extAuthNo"+rowNo).value;

  gdateFrom = document.getElementById("extdatefrom"+rowNo).value;
  gdateTo = document.getElementById("extdateto"+rowNo).value;
  rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
  fromDateD = new Date(gdateFrom);
  toDateD = new Date(gdateTo); 
  toDateDM1 = new Date(gdateTo);
  
  //******NEED TO FIGURE OUT FROM_DATE AND WHERE TO SEND THE DATE + 1??  
  //fromDateD.setDate(fromDateD.getDate() - 1);changed
  
  
  
  toDateD.setDate(toDateD.getDate() + 1);
  toDateDM1.setDate(toDateDM1.getDate() - 1);
  //alert("new from date = " + fromDateD);
  fromDateS = formatNewDate(fromDateD);
  toDateS = formatNewDate(toDateD);
  fromDateS2 = formatNewDateMMDDYYYY(fromDateD);
  toDateS2 = formatNewDateMMDDYYYY(toDateD); 
  toDateS2M1 = formatNewDateMMDDYYYY(toDateDM1);
  gfromDateMinusOne = "'" + fromDateS + "'";
  gtoDatePlusOne = "'" + toDateS + "'";  
  gfromDateMinusOneMMDDYYYY = "'" + fromDateS2 + "'";
  gtoDatePlusOneMMDDYYYY = "'" + toDateS2 + "'"; 
  gtoDateMinusOneMMDDYYYY = "'" + toDateS2M1 + "'";
  gdateFrom = "'" + gdateFrom + "'";
  gdateTo = "'" + gdateTo + "'";
  
  //******NEED TO FIGURE OUT FROM_DATE AND WHERE TO SEND THE DATE + 1??
  
  buildMySQL_TO_DATE(toDateD);
  buildMySQL_FROM_DATE(fromDateD);

  //return toDateMySQL, fromDateMySQL
 
   //setResponseURL("secureCCBatch.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);

 
  if(argStatus != "FINAL")
  {
   var segment14b = 'MultiUnitAdmin.resetDateRanges("'+ownerId+'","'+listingId+'","'+subUnitId+'","'+roomId+'","'+rentalCharge+'","'+gfromDateMinusOne+'","'+gtoDatePlusOne+'","'+gdateFrom+'","'+gdateTo+'","'+gfromDateMinusOneMMDDYYYY+'","'+gtoDateMinusOneMMDDYYYY+'","'+gtoDatePlusOneMMDDYYYY+'")';
   buildScriptSegment(segment14b);   
  }   

    /* Build the script segment.*/
   var segment24 = 'MultiUnitAdmin.setToApproved("'+batchId+'","'+ownerId+'","'+rentalCharge+'","'+authNo+'","'+argStatus+'")';
   buildScriptSegment(segment24);
   
   if(argStatus == "DEPOSIT")
   {
      recType = "<> 'BALANCE DUE'";
   }
   else
   {
      recType = "= 'BALANCE DUE'";
   }
 
    var segment14c = 'ReservationHandler.resetCCBatchDateSet("'+ownerId+'","'+recType+'")';
    buildScriptSegment(segment14c);

   submitForm(window, "fwForm");  
   if(argStatus == "FINAL")
   {
     resNumber = document.getElementById("extCOMPLEX_RESERVATION_NUM"+rowNo).value
     openPreviewWindow(rowNo,resNumber);
   }
}
  
function setApprovedRes(rowNo)
{
   ownerId = document.getElementById("extOwnerId").value;
   listingId = document.getElementById("extListingId"+rowNo).value;
   subUnitId = document.getElementById("extSubUnitId"+rowNo).value;
   roomId =  document.getElementById("extRoomId"+rowNo).value;
   batchId = document.getElementById("extdsCCBatchByOwner-BATCH_ID"+rowNo).value;
   rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
   
   //alert("setApproved 1.5");

  gdateFrom = document.getElementById("extdatefrom"+rowNo).value;
  gdateTo = document.getElementById("extdateto"+rowNo).value;
  rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
  fromDateD = new Date(gdateFrom);
  toDateD = new Date(gdateTo); 
  toDateDM1 = new Date(gdateTo);
  
  //******NEED TO FIGURE OUT FROM_DATE AND WHERE TO SEND THE DATE + 1??  
  //fromDateD.setDate(fromDateD.getDate() - 1);changed
  
  //alert("setApproved 2");
  
  toDateD.setDate(toDateD.getDate() + 1);
  toDateDM1.setDate(toDateDM1.getDate() - 1);
  //alert("new from date = " + fromDateD);
  fromDateS = formatNewDate(fromDateD);
  toDateS = formatNewDate(toDateD);
  fromDateS2 = formatNewDateMMDDYYYY(fromDateD);
  toDateS2 = formatNewDateMMDDYYYY(toDateD); 
  toDateS2M1 = formatNewDateMMDDYYYY(toDateDM1);
  gfromDateMinusOne = "'" + fromDateS + "'";
  gtoDatePlusOne = "'" + toDateS + "'";  
  gfromDateMinusOneMMDDYYYY = "'" + fromDateS2 + "'";
  gtoDatePlusOneMMDDYYYY = "'" + toDateS2 + "'"; 
  gtoDateMinusOneMMDDYYYY = "'" + toDateS2M1 + "'";
  gdateFrom = "'" + gdateFrom + "'";
  gdateTo = "'" + gdateTo + "'";
  
  //******NEED TO FIGURE OUT FROM_DATE AND WHERE TO SEND THE DATE + 1??
  
  //alert("setApproved 3");
  
  buildMySQL_TO_DATE(toDateD);
  buildMySQL_FROM_DATE(fromDateD);

  //return toDateMySQL, fromDateMySQL
 
   //setResponseURL("secureCCBatch.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
    //alert("fromDateMinusOne = " + gfromDateMinusOne);
    //alert("toDatePlusOne = " + gtoDatePlusOne);
    //alert("dateFrom = " + gdateFrom);
    //alert("dateTo = " + gdateTo);    
    //alert("fromDateMinusOneMMDDYYYY = " + gfromDateMinusOneMMDDYYYY);
    //alert("toDateMinusOneMMDDYYYY = " + gtoDateMinusOneMMDDYYYY);
    //alert("gtoDatePlusOneMMDDYYYY = " + gtoDatePlusOneMMDDYYYY);
 

  var segment14b = 'MultiUnitAdmin.resetDateRanges("'+ownerId+'","'+listingId+'","'+subUnitId+'","'+roomId+'","'+rentalCharge+'","'+gfromDateMinusOne+'","'+gtoDatePlusOne+'","'+gdateFrom+'","'+gdateTo+'","'+gfromDateMinusOneMMDDYYYY+'","'+gtoDateMinusOneMMDDYYYY+'","'+gtoDatePlusOneMMDDYYYY+'")';
  buildScriptSegment(segment14b);   
  var segment14c = 'ProcessReservations.createBalanceDue("'+batchId+'")';
  buildScriptSegment(segment14c);
  /* Build the script segment.*/
  var segment24 = 'MultiUnitAdmin.setToApprovedRes("'+batchId+'","'+ownerId+'")';
  buildScriptSegment(segment24);
   
   submitForm(window, "fwForm");  
}


function previewFinalConfirmationOnly(rowNo)
{
   ownerId = document.getElementById("extOwnerId").value;
   listingId = document.getElementById("extListingId"+rowNo).value;
   subUnitId = document.getElementById("extSubUnitId"+rowNo).value;
   roomId =  document.getElementById("extRoomId"+rowNo).value;
   batchId = document.getElementById("extdsCCBatchByOwner-BATCH_ID"+rowNo).value;
   rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
   //authNo = document.getElementById("extInitAuthNo"+rowNo).value;
   rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
   archiveFlag = "T";
 
   var segment24 = 'MultiUnitAdmin.prepareFinalConfirmation("'+batchId+'","'+ownerId+'","'+rentalCharge+'","'+listingId+'","'+archiveFlag+'")';
   buildScriptSegment(segment24);
   viewCCBatchBalDue();
   //setResponseURL("secureCCBatchBalDue.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
   submitForm(window, "fwForm");
   
   resNumber = document.getElementById("extCOMPLEX_RESERVATION_NUM"+rowNo).value
   openPreviewWindow(resNumber);
}

function previewFinalConfirmationOnly2(rowNo)
{
   ownerId = document.getElementById("extOwnerId").value;
   listingId = document.getElementById("extListingId"+rowNo).value;
   subUnitId = document.getElementById("extSubUnitId"+rowNo).value;
   roomId =  document.getElementById("extRoomId"+rowNo).value;
   batchId = document.getElementById("extdsCCBatchByOwner-BATCH_ID"+rowNo).value;
   rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;

   setQueryParam("dsPropertyImagesByListingId", "argListingId", listingId);
   executeQuery("dsPropertyImagesByListingId");
   setQueryParam("dsPropertyListingByListingId", "argListingId", listingId);
   executeQuery("dsPropertyListingByListingId");
   setQueryParam("dsCCBatchByConfirmation", "argBatchId", batchId);
   setQueryParam("dsCCBatchByConfirmation", "argBatchId2", batchId);
   executeQuery("dsCCBatchByConfirmation");
   setQueryParam("dsCCBatchByBatchId", "argBatchId", batchId);
   executeQuery("dsCCBatchByBatchId"); 
  setQueryParam("dsCCBatchOptionalByBatchId","argBatchId",batchId);
  executeQuery("dsCCBatchOptionalByBatchId");    
   
   setQueryParam("dsPaymentSummary", "argBatchId", batchId);
   executeQuery("dsPaymentSummary");
   setQueryParam("dsListingFeeSetup", "argListingId", listingId);
   executeQuery("dsListingFeeSetup");
   setQueryParam("dsPropertyAmenitiesPet", "argListingId", listingId);
   executeQuery("dsPropertyAmenitiesPet");
   setQueryParam("dsPropertyOwner", "argOwnerId", ownerId);
   executeQuery("dsPropertyOwner");
   setQueryParam("dsFinalConfirmation", "argBatchId", batchId);
   executeQuery("dsFinalConfirmation");  
   appendIfNoRow("dsFinalConfirmation");
   openPreviewWindowNew();
   //setResponseURL("previewEmailConfirmation.jsp");
   submitForm(window, "fwForm");   
}  
function openPreviewWindowNew()
{
  //get the resNumber and open a new window
//5-14-11  extPage=secureURLStart+"previewEmailConfirmation.jsp";
  extPage="previewEmailConfirmation.jsp";
//5-14-11  pw = window.open(secureURLStart+"kfrPDFredirect.jsp?extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");
  pw = window.open("kfrPDFredirect.jsp?extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");     
  if(!pw){ 
     alert('We have detected that you are using popup blocking software. In order to view the printable room grid, you must disable your popup blocker for KeysForRent only.'); 
  } 
}
function openPreviewWindow(resNumber)
{
  //get the resNumber and open a new window
//5-14-11  extPage=secureURLStart+"emails/"+resNumber+".jsp";
  extPage="emails/"+resNumber+".jsp";
//5-14-11  pw = window.open(secureURLStart+"kfrPDFredirect.jsp?extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");
  pw = window.open("kfrPDFredirect.jsp?extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");     
  if(!pw){ 
     alert('We have detected that you are using popup blocking software. In order to view the printable room grid, you must disable your popup blocker for KeysForRent only.'); 
  } 
}
function openAltPropsWindow()
{
  setResponseURL("alternatePropsAvailable.jsp");     
  submitForm(window, "fwForm");
}

function revokeBatchIdCC(rowNo, filter)
{ 
   var returnVal = confirm("Are you sure you to set this card to declined?");
   if(!returnVal)
   {
     return;
   }//if(!returnVal)
   
  gdateFrom = document.getElementById("extdatefrom"+rowNo).value;
  gdateTo = document.getElementById("extdateto"+rowNo).value;

  fromDateD = new Date(gdateFrom);
  toDateD = new Date(gdateTo);  
  fromDateD.setDate(fromDateD.getDate() - 1);
  toDateD.setDate(toDateD.getDate() + 1);
  //alert("new from date = " + fromDateD);
  fromDateS = formatNewDate(fromDateD);
  toDateS = formatNewDate(toDateD);
  gfromDateMinusOne = "'" + fromDateS + "'";
  gtoDatePlusOne = "'" + toDateS + "'"; 
  gdateFrom = "'" + gdateFrom + "'";
  gdateTo = "'" + gdateTo + "'";
  thisOwner = document.getElementById("extOwnerId").value;
   listingId = document.getElementById("extListingId"+rowNo).value;
   subUnitId = document.getElementById("extSubUnitId"+rowNo).value;

   roomId =  document.getElementById("extRoomId"+rowNo).value;
   batchId = document.getElementById("extdsCCBatchByOwner-BATCH_ID"+rowNo).value;
   rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
   authNo = 0;
   rectype = " <> 'BALANCE DUE'";
   if (filter == "BALANCE DUE")
   {
      recType = "= 'BALANCE DUE'";
   }
   else
   {
     rectype = " <> 'BALANCE DUE'";
   }

   setResponseURL("secureCCBatch.jsp?fwModuleName=genKfrent&extOwnerId="+thisOwner);
  
   /* Build the script segment.*/
   var segment24 = 'MultiUnitAdmin.revokeBatchIdCC("'+batchId+'","'+thisOwner+'","'+rentalCharge+'","'+authNo+'","'+rectype+'")';
   buildScriptSegment(segment24);  

  
   submitForm(window, "fwForm");   
}


function revokeBatchIdDR(rowNo, filter)
{
   var returnVal = confirm("This function will notify the requestor by email that this rental no longer has vacancy. Are you sure you to deny this rental?");
   if(!returnVal)
   {
     return;
   }//if(!returnVal)  
   
   ownerId = document.getElementById("extOwnerId").value;
   listingId = document.getElementById("extListingId"+rowNo).value;
   subUnitId = document.getElementById("extSubUnitId"+rowNo).value;
   roomId =  document.getElementById("extRoomId"+rowNo).value;
   batchId = document.getElementById("extdsCCBatchByOwner-BATCH_ID"+rowNo).value;
   rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
   authNo = document.getElementById("extAuthNo"+rowNo).value;
   rectype = " <> 'BALANCE DUE'";
   if (filter == "BALANCE DUE")
   {
      rectype = "= 'BALANCE DUE'";
   }

  gdateFrom = document.getElementById("extdatefrom"+rowNo).value;
  gdateTo = document.getElementById("extdateto"+rowNo).value;
  rentalCharge = document.getElementById("extrentalcharge"+rowNo).value;
  fromDateD = new Date(gdateFrom);
  toDateD = new Date(gdateTo);  
  fromDateD.setDate(fromDateD.getDate() - 1);
  toDateD.setDate(toDateD.getDate() + 1);
  //alert("new from date = " + fromDateD);
  fromDateS = formatNewDate(fromDateD);
  toDateS = formatNewDate(toDateD);
  gfromDateMinusOne = "'" + fromDateS + "'";
  gtoDatePlusOne = "'" + toDateS + "'"; 
  gdateFrom = "'" + gdateFrom + "'";
  gdateTo = "'" + gdateTo + "'";
  
   setResponseURL("secureCCBatch.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
   
   /* Build the script segment.*/
   var segment24 = 'MultiUnitAdmin.revokeBatchIdDR("'+batchId+'","'+ownerId+'","'+rentalCharge+'","'+authNo+'","'+rectype+'")';
   buildScriptSegment(segment24);  
   
   submitForm(window, "fwForm");   
}

function openOwnerLinks(ownerID)
{
  //alert(""+ownerID);
  setQueryParam("dsOwnerListingCountByOwner","argOwnerId",ownerID);
  executeQuery("dsOwnerListingCountByOwner");
  // setResponseURL("ownerReservationLinkSheet.jsp");  
  setResponseURL("myAvailabilityWResOwnerLogin.jsp");
   submitForm(window, "fwForm");
}
function validateOwnerLogin()
{
  if(document.getElementById("extPINcode").value == "")
  {
    alert("Please enter your 4 digit pin code");
    return;
  }
  if(document.getElementById("extFilterID").value != "-Select-")
  {
    //alert(""+document.getElementById("extFilterID").value );
    //validateOwnerLogon
    var segment = 'ProcessReservations.validateOwnerLogon("'+document.getElementById("extFilterID").value+'","'+ document.getElementById("extPINcode").value +'")';
    buildScriptSegment(segment);
    setResponseURL("myAvailabilityWResOwner2.jsp?extPinCode="+document.getElementById("extPINcode").value+"&extOwnerId="+document.getElementById("extOwnerId").value);
    submitForm(window, "fwForm");
  }
  else
  {
   alert("Please select your property from the drop down list.");
   return;
  }
}
function clearApproved()
{
   ownerId = document.getElementById("extOwnerId").value;

   setResponseURL("secureCCBatch.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
   
   /* Build the script segment.*/
   var segment25 = 'MultiUnitAdmin.clearApproved("'+ownerId+'")';
   buildScriptSegment(segment25);    
   
   setQueryParam("dsCCBatchByOwner", "argOwnerId", ownerId);
 
   executeQuery("dsCCBatchByOwner"); 

   submitForm(window, "fwForm");   
}

function acceptReservation(rowNo)
{
  //set value to 1 on dateset
  //save dataset
  //requery, show no ones
   ownerId = document.getElementById("extOwnerId").value;

   setResponseURL("reservationAcceptance.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);

   //call extension
   ownerId = document.getElementById("extOwnerId").value;
   batchId = document.getElementById("extdsCCBatchByOwner-BATCH_ID"+rowNo).value;
   resNo = document.getElementById("extResNumNo"+rowNo).value;

   userFilter = document.getElementById("extMultiUnitName"+rowNo).value;
   //alert("resNo = " + resNo + " and ownerID = " + ownerId);

   var segment24 = 'MultiUnitAdmin.setReservationNum("'+batchId+'","'+ownerId+'","'+resNo+'","'+userFilter+'")';
   buildScriptSegment(segment24);   

   submitForm(window, "fwForm");   
}

function acceptReservationOnCCBatch(rowNo)
{
  //set value to 1 on dateset
  //save dataset
  //requery, show no ones
   ownerId = document.getElementById("extOwnerId").value;

   ownerId = document.getElementById("extOwnerId").value;
   recType = "<> 'BALANCE DUE'";
   

//5-14-11   setResponseURL(secureURLStart+"secureCCBatch.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
   setResponseURL("secureCCBatch.jsp?extOwnerId="+ownerId);


   //call extension
   ownerId = document.getElementById("extOwnerId").value;
   batchId = document.getElementById("extdsCCBatchByOwner-BATCH_ID"+rowNo).value;
   listingId = document.getElementById("extListingId"+rowNo).value;
   subUnitId = document.getElementById("extSubUnitId"+rowNo).value;   
   resNo = document.getElementById("extResNumNo"+rowNo).value;
   authNo = document.getElementById("extAuthNo"+rowNo).value;
   chargeAmt = document.getElementById("extrentalcharge"+rowNo).value;  
   
   if(authNo != "" && authNo != null)
   {
     var argCurrentDate = new Date();
     var argSystemDate = argCurrentDate.getFullYear() + "-" + (argCurrentDate.getMonth() + 1) + "-" + argCurrentDate.getDate(); 
     //document.getElementById("fwModified").value = "true";
     document.getElementById("dsCCBatchByOwnerJoinPayment-PAYMENT_REC_DATE").value = argSystemDate;
   }
    
  var segment14a = 'MultiUnitAdmin.verifyAvailability("'+batchId+'","'+listingId+'","'+subUnitId+'")';
  buildScriptSegment(segment14a);   

   var segment24 = 'MultiUnitAdmin.setReservationNumOnCCBatch("'+batchId+'","'+ownerId+'","'+resNo+'","'+recType+'","'+chargeAmt+'","'+authNo+'")';
   buildScriptSegment(segment24);   

//   submitForm(window, "fwForm");  
  
}
//NEW CHACHI NEW CHAD

function findCCRecord(extType)
{
   clearDataSet("dsCCBatchByBatchId");
   clearDataSet("dsPaymentSummary");
   clearDataSet("dsPaymentsDetail");
   clearDataSet("dsContactDetail");
   ownerId = document.getElementById("extOwnerId").value;
//5-14-11   setResponseURL(secureURLStart+"searchResults.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
   setResponseURL("searchResults.jsp?extOwnerId="+ownerId);

   var segment24 = 'MultiUnitAdmin.findCCRecord("'+extType+'")';
   buildScriptSegment(segment24);   
   
   setQueryParam("dsOwnerAdChannelDropDown","argOwnerId",document.getElementById("extOwnerId").value);
   executeQuery("dsOwnerAdChannelDropDown");
   

   submitForm(window, "fwForm");
}


function clearModuleScript()
{
// alert("mod script before clear = " + document.getElementById("fwModuleScript").value + " fwMod = " + document.getElementById("fwModified").value);
// document.getElementById("fwModuleScript").value="";
// fwForm.elements["fwModified").value = "false";
// alert("mod script after clear = " + document.getElementById("fwModuleScript").value + " fwMod = " + document.getElementById("fwModified").value);
}
function setImageApproved(rowNo)
{
   listingId = document.getElementById("extdsPropertyImagesByStatus-LISTING_ID"+rowNo).value;

   setResponseURL("_CKC_vis.jsp?fwModuleName=genKfrent");
   
   /* Build the script segment.*/
   var segment24 = 'MultiUnitAdmin.setImageApproved("'+listingId+'")';
   buildScriptSegment(segment24);  
   
   
  setQueryParam("dsPropertyImagesByStatus", "argImageStatus", "0");

  /* Run the query.*/
  executeQuery("dsPropertyImagesByStatus")

   submitForm(window, "fwForm");   
}

/**
 * Select an Admin Row from the list.
 */
function showSelectedOnClick(rowNo, tableRow)
{
  if(submitInProcess == true)
  {
    alert("If you have received this message then please RELOAD the page and let PLEASE allow time for the page to load to completion.  Thank You!");
    return;
  }  
  /* Set the selected row */
  setSelectedRow(tableRow);
  
  
  setQueryParam("dsSelectedAmenitiesByListingId", "argListingId", document.getElementById("extdsRentalSearch-LISTING_ID"+rowNo).value);
  setQueryParam("dsSelectedAmenitiesByListingId", "argRentalTypeNo", document.getElementById("extdsRentalSearch-RENTAL_TYPE_NO"+rowNo).value);
  setQueryParam("dsPropertyListingByListingId", "argListingId", document.getElementById("extdsRentalSearch-LISTING_ID"+rowNo).value);
  setQueryParam("dsListingFeeSetup", "argListingId", document.getElementById("extdsRentalSearch-LISTING_ID"+rowNo).value);

  setQueryParam("dsRatesDetail", "argListingId", document.getElementById("extdsRentalSearch-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argSubUnitId", 0);
  setQueryParam("dsMultiUnit", "argListingId", document.getElementById("extdsRentalSearch-LISTING_ID"+rowNo).value);

  executeQuery("dsRatesDetail");
  //NEW CHAD
  setQueryParam("dsRatesDetailFreeform", "argListingId", document.getElementById("extdsRentalSearch-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetailFreeform", "argSubUnitId", 0);
  executeQuery("dsRatesDetailFreeform");
  executeQuery("dsMultiUnit");
  executeQuery("dsListingFeeSetup");
  executeQuery("dsPropertyListingByListingId");
  executeQuery("dsSelectedAmenitiesByListingId");
  

  /* Submit form on Main page.*/
  submitForm(window, "fwForm");
  location_window =  window.open("MyRentalListing.jsp?fwModuleName=genKfrent","locate","scrollbars=yes,location,height=580,width=772");  
  if(!location_window){
     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
  }
}//function showSelectedOnClick(dataSet, rowNo)

function showHelpScreenOnListingEntry(arg)
{
  location_window =  window.open("listingEntryHelp.htm"+arg,"locate","scrollbars=yes,location,height=300,width=500");  
  if(!location_window){
     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
  }
}

function loadSearch()
{
  setResponseURL("search_listings.jsp");
  //load the features
  executeQuery("dsPropertyListingByFeature");
  
  submitForm(window, "fwForm");    
}
function loadBrowseDatasets()
{
  if(submitInProcess == true)
  {
    alert("If you have received this message then please RELOAD the page and let PLEASE allow time for the page to load to completion.  Thank You!");
    return;
  }
  //alert("load browse");
  setResponseURL("browse_listings.jsp");
  executeQuery("dsBrowseVacationRentals");
  executeQuery("dsBrowseAviationRentals");

  executeQuery("dsListingCount");
  
  //load the features
  executeQuery("dsPropertyListingByFeature");
  //make sure all datasets are reset and cleared.
  clearDataSet("dsPropertyOwner");
  clearDataSet("dsPropertyListingByOwner");
  clearDataSet("dsRatesDetail");  
  submitForm(window, "fwForm");    

}

function vacancyDiscounts()
{
  if(submitInProcess == true)
  {
    alert("If you have received this message then please RELOAD the page and let PLEASE allow time for the page to load to completion.  Thank You!");
    return;
  }
  setResponseURL("chooseDiscountDates.jsp");
  //load the features
  executeQuery("dsPropertyListingByFeature");
  submitForm(window, "fwForm");   
}

function showPropertyOnClick(rowNo, tableRow)
{
   if(submitInProcess == true)
  {
    alert("If you have received this message then please RELOAD the page and let PLEASE allow time for the page to load to completion.  Thank You!");
    return;
  } 
  /* Set the selected row */
  setSelectedRow(tableRow);
   //NEW CHAD
  //alert("listing id = " + document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value + " row no = " + rowNo);
 
  listId = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
  rentalTypeNo = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.RENTAL_TYPE_NO"+rowNo).value;
  subUnitId = "0";
  setResponseURL("kfrRentalListingAdmin.jsp?extListingId="+listId+"&extSubUnitId="+subUnitId+"&extRentalTypeNo="+rentalTypeNo);

  /* Submit form on Main page.*/
  submitForm(window, "fwForm");
  

}//function showPropertyOnClick(dataSet, rowNo)

function showDetailOnClick(listId)
{

  rentalTypeNo = "1";
  subUnitId = "0";
 
  /* Submit form on Main page.*/
  submitForm(window, "fwForm");
  location_window =  window.open("kfrRentalListingAdmin.jsp?extListingId="+listId+"&extSubUnitId="+subUnitId+"&extRentalTypeNo="+rentalTypeNo,"locate","scrollbars=yes,location,height=580,width=772");  
  if(!location_window){
     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
  }
}//function showPropertyOnClick(dataSet, rowNo)

//NEW
function showPropertyOnClickPMG(rowNo, tableRow)
{
   if(submitInProcess == true)
  {
    alert("If you have received this message then please RELOAD the page and let PLEASE allow time for the page to load to completion.  Thank You!");
    return;
  } 
  /* Set the selected row */
  setSelectedRow(tableRow);
  
  
  setQueryParam("dsSelectedAmenitiesByListingId", "argListingId", document.getElementById("extdsFindAvailPropsDetailPMS-LISTING_ID"+rowNo).value);
  setQueryParam("dsSelectedAmenitiesByListingId", "argRentalTypeNo", document.getElementById("1"+rowNo).value);
  setQueryParam("dsPropertyListingByListingId", "argListingId", document.getElementById("extdsFindAvailPropsDetailPMS-LISTING_ID"+rowNo).value);
  setQueryParam("dsListingFeeSetup", "argListingId", document.getElementById("extdsFindAvailPropsDetailPMS-LISTING_ID"+rowNo).value);

  setQueryParam("dsMultiUnit", "argListingId", document.getElementById("extdsFindAvailPropsDetailPMS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argListingId", document.getElementById("extdsFindAvailPropsDetailPMS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argSubUnitId", 0);

  executeQuery("dsRatesDetail");
  //NEW CHAD
  setQueryParam("dsRatesDetailFreeform", "argListingId", document.getElementById("extdsFindAvailPropsDetailPMS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetailFreeform", "argSubUnitId", 0);
  executeQuery("dsRatesDetailFreeform");  
  executeQuery("dsListingFeeSetup");
  executeQuery("dsPropertyListingByListingId");
  executeQuery("dsSelectedAmenitiesByListingId");
  executeQuery("dsMultiUnit");
  

  /* Submit form on Main page.*/
  submitForm(window, "fwForm");
  location_window =  window.open("MyRentalListing.jsp?fwModuleName=genKfrent","locate","scrollbars=yes,location,height=580,width=772");  
  if(!location_window){
     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
  }
}//function showPropertyOnClickPMG(dataSet, rowNo)
//NEW
function showPropertyOnClickMUS(rowNo, tableRow)
{
   if(submitInProcess == true)
  {
    alert("If you have received this message then please RELOAD the page and let PLEASE allow time for the page to load to completion.  Thank You!");
    return;
  } 
  /* Set the selected row */
  setSelectedRow(tableRow);
  
  
  setQueryParam("dsSelectedAmenitiesByListingId", "argListingId", document.getElementById("extdsFindAvailPropsDetailMUS-LISTING_ID"+rowNo).value);
  setQueryParam("dsSelectedAmenitiesByListingId", "argRentalTypeNo", document.getElementById("1"+rowNo).value);
  setQueryParam("dsPropertyListingByListingId", "argListingId", document.getElementById("extdsFindAvailPropsDetailMUS-LISTING_ID"+rowNo).value);
  setQueryParam("dsListingFeeSetup", "argListingId", document.getElementById("extdsFindAvailPropsDetailMUS-LISTING_ID"+rowNo).value);

  setQueryParam("dsMultiUnit", "argListingId", document.getElementById("extdsFindAvailPropsDetailMUS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argListingId", document.getElementById("extdsFindAvailPropsDetailMUS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argSubUnitId", 0);

  executeQuery("dsRatesDetail");
  //NEW CHAD
  setQueryParam("dsRatesDetailFreeform", "argListingId", document.getElementById("extdsFindAvailPropsDetailMUS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetailFreeform", "argSubUnitId", 0);
  executeQuery("dsRatesDetailFreeform");  
  executeQuery("dsListingFeeSetup");
  executeQuery("dsPropertyListingByListingId");
  executeQuery("dsSelectedAmenitiesByListingId");
  executeQuery("dsMultiUnit");
  

  /* Submit form on Main page.*/
  submitForm(window, "fwForm");
  location_window =  window.open("MyRentalListing.jsp?fwModuleName=genKfrent","locate","scrollbars=yes,location,height=580,width=772");  
  if(!location_window){
     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
  }
}//function showPropertyOnClickMUS(dataSet, rowNo)

//NEW
function showPropertyOnClickSPAS(rowNo, tableRow)
{
   if(submitInProcess == true)
  {
    alert("If you have received this message then please RELOAD the page and let PLEASE allow time for the page to load to completion.  Thank You!");
    return;
  } 
  /* Set the selected row */
  setSelectedRow(tableRow);
  
  
  setQueryParam("dsSelectedAmenitiesByListingId", "argListingId", document.getElementById("extdsFindAvailPropsDetailSPAS-LISTING_ID"+rowNo).value);
  setQueryParam("dsSelectedAmenitiesByListingId", "argRentalTypeNo", document.getElementById("1"+rowNo).value);
  setQueryParam("dsPropertyListingByListingId", "argListingId", document.getElementById("extdsFindAvailPropsDetailSPAS-LISTING_ID"+rowNo).value);
  setQueryParam("dsListingFeeSetup", "argListingId", document.getElementById("extdsFindAvailPropsDetailSPAS-LISTING_ID"+rowNo).value);

  setQueryParam("dsMultiUnit", "argListingId", document.getElementById("extdsFindAvailPropsDetailSPAS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argListingId", document.getElementById("extdsFindAvailPropsDetailSPAS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argSubUnitId", 0);

  executeQuery("dsRatesDetail"); 
  //NEW CHAD
  setQueryParam("dsPropertyOwnerByListingId","argListingId",document.getElementById("extdsFindAvailPropsDetailSPAS-LISTING_ID"+rowNo).value);
  executeQuery("dsPropertyOwnerByListingId");
  
  setQueryParam("dsRatesDetailFreeform", "argListingId", document.getElementById("extdsFindAvailPropsDetailSPAS-LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetailFreeform", "argSubUnitId", 0);
  executeQuery("dsRatesDetailFreeform");  
  executeQuery("dsListingFeeSetup");
  executeQuery("dsPropertyListingByListingId");
  executeQuery("dsSelectedAmenitiesByListingId");
  executeQuery("dsMultiUnit");
  

  /* Submit form on Main page.*/
  submitForm(window, "fwForm");
  location_window =  window.open("MyRentalListing.jsp?fwModuleName=genKfrent","locate","scrollbars=yes,location,height=580,width=772");  
  if(!location_window){
     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
  }
}//function showPropertyOnClickSPAS(dataSet, rowNo)

function openResPageNormal(listingID, subUnitId)
{
  clearDataSet("dsReservationNotes");
  if(subUnitId == '0')
  {
     setResponseURL("resPT1ManOver.jsp?fwModuleName=genKfrent&extLID="+listingID+"&extStatus=0&extSID=0&extClassName=&extRoomID=0&extBC=0&extFromDate=&extToDate=&extDateFrame=1","locate","scrollbars=yes,location,height=580,width=797");
     submitForm(window, "fwForm");
     //location_window =  window.open("resPT1ManOver.jsp?fwModuleName=genKfrent&extLID="+listingID+"&extStatus=0&extSID=0&extClassName=&extRoomID=0&extBC=0&extFromDate=&extToDate=&extDateFrame=1","locate","scrollbars=yes,location,height=580,width=797");  
  }
  else
  {
     location_window =  window.open("myAvailabilityWResManOverMU.jsp?fwModuleName=genKfrent&extLID="+listingID+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID=0&extBC=0&extFromDate=&extToDate=","locate","scrollbars=yes,location,height=580,width=797");  
  }
}
function openResPage(listdesc,listcode)
{
 if (document.getElementById("ext"+listcode).selectedIndex == 0)
 {
   alert("Please select a property from the " + listdesc+ " drop-down list first.");
 }
 else
 {
   list_idx = document.getElementById("ext"+listcode).selectedIndex;
   listingID = document.getElementById("ext"+listcode).options[list_idx].value;
   setResponseURL("resPT1ManOver.jsp?fwModuleName=genKfrent&extLID="+listingID+"&extStatus=0&extSID=0&extClassName=&extRoomID=0&extBC=0&extFromDate=&extToDate=&extDateFrame=1","locate","scrollbars=yes,location,height=580,width=797");
   submitForm(window, "fwForm");
 }
}
function quickUpdateAvailBdrm(listdesc,listcode)
{
   list_idx = document.getElementById("ext"+listcode).selectedIndex;
   listingID = document.getElementById("ext"+listcode).options[list_idx].value;
   className = document.getElementById("ext"+listcode).options[list_idx].text;
   subunitID = "0";
 if (list_idx == 0)
 {
   alert("Please select a property from the " + listdesc+ " drop-down list first.");
 }
 else
 {   
  setQueryParam("dsListingScheduleByListingID","argListingId",listingID);
  setQueryParam("dsListingScheduleByListingID","argListingIdDUP",listingID);
  executeQuery("dsListingScheduleByListingID");

  if (subunitID > 0)
  {
	setResponseURL("quickAdminSelectRoom.jsp?fwModuleName=genKfrent&extListingID="+listingID+"&extStatus=0&extSubUnitId="+subunitID+"&extClassName="+className);  
     	setQueryParam("dsMultiUnitRoomDetail", "argListingId", listingID);
     	setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subunitID);
   
     	/* Run the query for next page.*/
    	executeQuery("dsMultiUnitRoomDetail");
  }
  else
  {

	 setResponseURL("quickAdminCommonAvailablity.jsp?fwModuleName=genKfrent&extListingID="+listingID+"&extStatus=0&extSubUnitId=0&extClassName="+className+"&extRoomId=0");  
	 setQueryParam("dsListingAvailability", "argListingId", listingID);
	 setQueryParam("dsListingAvailability", "argSubUnitId", 0);
	 setQueryParam("dsListingAvailability", "argRoomId", 0);

	 executeQuery("dsListingAvailability");
  }	 
 
 submitForm(window, "fwForm");
 }
}
function openResPagePast(listingID, subUnitId)
{
 location_window =  window.open("resPT1ManOverByPass.jsp?fwModuleName=genKfrent&extLID="+listingID+"&extStatus=0&extSID=0&extClassName=&extRoomID=0&extBC=0&extFromDate=&extToDate=","locate","scrollbars=yes,location,height=580,width=786");  
 if(!location_window){
     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
  }  
}
function resetMUResAvailibility(uRL)
{
  var selIndex1 = document.fwForm.extRoomName.selectedIndex;
  var roomId = document.fwForm.extRoomName.options[selIndex1].value;
  listingId = document.getElementById("extListingID").value;
  subUnitId = document.getElementById("extSubUnitId").value;
  var segment = 'MultiUnitAdmin.openVacationRentalAvailability("'+ listingId +'", "'+subUnitId+'", "'+roomId+'")';
  buildScriptSegment(segment); 
  setResponseURL(uRL+".jsp?fwModuleName=genKfrent&extLID="+listingId+"&extStatus=0&extSID="+subUnitId+"&extClassName=&extRoomID="+roomId+"&extBC=0");
  submitForm(window, "fwForm");
}
/* Function for Register for Keys For Rent */
function loadNewPagesp()
{

  if(submitInProcess == true)
  {
    alert("If you have received this message then please RELOAD the page and let PLEASE allow time for the page to load to completion.  Thank You!");
    return;
  }

  nationIdx = document.getElementById("dsNations-NATION_NAME").selectedIndex;

  selNation = document.getElementById("dsNations-NATION_NAME").value;

 if (selNation < 1)
 {
   alert("Please select a nation.");
   return;
 }
    
  selNation = document.getElementById("dsNations-NATION_NAME").value;
  //alert("nation = " + selNation); 
  selRentalType = document.getElementById("dsRentalType-RENTAL_DESCRIPTION").value;
  //alert("selected rental type = " + selRentalType);
  
  //this function is called after a new user has signed up
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("selectStateOrProvince.jsp?fwModuleName=genKfrent&selectedNation="+selNation+"&selectedRentalType="+selRentalType);
  //alert("setResponseURL");
  
  setQueryParam("dsPropertyOwner", "argOwnerId", document.getElementById("dsPropertyOwner-OWNER_ID").value);
  setQueryParam("dsStatesProvinces", "argNationCode", selNation);

  /* Run the query.*/
  executeQuery("dsPropertyOwner"); 
  
  executeQuery("dsStatesProvinces");
  
  submitForm(window, "fwForm");

}



//NEW
function contToListEntry()
{
  if ((!document.getElementById("extCbx-MULTIUNIT_FLAG").checked) && (!document.getElementById("extCbx-SINGLEUNIT_FLAG").checked))
  {
    alert("You must select whether your property is a mulit-unit property or single unit property under Step 2.");
    return;
  }
  selNation = document.getElementById("extNat").value;
 
  selRentalType = document.getElementById("extRentType").value;
  stateProvCode = document.getElementById("extStateProv").value;
   //alert("nation = " + selNation + " stateProvCode = " + stateProvCode);
  if (document.getElementById("extCbx-ONLINE_RESERVABLE").checked)
  {
    onlineRes = 1;
  }
  else
  {
    onlineRes = 0;  
  }
  if (document.getElementById("extCbx-MULTIUNIT_FLAG").checked)
    {
      multiFlag = 1;
      //alert("multiFlag = checked");
    }
    else
    {
      multiFlag = 0;  
    }
  if(document.getElementById("extCbx-SPACE_AVAILABLE_LISTING").checked)
    {
      spaceAvail = 1;
    }
    else
    {
      spaceAvail = 0;  
    } 

  ownerId = document.getElementById("extownId").value;
  //alert("ownerId = " + ownerId);
     setResponseURL("listingEntryFormANew.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation+"&multiFlag="+multiFlag+"&onlineRes="+onlineRes+"&spaceAvail="+spaceAvail);
   setQueryParam("dsPropertyListingByOwner", "argOwnerId", ownerId);
   executeQuery("dsPropertyListingByOwner");   

   /*to set up the key and append a row*/
     appendRow("dsPropertyListingByOwner");
     submitForm(window, "fwForm");
}

function openstep3of6()
{

  needState = false;
  selNation = document.getElementById("dsNations-NATION_NAME").value;
  //alert("nation = " + selNation); 
  selRentalType = document.getElementById("dsRentalType-RENTAL_DESCRIPTION").value;
 if (selNation < 1)
 {
   alert("Please select a nation.");
   return;
 }
  if (selRentalType < 1)
  {
    alert("Please select a rental type.");
    return;
 }
 
 if (selNation > 1)
 {
   if (selRentalType > 1)
   {
     alert("KeyForRent currently only lists Vacation Rentals in other Nations. Check back in in upcoming months for expanded rental types. Thank You!");
     setResponseURL("selectRentalType.jsp");
     submitForm(window, "fwForm");
   }
 }
//NEW
    switch(selNation)
    {
    case '1':
       //us
       needState = true;
       break;   
    case '2':
       //canada
       needState = true;
       break;
    case '3':
       stateProvCode = 62;
       break;    
    case '4':
       //CARRIBEAN HAS STATES/ISLANDS
       needState = true;
       break;   
    case '5':
       stateProvCode = 90;
       break;
    case '6':
       stateProvCode = 91;
       break;
    case '7':
       stateProvCode = 92;
       break;       
    case '8':
       stateProvCode = 93;
       break;
    case '9':
       stateProvCode = 94;
       break;
    case '10':
       stateProvCode = 95;
       break;
    case '11':
       stateProvCode = 96;
       break;       
    case '12':
       stateProvCode = 97;
       break;  
    case '13':
       stateProvCode = 98;
       break;       
    case '14':
       stateProvCode = 99;
       break;  
    case '15':
       //central america has states
       needState = true;
       break;
    case '16':
       stateProvCode = 105;
       break;
    case '17':
       stateProvCode = 106;
       break;       
    case '18':
       stateProvCode = 107;
       break;
    case '19':
       stateProvCode = 108;
       break;
    case '20':
       stateProvCode = 109;
       break;
    case '21':
       stateProvCode = 110;
       break;       
    case '22':
       stateProvCode = 111;
       break;  
    case '23':
       stateProvCode = 112;
       break;       
    case '24':
       stateProvCode = 113;
       break;  
    case '25':
       stateProvCode = 114;
       break;
    case '26':
       stateProvCode = 115;
       break;
    case '27':
       stateProvCode = 116;
       break;       
    case '28':
       stateProvCode = 117;
       break;
    case '29':
       stateProvCode = 118;
       break;
    case '30':
       stateProvCode = 119;
       break;
    case '31':
       stateProvCode = 120;
       break;       
    case '32':
       stateProvCode = 121;
       break;  
    case '33':
       stateProvCode = 122;
       break;       
    case '34':
       stateProvCode = 123;
       break;  
    case '36':
       stateProvCode = 124;
       break;     
    case '37':
       stateProvCode = 132;
       break; 
    case '38':
       stateProvCode = 128;
       break; 
    case '39':
       stateProvCode = 129;
       break; 
    case '40':
       stateProvCode = 130;
       break; 
    case '41':
       stateProvCode = 131;
       break;   
    case '42':
       stateProvCode = 137;
       break;         
    default:
      break;
   }
   
 if (!needState)
 {
   //if the selected nation <> to the U.S. or Canada..then skip the intermediate page
   //which asks for the state/province and go right to the meat!
   
    
   selNation = document.getElementById("dsNations-NATION_NAME").value;
   
  
   ownerId = document.getElementById("extOwnId").value;
   //stateProvCode = 62;
   switch(selRentalType)
   {
    case '1':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
//      setResponseURL("listingEntryFormA.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
//NEW
      setResponseURL("commonOrPropMngment.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;      
    case '6':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormB.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break; 
    case '7':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormB.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;  
    case '2':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;  
    case '3':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break; 
    case '4':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break; 
    case '5':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;       
    case '8':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;  
    case '9':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;       
    default:
      break;
   }
       
   setQueryParam("dsSelectedAmenities", "argOwnerId", 0);
   setQueryParam("dsSelectedAmenities", "argListingId", 0);
   setQueryParam("dsSelectedAmenities", "argRentalTypeNo", selRentalType);
   
   setQueryParam("dsPropertyListingByOwner", "argOwnerId", ownerId);
   executeQuery("dsPropertyListingByOwner");  
   executeQuery("dsSelectedAmenities");
   /*to set up the key and append a row*/
   //appendRow("dsPropertyListingByOwner");
   appendRow("dsPropertyAmenities");   
 
   /* Save the buffer.*/
   ///no need to save a dataset here
  
   /* Set query params */
 
   setQueryParam("dsLogon", "argUserName", document.getElementById("dsPropertyOwner-USER_NAME").value);
   setQueryParam("dsLogon", "argPassword", document.getElementById("dsPropertyOwner-PASSWORD").value);  
   setQueryParam("dsAmenities", "argRentalTypeNo", selRentalType);
 
   setQueryParam("dsAirports", "argNationCode", selNation);
   setQueryParam("dsAirports", "argStateProvinceCode", stateProvCode);
   setQueryParam("dsStatesProvinces", "argNationCode", selNation);
   
   setQueryParam("dsRentalSubregions", "argNationCode", selNation);
   setQueryParam("dsRentalSubregions", "argStatesProvinces", stateProvCode);
   setQueryParam("dsRentalSubcategories", "argRentalTypeNo", selRentalType);
   
   
   /* Run the query.*/
   executeQuery("dsLogon");
   executeQuery("dsAirports");
   executeQuery("dsStatesProvinces");
   executeQuery("dsRentalSubregions");
   //CHAD//sortDataSet("dsRentalSubregions", "SUBREGION_NAME ASC");
   executeQuery("dsRentalSubcategories");
   //sortDataSet("dsRentalSubcategories", "DESCRIPTION ASC");
   executeQuery("dsAmenities"); 
   
   submitForm(window, "fwForm");

   return;
 }



  //this function is called after a new user has signed up
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("selectStateOrProvince.jsp?fwModuleName=genKfrent&selectedNation="+selNation+"&selectedRentalType="+selRentalType);

  /* Set query params */
  setQueryParam("dsLogon", "argUserName", document.getElementById("dsPropertyOwner-USER_NAME").value);
  setQueryParam("dsLogon", "argPassword", document.getElementById("dsPropertyOwner-PASSWORD").value);
  setQueryParam("dsStatesProvinces", "argNationCode", selNation);

  /* Run the query.*/
  executeQuery("dsLogon"); 
  
  executeQuery("dsStatesProvinces");

  
  submitForm(window, "fwForm");

}

function openstep3of6sp()
// similar to openstep3of6sp, however, this function is called form the 
// page that has the states/provinces dropdown (newlisting2of6sp.jsp)
{
   selNation = document.getElementById("dsNations-NATION_NAME").value;

   selRentalType = document.getElementById("dsRentalType-RENTAL_DESCRIPTION").value;
  
   stateProvCode = document.getElementById("dsStatesProvinces-STATE_PROVINCE_NAME").value;

//   ownerId = document.getElementById("dsPropertyOwner-OWNER_ID").value;

 if (selNation < 1)
 {
   alert("Please select a nation.");
   return;
 }
  if (stateProvCode < 1)
  {
    alert("Please select a State/Territory/Province.");
    return;
 }

   switch(selRentalType)
   {
    case '1':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
//      setResponseURL("listingEntryFormA.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&ownId="+ownerId);
//      setResponseURL("listingEntryFormA.jsp?adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
//NEW
      setResponseURL("commonOrPropMngment.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;      
    case '6':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormB.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break; 
    case '7':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormB.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;  
    case '2':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;  
    case '3':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break; 
    case '4':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break; 
    case '5':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;       
    case '8':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;  
    case '9':
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("listingEntryFormC.jsp?fwModuleName=genKfrent&adminRentalType="+selRentalType+"&stateCode="+stateProvCode+"&nationCode="+selNation);
      break;       
    default:
      break;
   }
     
   //setQueryParam("dsPropertyListingByOwner", "argOwnerId", document.getElementById("dsPropertyOwner-OWNER_ID").value);
   
   /*to set up the key and append a row*/
   //appendRow("dsPropertyListingByOwner");
   
   // Kent 05-14-2002 executeQuery("dsPropertyListingByOwner");  

 
   /* Save the buffer.*/
   //no need to save a dataset here
  
   /* Set query params */
 
 
   setQueryParam("dsAmenities", "argRentalTypeNo", selRentalType);
   
   setQueryParam("dsSelectedAmenities", "argOwnerId", 0);
   setQueryParam("dsSelectedAmenities", "argListingId", 0);
   setQueryParam("dsSelectedAmenities", "argRentalTypeNo", selRentalType);
 
   setQueryParam("dsAirports", "argNationCode", selNation);
   setQueryParam("dsAirports", "argStateProvinceCode", stateProvCode);
   // Kent 05-14-2002 setQueryParam("dsStatesProvinces", "argNationCode", selNation);
  
   //alert("setting dsRentalSubregions to nation: " + selNation + " and stateProv= " + stateProvCode);
   setQueryParam("dsRentalSubregions", "argNationCode", selNation);
   setQueryParam("dsRentalSubregions", "argStatesProvinces", stateProvCode);
   setQueryParam("dsRentalSubcategories", "argRentalTypeNo", selRentalType);
   
   
   /* Run the query.*/
   executeQuery("dsSelectedAmenities");  
   appendRow("dsPropertyAmenities");   
   //executeQuery("dsLogon");
   executeQuery("dsAirports");
   executeQuery("dsStatesProvinces");
   executeQuery("dsRentalSubregions");
   //chad//sortDataSet("dsRentalSubregions", "SUBREGION_NAME ASC");
   executeQuery("dsRentalSubcategories");
   //sortDataSet("dsRentalSubcategories", "DESCRIPTION ASC");
   executeQuery("dsAmenities"); 

   
   submitForm(window, "fwForm");
}


function adminSaveRentalInfo(listingId)
{
  var propOwnerId = top.frames['mainFrame'].document.getElementById("dsAdminPropertyListingByListingId-OWNER_ID").value;
  var ConfirmStatus
  //alert("adminSaveRentalInfo - ownerID = " + propOwnerId);
  if ( top.frames['mainFrame'].document.getElementById("extIsFreeTrailValid").value == "1")
  {
	  if (top.frames['mainFrame'].document.getElementById("extENDFREETRIAL").checked)
	 {
	    ConfirmStatus = confirm("Are you sure you want to terminate your FREE TRIAL PERIOD?")

	    if (ConfirmStatus == false) 
	    {
	      return;
	    }
	 }
   }

 saveDataSet("dsAdminPropertyListingByListingId");
 saveDataSet("dsListingFeeSetup");
 saveDataSet("dsListingFeeSetupOptional");

  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("adminRentalInfo.jsp?extListingId="+listingId); 
 		
 /* Build the script segment.*/
 var segment1 = 'KfrentAdminAmenitiesAndSeasons.processAmenitiesAdmin()';
 buildScriptSegment(segment1); 
 
  if ( top.frames['mainFrame'].document.getElementById("extIsFreeTrailValid").value == "1")
  { 
	 if (top.frames['mainFrame'].document.getElementById("extENDFREETRIAL").checked)
	 {
	    //alert("checkbox checked");
	   /* Build the script segment to discontinue free trial */
	   var segment3 = 'KfrentAmenities.discontinueFreeTrial("'+listingId+'","'+propOwnerId+'")';
	   buildScriptSegment(segment3); 

	   //CHRIS uncomment next 4 lines of code
	   var segment4 = 'EmailManager.sendEndPromoEmailToKFR("'+listingId+'","'+propOwnerId+'")';
	   buildScriptSegment(segment4); 

	   var segment5 = 'EmailManager.sendEndPromoEmailToOwner("'+listingId+'","'+propOwnerId+'")';
	   buildScriptSegment(segment5);
	 }
   }

 setQueryParam("dsAdminPropertyListingByListingId", "argListingId", listingId);
 executeQuery("dsAdminPropertyListingByListingId"); 
 
  mainDataFrameTarget = top.frames['mainFrame'];
  submitForm(mainDataFrameTarget, "fwForm");  
 }



/* Function to save all property amenities for a new listing */
function savestep3of6()
{
 var extrentalTypeNo = document.getElementById("dsPropertyListingByOwner-RENTAL_TYPE_NO").value;
 var propListingId = document.getElementById("dsPropertyListingByOwner-LISTING_ID").value;
 var propOwnerId = document.getElementById("dsPropertyListingByOwner-OWNER_ID").value;
 var desc = document.getElementById("dsPropertyListingByOwner-DESCRIPTION").value;
 //weAreAgent = document.getElementById("dsPropertyListingByOwner-WE_ARE_AGENT").value;
 var spaceAvailableListing = document.getElementById("dsPropertyListingByOwner-SPACE_AVAILABLE_LISTING").value;

 weAreAgent = 0;
 isPMRes = false;
 if (document.getElementById("dsPropertyListingByOwner-SUBREGION_CODE").selectedIndex == 0)
 {
   alert("Please select a Rental Subregion.");
   return;
 } 
 if (document.getElementById("dsPropertyListingByOwner-RENTAL_SUBCAT_NO").selectedIndex == 0)
 {
   alert("Please select a sub category type.");
   return;
 }
 
 if (extrentalTypeNo == 1){
   isMultiUnitInt = document.getElementById("dsPropertyListingByOwner-MULTIUNIT_FLAG").value;
   if (isMultiUnitInt == 1)
   {
     isMultiUnit = true;
   }
   else
   {
     isMultiUnit = false; 
   }
 //alert("multiunit flag = " + isMultiUnit);
   if ((document.getElementById("dsPropertyListingByOwner-MULTIUNIT_NAME").value == "") && (document.getElementById("dsPropertyListingByOwner-MULTIUNIT_FLAG").value=="1"))
     {
        alert("Please select a MultiUnit name for your rental complex");
        return;
     }
 if (document.getElementById("dsPropertyListingByOwner-ONLINE_RESERVABLE").value == "1")
   {
    isPMRes = true;
   }
   else
   {
    isPMRes = false;
   }
 }

 else
 {
 isMultiUnit = false;
 isPMRes = false;
 //alert("multiunit = false");
 }

 
 /* Build the script segment.*/

 buildScriptSegment('KfrentAmenities.setState("'+propListingId+'")');  
   saveDataSet("dsPropertyListingByOwner");
   
    setQueryParam("dsOwnerListingCountByOwner","argOwnerId",propOwnerId);
   
    executeQuery("dsOwnerListingCountByOwner");
 if (extrentalTypeNo == 1){
    if (isPMRes )
    {
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("paymentConfig.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extMultiUnit="+isMultiUnit+"&extPMRes="+isPMRes+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo);
    }
    else
    {
      /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
      setResponseURL("paymentConfigB.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extMultiUnit="+isMultiUnit+"&extPMRes="+isPMRes+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo);
    
    }
    clearDataSet("dsListingFeeSetup");
    clearDataSet("dsListingFeeSetupOptional");
    setQueryParam("dsListingFeeSetup","argListingId",propListingId);
    executeQuery("dsListingFeeSetup");
    appendIfNoRow("dsListingFeeSetup");
    setQueryParam("dsListingFeeSetupOptional","argListingId",propListingId);
    executeQuery("dsListingFeeSetupOptional");    
    appendIfNoRow("dsListingFeeSetupOptional") ;
 }
 else
 {
    /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
    setResponseURL("ratesAndDatesFormB.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo);
    //alert("Rental Type No = "  + extrentalTypeNo + " owner id = " +propOwnerId + " we are agent = " + weAreAgent);

    setQueryParam("dsRatesDetail","argListingId",propListingId);
    setQueryParam("dsRatesDetail","argSubUnitId","0");
   
    executeQuery("dsRatesDetail");
    appendIfNoRow("dsRatesDetail"); 
 }
   /* Build the script segment.*/
   var segment1 = 'KfrentAmenities.processAmenities("'+extrentalTypeNo+'","'+propListingId+'")';
   buildScriptSegment(segment1); 

   /* Save the buffer.*/


    submitForm(window, "fwForm");    
}

function formatDateH(argD) {

  var mm, dd, yyyy;

  // Return the target date in "mm/dd/yyyy" format.

  mm = String(argD.getMonth() + 1);
  while (mm.length < 2)
    mm = "0" + mm;
  dd = String(argD.getDate());
  while (dd.length < 2)
    dd = "0" + dd;
  yyyy = String(argD.getFullYear());
  while (yyyy.length < 4)
    yyyy = "0" + yyyy;

  return mm + "/" + dd + "/" + yyyy;
}
function formatInputYYYYMMDD(argS)
{
  YYYY= argS.substring(0,4);
  MM = argS.substring(5,7);
  DD = argS.substring(8,10);
  return MM + "/" + DD + "/" + YYYY;
}

//**********new
function saveAdminAvailabilityCal()
{
  listingID = document.getElementById("extListingID").value;
  subunitID = document.getElementById("extSubUnitId").value;
  className = document.getElementById("extClassName").value;  
    roomID = document.getElementById("extRoomId").value;
  /* First call the processRoomIdCreation class */
  var segment = 'MultiUnitAdmin.setAvailabilityFromCalendar("'+listingID+'","'+subunitID+'","'+roomID+'")';
  buildScriptSegment(segment); 
  
   setResponseURL("quickAdminCommonAvailablity.jsp?fwModuleName=genKfrent&extListingID="+listingID+"&extSubUnitId="+subunitID+"&extClassName="+className+"&extRoomId="+roomID);  
   executeQuery("dsListingAvailability");
   submitForm(window, "fwForm");  
}

//**********new
function openUpdateRatesAndDates(rowNo)
{
  propListingId = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
  extrentalTypeNo = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.RENTAL_TYPE_NO"+rowNo).value;

 var propOwnerId = document.getElementById("extOwnerId").value;

 var subUnitId = document.getElementById("extdsPropertyListingByOwnerMUuserid-B.SUBUNIT_ID"+rowNo).value;
 var muName = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.MULTIUNIT_NAME"+rowNo).value;
 if ((subUnitId == "") || (subUnitId == null))
 {
   subUnitId = 0;
 }
 //isMultiUnit = document.fwForm.extmultiUnitFlag.value;

 isPMRes = document.getElementById("extPMres"+rowNo).value;
 weAreAgent = 0;

    setQueryParam("dsRatesDetailFreeform", "argListingId", propListingId);
    setQueryParam("dsRatesDetailFreeform", "argSubUnitId", subUnitId);
    setQueryParam("dsSpecialRatesDetail", "argListingId", propListingId);
    setQueryParam("dsSpecialRatesDetail", "argSubUnitId", subUnitId);    
    setQueryParam("dsRatesHeader", "argListingId", propListingId);
    executeQuery("dsRatesDetailFreeform");
    executeQuery("dsRatesHeader");
    executeQuery("dsSpecialRatesDetail");
    setQueryParam("dsOwnerListingCountByOwner", "argOwnerId", propOwnerId);
    executeQuery("dsOwnerListingCountByOwner");
    appendIfNoRow("dsRatesHeader");
    appendIfNoRow("dsSpecialRatesDetail");
    appendIfNoRow("dsRatesDetailFreeform");
  var todayD = null;
  var todayS = "";
  todayD = new Date();
  todayS = formatDateH(todayD);  
  
  setRow("dsPropertyListingByOwnerMUuserid",rowNo);
	    if (isPMRes == 1) 
	    {
	      setResponseURL("ratesAndDatesFormAUpdate.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo+"&extPMRes="+isPMRes+"&extDate="+todayS+"&extSubUnitId="+subUnitId+"&extMuName="+muName);
	    }
	    else
	    {
	      setResponseURL("kfrRatesAndDatesFreeFormUpdate.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo+"&extPMRes="+isPMRes+"&extDate="+todayS+"&extSubUnitId="+subUnitId);
	    }   

    setQueryParam("dsRatesDetail","argListingId",propListingId);
    setQueryParam("dsRatesDetail","argSubUnitId",subUnitId);
   
    executeQuery("dsRatesDetail");
    appendIfNoRow("dsRatesDetail") ; 

   submitForm(window, "fwForm");
}
function openUpdateRatesAndDatesBdrm(listdesc,listcode)
{
 if (document.getElementById("ext"+listcode).selectedIndex == 0)
 {
   alert("Please select a property from the " + listdesc+ " drop-down list first.");
 }
 else
 {
   list_idx = document.getElementById("ext"+listcode).selectedIndex;
   propListingId = document.getElementById("ext"+listcode).options[list_idx].value;
   argMUname = document.getElementById("ext"+listcode).options[list_idx].text;
   
  extrentalTypeNo = 1;
  var propOwnerId = document.getElementById("extOwnerId").value;
  subUnitId = 0;
  isPMRes = 1
  weAreAgent = 0;
    setQueryParam("dsRatesDetailFreeform", "argListingId", propListingId);
    setQueryParam("dsRatesDetailFreeform", "argSubUnitId", subUnitId);
    setQueryParam("dsSpecialRatesDetail", "argListingId", propListingId);
    setQueryParam("dsSpecialRatesDetail", "argSubUnitId", subUnitId);    
    setQueryParam("dsRatesHeader", "argListingId", propListingId);
    executeQuery("dsRatesDetailFreeform");
    executeQuery("dsRatesHeader");
    executeQuery("dsSpecialRatesDetail");
    setQueryParam("dsOwnerListingCountByOwner", "argOwnerId", propOwnerId);
    executeQuery("dsOwnerListingCountByOwner");
    appendIfNoRow("dsRatesHeader");
    appendIfNoRow("dsSpecialRatesDetail");
    appendIfNoRow("dsRatesDetailFreeform");
    var todayD = null;
    var todayS = "";
    todayD = new Date();
    todayS = formatDateH(todayD);  
    setResponseURL("ratesAndDatesFormAUpdate.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo+"&extPMRes="+isPMRes+"&extDate="+todayS+"&extSubUnitId="+subUnitId+"&extMuName="+argMUname);
    setQueryParam("dsRatesDetail","argListingId",propListingId);
    setQueryParam("dsRatesDetail","argSubUnitId",subUnitId);
    executeQuery("dsRatesDetail");
    appendIfNoRow("dsRatesDetail") ; 
    submitForm(window, "fwForm");
  }
}

function reloadHoldiayPricingTemplate(argType)
{
 var extrentalTypeNo = "1";
 var propListingId = document.getElementById("extLISTING_ID").value;
 var propOwnerId = document.getElementById("extownId").value;
 //isMultiUnit = document.getElementById("extmultiUnitFlag").value;
 weAreAgent  = document.getElementById("extAgent").value;

  var selIndex1 = document.getElementById("extPricingTemplateListingId2").selectedIndex;

  
  //var listingIDselected = document.getElementById("extPricingTemplateListingId").options[selIndex1].text;
  var listingIDselected = document.getElementById("extPricingTemplateListingId2").options[selIndex1].value;
//alert("listingIDselected = " + listingIDselected + " currentID= " +propListingId);
  var segment = 'MultiUnitAdmin.loadHolidayPricingTemplate("'+ listingIDselected +'", "'+propListingId+'")';
  buildScriptSegment(segment); 
  var todayD = null;
  var todayS = "";
  todayD = new Date();
  todayS = formatDateH(todayD);
subUnitId = document.getElementById("extSubUnitId").value;  
    /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
if(argType=="LISTING")
{
    formatDatesToYYYYmmDD();
    saveDataSet("dsRatesDetail");
    setResponseURL("kfrRatesAndDatesFormA.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo+"&extPMRes=1&extDate=01/21/2006&extSubUnitId="+subUnitId);
}
else
{
    setResponseURL("ratesAndDatesFormAUpdate.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo+"&extPMRes=1&extDate=01/21/2006&extSubUnitId="+subUnitId);
}
    setQueryParam("dsRatesDetail","argListingId",propListingId);
    setQueryParam("dsRatesDetail","argSubUnitId","0");
   
    executeQuery("dsRatesDetail");
    //sortDataSet("dsRatesDetail", "DATE_TO ASC");
    appendIfNoRow("dsRatesDetail") ;

   submitForm(window, "fwForm");    

}
function reloadPricingTemplate(argType)
{
 var extrentalTypeNo = "1";
 var propListingId = document.getElementById("extLISTING_ID").value;
 var propOwnerId = document.getElementById("extownId").value;
 //isMultiUnit = document.getElementById("extmultiUnitFlag").value;
 weAreAgent  = document.getElementById("extAgent").value;

  var selIndex1 = document.getElementById("extPricingTemplateListingId").selectedIndex;

  
  //var listingIDselected = document.getElementById("extPricingTemplateListingId").options[selIndex1].text;
  var listingIDselected = document.getElementById("extPricingTemplateListingId").options[selIndex1].value;

  var segment = 'MultiUnitAdmin.loadPricingTemplate("'+ listingIDselected +'", "'+propListingId+'")';
  buildScriptSegment(segment); 
  var todayD = null;
  var todayS = "";
  todayD = new Date();
  todayS = formatDateH(todayD);
    subUnitId = document.fwForm.extSubUnitId.value;  
    /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
if(argType=="LISTING")
{
    setResponseURL("kfrRatesAndDatesFormA.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo+"&extPMRes=1&extDate=01/21/2006&extSubUnitId="+subUnitId);
}
else
{
    setResponseURL("ratesAndDatesFormAUpdate.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo+"&extPMRes=1&extDate=01/21/2006&extSubUnitId="+subUnitId);
}
    setQueryParam("dsRatesDetail","argListingId",propListingId);
    setQueryParam("dsRatesDetail","argSubUnitId","0");
   
    executeQuery("dsRatesDetail");
    //sortDataSet("dsRatesDetail", "DATE_TO ASC");
    appendIfNoRow("dsRatesDetail") ;

   submitForm(window, "fwForm");    

}

function getRoomGrid()
{
  var selIndex1 = document.fwForm.extGridDate.selectedIndex;
  var dateSelected = document.fwForm.extGridDate.options[selIndex1].value;
  var argOwnID = document.getElementById("extOwnerId").value;
  setResponseURL("roomGrid.jsp?extStartDate='"+dateSelected+"'&extOwnerId="+argOwnID);
  submitForm(window, "fwForm");
}
function getNewRoomGrid(numProps)
{
  var selIndex1 = document.fwForm.extGridDate.selectedIndex;
  var dateSelected = "'"+document.fwForm.extGridDate.options[selIndex1].value+"'";
  var argOwnID = document.getElementById("extOwnerId").value;
  var legalPaper = "0"; 
  var largeFont="0";
  var bedrooms = "ALL"; //this is the default
  //for larger sized companies, we will have to make them choose
  //number of bedrooms for the grid.
  if(document.getElementById("extRoomGridBdrms"))
  {
	  if(document.getElementById("extRoomGridBdrms").selectedIndex > 0)
	  {
	    selIndex2 = document.getElementById("extRoomGridBdrms").selectedIndex;
	    bedrooms = document.getElementById("extRoomGridBdrms").options[selIndex2].value;
	    
	    numProps = document.getElementById("extCount"+document.getElementById("extRoomGridBdrms").selectedIndex).value;
	  }
  }
  if(document.getElementById("extUseLegalSizePaper").checked)
  {
    legalPaper = "1";
  }
  if(document.getElementById("extLargerFont").checked)
  { alert("Make sure to print in landscape when using larger fonts");   largeFont = "1";  }  
  
//window.open("kfrPDFintermed.jsp?extDS="+dateSelected+"&extOwnerId="+argOwnID+"&extLP="+legalPaper+"&extBdrms="+bedrooms+"&extLF="+largeFont);
//5-14-11  pw = window.open(URLStart+"kfrPDFintermed.jsp?extDS="+dateSelected+"&extOwnerId="+argOwnID+"&extLP="+legalPaper+"&extBdrms="+bedrooms+"&extLF="+largeFont,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");
  pw = window.open("kfrPDFintermed.jsp?extDS="+dateSelected+"&extOwnerId="+argOwnID+"&extLP="+legalPaper+"&extBdrms="+bedrooms+"&extLF="+largeFont,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");     
  if(!pw){ 
     alert('We have detected that you are using popup blocking software. In order to view the printable room grid, you must disable your popup blocker for KeysForRent only.'); 
  } 
  //var segment = 'MultiUnitAdmin.buildRoomGrid("'+dateSelected+'","'+argOwnID+'","'+legalPaper+'","'+bedrooms+'","'+largeFont+'")'; 
  //buildScriptSegment(segment);
 
  //submitForm(window, "fwForm");  
  //setTimeout('showPDFWindow("'+argOwnID+'")', 1200);
  //var argDelay = numProps * 2.0 + ""; 
  //if(argDelay < 15)
  //{ argDelay = "15.0"; }
  //perPos = argDelay.lastIndexOf('.');
  //if(perPos > 1)
  //{ 
  //  argDelay = argDelay.substring(0,argDelay.lastIndexOf('.'));
  //}

  //alert("This grid will build in " + argDelay + " seconds.");
  //openPDFGrid(argOwnID,argDelay);
     
}

//NEW chad
function reloadPricingTemplateForPaymentConfig(pageArg)
{
 var extrentalTypeNo = "1";
 var propListingId = document.getElementById("dsListingFeeSetup-LISTING_ID").value;
 var propOwnerId = document.getElementById("dsAdminPropertyListingByListingId-OWNER_ID").value;
 isMultiUnit = "0";
 weAreAgent  = "0";
 //alert("multiunit flag = " + isMultiUnit);
  var selIndex1 = document.fwForm.extPricingTemplateListingId.selectedIndex;

  
  //var listingIDselected = fwForm.extPricingTemplateListingId.options[selIndex1].text;
  var listingIDselected = document.fwForm.extPricingTemplateListingId.options[selIndex1].value;
//I need to create an extension to copy vals from listing id selected to new listing id
  var segment = 'MultiUnitAdmin.loadPricingTemplateForPaymentConfig("'+ listingIDselected +'", "'+propListingId+'")';
  buildScriptSegment(segment); 
  var todayD = null;
  var todayS = "";
  todayD = new Date();
  todayS = formatDateH(todayD);
  
 if (pageArg == "B")
 {
 /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
    setResponseURL("paymentConfigB.jsp?fwModuleName=genKfrent&extlistingid="+propListingId+"&extownerId="+propOwnerId+"&extAgent="+weAreAgent+"&extrentalTypeNo="+extrentalTypeNo+"&extMultiUnit="+isMultiUnit);
  }
 else
 {
 /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
    setResponseURL("kfrUpdateRentalInfo.jsp");
 }
    setQueryParam("dsListingFeeSetup","argListingId",propListingId);
    executeQuery("dsListingFeeSetup");
    setQueryParam("dsListingFeeSetupOptional","argListingId",propListingId);
    executeQuery("dsListingFeeSetupOptional");    
    ////sortDataSet("dsRatesDetail", "DATE_TO ASC");
    appendIfNoRow("dsListingFeeSetup") ;
    appendIfNoRow("dsListingFeeSetupOptional") ;

   submitForm(window, "fwForm");    

}

function openPDFGrid(argOwnID,argDelay)
{
  //get the resNumber and open a new window
//5-14-11  extPage=URLStart+"PDFs/roomGrid"+argOwnID+".pdf";
  extPage="PDFs/roomGrid"+argOwnID+".pdf";
//5-14-11  pw = window.open(URLStart+"kfrPDFredirectDelay.jsp?extDelay="+argDelay+"&extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");
  pw = window.open("kfrPDFredirectDelay.jsp?extDelay="+argDelay+"&extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");     
  if(!pw){ 
     alert('We have detected that you are using popup blocking software. In order to view the printable room grid, you must disable your popup blocker for KeysForRent only.'); 
  } 
}
//function showPDFRoomGrid(daysBuilt,ownerID) 
//{ 
//  var segment = 'MultiUnitAdmin.buildPDFRoomGrid('+daysBuilt+', "'+ownerID+'")'; 
//  buildScriptSegment(segment); 
//  submitForm(window, "fwForm");  
//  setTimeout('showPDFWindow("'+ownerID+'")', 1200); 
//} 
//function showPDFWindow(ownerID) 
//{ 
//  //pw = window.open(URLStart+"PDFs/roomGrid"+ownerID+".pdf","locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");     
// extPage="PDFs/roomGrid"+ownerID+".pdf";
//  pw = window.open(URLStart+"kfrPDFredirectLong.jsp?extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");     
//
//  if(!pw){ 
//     alert('We have detected that you are using popup blocking software. In order to view the printable room grid, you must disable your popup blocker for KeysForRent only.'); 
//  } 
//}
function showPDFDetailReceipt(batchID) 
{ 
 extPage="PDFs/detailReceipt"+batchID+".pdf";
//5-11-14  pw = window.open(secureURLStart+"kfrPDFredirect.jsp?extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");
  pw = window.open("kfrPDFredirect.jsp?extPage="+extPage,"locate","scrollbars=yes,location=0,directories=0,height=580,width=772,resizable=1,toolbar=0,menubar=0");     

  if(!pw){ 
     alert('We have detected that you are using popup blocking software. In order to view the printable room grid, you must disable your popup blocker for KeysForRent only.'); 
  } 
}

/* Function to save ratesAndDates for common rentals...NO MULTIUNITS HERE! */
function saveRatesAndDates()
{
  propOwnerId = document.getElementById("extownId").value;
  rentalTypeNo = document.getElementById("extRentalTypeNo").value;
  weAreAgent = document.getElementById("extAgent").value;
  isPMRes = document.fwForm.extPMRes.value;
  var spaceAvailListing = document.fwForm.extSpaceAvailable.value;
 
  listingID = document.getElementById("extLISTING_ID").value;
  /* First call the FileUploadExtension class */
  var segment = 'ComputeHighAndLowRates.processHighLowRates("'+ listingID +'","0")';
  //sending parameter of '0' because this is a non-multi-unit rental
  buildScriptSegment(segment);  
  
  ownerId = (document.getElementById("extownId").value);
  if (rentalTypeNo == 1) {
	   if ((isPMRes == 1) && (spaceAvailListing == "0"))
	   {   
		/* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
		setResponseURL("commonRentalAvailability.jsp?extkfrOwnerId="+ownerId); 
		//CMY CHAD UNCOMMENT WHEN WE RE-INITIATE AGENCY PERCENTAGE CHARGE
		setQueryParam("dsListingAvailability", "argListingId", listingID);
		/* query param should be 0 for non multiunit rentals */
		setQueryParam("dsListingAvailability", "argSubUnitId", 0); 
		setQueryParam("dsListingAvailability", "argRoomId", 0);   
		/* Run the query for next page.*/
		executeQuery("dsListingAvailability");
		appendIfNoRow("dsListingAvailability");
	  } 
	  else
	  {
	    	setResponseURL("fileUploadForm.jsp?fwModuleName=genKfrent&extlistingid="+listingID+"&extownerId="+propOwnerId+"&extMultiUnit="+0);
	  }
   }
   else
   {
     setResponseURL("fileUploadForm.jsp?fwModuleName=genKfrent&extlistingid="+listingID+"&extownerId="+propOwnerId+"&extMultiUnit="+0);
   }
  

  setQueryParam("dsPropertyImages", "argListingId", listingID); 
  
  /* Run the query.*/
  executeQuery("dsPropertyImages"); 
  
  appendIfNoRow("dsPropertyImages");  
  
  submitForm(window, "fwForm");
}

function updateSchedule(rowNo)
{
  listingID =  document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;

  setQueryParam("dsListingScheduleByListingID","argListingId",listingID);
  setQueryParam("dsListingScheduleByListingID","argListingIdDUP",listingID);
  executeQuery("dsListingScheduleByListingID");
  setRow("dsPropertyListingByOwnerMUuserid",rowNo);
  setResponseURL("updateSchedule.jsp");
  submitForm(window, "fwForm");
}

function quickUpdateAvail(rowNo)
{
  listingID =  document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
  subunitID =  document.getElementById("extdsPropertyListingByOwnerMUuserid-B.SUBUNIT_ID"+rowNo).value;
  className =  document.getElementById("extdsPropertyListingByOwnerMUuserid-B.CLASS"+rowNo).value;
  roomID =  0;
  setQueryParam("dsListingScheduleByListingID","argListingId",listingID);
  setQueryParam("dsListingScheduleByListingID","argListingIdDUP",listingID);
  executeQuery("dsListingScheduleByListingID");
  setRow("dsPropertyListingByOwnerMUuserid",rowNo);
  if (subunitID > 0)
  {
	setResponseURL("quickAdminSelectRoom.jsp?fwModuleName=genKfrent&extListingID="+listingID+"&extStatus=0&extSubUnitId="+subunitID+"&extClassName="+className);  
     	setQueryParam("dsMultiUnitRoomDetail", "argListingId", listingID);
     	setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subunitID);
   
     	/* Run the query for next page.*/
    	executeQuery("dsMultiUnitRoomDetail");
  }
  else
  {

	 setResponseURL("quickAdminCommonAvailablity.jsp?fwModuleName=genKfrent&extListingID="+listingID+"&extStatus=0&extSubUnitId=0&extClassName="+className+"&extRoomId=0");  
	 setQueryParam("dsListingAvailability", "argListingId", listingID);
	 setQueryParam("dsListingAvailability", "argSubUnitId", 0);
	 setQueryParam("dsListingAvailability", "argRoomId", 0);

	 executeQuery("dsListingAvailability");
  }	 
 
 submitForm(window, "fwForm");

}

function quickUpdateROOMAvailability(rowNo)
{
  listingID =  document.getElementById("dsMultiUnitRoomDetail-LISTING_ID").value;
  subunitID =  document.getElementById("dsMultiUnitRoomDetail-SUBUNIT_ID").value;
  roomID =  document.getElementById("extdsMultiUnitRoomDetail-ROOM_ID"+rowNo).value;
  className = document.getElementById("extClassName").value;
  //alert("saving avail .. subunitID = " + subunitID + " and room id = " + roomID);
	 setResponseURL("quickAdminCommonAvailablity.jsp?fwModuleName=genKfrent&extListingID="+listingID+"&extStatus=0&extSubUnitId="+subunitID+"&extClassName="+className+"&extRoomId="+roomID);  
	 setQueryParam("dsListingAvailability", "argListingId", listingID);
	 setQueryParam("dsListingAvailability", "argSubUnitId", subunitID);
	 setQueryParam("dsListingAvailability", "argRoomId", roomID);

	 executeQuery("dsListingAvailability");
	 //setQueryParam("dsListingAvailabilityUpdate", "argListingId", listingID);
	 //setQueryParam("dsListingAvailabilityUpdate", "argSubUnitId", subunitID);
	 //setQueryParam("dsListingAvailabilityUpdate", "argRoomId", roomID);

	 //executeQuery("dsListingAvailabilityUpdate");
	 
 submitForm(window, "fwForm");	 
}

function saveQuickUpdateAvail()
{
  listingID = document.getElementById("extListingID").value;
  subunitID = document.getElementById("extSubUnitId").value;
  className = document.getElementById("extClassName").value;
  roomID = document.getElementById("extRoomId").value;
  
  //alert("saving avail .. subunitID = " + subunitID + " and room id = " + roomID);
    setResponseURL("quickAdminCommonAvailablity.jsp?fwModuleName=genKfrent&extListingID="+listingID+"&extStatus=1&extSubUnitId="+subunitID+"&extClassName="+className+"&extRoomId="+roomID);  
    saveDataSet("dsListingAvailabilityUpdate");
	 setQueryParam("dsListingAvailabilityUpdate", "argListingId", listingID);
	 setQueryParam("dsListingAvailabilityUpdate", "argSubUnitId", subunitID);
	 setQueryParam("dsListingAvailabilityUpdate", "argRoomId", roomID)    
    executeQuery("dsListingAvailabilityUpdate");
    
    var segment = 'MultiUnitAdmin.checkOverlappingDates()' ;
    buildScriptSegment(segment);
    executeQuery("dsListingAvailabilityUpdate");
   submitForm(window, "fwForm");
}

function doneWithQuickUpdate()
{
  listingID = document.getElementById("extListingID").value;
  subunitID = document.getElementById("extSubUnitId").value;
  className = document.getElementById("extClassName").value;
	 if (subunitID > 0)
	 {
	     setResponseURL("quickAdminSelectRoom.jsp?fwModuleName=genKfrent&extListingID="+listingID+"&extStatus=0&extSubUnitId="+subunitID+"&extClassName="+className);  
	 }
	 else
	 {
	  setResponseURL("Welcome.jsp?fwModuleName=genKfrent");
	 }
  submitForm(window, "fwForm");
}

function updatePhotos(rowNo)
{
  ownerId = document.getElementById("extOwnerId").value;
  listingID =  document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
  setResponseURL("kfrFileUploadFormUpdate.jsp?fwModuleName=genKfrent&extlistingid="+listingID+"&extownerId="+ownerId+"&extMultiUnit="+0);
  setQueryParam("dsPropertyImages", "argListingId", listingID);
  executeQuery("dsPropertyImages");
  appendIfNoRow("dsPropertyImages");
  setQueryParam("dsPropertyImagesByListingId", "argListingId", listingID);
  executeQuery("dsPropertyImagesByListingId");
  appendIfNoRow("dsPropertyImagesByListingId");  
  submitForm(window, "fwForm");
}
function updatePhotos_CCNS(rowNo)
{
  ownerId = document.getElementById("extOwnerId").value;
  listingID =  document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
  setResponseURL("kfrFileUploadFormUpdate_CCNS.jsp?fwModuleName=genKfrent&extlistingid="+listingID+"&extownerId="+ownerId+"&extMultiUnit="+0);
  setQueryParam("dsPropertyImages", "argListingId", listingID);
  executeQuery("dsPropertyImages");
  appendIfNoRow("dsPropertyImages");
  setQueryParam("dsPropertyImagesByListingId", "argListingId", listingID);
  executeQuery("dsPropertyImagesByListingId");
  appendIfNoRow("dsPropertyImagesByListingId");  
  submitForm(window, "fwForm");
}
function updatePhotosBdrm(listdesc,listcode)
{
 if (document.getElementById("ext"+listcode).selectedIndex == 0)
 {
   alert("Please select a property from the " + listdesc+ " drop-down list first.");
 }
 else
 {
   list_idx = document.getElementById("ext"+listcode).selectedIndex;
   listingID = document.getElementById("ext"+listcode).options[list_idx].value;
   argMUname = document.getElementById("ext"+listcode).options[list_idx].text;
   ownerId = document.getElementById("extOwnerId").value;
   setResponseURL("kfrFileUploadFormUpdate.jsp?fwModuleName=genKfrent&extlistingid="+listingID+"&extownerId="+ownerId+"&extMultiUnit="+0);
   setQueryParam("dsPropertyImages", "argListingId", listingID);
   executeQuery("dsPropertyImages");
   appendIfNoRow("dsPropertyImages");  
   submitForm(window, "fwForm");
 }
}
function deleteLastPhoto()
{
  var listingID = document.getElementById("dsPropertyImages-LISTING_ID").value;
  var segment = 'FileUploadExtension.deletePhotoReference("'+listingID+'")';
  var retChar = buildScriptSegment(segment); 
  submitForm(window, "fwForm");
}
/* Function to save updated file uploads for a new listing */
function savePhotos()
{
  var listingID = document.getElementById("dsPropertyImages-LISTING_ID").value;  
//NEW
  /* First call the FileUploadExtension class */
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL1", "'+listingID+'","IMAGE_URL1_DESC")';
  var retChar = buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL2", "'+listingID+'","IMAGE_URL2_DESC")';
  buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL3", "'+listingID+'","IMAGE_URL3_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL4", "'+listingID+'","IMAGE_URL4_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL5", "'+listingID+'","IMAGE_URL5_DESC")';
  buildScriptSegment(segment);  
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL6", "'+listingID+'","IMAGE_URL6_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL7", "'+listingID+'","IMAGE_URL7_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL8", "'+listingID+'","IMAGE_URL8_DESC")';
  buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL9", "'+listingID+'","IMAGE_URL9_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL10", "'+listingID+'","IMAGE_URL10_DESC")';
  buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL11", "'+listingID+'","IMAGE_URL11_DESC")';
  buildScriptSegment(segment);   
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL12", "'+listingID+'","IMAGE_URL12_DESC")';
  buildScriptSegment(segment);  
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL13", "'+listingID+'","IMAGE_URL13_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL14", "'+listingID+'","IMAGE_URL14_DESC")';
  buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL15", "'+listingID+'","IMAGE_URL15_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL16", "'+listingID+'","IMAGE_URL16_DESC")';
  buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL17", "'+listingID+'","IMAGE_URL17_DESC")';
  buildScriptSegment(segment);   
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL18", "'+listingID+'","IMAGE_URL18_DESC")';
  buildScriptSegment(segment);  
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL19", "'+listingID+'","IMAGE_URL19_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL20", "'+listingID+'","IMAGE_URL20_DESC")';  
  buildScriptSegment(segment);   
  //setResponseURL("Welcome.jsp");
  alert("This process may take a few minutes depending on the size of your files.");
  executeQuery("dsPropertyListingByOwnerMUuserid");
  
  //Save the photo captions
  saveDataSet("dsPropertyImagesByListingId");
  
  submitForm(window, "fwForm");
}


/* Function to save ratesAndDates */
function saveUpdatedRatesAndDates(rowNo)
{
  var subUnitID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value;
  var className = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.CLASS"+rowNo).value;
  var listingID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value;
  var propOwnerId = top.frames['mainFrame'].document.getElementById("extownId").value;  
  if (subUnitID < 1) 
  {
    subUnitID = 0;
  }
  
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("adminRates.jsp?extListingId="+listingID+"&extSubUnitId="+subUnitID+"&extClassName="+className+"&extRowNo="+rowNo); 

  /* First call the FileUploadExtension class */
  var segment = 'ComputeHighAndLowRates.processHighLowRates("'+listingID+'","'+subUnitID+'")';
  //sending parameter of '0' because this is a non-multi-unit rental
  buildScriptSegment(segment);  
  //alert("listing ID = " + listingID + " subunit id = " + subUnitID);

  /* save the current dataset */
  saveDataSet("dsRatesDetail"); 
  
  /* query param should be 0 for non multiunit rentals */  
  setQueryParam("dsRatesDetail", "argListingId", listingID);
  setQueryParam("dsRatesDetail", "argSubUnitId", subUnitID);
  
  /* Run the query for next page.*/
  executeQuery("dsRatesDetail");
  mainDataFrameTarget = top.frames['mainFrame'];
  submitForm(mainDataFrameTarget, "fwForm");  

}//saveUpdatedRatesAndDates


//NEW chad
 /* Function to save ratesAndDates */
 function saveUpdatedRatesFreeform(rowNo)
 {
   if ((document.getElementById("dsRatesHeader-HIGH_WEEKLY_RATE").value == "") && (!document.getElementById("dsRatesHeader-LOW_WEEKLY_RATE").value == ""))
      {
        alert("You must complete the highest weekly rate");
        document.getElementById("dsRatesHeader-HIGH_WEEKLY_RATE").focus();
        return;
      }
   if ((!document.getElementById("dsRatesHeader-HIGH_WEEKLY_RATE").value == "") && (document.getElementById("dsRatesHeader-LOW_WEEKLY_RATE").value == ""))
      {
        alert("You must complete the lowest weekly rate");
        document.getElementById("dsRatesHeader-LOW_WEEKLY_RATE").focus();
        return;
      } 
   if ((document.getElementById("dsRatesHeader-HIGH_DAILY_RATE").value == "") && (!document.getElementById("dsRatesHeader-LOW_DAILY_RATE").value == ""))
      {
        alert("You must complete the highest daily rate");
        document.getElementById("dsRatesHeader-HIGH_DAILY_RATE").focus();
        return;
      }
   if ((!document.getElementById("dsRatesHeader-HIGH_DAILY_RATE").value == "") && (document.getElementById("dsRatesHeader-LOW_DAILY_RATE").value == ""))
      {
        alert("You must complete the lowest daily rate");
        document.getElementById("dsRatesHeader-LOW_DAILY_RATE").focus();
        return;
      }      
   if ((document.getElementById("dsRatesHeader-HIGH_WEEKLY_RATE").value == "") && (document.getElementById("dsRatesHeader-HIGH_DAILY_RATE").value == ""))
     {
       alert("Please complete both the highest and lowest rate for at least one of the rating schemes(daily or weekly)");
       return;
    }
 
   var subUnitID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value;
   var className = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.CLASS"+rowNo).value;
   var listingID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value;
   var propOwnerId = top.frames['mainFrame'].document.getElementById("extownId").value;  
   if (subUnitID < 1) 
   {
     subUnitID = 0;
   }
   
   /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
   setResponseURL("adminRates.jsp?extListingId="+listingID+"&extSubUnitId="+subUnitID+"&extClassName="+className+"&extRowNo="+rowNo); 
 
   /* save the current dataset */
   saveDataSet("dsRatesHeader");   
   
   saveDataSet("dsRatesDetailFreeform"); 

   
   /* query param should be 0 for non multiunit rentals */  
   setQueryParam("dsRatesDetailFreeform", "argListingId", listingID);
   setQueryParam("dsRatesDetailFreeform", "argSubUnitId", subUnitID);
   setQueryParam("dsRatesHeader", "argListingId", listingID);
   
   /* Run the query for next page.*/
   executeQuery("dsRatesDetailFreeform");
   executeQuery("dsRatesHeader");
   mainDataFrameTarget = top.frames['mainFrame'];
   submitForm(mainDataFrameTarget, "fwForm");  
 
}//saveUpdatedRatesAndDates


/* Function to save multiunit classes */
function saveMultiUnitClasses()
{

  listingID = document.getElementById("extlistingid").value;
  ownerId = (document.getElementById("extownId").value);
  
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("multiUnitAdmin.jsp?kfrOwnerId="+ownerId);
  
  /* save the current dataset */
  saveDataSet("dsMultiUnit");  
  //alert("saved multi unit class with id = " + listingID);
  
  setQueryParam("dsMultiUnit", "argListingId", listingID);
 
  /* Run the query for next page.*/
  executeQuery("dsMultiUnit");
  
  submitForm(window, "fwForm");
}

/* Set MultiUnit rates */
function setMultiUnitRates(rowNumber, checkStep1)
{
  listingID = document.getElementById("dsMultiUnit-LISTING_ID").value;
  subUnitID = document.getElementById("extdsMultiUnit-SUBUNIT_ID"+rowNumber).value;

  //alert("checkstep = " + checkStep1);
  if ((checkStep1 / rowNumber) == 1) 
  {
    //alert("subUnitId = " + subUnitID);
    var className = document.getElementById("extdsMultiUnit-CLASS"+rowNumber).value;
    /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/

    setQueryParam("dsRatesDetail", "argListingId", listingID);
    setQueryParam("dsRatesDetail", "argSubUnitId", subUnitID);
  
    /* Run the query for next page.*/
    executeQuery("dsRatesDetail");
    appendIfNoRow("dsRatesDetail");
  
    submitForm(window, "fwForm");
  
    ratesSubWin = window.open("ratesAndDatesMultiUnitForm.jsp?fwModuleName=genKfrent&extClassName="+className+"&extSubUnitId="+subUnitID,"locate","scrollbars=yes,location=no,height=410,width=625");  
	  if(!ratesSubWin){
	     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
	  }
  }
  else
  {
    alert("Please complete the prior step first. Thank You!");
  }
    
}

/* Function to save ratesAndDates for MultiUnits */
function saveMultiUnitRatesAndDates()
{
  listingID = document.getElementById("extLISTING_ID").value;
  subUnitID = document.getElementById("extSUBUNIT_ID").value;
  ownerId = (document.getElementById("extownId").value);
  //alert("listing id = " + listingID + " subunit id = " + subUnitID);
  
    /* save the current dataset */
  saveDataSet("dsRatesDetail"); 
  
  /* Ccall the ComputeHighAndLowRates class */
  var segmentY = 'ComputeHighAndLowRates.processHighLowRates("'+listingID+'","'+subUnitID+'")';
  //sending parameter of '0' because this is a non-multi-unit rental
  buildScriptSegment(segmentY);  
 
  clearDataSet("dsMultiUnit");
  setQueryParam("dsMultiUnit", "argListingId", listingID);
 
  /* Run the query for next page.*/
  executeQuery("dsMultiUnit");
  
  if(submitForm(window, "fwForm") != true)
  {
    return;
  }
 
  window.close();
  
  opener.focus();
  opener.location.reload();    
}

/* Set multiUnit room Availability admin page */
function openMultiUnitRoomAvailAdmin(rowNumber, checkStep1)
{
  listingID = document.getElementById("dsMultiUnit-LISTING_ID").value;
  subUnitID = document.getElementById("extdsMultiUnit-SUBUNIT_ID"+rowNumber).value;
  className = document.getElementById("extdsMultiUnit-CLASS"+rowNumber).value;

  if ((checkStep1 / rowNumber) == 1) 
  {  
  
    /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
    setResponseURL("multiUnitRoomAvailAdmin.jsp?fwModuleName=genKfrent&extClassName="+className+"&extSubUnitId="+subUnitID);
  
    setQueryParam("dsMultiUnitRoomDetail", "argListingId", listingID);
    setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subUnitID);
  
    /* Run the query for next page.*/
    executeQuery("dsMultiUnitRoomDetail");
  
    submitForm(window, "fwForm");  
  }
  else
  {
    alert("Please complete the prior step first. Thank You!");
  }
      
}

/* Set MultiUnit availability */
function setMultiUnitAvailability(rowNumber)
{
  listingID = document.getElementById("dsMultiUnitRoomDetail-LISTING_ID").value;
  subUnitID = document.getElementById("dsMultiUnitRoomDetail-SUBUNIT_ID").value;
  roomId = document.getElementById("extdsMultiUnitRoomDetail-ROOM_ID"+rowNumber).value;
  //alert("rownumber = " + rowNumber + " subUnitId = " + subUnitID + " room id = " + roomId);
  var className = document.getElementById("extClass").value;
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/

  setQueryParam("dsListingAvailability", "argListingId", listingID);
  setQueryParam("dsListingAvailability", "argSubUnitId", subUnitID);
  setQueryParam("dsListingAvailability", "argRoomId", roomId);  
  
  /* Run the query for next page.*/
  executeQuery("dsListingAvailability");
  //sortDataSet("dsListingAvailability", "AVAIL_FROM ASC");
  appendIfNoRow("dsListingAvailability");
  
  submitForm(window, "fwForm");
  
  ratesSubWin = window.open("multiUnitRentalAvailability.jsp?fwModuleName=genKfrent&extSubUnitId="+subUnitID+"&extClassName="+className+"&extRoomId="+roomId,"locate","scrollbars=yes,location=no,height=410,width=625");  
	  if(!ratesSubWin){
	     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
	  }
    
}

/* function to update MultiUnit availability */
function updateMultiUnitAvailability(rowNumber)
{
  listingID = top.frames['mainFrame'].document.getElementById("dsMultiUnitRoomDetail-LISTING_ID").value;
  subUnitID = top.frames['mainFrame'].document.getElementById("dsMultiUnitRoomDetail-SUBUNIT_ID").value;
  roomId = top.frames['mainFrame'].document.getElementById("extdsMultiUnitRoomDetail-ROOM_ID"+rowNumber).value;
  var className = top.frames['mainFrame'].document.getElementById("extClass").value;
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/

  setQueryParam("dsListingAvailability", "argListingId", listingID);
  setQueryParam("dsListingAvailability", "argSubUnitId", subUnitID);
  setQueryParam("dsListingAvailability", "argRoomId", roomId);  
  
  /* Run the query for next page.*/
  executeQuery("dsListingAvailability");
  //sortDataSet("dsListingAvailability", "AVAIL_FROM ASC");
  appendIfNoRow("dsListingAvailability");
  
  submitForm(mainDataFrameTarget, "fwForm");
  
  popupWin = window.open("updateMultiUnitRentalAvailability.jsp?fwModuleName=genKfrent&extListingId="+listingID+"&extSubUnitId="+subUnitID+"&extClassName="+className+"&extRoomId="+roomId,"locate","scrollbars=yes,location=no,height=410,width=625");  
	  if(!popupWin){
	     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
	  }
    
}

/* Function to save available dates for MultiUnits */
function saveMultiUnitAvailability()
{
  listingID = document.getElementById("extLISTING_ID").value;
  subUnitID = document.getElementById("extSUBUNIT_ID").value;
  roomID = document.getElementById("extROOM_ID").value;
  //alert("subunit id = " + subUnitID + "  listing id = " + listingID);
  ownerId = (document.getElementById("extownId").value);
  var className = document.getElementById("extClass").value;

// ************************************************************************* //
  /* First call the processRoomIdCreation class */
  var segment = 'MultiUnitAdmin.setAvailabilitySetFlag("'+listingID+'","'+subUnitID+'","'+roomID+'")';
  buildScriptSegment(segment); 
// ************************************************************************* //
// END CALL TO EXTENSION  


  /* save the current dataset */
  saveDataSet("dsListingAvailability"); 
  //alert("data set saved"); 

  setQueryParam("dsMultiUnitRoomDetail", "argListingId", listingID);
  setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subUnitID);  
 
  /* Run the query for next page.*/
  executeQuery("dsMultiUnitRoomDetail");
  
  submitForm(window, "fwForm");

  window.close();
  opener.focus();
  opener.location.reload();    
}

/* Function to save available dates for MultiUnits */
function saveUpdatedMultiUnitAvailability()
{
  listingID = document.getElementById("extLISTING_ID").value;
  subUnitID = document.getElementById("extSUBUNIT_ID").value;
  roomID = document.getElementById("extROOM_ID").value;
  //alert("IN SAVE PROCESS subunit id = " + subUnitID + "  listing id = " + listingID + " room id = " + roomID);
  ownerId = (document.getElementById("extownId").value);
  var className = document.getElementById("extClass").value;
     
  opener.setResponseURL("adminAvail.jsp?extSubUnitId="+subUnitID+"&extClassName="+className);
  /* save the current dataset */
  saveDataSet("dsListingAvailability"); 

  setQueryParam("dsMultiUnitRoomDetail", "argListingId", listingID);
  setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subUnitID);  
 
  /* Run the query for next page.*/
  executeQuery("dsMultiUnitRoomDetail");
  
  submitForm(window, "fwForm");

  window.close();

}//saveUpdatedMultiUnitAvailability

function closeSubWindows()
{
 if (ratesSubWin != null && ratesSubWin.open) 
 { 
    ratesSubWin.close();
 }
}

/* Set room/suite names */
function setRoomNames(rowNumber)
{
  listingID = document.getElementById("dsMultiUnit-LISTING_ID").value;
  subUnitID = document.getElementById("extdsMultiUnit-SUBUNIT_ID"+rowNumber).value;
  var noOfClasses = document.getElementById("extdsMultiUnit-CLASS_UNITS"+rowNumber).value;
  var ii = 0;

  var className = document.getElementById("extdsMultiUnit-CLASS"+rowNumber).value;

  //opener.setResponseURL("multiUnitAdmin.jsp?fwModuleName=genKfrent&extClassName="+className+"&extSubUnitId="+subUnitID);
  
  /* First call the processRoomIdCreation class */
  var segment = 'MultiUnitAdmin.processRoomIdCreation("'+listingID+'","'+subUnitID+'","'+noOfClasses+'")';
  buildScriptSegment(segment);  

  setQueryParam("dsMultiUnitRoomDetail", "argListingId", listingID);
  setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subUnitID);
  
  /* Run the query for next page.*/
  executeQuery("dsMultiUnitRoomDetail");
  
  
  submitForm(window, "fwForm");
  
  ratesSubWin =  window.open("setRoomSuiteNames.jsp?fwModuleName=genKfrent&extlistingid="+listingID+"&extClassName="+className+"&extSubUnitId="+subUnitID,"locate","scrollbars=yes,location=no,height=410,width=625");  
	  if(!ratesSubWin){
	     alert('We have detected that you are using popup blocking software. In order to access this portion of KeysForRent, you must disable your popup blocker.'); 
	  }    
}//end set room/suite names

/* Function to save roomNames for MultiUnits */
function saveMultiUnitRoomNames()
{
  listingID = document.getElementById("extlistingid").value;
  subUnitID = document.getElementById("extsubunitid").value;

  var ownerId = (document.getElementById("extownId").value);
  
  /* save the current dataset */
  saveDataSet("dsMultiUnitRoomDetail");
  
// CMY NEED TO REMEMBER TO CALL EXTENSION TO SET VALUE "ROOMS_SET"
// WRITE EXTENSION HERE
// ************************************************************************* //
  /* First call the processRoomIdCreation class */ 
  var segment = 'MultiUnitAdmin.setRoomsSetFlag("'+listingID+'","'+subUnitID+'")';
  buildScriptSegment(segment); 
// ************************************************************************* //
// END CALL TO EXTENSION  

  setQueryParam("dsMultiUnit", "argListingId", listingID);
 
  /* Run the query for next page.*/
  executeQuery("dsMultiUnit");
  
  if(submitForm(window, "fwForm") != true)
  {
    return;
  }

  window.close();
  opener.focus();
  opener.location.reload();    

}// end saveMultiUnitRoomNames

/* function to save mulitUnit Room names from admin page */
function updateMultiUnitRoomNames(rowNo)
{

  var subUnitID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value;
  var className = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.CLASS"+rowNo).value;
  var listingID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value;
  var propOwnerId = top.frames['mainFrame'].document.getElementById("extownId").value;  
  if (subUnitID < 1) 
  {
    subUnitID = 0;
  }
  
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("adminRoomNames.jsp?extListingId="+listingID+"&extSubUnitId="+subUnitID+"&extClassName="+className+"&extRowNo="+rowNo); 


  /* save the current dataset */
  saveDataSet("dsMultiUnitRoomDetail");
  
  /* query param should be 0 for non multiunit rentals */  
  setQueryParam("dsMultiUnitRoomDetail", "argListingId", listingID);
  setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subUnitID);
  
  /* Run the query for next page.*/
  executeQuery("dsMultiUnitRoomDetail");
  mainDataFrameTarget = top.frames['mainFrame'];
  submitForm(mainDataFrameTarget, "fwForm");    

}

/* function to save mulitUnit Room names from admin page */
function updateMultiUnitDiscounts(rowNo)
{

  var subUnitID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value;
  var className = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.CLASS"+rowNo).value;
  var listingID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value;
  var propOwnerId = top.frames['mainFrame'].document.getElementById("extownId").value;  
  if (subUnitID < 1) 
  {
    subUnitID = 0;
  }
  
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("adminRoomDiscounts.jsp?extListingId="+listingID+"&extSubUnitId="+subUnitID+"&extClassName="+className+"&extRowNo="+rowNo); 


  /* save the current dataset */
  saveDataSet("dsMultiUnitBySubUnit");
  
  /* query param should be 0 for non multiunit rentals */  
  setQueryParam("dsMultiUnitBySubUnit", "argListingId", listingID);
  setQueryParam("dsMultiUnitBySubUnit", "argSubUnitId", subUnitID);
  
  /* Run the query for next page.*/
  executeQuery("dsMultiUnitBySubUnit");
  mainDataFrameTarget = top.frames['mainFrame'];
  submitForm(mainDataFrameTarget, "fwForm");    

}

/* Function to complete all multiUnit availability setttings and return to MultiUnitAdmin */
function completedMultiUnitRatesAndDates()
{
//get a listing ID and subunitid for the extension
  listingID = document.getElementById("dsMultiUnitRoomDetail-LISTING_ID").value;
  subUnitID = document.getElementById("dsMultiUnitRoomDetail-SUBUNIT_ID").value;
  ownerId = (document.getElementById("extownId").value);
// *********** Call extension to set availability_set flag on multi_unit detail table
  var segment = 'MultiUnitAdmin.setDetailAvailabilitySetFlag("'+listingID+'","'+subUnitID+'")';
  buildScriptSegment(segment); 
// ************************************************************************* //

// there is no dataset to save since this is an admin page
// so lets call the next page
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("multiUnitAdmin.jsp?kfrOwnerId="+ownerId);
  

  setQueryParam("dsMultiUnit", "argListingId", listingID);
 
  /* Run the query for next page.*/
  executeQuery("dsMultiUnit");
  
  submitForm(window, "fwForm");  
  window.close();
  opener.focus();
  opener.location.reload();  

}

/* Function to complete all multiUnitAdmin and go to upload Files */
function completedMultiUnitAdmin()
{
  propOwnerId = document.getElementById("extownId").value;
  var listID = document.getElementById("dsMultiUnit-LISTING_ID").value
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("fileUploadForm.jsp?fwModuleName=genKfrent&extlistingid="+listID+"&extownerId="+propOwnerId+"&extMultiUnit="+1);

  setQueryParam("dsPropertyImages", "argListingId", listID); 
  
  /* Run the query.*/
  executeQuery("dsPropertyImages"); 
  
  appendIfNoRow("dsPropertyImages");
  
  submitForm(window, "fwForm");    
}

/* Function to complete all common rental availability and go to upload Files */
function saveCommonAvailability()
{
  propOwnerId = document.getElementById("extownId").value;
  var listID = document.getElementById("extLISTING_ID").value
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("fileUploadForm.jsp?fwModuleName=genKfrent&extlistingid="+listID+"&extownerId="+propOwnerId+"&extMultiUnit="+0);
 
  //alert("saving avail");
  saveDataSet("dsListingAvailability");
  setQueryParam("dsPropertyImages", "argListingId", listID); 
  
  /* Run the query.*/
  executeQuery("dsPropertyImages"); 
  //alert("append new row to property images with listing ID = " + listID);
  appendIfNoRow("dsPropertyImages");
  
  submitForm(window, "fwForm"); 
}



/* Function to save all file uploads for a new listing */
function savestep5of6()
{
  propOwnerId = document.getElementById("extownId").value;
  setQueryParam("dsPreferences",argOwnerId);
  appendIfNoRow("dsPreferences");
  var listingID = document.getElementById("dsPropertyImages-LISTING_ID").value;  
  var scanServ = 0;
  if (document.getElementById("extCbx-SCAN_SERVICE").checked)
  {
    scanServ = 1;
  }
  else
  {
     //verify a file has been submitted
     if (document.getElementById("dsPropertyImages-IMAGE_URL1").value == "")
     {
        alert("You must select at least 1 file to upload or select to mail in your photos with a scan service charge. If you have chosen to upload a file be sure that it is loaded in the 'IMAGE 1' column first.");
        return;
        }
  }

  var multiUnitFlag = document.getElementById("extmultiUnitFlag").value;
  
  if (scanServ == 1){
  //alert("Scan service value = " + scanServ + " calling extension with listing id = " + listingID);
  var segment = 'FileUploadExtension.saveNoUpload("'+listingID+'")';
  buildScriptSegment(segment);  
  }
  else
  {
  /* First call the FileUploadExtension class */
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL1", "'+listingID+'","IMAGE_URL1_DESC")';
  var retChar = buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL2", "'+listingID+'","IMAGE_URL2_DESC")';
  buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL3", "'+listingID+'","IMAGE_URL3_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL4", "'+listingID+'","IMAGE_URL4_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL5", "'+listingID+'","IMAGE_URL5_DESC")';
  buildScriptSegment(segment);  
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL6", "'+listingID+'","IMAGE_URL6_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL7", "'+listingID+'","NONE")';
  buildScriptSegment(segment);  
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL8", "'+listingID+'","IMAGE_URL8_DESC")';
  buildScriptSegment(segment);  
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL9", "'+listingID+'","IMAGE_URL9_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL10", "'+listingID+'","IMAGE_URL10_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL11", "'+listingID+'","IMAGE_URL11_DESC")';
  buildScriptSegment(segment);   
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL12", "'+listingID+'","IMAGE_URL12_DESC")';
  buildScriptSegment(segment); 
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL13", "'+listingID+'","IMAGE_URL13_DESC")';
  buildScriptSegment(segment);
  var segment = 'FileUploadExtension.saveUploadedFile("dsPropertyImages","IMAGE_URL14", "'+listingID+'","IMAGE_URL14_DESC")';
  buildScriptSegment(segment);  
  //alert("built script segments");
  }
  //alert("responseURL = " + "paymentFormA.jsp?fwModuleName=genKfrent&extlistingid="+listingID+"&extownerId="+propOwnerId);

  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
//  setResponseURL("paymentFormA.jsp?fwModuleName=genKfrent&listingid="+listingID+"&ownerId="+propOwnerId);
    setResponseURL("paymentFormA.jsp?fwModuleName=genKfrent&extlistingid="+listingID+"&extownerId="+propOwnerId);

setQueryParam("dsPreviousBillingAmount", "argOwnerId", propOwnerId);
setQueryParam("dsVacationPropertyCharge", "argOwnerId", propOwnerId);
setQueryParam("dsAviationCharge", "argOwnerId", propOwnerId);
//setQueryParam("dsBoatYachtCharge", "argOwnerId1", propOwnerId);
//setQueryParam("dsBoatYachtCharge", "argOwnerId2", propOwnerId);
setQueryParam("dsFeaturesCharges", "argOwnerId", propOwnerId);
setQueryParam("dsMultiUnitCharges", "argOwnerId", propOwnerId);
setQueryParam("dsOnlineReservableCharges", "argOwnerId", propOwnerId);


  executeQuery("dsPreviousBillingAmount");
  executeQuery("dsVacationPropertyCharge");
  executeQuery("dsAviationCharge");
 //executeQuery("dsBoatYachtCharge");
  executeQuery("dsFeaturesCharges");
  executeQuery("dsMultiUnitCharges");
  executeQuery("dsOnlineReservableCharges");  


  //saveDataSet("dsPropertyImages");
  
  setQueryParam("dsPricingReference", "argListingId", listingID); 
  setQueryParam("dsPropertyListingByOwner", "argOwnerId", propOwnerId);
  //alert("opening up paymentFormA with listing id = " + listingID + " owner ID = " + propOwnerId + " multiUnitflag = " + multiUnitFlag);
  /* Run the query.*/
  executeQuery("dsPricingReference");
  executeQuery("dsPropertyListingByOwner");
  

  submitForm(window, "fwForm");
}

/*function to add in monthly fees for Feature Listings */
function addMonthlyFee(rowNo, listingId, cycleType)
{
  chkBoxValue = document.getElementById("extCbx-FEATURE_LISTING"+rowNo).value;
  chkBoxValue2 = document.getElementById("extCbx-FEATURE_LISTING"+rowNo).checked;
 //alert("current row checked value = " + chkBoxValue2 + " listing id = " + listingId + " cycleType = " + cycleType); 
 if (chkBoxValue2 == false)
 {
   // call extension to check prior feature listing setting
  propOwnerId = document.getElementById("extpropertyOwnerId").value;
    var segmentCPF = 'MultiUnitAdmin.checkPriorFeature("'+propOwnerId+'","'+listingId+'","'+cycleType+'")';
    buildScriptSegment(segmentCPF); 
    setResponseURL("paymentFormA.jsp?fwModuleName=genKfrent&extlistingid="+listingId+"&extownerId="+propOwnerId);
    submitForm(window, "fwForm");  
 }
 
 if (chkBoxValue2 == true)
 {
  propOwnerId = document.getElementById("extpropertyOwnerId").value;
    var segmentAM = 'MultiUnitAdmin.addMonthlyFee("'+propOwnerId+'","'+listingId+'","'+cycleType+'")';
    buildScriptSegment(segmentAM); 
    setResponseURL("paymentFormA.jsp?fwModuleName=genKfrent&extlistingid="+listingId+"&extownerId="+propOwnerId);
    submitForm(window, "fwForm"); 
    }
}

/* Function to save the billing info */
function saveBilling(parm1)
{
   if (checkCreditCard('dsOwnerPayments-CC_TYPE','dsOwnerPayments-CC_NUMBER') == true) 
   {
  	var ownerId = (document.getElementById("extownId").value);
  	var billingNo = (document.getElementById("extBILLING_NO").value);
  	var billingCycle = (document.getElementById("extBILLING_CYCLE").value);
  	var discountCode = document.getElementById("dsRentalDiscounts-DISCOUNT_VALUE").value;
  	//alert("discountCode = " + discountCode);
  	if (discountCode == ""){
      	discountCode = "0";
    	}
	//CMY changed 01/21/03...this should be coming correctly from dataset value
	//    else
	//    {
	//      discountCode = "1";
	//  }
  	if (billingCycle == "")
  	{
    		alert("billing cycle is null");
   	}
  	document.getElementById("dsOwnerPayments-BILLING_NO").value = billingNo;
  	targetDate = new Date();
  	mm = String(targetDate.getMonth() + 1);
  	while (mm.length < 2)
    	mm = "0" + mm;
  	dd = String(targetDate.getDate());
  	while (dd.length < 2)
   		 dd = "0" + dd;
  		yyyy = String(targetDate.getFullYear());
  		while (yyyy.length < 4)
    		yyyy = "0" + yyyy;

  	stringDate =  mm + "/" + dd + "/" + yyyy;
  	stringDate = '"' + stringDate + '"';  
  	//alert("owner no = " + ownerId +"!");
  
  	/* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
//5-14-11  	setResponseURL(URLStart+"thankyou.jsp?extkfrOwnerId="+ownerId);
  	setResponseURL("thankyou.jsp?extkfrOwnerId="+ownerId);
 
  	var segmentOP = 'MultiUnitAdmin.setOwnerPayment("'+ownerId+'", "'+billingNo+'", '+stringDate+', "'+billingCycle+'", "'+discountCode+'")';
  	buildScriptSegment(segmentOP); 
  
  	var segmentSS = 'MultiUnitAdmin.setListingStatus("'+ownerId+'", "'+discountCode+'")';
  	buildScriptSegment(segmentSS); 
 
  	//if (parm1 == "Xfer")
  	//{
    	//	var segmentXF ='MultiUnitAdmin.changeOwner('+ownerId+')';
    	//	buildScriptSegment(segmentXF);   
  	//} 
  	//clearDataSet("dsPropertyOwner");
  	executeQuery("dsPropertyListingByOwnerMUuserid");
  	submitForm(window, "fwForm");  
   }  	

}
//chad new
/* Function to save the billing info */
function saveBillingSecureLink()
{
   if (checkCreditCard('dsOwnerPayments-CC_TYPE','dsOwnerPayments-CC_NUMBER') == true) 
   {
  	var ownerId = (document.getElementById("extownId").value);
  	var billingNo = (document.getElementById("extBILLING_NO").value);
  	var billingCycle = (document.getElementById("extBILLING_CYCLE").value);
 	discountCode = "95";
  	document.getElementById("dsOwnerPayments-BILLING_NO").value = billingNo;
  	targetDate = new Date();
  	mm = String(targetDate.getMonth() + 1);
  	while (mm.length < 2)
    	mm = "0" + mm;
  	dd = String(targetDate.getDate());
  	while (dd.length < 2)
   		 dd = "0" + dd;
  		yyyy = String(targetDate.getFullYear());
  		while (yyyy.length < 4)
    		yyyy = "0" + yyyy;

  	stringDate =  mm + "/" + dd + "/" + yyyy;
  	stringDate = '"' + stringDate + '"';  
  	//alert("owner no = " + ownerId +"!");
  
  	/* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
//5-14-11  	setResponseURL(URLStart+"thankyou.jsp?extkfrOwnerId="+ownerId);
  	setResponseURL("thankyou.jsp?extkfrOwnerId="+ownerId);
 
  	var segmentOP = 'MultiUnitAdmin.setOwnerPayment("'+ownerId+'", "'+billingNo+'", '+stringDate+', "'+billingCycle+'", "'+discountCode+'")';
  	buildScriptSegment(segmentOP); 
  
  	var segmentSS = 'MultiUnitAdmin.setListingStatus("'+ownerId+'", "'+discountCode+'")';
  	buildScriptSegment(segmentSS); 
 
  	clearDataSet("dsPropertyOwner");
  	executeQuery("dsPropertyListingByOwnerMUuserid");
  	submitForm(window, "fwForm");  
   }  	

}
//CHAD 03/03/2004
/* Function to save all property amenities for a new listing */
function updateRentalInfo2()
{

  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("adminListing.jsp?fwModuleName=genKfrent");

 /* Save the buffer.*/
  saveDataSet("dsPropertyListingByOwner");

   submitForm(window, "fwForm");

}

/* Function to save all property amenities for a new listing */
function kfrUpdateRentalInfo(windowName)
{

  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  //setResponseURL("adminListing.jsp?fwModuleName=genKfrent");

 /* Save the buffer.*/
  saveDataSet("dsPropertyListingByOwner");

  //saveAllDataSets();
  /* Submit the main form.*/
  submitOnLoadTarget = listDataFrameTarget;
  if(!submitForm(mainDataFrameTarget, "fwForm"))
  {
    return;
  }//if(!submitForm(mainDataFrameTarget, "fwForm")) 

}

function showPromoInfo()
{
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("freepromoinfo.jsp?fwModuleName=genKfrent");
 
  submitForm(window, "fwForm");
}


function adminUserSecurity(rowNo,userNo)
{
  ownerId = document.getElementById("extOwnerId").value;
  executeQuery("dsPropertyOwner");
  setRow("dsPropertyOwner", rowNo);
  setResponseURL("newUserSetupAdmin.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId+"&extRowNo="+rowNo+"&insertFlag=N");
  submitForm(window, "fwForm");
  //this function will verify the userNo is 1 before allowing this call to the function
  //only users of #1 status can have access to the admin page. 
  //This must bring up a similar page to add.. allowing changes for password, userName
  //and accessLevel
} 

function InsRowUser()
{
  ownerId = document.getElementById("extOwnerId").value;
  appendRow("dsPropertyOwner");
  setResponseURL("newUserSetup.jsp?fwModuleName=genKfrent&extOwnerId="+ownerId);
  submitForm(window, "fwForm");
}
function DelRowUser(rowNo)
{
  setRow("dsPropertyOwner", rowNo);
  deleteRow("dsPropertyOwner");
  saveDataSet("dsPropertyOwner");
  submitForm(window, "fwForm");
}
function saveNewUser()
{
  var pswd = document.getElementById("dsPropertyOwner-PASSWORD").value;
  var verifyPswd = document.getElementById("extverifyPassword").value;
  var userName = document.getElementById("dsPropertyOwner-USER_NAME").value;
 
  if (pswd != verifyPswd)
  {
    alert("Your Password does not match the verify password! Please re-enter.");
    return;
  }

  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  //setResponseURL("Welcome.jsp");
  //saveDataSet("dsPropertyOwner");
  
  submitForm(window, "fwForm");
}

function alterOwnerBillingInfo()
{
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("alterRegistration.jsp?fwModuleName=genKfrent");
  
  
  setQueryParam("dsPropertyOwner","argOwnerId",document.getElementById("extOwnerId").value);
  /* If the query returns no rows, then append a row.*/
  executeQuery("dsPropertyOwner");
  
  setQueryParam("dsOwnerCCMerch","argOwnerId",document.getElementById("extOwnerId").value);
  executeQuery("dsOwnerCCMerch");
  
  submitForm(window, "fwForm");
}


function maLogon()
{
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("_CKC.jsp");
  
  setQueryParam("dsLogonMA", "argUserName", document.fwForm.extUserName2.value);
  setQueryParam("dsLogonMA", "argPassword", document.fwForm.extPassword2.value);

    
  /* Save the buffer.*/
  executeQuery("dsLogonMA");

  submitForm(window, "fwForm"); 
}

/* Admin function for Keys For Rent */
function admin() 
{
  
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("adminListingN.jsp?fwModuleName=genKfrent");

  setQueryParam("dsPropertyListingByOwner", "argOwnerId", document.getElementById("extOwnerId").value);
  setQueryParam("dsPropertyListingByOwnerMU", "argOwnerId", document.getElementById("extOwnerId").value);  
  
  setQueryParam("dsSelectedAmenitiesByOwner", "argOwnerId", document.getElementById("extOwnerId").value);
  setQueryParam("dsSelectedAmenitiesByOwner", "argRentalTypeNo", 1);
  
   /* Run the query.*/
   executeQuery("dsPropertyListingByOwner");
   executeQuery("dsPropertyListingByOwnerMU");   
   executeQuery("dsSelectedAmenitiesByOwner");
  executeQuery("dsBrowseVacationRentals");
  executeQuery("dsBrowseAviationRentals");
  executeQuery("dsListingCount");   


  /* If the query returns no rows, then append a row.*/
  //appendIfNoRow("dsSelectedAmenities");
  
  /* Always append a row for images */
  //appendRow("dsPropertyImages");
  
  submitForm(window, "fwForm");

}

function doOnLoadAdmin(targetFrame)
{
  /* Set up frame targets.*/
  listDataFrameTarget = top.frames['leftFrame'];
  mainDataFrameTarget = top.frames['mainFrame'];
  tabsFrameTarget = top.frames['tabFrame'];

    /* Common On Load processing.*/
  doCommonOnLoad(targetFrame);
}


/* Submit main form on load of list form */
function submitAdminMainForm()
{
  
  submitForm(mainFrame, "fwForm");         
}

function addProperty(windowName)
{

  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
   setResponseURL("admin_rentalinfo.jsp"); 
  
  /* If the query returns no rows, then append a row.*/
  appendRow("dsPropertyListing");
  appendRow("dsPropertyImages");


  submitForm(mainDataFrameTarget, "fwForm");
  
}

function deleteListing(windowName)
{

   /* Outline:
    *
    * Confirm with the user.
    * Delete the row.
    * Save the buffer.
    * Execute the query.
    * Submit the form.
    */
 
   /* Check the module status.*/
   if(!fwCheckModuleStatus())
   {
     return;
   }//if(!fwCheckModuleStatus())
 
   var targetForm = null;
 
   /* Confirm with the user.*/
   var returnVal = confirm("Are you sure you want to delete the current record?");
   if(!returnVal)
   {
     return;
   }//if(!returnVal)

 
   /* Delete the row.*/
  deleteRow("dsPropertyListing");
  saveDataSet("dsPropertyListing");
  deleteRow("dsPropertyImages");
  saveDataSet("dsPropertyImages");
 
   /* Save the buffer.*/
  
  
 
   /* Execute the query.*/
  executeQuery("dsPropertyListing");
  executeQuery("dsPropertyImages");;
 
   /* Validate the main form.*/
   targetForm = mainDataFrameTarget.document.getElementById('fwForm');

   if(!fwValidateForm(targetForm))
   {
     return;
   }//if(!fwValidateForm(targetForm))
 
   /* Submit the list form.*/
   submitOnLoadTarget = listDataFrameTarget;
  submitForm(mainDataFrameTarget, "fwForm");
 

}


/* Function to save all property amenities for a new listing */
function saveMultiUnitClasses2()
{
  listingID = document.getElementById("extlistingid").value;
  ownerId = (document.getElementById("extownId").value);
  
  /* save the current dataset */
  saveDataSet("dsMultiUnit");  
  
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("adminMultiUnitListing.jsp?fwModuleName=genKfrent");

  setQueryParam("dsPropertyListingByListingIDMU","argListingId", listingID);
 /* Save the buffer.*/
  executeQuery("dsPropertyListingByListingIDMU");


 /* Submit the main form.*/
  submitForm(window, "fwForm");

}


function upLoadQBFile(argOwnerId)
{
	var segment = 'FileUploadExtension.saveUploadedQBFile("'+argOwnerId+'")';
	var retChar = buildScriptSegment(segment);
	
	segment = 'MultiUnitAdmin.buildOwnerAccounting("' + argOwnerId + '")';
    	buildScriptSegment(segment);
	
	setResponseURL("Welcome.jsp");
 	/* Submit the main form.*/
  	submitForm(window, "fwForm");
  	
  	alert("Upload complete");
}


//CHAD 03/03/2004
function openUpdateRentalInfo(rowNo)
{
  listingId = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.LISTING_ID"+rowNo).value;
  rentalType = document.getElementById("extdsPropertyListingByOwnerMUuserid-A.RENTAL_TYPE_NO"+rowNo).value;
  natCode = document.getElementById("extdsPropertyListingByOwnerMUuserid-NATION_CODE"+rowNo).value;
  statProvCode = document.getElementById("extdsPropertyListingByOwnerMUuserid-STATE_PROVINCE_CODE"+rowNo).value;
  setQueryParam("dsOwnerListingCountByOwner","argOwnerId",document.getElementById("extOwnerId").value);
  executeQuery("dsOwnerListingCountByOwner");
  setQueryParam("dsRentalSubregions", "argNationCode", natCode);
  setQueryParam("dsRentalSubregions", "argStatesProvinces", statProvCode);
  executeQuery("dsRentalSubregions"); 
  setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argListingId", listingId);
  setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argRentalTypeNo", rentalType);
  setQueryParam("dsAdminPropertyListingByListingId", "argListingId", listingId);
  setQueryParam("dsListingFeeSetup", "argListingId", listingId);
  executeQuery("dsListingFeeSetup");
  setQueryParam("dsListingFeeSetupOptional", "argListingId", listingId);
  executeQuery("dsListingFeeSetupOptional");  
  setQueryParam("dsHouseKeepingUsers","argOwnerId",document.getElementById("extOwnerId").value);
  executeQuery("dsHouseKeepingUsers");
  setQueryParam("dsCancellationSetup", "argListingId", listingId);
  executeQuery("dsCancellationSetup");
  appendIfNoRow("dsCancellationSetup");
  executeQuery("dsAdminPropertyListingByListingId"); 
  executeQuery("dsSelectedAmenitiesByListingIdAdmin");
  setResponseURL("kfrUpdateRentalInfo.jsp?extListingId="+listingId);
  submitForm(window, "fwForm");
}
function openUpdateRentalInfoBdrm(listdesc,listcode)
{
 if (document.getElementById("ext"+listcode).selectedIndex == 0)
 {
   alert("Please select a property from the " + listdesc+ " drop-down list first.");
 }
 else
 {
   list_idx = document.getElementById("ext"+listcode).selectedIndex;
   listingId = document.getElementById("ext"+listcode).options[list_idx].value;
   argMUname = document.getElementById("ext"+listcode).options[list_idx].text;
   
  rentalType = "1";
  setQueryParam("dsOwnerListingCountByOwner","argOwnerId",document.getElementById("extOwnerId").value);
  executeQuery("dsOwnerListingCountByOwner");
 
  setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argListingId", listingId);
  setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argRentalTypeNo", rentalType);
  setQueryParam("dsAdminPropertyListingByListingId", "argListingId", listingId);
  setQueryParam("dsListingFeeSetup", "argListingId", listingId);
  executeQuery("dsListingFeeSetup");
  setQueryParam("dsListingFeeSetupOptional", "argListingId", listingId);
  executeQuery("dsListingFeeSetupOptional");  
  setQueryParam("dsHouseKeepingUsers","argOwnerId",document.getElementById("extOwnerId").value);
  executeQuery("dsHouseKeepingUsers");
  setQueryParam("dsCancellationSetup", "argListingId", listingId);
  executeQuery("dsCancellationSetup");
  appendIfNoRow("dsCancellationSetup");
  executeQuery("dsAdminPropertyListingByListingId"); 
  executeQuery("dsSelectedAmenitiesByListingIdAdmin");
  setResponseURL("kfrUpdateRentalInfo.jsp?extListingId="+listingId);
  submitForm(window, "fwForm");
 }
}

/**
 * Select an Admin Row from the list.
 */
function doAdminRowOnClick(rowNo, tableRow, rowCount)
{
  //var subUnitID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value;
  var className = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.CLASS"+rowNo).value;
  var listingID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value;
  var rentalTypeNo = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.RENTAL_TYPE_NO"+rowNo).value;
  //NEW
  var onlineRes = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.ONLINE_RESERVABLE"+rowNo).value;
  var spaceAvail = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.SPACE_AVAILABLE_LISTING"+rowNo).value;
//alert("onlineRes = " + onlineRes + " spaceAvail = " + spaceAvail);


  if (top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value < 1) 
  {
    subUnitID = 0;
    /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
    setResponseURL("adminRentalInfo.jsp?extSubUnitId="+top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value+"&extListingId="+listingID+"&extClassName="+className+"&extRowNo="+rowNo); 
  }
 else
 {
   subUnitID = top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo);
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
   setResponseURL("adminRentalInfo.jsp?extSubUnitId="+top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value+"&extListingId="+listingID+"&extClassName="+className+"&extRowNo="+rowNo); 
 }  
  /* Set the row.*/
  setRow("dsPropertyListingByOwner", rowNo);
  //alert("subunitId = " + subUnitID + " className = " + className + " listingID = " + listingID + " rental type no = " + rentalTypeNo);
 
  clearDataSet("dsMultiUnitRoomDetail");
  //setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argOwnerId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.OWNER_ID").value);
  setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argListingId", top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value);
  setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argRentalTypeNo", top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.RENTAL_TYPE_NO"+rowNo).value);
  setQueryParam("dsAdminPropertyListingByListingId", "argListingId", top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value);
  
  executeQuery("dsAdminPropertyListingByListingId"); 
  
  executeQuery("dsSelectedAmenitiesByListingIdAdmin");
  /* Set query params */
  setQueryParam("dsMultiUnitRoomDetail", "argListingId", top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value);
  setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value);
  //alert("subunit id = " + top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argListingId", top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-A.LISTING_ID"+rowNo).value);
  setQueryParam("dsRatesDetail", "argSubUnitId", top.frames['leftFrame'].document.getElementById("extdsPropertyListingByOwnerMU-B.SUBUNIT_ID"+rowNo).value);
  setQueryParam("dsListingAvailabilityCommon", "argListingId", listingID);
  setQueryParam("dsListingFeeSetup", "argListingId", listingID);
  executeQuery("dsListingFeeSetup");
  setQueryParam("dsListingFeeSetupOptional", "argListingId", listingID);
  executeQuery("dsListingFeeSetupOptional");  
  executeQuery("dsMultiUnitRoomDetail"); 
  executeQuery("dsRatesDetail");
  executeQuery("dsListingAvailabilityCommon"); 
  //sortDataSet("dsListingAvailabilityCommon", "AVAIL_FROM ASC");
  //NEW
  appendIfNoRow("dsListingFeeSetup");
  appendIfNoRow("dsListingFeeSetupOptional") ;
  /* Set the selected row */
  setAdminSelectedRow(tableRow,rowCount);
  //setAdminSelectedRow(rowNo,rowCount);
  selectedRow = rowNo;
  //alert("table row = " + tableRow + " rowCount = " + rowCount + " selected row = " + selectedRow);
  
  /* Submit form on Main page.*/
  submitForm(mainDataFrameTarget, "fwForm");
  
 //setResponseURL("admin_tabs.jsp?extRowNo="+rowNo);
 //submitForm(tabsFrameTarget, "fwForm");

  top.frames['tabFrame'].document.fwForm.visiLayer.style.visibility="visible";
  top.frames['tabFrame'].document.fwForm.layer2.style.visibility="visible";
  top.frames['tabFrame'].document.fwForm.layer8.style.visibility="visible";

  top.frames['tabFrame'].document.fwForm.layer33.style.visibility="visible";
  top.frames['tabFrame'].document.fwForm.layer88.style.visibility="visible";
    

  top.frames['tabFrame'].document.fwForm.layer3.style.visibility="hidden";
  top.frames['tabFrame'].document.fwForm.layer9.style.visibility="hidden";
  top.frames['tabFrame'].document.fwForm.layer22.style.visibility="hidden";
  top.frames['tabFrame'].document.fwForm.layer99.style.visibility="hidden";
//NEW  
if ((rentalTypeNo != 1) || (onlineRes == 0) || (spaceAvail == 1)){
   top.frames['tabFrame'].document.fwForm.layer33.style.visibility="hidden";
   top.frames['tabFrame'].document.fwForm.layer88.style.visibility="hidden";
   top.frames['tabFrame'].document.fwForm.layer22.style.visibility="hidden";
   top.frames['tabFrame'].document.fwForm.layer99.style.visibility="hidden";

}             
  
  top.frames['bottomFrame'].document.fwForm.visiLayer.style.visibility="visible"; 

}//function selectAdminRow(dataSet, rowNo)


function adminSave()
{

 saveDataSet("dsAdminPropertyListingByListingId");
 		
 /* Build the script segment.*/
 var segment1 = 'KfrentAdminAmenitiesAndSeasons.processAmenitiesAdmin()';
 buildScriptSegment(segment1);  

 saveDataSet("dsSelectedAmenitiesByListingIdAdmin");
 setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argListingId", top.frames['mainFrame'].document.getElementById("dsAdminPropertyListingByListingId-LISTING_ID").value);
 setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argRentalTypeNo", top.frames['mainFrame'].document.getElementById("dsAdminPropertyListingByListingId-RENTAL_TYPE_NO").value);
 executeQuery("dsSelectedAmenitiesByListingIdAdmin"); 


 saveDataSet("dsAdminListingSeasons");
 setQueryParam("dsAdminListingSeasons", "argOwnerId", top.frames['mainFrame'].document.getElementById("dsAdminPropertyListingByListingId-OWNER_ID").value); 
 setQueryParam("dsAdminListingSeasons", "argListingId", top.frames['mainFrame'].document.getElementById("dsAdminPropertyListingByListingId-LISTING_ID").value); 
   
 executeQuery("dsAdminListingSeasons");  
  
  
  //saveAllDataSets();
  /* Submit form on Main page.*/
  mainDataFrameTarget = top.frames['mainFrame'];
  submitForm(mainDataFrameTarget, "fwForm");  
  //submitForm(top.frames['mainFrame'], "fwForm");


}//function doCPBtnSaveOnClick()



/* Owner Profile function for Keys For Rent */
function ownerprofile()
{
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  //setResponseURL("register.jsp?fwModuleName=genKfrent");
  setResponseURL("register_pt1?fwModuleName=genKfrent");
  
  setQueryParam("dsPropertyOwner", "argUserNo", document.getElementById("dsLogon-USER_NO").value);
  
  /* Run the query.*/
  executeQuery("dsPropertyOwner");
  
  /* If the query returns no rows, then append a row.*/
  appendIfNoRow("dsPropertyOwner");
  
  submitForm(window, "fwForm");
}

/* Owner Logon page */
function ownerlogon()
{
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  setResponseURL("Login.jsp?fwModuleName=genKfrent");

  /* Submit form on Main page.*/
  submitForm(window, "fwForm");
}

/**
 * Process a data page onload for list pages.
 */
function doDataListOnLoad(targetFrame)
{
    var tableRow = null;
    var listTable = null; 
  
    submitInProcess = false;
  /* Apply formats to data columns.*/

  /* Submit any related page.*/
  if(submitOnLoadTarget != null)
  {
    submitForm(submitOnLoadTarget, "fwForm");
    submitOnLoadTarget = null;
  }//if(submitOnLoadTarget != null)
  
  
  /* Get control values.*/
  var rowCount = parseInt(targetFrame.document.getElementById("fwRowCount").value);
  var rowNo = parseInt(targetFrame.document.getElementById("fwRowNo").value);
  /* Set the rowNo -1 to get the proper table row no */
  rowNo = rowNo -1;

  /* Set the tableRow.*/
  listTable = targetFrame.document.getElementById("fwListTable");
  if(rowNo > 0)
  {
    tableRow = listTable.rows(rowNo);
    setSelectedRow(tableRow);
  }//if(rowCount > 0)
  else
  {
    tableRow = listTable.rows(0);
    setSelectedRow(tableRow);
  }  

  /* Show any server messages.*/
  /* If there are server messages, stop further processing.*/
  if(showFWMessages(targetFrame)) 
  {
    submitOnLoadTarget = null;
    return;
  }//if(showFWMessages(targetFrame))

  /* Reset the save and modified variables.*/
  if(saveInProcess)
  {
    saveInProcess = false;
    fwModuleModified = false;
  }//if(saveInProcess)

  /* Perform extension processing.*/
  if(typeof(doAfterDataListOnLoad) == "function")
  {
    doAfterDataListOnLoad.apply(targetFrame);
  }//if(typeof(doAfterDataListOnLoad) == "function")

}//function doDataListOnLoad(frameTarget)

/**
 * Process a data page onload for list pages.
 */
function doDataListOnLoadAdmin(targetFrame)
{
    var tableRow = null;
    var listTable = null; 
  listDataFrameTarget = top.frames['leftFrame'];
  mainDataFrameTarget = top.frames['mainFrame'];  
    submitInProcess = false;
  /* Apply formats to data columns.*/

  /* Submit any related page.*/
  if(submitOnLoadTarget != null)
  {
    submitForm(targetFrame, "fwForm");
    submitOnLoadTarget = null;
  }//if(submitOnLoadTarget != null)
  
  
  /* Get control values.*/
  var rowCount = parseInt(targetFrame.document.getElementById("fwRowCount").value);
  var rowNo = parseInt(targetFrame.document.getElementById("fwRowNo").value);
  /* Set the rowNo -1 to get the proper table row no */
  rowNo = rowNo -1;
  var numberOfListings = targetFrame.document.getElementById("fwRowCount").value;
  
  if(numberOfListings == "1")
  {
  	  /* Set the row.*/
  	  setRow("dsPropertyListingByOwnerMU", 1);

//**************************************************************************************************
  var subUnitID = top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-B.SUBUNIT_ID"+1).value;
  var className = top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-B.CLASS"+1).value;
  var listingID = top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value;
  var rentalTypeNo = top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.RENTAL_TYPE_NO"+1).value;


  if (subUnitID < 1) 
  {
    subUnitID = 0;
    /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
    setResponseURL("adminRentalInfo.jsp?extSubUnitId="+subUnitID+"&extListingId="+listingID+"&extClassName="+className); 
    
  }
 else
 {
   subUnitID = top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-B.SUBUNIT_ID"+1);
  /* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
   setResponseURL("adminRentalInfo.jsp?extSubUnitId="+subUnitID+"&extListingId="+listingID+"&extClassName="+className); 
 }  
  /* Set the row.*/
  setRow("dsPropertyListingByOwner", rowNo);

  clearDataSet("dsMultiUnitRoomDetail");
  //setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argOwnerId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.OWNER_ID").value);
  setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argListingId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value);
  setQueryParam("dsSelectedAmenitiesByListingIdAdmin", "argRentalTypeNo", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.RENTAL_TYPE_NO"+1).value);
  setQueryParam("dsAdminPropertyListingByListingId", "argListingId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value);
    setQueryParam("dsListingFeeSetup", "argListingId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value);
    executeQuery("dsListingFeeSetup");
    setQueryParam("dsListingFeeSetupOptional", "argListingId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value);
    executeQuery("dsListingFeeSetupOptional");    
    //NEW
    appendIfNoRow("dsListingFeeSetup");
    appendIfNoRow("dsListingFeeSetupOptional") ;
  executeQuery("dsAdminPropertyListingByListingId");
  executeQuery("dsSelectedAmenitiesByListingIdAdmin");
  /* Set query params */
  //setQueryParam("dsListingRates", "argListingId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value);
  setQueryParam("dsAdminListingSeasons", "argOwnerId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.OWNER_ID").value); 
  setQueryParam("dsAdminListingSeasons", "argListingId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value); 
  setQueryParam("dsMultiUnitRoomDetail", "argListingId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value);
  setQueryParam("dsMultiUnitRoomDetail", "argSubUnitId", subUnitID);
  //alert("subunit id = " + top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-B.SUBUNIT_ID"+1).value);
  setQueryParam("dsRatesDetail", "argListingId", top.frames['leftFrame'].document.getElementById("dsPropertyListingByOwnerMU-A.LISTING_ID"+1).value);
  setQueryParam("dsRatesDetail", "argSubUnitId", subUnitID);
  setQueryParam("dsListingAvailabilityCommon", "argListingId", listingID);



  /* Run the dataset queries.*/
  executeQuery("dsCalendarMonths");  
  executeQuery("dsAdminListingSeasons");
  executeQuery("dsMultiUnitRoomDetail"); 
  executeQuery("dsRatesDetail");
  executeQuery("dsListingAvailabilityCommon");  

  
  /* Set the selected row */
  setAdminSelectedRow(tableRow);
  selectedRow = 1;
  
  /* Submit form on Main page.*/
  submitForm(mainDataFrameTarget, "fwForm");
  

 //submitForm(tabsFrameTarget, "fwForm");

  top.frames['tabFrame'].document.fwForm.visiLayer.style.visibility="visible";
  top.frames['tabFrame'].document.fwForm.layer2.style.visibility="visible";
  top.frames['tabFrame'].document.fwForm.layer8.style.visibility="visible";
  top.frames['tabFrame'].document.fwForm.layer33.style.visibility="visible";
  top.frames['tabFrame'].document.fwForm.layer88.style.visibility="visible";
  top.frames['tabFrame'].document.fwForm.layer3.style.visibility="hidden";
  top.frames['tabFrame'].document.fwForm.layer9.style.visibility="hidden";
  top.frames['tabFrame'].document.fwForm.layer22.style.visibility="hidden";
  top.frames['tabFrame'].document.fwForm.layer99.style.visibility="hidden";
if (rentalTypeNo != 1){
   top.frames['tabFrame'].document.fwForm.layer33.style.visibility="hidden";
   top.frames['tabFrame'].document.fwForm.layer88.style.visibility="hidden";
   top.frames['tabFrame'].document.fwForm.layer22.style.visibility="hidden";
   top.frames['tabFrame'].document.fwForm.layer99.style.visibility="hidden"; 

}             
  
  top.frames['bottomFrame'].document.fwForm.visiLayer.style.visibility="visible"; 
//**************************************************************************************************
    	   /* Set the selected row */
  	   setAdminSelectedRow(tableRow);
  }

  /* Set the tableRow.*/
  listTable = targetFrame.document.getElementById("fwListTable");
  oldTableRow = tableRow;
  if(rowNo > 0)
  {
    tableRow = listTable.rows(rowNo);
    setAdminSelectedRow(tableRow);
  }//if(rowCount > 0)
  else
  {
    tableRow = listTable.rows(0);
    setAdminSelectedRow(tableRow);
  }  
 selectedRow = 1;
  /* Show any server messages.*/
  /* If there are server messages, stop further processing.*/
  if(showFWMessages(targetFrame))
  {
    submitOnLoadTarget = null;
    return;
  }//if(showFWMessages(targetFrame))

  /* Reset the save and modified variables.*/
  if(saveInProcess)
  {
    saveInProcess = false;
    fwModuleModified = false;
  }//if(saveInProcess)

  /* Perform extension processing.*/
  if(typeof(doAfterDataListOnLoad) == "function")
  {
    doAfterDataListOnLoad.apply(targetFrame);
  }//if(typeof(doAfterDataListOnLoad) == "function")

}//function doDataListOnLoad(frameTarget)



/**
 * Process a data page onload for list pages.
 */
function doDataListOnLoadBrowse(targetFrame)
{
    var tableRow = null;
    var listTable = null; 
 
    submitInProcess = false;
  /* Apply formats to data columns.*/

  /* Submit any related page.*/
  if(submitOnLoadTarget != null)
  {
    submitForm(targetFrame, "fwForm");
    submitOnLoadTarget = null;
  }//if(submitOnLoadTarget != null)
  
  
  /* Get control values.*/
  var rowCount = parseInt(targetFrame.document.getElementById("fwRowCount").value);
  var rowNo = parseInt(targetFrame.document.getElementById("fwRowNo").value);

  var numberOfListings = targetFrame.document.getElementById("fwRowCount").value;
   /* Set the selected row */
  setSelectedRow(tableRow);

  /* Set the tableRow.*/
  listTable = targetFrame.document.getElementById("fwListTable");
  if(rowNo > 0)
  {
    tableRow = listTable.rows(rowNo);
    setSelectedRow(tableRow);
  }//if(rowCount > 0)
  else
  {
    tableRow = listTable.rows(0);
    setSelectedRow(tableRow);
  }  
 selectedRow = 1;
  /* Show any server messages.*/
  /* If there are server messages, stop further processing.*/
  if(showFWMessages(targetFrame))
  {
    submitOnLoadTarget = null;
    return;
  }//if(showFWMessages(targetFrame))

  /* Reset the save and modified variables.*/
  if(saveInProcess)
  {
    saveInProcess = false;
    fwModuleModified = false;
  }//if(saveInProcess)

  /* Perform extension processing.*/
  if(typeof(doAfterDataListOnLoad) == "function")
  {
    doAfterDataListOnLoad.apply(targetFrame);
  }//if(typeof(doAfterDataListOnLoad) == "function")

}  

function setSelectedRow(tableRow, rowCount)
{
    xCount = 0;
    /* Reset the class of the current selectedRow.*/
    if(selectedRow != null)
    {
      selectedRow.className = "listData";
    }//if(selectedRow != null)

    /* Select the clicked row.*/
    if(tableRow != null)
    {
   
      selectedRow = tableRow;
      selectedRow.className = "listDataSelected";
    }//if(tableRow != null)
 }
function setAdminSelectedRow(tableRow, rowCount)
{
    xCount = 0;
    /* Reset the class of the current selectedRow.*/
    //alert("selected row = " + selectedRow);
    if(selectedRow != null)
    {
      selectedRow.className = "listData";
    }//if(selectedRow != null)

    /* Select the clicked row.*/
    if(tableRow != null)
    {
  //reset the rows first
  listTable = top.frames['leftFrame'].document.getElementById("fwListTable");
  while(xCount < rowCount)
  {
    listTable.rows[xCount].className = "listData";
    xCount++;
  }
  //done    
      selectedRow = tableRow;
      selectedRow.className = "listDataSelected";
    }//if(tableRow != null)
 } 
function ownerItems()
{
    var argOwnerId = document.getElementById("dsAdminPropertyListingByListingId-OWNER_ID").value;
    var argListingId = document.getElementById("dsAdminPropertyListingByListingId-LISTING_ID").value;
    setQueryParam("dsListingItems", "argOwnerId", argOwnerId);
    setQueryParam("dsListingItems", "argListingId", argListingId);
    setQueryParam("dsOwnerItem", "argOwnerId", argOwnerId);
    setQueryParam("dsOwnerClasses", "argOwnerId", argOwnerId);
    setQueryParam("dsQbVendor", "argOwnerId", argOwnerId);
    setQueryParam("dsListingFeeSetup", "argListingId", argListingId);
    setQueryParam("dsListingFeeSetupOptional", "argListingId", argListingId);
    setQueryParam("dsOwnerDepositAcct", "argOwnerId", argOwnerId);
	  
    /* Run the query.*/
    executeQuery("dsListingItems");
    executeQuery("dsOwnerItem");
    executeQuery("dsOwnerClasses");
    executeQuery("dsQbVendor");
    executeQuery("dsListingFeeSetup");
    executeQuery("dsListingFeeSetupOptional");
    executeQuery("dsOwnerDepositAcct");
    appendIfNoRow("dsListingItems");
    setResponseURL("kfrOwnerItems.jsp");
    submitForm(window, "fwForm");
}
function doOwnerLogon(argUserName, argPassword)
{
  	/* Set Response URL to List. This is the page that will be returned from the server after the submit.*/
  	//setResponseURL("Welcome.jsp?extFilter=");

  	setQueryParam("dsLogon", "argUserName", argUserName);
  	setQueryParam("dsLogon", "argPassword", argPassword);
  	setQueryParam("dsOwnerListingCount", "argUserName", argUserName);
  	setQueryParam("dsOwnerListingCount", "argPassword", argPassword);
  	setQueryParam("dsHouseKeepingLogin", "argUserName", argUserName);
  	setQueryParam("dsHouseKeepingLogin", "argPassword", argPassword);
  	setQueryParam("dsOwnerListingCountMU", "argUserName", argUserName);
  	setQueryParam("dsOwnerListingCountMU", "argPassword", argPassword);
  	setQueryParam("dsPropertyListingByOwnerMUuserid", "argUserId",argUserName);
        setQueryParam("dsPropertyListingByOwnerMUuserid", "argPassword",argPassword);
  	setQueryParam("dsPropertyListingByOwnerMUuserid", "argBed1", 0);
        setQueryParam("dsPropertyListingByOwnerMUuserid", "argBed2", 20);
  	/* Save the buffer.*/
  	executeQuery("dsLogon");
  	executeQuery("dsHouseKeepingLogin");
  	executeQuery("dsOwnerListingCount");
  	executeQuery("dsOwnerListingCountMU");
  	executeQuery("dsPropertyListingByOwnerMUuserid");
        submitForm(window, "fwForm");
        window.open("Welcome.jsp");
}
	
function doSaveOwnerListingItems()
{
  alert("Your change have been updated.");
  saveDataSet("dsListingItems");
  submitForm(window, "fwForm");
}
	
function doExportQBInvoice()
{
      var argOwnerId = document.getElementById("extOwnerId").value;
      var argCalendarFrom = document.getElementById("extCalendarFrom").value;
      var argCalendarTo = document.getElementById("extCalendarTo").value;
      var argFromDate = argCalendarFrom.substring(0,2) + "-" + argCalendarFrom.substring(3,5) + "-" + argCalendarFrom.substring(6,10);
      var argToDate = argCalendarTo.substring(0,2) + "-" + argCalendarTo.substring(3,5) + "-" + argCalendarTo.substring(6,10);
      var argCurrentDate = new Date();
      var argSystemDate = argCurrentDate.getFullYear() + "-" + (argCurrentDate.getMonth() + 1) + "-" + argCurrentDate.getDate() + "_" + argCurrentDate.getHours() + argCurrentDate.getMinutes() + argCurrentDate.getSeconds();
      var argFileName = "owneracct/" + argOwnerId + "invoice_" + argSystemDate + ".IIF";
      setResponseURL("kfrImportQuickBooksInvoice.jsp?extGetExportFileFlag=Y&extFileName=" + argFileName);
      var segment = 'MultiUnitAdmin.exportQBInvoices("' + argOwnerId + '", "' + argFromDate + '", "' + argToDate + '", "' + argSystemDate + '")';
      buildScriptSegment(segment);
      //setResponseURL("Welcome.jsp");
      /* Submit the main form.*/
      submitForm(window, "fwForm");
}

function doExportQBInvoiceByArrivalDate()
{
      var argOwnerId = document.getElementById("extOwnerId").value;
      var argCalendarFrom = document.getElementById("extCalendarFrom").value;
      var argCalendarTo = document.getElementById("extCalendarTo").value;
      var argFromDate = argCalendarFrom.substring(6,10) + "-" + argCalendarFrom.substring(0,2) + "-" + argCalendarFrom.substring(3,5);
      var argToDate = argCalendarTo.substring(6,10) + "-" + argCalendarTo.substring(0,2) + "-" + argCalendarTo.substring(3,5);
      var argCurrentDate = new Date();
      var argSystemDate = argCurrentDate.getFullYear() + "-" + (argCurrentDate.getMonth() + 1) + "-" + argCurrentDate.getDate() + "_" + argCurrentDate.getHours() + argCurrentDate.getMinutes() + argCurrentDate.getSeconds();
      var argFileName = "owneracct/" + argOwnerId + "invoice_" + argSystemDate + ".IIF";
      setResponseURL("kfrExportQuickBooksInvoiceByArrivalDate.jsp");
      var segment = 'MultiUnitAdmin.exportQBInvoicesByArrivalDate("' + argOwnerId + '", "' + argFromDate + '", "' + argToDate + '", "' + argSystemDate + '")';
      buildScriptSegment(segment);
      //setResponseURL("Welcome.jsp");
      /* Submit the main form.*/
      submitForm(window, "fwForm");
      
      window.open(argFileName,"replace");
}

function doExportQBDepositsPayments()
{
      var argOwnerId = document.getElementById("extOwnerId").value;
      var argCalendarFrom = document.getElementById("extCalendarFrom").value;
      var argCalendarTo = document.getElementById("extCalendarTo").value;
      var argFromDate = argCalendarFrom.substring(6,10) + "-" + argCalendarFrom.substring(0,2) + "-" + argCalendarFrom.substring(3,5);
      var argToDate = argCalendarTo.substring(6,10) + "-" + argCalendarTo.substring(0,2) + "-" + argCalendarTo.substring(3,5);
      var argCurrentDate = new Date();
      var argSystemDate = argCurrentDate.getFullYear() + "-" + (argCurrentDate.getMonth() + 1) + "-" + argCurrentDate.getDate() + "_" + argCurrentDate.getHours() + argCurrentDate.getMinutes() + argCurrentDate.getSeconds();
      var argFileName = "owneracct/" + argOwnerId + "payment_" + argSystemDate + ".IIF";
      setResponseURL("kfrExportQuickBooksDepositsPayments.jsp?extGetExportFileFlag=Y&extFileName=" + argFileName);
      
      setQueryParam("dsPreferences", "argOwnerId", argOwnerId);  
  	  executeQuery("dsPreferences");
      
      var segment = 'MultiUnitAdmin.exportQbDepositPayments("' + argOwnerId + '", "' + argFromDate + '", "' + argToDate + '", "' + argSystemDate + '")';
      buildScriptSegment(segment);
      
      /* Submit the main form.*/
      submitForm(window, "fwForm");      
}

function movePhoto()
{
  var argOwnerId = document.getElementById("extownId").value;
  var argMoveFrom = document.getElementById("extMoveFrom").value;
  var argMoveTo = document.getElementById("extMoveTo").value;
  
  var segment = 'MultiUnitAdmin.movePicture('+argMoveFrom+', '+argMoveTo+', "'+argOwnerId+'")';
  buildScriptSegment(segment);
  
  //saveDataSet("dsPropertyImages");
  
  /* Submit the main form.*/
  submitForm(window, "fwForm");
}
function loadContactActivities(argOwnerId)
{
      setQueryParam("dsContactActivityWithNotes", "argOwnerId", argOwnerId);  
      executeQuery("dsContactActivityWithNotes");
      setResponseURL("pendingContactActions.jsp");      
      /* Submit the main form.*/
      submitForm(window, "fwForm");
}
function fixCalendar(ownerId, listingId, gfromDateMinusOne, gtoDatePlusOne, gdateFrom, gdateTo, gfromDateMinusOneMMDDYYYY, gtoDateMinusOneMMDDYYYY, gtoDatePlusOneMMDDYYYY)
{
    var subUnitId = 0;
    var roomId = 0;
    var rentalCharge = 0;
    gfromDateMinusOne = "'"+gfromDateMinusOne+"'";
    gtoDatePlusOne = "'"+gtoDatePlusOne+"'";
    gdateFrom = "'"+gdateFrom+"'";
    gdateTo = "'"+gdateTo+"'";
    gfromDateMinusOneMMDDYYYY = "'"+gfromDateMinusOneMMDDYYYY+"'";
    gtoDateMinusOneMMDDYYYY = "'"+gtoDateMinusOneMMDDYYYY+"'";
    gtoDatePlusOneMMDDYYYY = "'"+gtoDatePlusOneMMDDYYYY+"'";
    var segment14b = 'ProcessReservations.resetDateRangesBypass("'+ownerId+'","'+listingId+'","'+subUnitId+'","'+roomId+'","'+rentalCharge+'","'+gfromDateMinusOne+'","'+gtoDatePlusOne+'","'+gdateFrom+'","'+gdateTo+'","'+gfromDateMinusOneMMDDYYYY+'","'+gtoDateMinusOneMMDDYYYY+'","'+gtoDatePlusOneMMDDYYYY+'")';
    buildScriptSegment(segment14b);
    submitForm(window, "fwForm");
}
function doAddMerch()
{
  appendIfNoRow("dsOwnerCCMerch");
  /* Submit the main form.*/
  submitForm(window, "fwForm");
}

