function showUserInfo(userID) {
 window.open("/showShortUserInfo.do?id="+userID, "UserInfo", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=200");
 return false;
}
function createListingContractManual() {
   window.location = "/createListingContractManually.do";
}
function cancelCreateListingContractManually() {
   window.location = "/cancelCreationListingContractManually.do";
}
function showListingContract(contractID) {
   window.location = "/showListingContract.do?cid="+contractID;
}
function deleteListingContract(contractID){
    if (confirm("Are you sure you want to delete the information?"))
		window.location = "/deleteListingContract.do?cid="+contractID;
}
function showMyLCPage(page){
   window.location = "/showListingContracts.do?userPage="+page;
}
function showAssignedLCPage(page){
   window.location = "/showAssignedListingContracts.do?assPage="+page;
}
function showPropertyInfo(contractID){
   window.location = "/showPropertyInfoForListingContract.do?cid="+contractID;
}
function showSECOSInfo(contractID){
   window.location = "/showListingContractSECOS.do?cid="+contractID;
}
function editSECOS(contractID){
  window.location="/editListingContractSECOS.do?cid="+contractID;
}
function showContractInfo(contractID){
   window.location = "/showListingContractAdditionalInfo.do?cid="+contractID;
}
function editInfo(contractID){
  window.location="/editListingContractAdditionalInfo.do";
}
function showContractPropertyDescription(contractID){
   window.location = "/showListingContractPropertyDescription.do?cid="+contractID;
}
function editContractPropertyDescription(){
   window.location = "/editListingContractPropertyDescription.do";
}
function showContractSignatures(contractID){
   window.location = "/showListingContractSignatures.do?cid="+contractID;
}
function showLCPDF(contractID){
   window.open("/showListingContractPDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showLCSECOSPDF(contractID){
   window.open("/showListingContractSECOSPDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showLCShortSaleAddendumPDF(contractID){
   window.open("/showListingContractShortSaleAddendumPDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showLCRequestForCondominiumDiscloseurePDF(contractID){
   window.open("/showListingContractRequestForCondominiumDisclosurePDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showLCRequestForHOADiscloseurePDF(contractID){
   window.open("/showListingContractRequestForHOADisclosurePDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showResidentialPropertyDisclaimerStatementPDF(contractID){
   window.open("/showListingContractResidentialPropertyDisclaimerStatementPDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showResidentialPropertyDisclosureStatementPDF(contractID){
   window.open("/showListingContractResidentialPropertyDisclosureStatementPDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showSellersDisclosureStatementPDF(contractID){
   window.open("/showListingContractSellersDisclosurePDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showDisclosureOfDualRepresentationPDF(contractID){
   window.open("/showListingContractDisclosureOfDualRepresentationPDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showDisclosureOfLeadBasedPaintPDF(contractID){
   window.open("/showDisclosureOfLeadBasedPaintPDF.do?cid="+contractID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showErtsPresentation(){
   window.open("/showErtsPresentation.do","PPT","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");   
}
function showErtsContractGeneration(){
   window.open("/showErtsContractGeneration.do","PPT","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function uploadDocuments(contractID){
   window.location="/prepareUploadForListingContract.do?cid="+contractID;
}
function deleteDocument(contractID, documentID){
    if (confirm("Are you sure you want to delete the information?"))
       window.location="/deleteAdditionalDocumentForListingContract.do?cid="+contractID+"&did="+documentID;
}
function createAmendment(contractID){
   window.location="/createListingContractAddendum.do?cid="+contractID;
}
function deleteAmendment(amendmentID){
    if (confirm("Are you sure you want to delete the information?"))
         window.location="/deleteListingContractAddendum.do?aid="+amendmentID;
}
function showAmendment(amendmentID){
  window.location="/showListingContractAddendum.do?aid="+amendmentID;
}
function showAmendmentPDF(amendmentID){
   window.open("/showListingContractAmendmentPDF.do?aid="+amendmentID,"PDF","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no");
}
function showDocument(documentID){
   window.open("/viewAdditionalDocument.do?did="+documentID,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no");
}
function editListingContractOwners(contractID){
   window.location = "/editListingContractOwners.do?cid="+contractID;
}
function deleteOwner(userID) {
  if (confirm("Delete Owner?"))
    window.location = "/deleteListingContractOwner.do?uid="+userID;
}
function deleteUnregisteredOwner(userID) {
  if (confirm("Delete Owner?"))
    window.location = "/deleteListingContractUnregisteredOwner.do?uid="+userID;
}
function showUnregisteredOwner(userID,contractID) {
    window.location = "/showListingContractUnregisteredOwner.do?uid="+userID+"&cid="+contractID;
}
function editUnregisteredOwner(userID) {
    window.location = "/editListingContractUnregisteredOwner.do?uid="+userID;
}
function editListingContractAgents(contractID){
   window.location = "/editListingContractAgents.do?cid="+contractID;
}
function signListingContractAmendment(){
  window.location = "/signListingContractAmendment.do";
}
function signListingContract(){
  window.location = "/signListingContract.do";
}
function changeOwner()
{
 var deleteBox = document.ListingContractForm.deleteOwner;
 var addBox    = document.ListingContractForm.addOwner;

 if(isDataItem(addBox.options[addBox.selectedIndex].value)){
  deleteBox.options[deleteBox.length]= new Option (addBox.options[addBox.selectedIndex].text, addBox.options[addBox.selectedIndex].value);

      addBox.options[addBox.selectedIndex]=null;

      var szText = "";
      for (i=0; i< deleteBox.length; i++)
      {
       if(isDataItem(deleteBox.options[i].value)){
        szText=szText + deleteBox.options[i].value;
        if (i < deleteBox.length-1){
          szText = szText +",";
        }
       }
      }
      organizeBox(deleteBox);
      organizeBox(addBox);
      document.ListingContractForm.txtOwners.value=szText;
    }
  }

function changeAgent()
{
 var deleteBox = document.ListingContractForm.deleteAgent;
 var addBox    = document.ListingContractForm.addAgent;

 if(isDataItem(addBox.options[addBox.selectedIndex].value) && confirm("Reassign Agent?")){
  if (isDataItem(deleteBox.options[0].value)){

      addBox.options[addBox.length]=
        new Option (deleteBox.options[0].text,
                    deleteBox.options[0].value);

  }
      deleteBox.options[deleteBox.length]=
        new Option (addBox.options[addBox.selectedIndex].text,
                    addBox.options[addBox.selectedIndex].value);
      deleteBox.options[0]=null;
      addBox.options[addBox.selectedIndex]=null;
      var szText = "";
      for (i=0; i< deleteBox.length; i++){
       if (isDataItem(deleteBox.options[i].value)){
          szText=deleteBox.options[i].value;
       }
      }
      organizeBox(deleteBox);
      organizeBox(addBox);
      document.ListingContractForm.txtAgent.value=szText;
 }

}
function organizeBox(box){
   var tmpvalue = "";
   var tmptext  = "";
   for(i=0; i < box.length; i++){
     if(!isDataItem(box.options[i].value) && (i < box.length-1)){
       tmpvalue = box.options[i].value;
       tmptext  = box.options[i].text;
       box.options[i].value = box.options[i+1].value;
       box.options[i].text  = box.options[i+1].text;
       box.options[i+1].value = tmpvalue;
       box.options[i+1].text  = tmptext;
     }
   }
}
function isDataItem(optionValue) {
	if (optionValue.indexOf("-100") == 0 || optionValue.indexOf("-1") == 0)
		return false;
	return true;
}

function showListingContractsPage(startsWith, page){
  location = "/searchAssignedListingContracts.do?listPage="+page+"&startsWith="+startsWith;
}


