<?php 

require_once "MU_database2024.php";
$dbObject = new MySQLDB();  //The database connection
$dbObject->logger->logDebug("home_v Info: ".print_r($_REQUEST,true));

// get the people related to this GUID
$MessageID = $_GET['MessageID'];
$Method = $_GET['method'];
$UnverifiedMonthCount = 0;

	//$q0 = "select count(*) from email_reminder ER where MessageGUID = ?";
	$q0 = "select count(*) from lease_payment where ReminderGUID = ?";

	$PrelimQuery  = $dbObject->connection->prepare($q0);
	$PrelimQuery->bindValue(1, $MessageID);
	$PrelimQuery->execute();
	$GUIDCount = $PrelimQuery->fetchColumn();
	
	if ($GUIDCount > 0)
	{
	 
		$q = " select distinct L.LeaseID, LP.PaymentID, concat(cap_first(T.FirstName),' ', cap_first(T.LastName)) TenantName, T.UserID, PM_Name(L.PropertyManagerID) LLName,  ";
		$q = $q." GetMonthNameFromID(LP.MonthID) MonthName, concat(GetMonthNameFromID(LP.MonthID),' ',GetYearFromID(LP.MonthID)) RentMonth, ";  
		$q = $q." IsDate(LP.VerifiedDate) IsVerified, LP.VerifiedDate, L.USPSAddress1, L.USPSAddress2, PM.PropertyManagerID, LP.Amount   ";
		$q = $q." from lease_payment LP inner join lease L on L.LeaseID = LP.LeaseID   ";
		$q = $q." inner join propertymanager PM on PM.PropertyManagerID = L.PropertyManagerID  ";
		$q = $q." inner join tenant T on T.UserID = L.TenantID   ";
		$q = $q." where L.PropertyManagerID = (select distinct L.PropertyManagerID from lease L inner join lease_payment LP on LP.LeaseID = L.LeaseID  where LP.ReminderGUID = ? ) ";
		$q = $q." order by L.LeaseID, LP.MonthID  ";
		
		$MonthlyUpdateInfoQuery = $dbObject->connection->prepare($q);
		  $MonthlyUpdateInfoQuery->bindValue(1, $MessageID);
		  $MonthlyUpdateInfoQuery->execute();
		  $MonthlyUpdateData = $MonthlyUpdateInfoQuery->fetchAll(PDO::FETCH_BOTH);
		  
		  if (!isset($MonthlyUpdateData))
		  {
			//  need to figure out how to handle a no-found row.  Bounce to a semi-404.
			print "no data found.";
		  }
		  else 
		  {
			
			 // go through these and see if anything needs updating.  If not, just show a simple "you're good!" page with a link to revise.
			 $TenantCount = 0;
			 $LastTenantName = "";
			 $LastMonthID = 0;
			 $FirstMonthName = "";
			 foreach ($MonthlyUpdateData as $MU_Row)
			 {
				 $LLName = $MU_Row["LLName"];
				 $LLID = $MU_Row["PropertyManagerID"];
				 if ($MU_Row["TenantName"] != $LastTenantName)
				 {
					 if ($TenantCount == 0)
						 $TenantName = $MU_Row["TenantName"];
					 else
						 $TenantName = $TenantName." and ".$MU_Row["TenantName"];
					 $TenantCount++;
					 $LastTenantName = $MU_Row["TenantName"];
					 $MonthName = $MU_Row["ThisRentMonth"];
					 $RentAmount = $MU_Row["Amount"];
				 }
				 if ($MU_Row["IsVerified"] != 1)
				 {
					 if ($FirstMonthName == "")
						 $FirstMonthName = $MU_Row["RentMonth"];
					 $UnverifiedMonthCount++;
					 //print "Unverified Mohths: ".$UnverifiedMonthCount;
				 }
			 }
		  }
	} else		
	{
		// ok, we may need to bounce somewhere else 
			header('Location: not_home_v.php');
			
	}
?>
<!DOCTYPE html>


<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	
	<link rel="icon" type="image/x-icon" href="//rentalkharma.com/formsite2015/images/favicon.ico">
        <!-- <link href="../css/main2.css" rel="stylesheet" type="text/css" /> --> <!-- Should be included in every page. Carries CSS of header-footer -->
        
    <title>Rental Kharma Monthly Updates</title>
    
    <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

	<!-- Optional theme -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

	<!-- Latest compiled and minified JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

	<link rel="stylesheet" type="text/css" href="./css/main.css">
	
    <link rel="stylesheet" href="./pikaday/css/pikaday.css">
    <link rel="stylesheet" href="./pikaday/css/site.css">
	
 <html  lang="en-US" dir="ltr" xmlns="http://www.w3.org/1999/xhtml" webdriver="true"> 
</head>
<?php 

    
	
?>


</head>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js"></script>
<script src="./pikaday/pikaday.js"></script>

<div class="header-image">
<a href="https://www.rentalkharma.com/"><img src="./images/Rental-Kharma-Logo1.png"></a>
<div class="small_banner"></div>
  
</div>

<input type="hidden" id="PropertyManagerID" value="" />
<input type="hidden" id="LeaseIDs" value="" />
<input type="hidden" id="PaymentIDs" value="" />
<input type="hidden" id="MessageID" value="<?php echo $MessageID ?>" />
<div class="tabcontainer" id= "tabcontainer">
<h1>Monthly Rent Update for <?php print $LLName; ?></h1>
  
	<div class="topnav" id="myTopnav">
		<button class="tablinks" onclick="showBlock(event, 'Tenants')"   id="defaultOpen" >My Tenants</button>
		<!-- <button class="tablinks" onclick="showBlock(event, 'Preferences')">Preferences</button> -->
		<button class="tablinks" onclick="showBlock(event, 'Details')"   id="alternateOpen" >Rent Details</button>
		<button class="tablinks" onclick="showBlock(event, 'Contact')">Contact RK</button>
		<button class="tablinks" onclick="showBlock(event, 'About')">What we do</button>
		<button class="tablinksicon"   onclick="doHamburger()">&#9776;</a>
	</div> 
	 
		
			<div id="Tenants" class="tabcontent">
			  
			  <h3>Hello and thanks for taking a quick moment to report your renters' payment status this month. We're sure you know how much they appreciate your helping them establish good credit with their on time rent payments.</h3>
			  <br>
			  <?php 
				  if ($TenantCount == 1) { 
			          if ($UnverifiedMonthCount == 1) {
					      print "<h3>Has ".$TenantName."  paid his/her rent of $".$RentAmount." for ".$MonthName." on time, or less than 30 days late?</h3>";
				      } else {
					      print "<h3>Has ".$TenantName."  paid his/her rent of $".$RentAmount." for the months from ".$FirstMonthName." to ".$MonthName." on time, or less than 30 days late?</h3>";
			          }
			      } else { 
			          if ($UnverifiedMonthCount == 1) {
					      print "<h3>Have ".$TenantName."  paid their rents of $".$RentAmount." for ".$MonthName." on time, or less than 30 days late?</h3>";
				      } else {
					      print "<h3>Has ".$TenantName."  paid their rent for the months from ".$FirstMonthName." to ".$MonthName." on time, or less than 30 days late?</h3>";
			          }
				  }
			   ?>
			  
			  <div class="answerbox">
				<button class="rentbutton" id="OnTimeButton" onclick="MUButtonClick('OnTimeButton')" style="background-color:Green">Yes, on time</button>
				<div id="OnTimeConfirm" style="display:none;" >
				  <button class="confirmbutton" onclick="ConfirmMUClick('OnTime')" id="ConfirmOnTimeButton" style="background-color:Green">Confirm</button>
				</div>
			  </div>
			  <div class="answerbox">
				<button class="rentbutton" onclick="MUButtonClick('LateButton')" id="LateButton" style="background-color:Orange">Paid, but late</button>
				<div id="LateConfirm" style="display:none;" >
				  <div class="followupQuestion"><h3>OK. Now, how late?</h3> <select id="Lateness">
					  <option value="30">Under 30 days late</option>
					  <option value="31">31-60 days late</option>
					  <option value="61">61-90 days late</option>
					  <option value="91">91-120 days late</option>
					  <option value="121">More than 120 days late</option>
					</select> 
					</div>
					<div style="display:inline-block" >
					  <button class="confirmbutton" onclick="ConfirmMUClick('Late')" style="background-color:Orange">Confirm</button>
					</div>
				</div>
			  </div>
			  
			  <div class="answerbox">
				<button class="rentbutton" onclick="MUButtonClick('MoveOutButton')" id="MoveOutButton" style="background-color:Orange">Moved Out</button>
				<div id="MoveOutConfirm" style="display:none;" >
				  <div class="followupQuestion"><h3>When did they move out?</h3> 
                  <input type="text" id="MoveOutDate">
                  </div>
                  <div class="followupQuestion"><h3>Was their rent paid up?</h3> 
                  <select id="LeaseStatusCode">
					  <option value="0">Yes</option>
					  <option value="11">They owe rent</option>
					  <option value="12">Transferred to collections</option>
					  <option value="99">Other</option>
					  
					</select> 
					
					</div>
					<div class="followupQuestion"><h3>Add any extra details if needed:</h3> 
						<textarea rows="4" cols="35" id="MoveOutDetails"> </textarea>
					</div>
					<div style="display:inline-block" >
					  <button class="confirmbutton" onclick="ConfirmMUClick('MoveOut')" style="background-color:Orange">Confirm</button>
					</div>
				</div>
			  </div>
			  <div class="answerbox">
				<button class="rentbutton" onclick="MUButtonClick('ComplicatedButton')" id="ComplicatedButton" style="background-color:Orange">It's complicated</button>
				<div id="ComplicatedConfirm" style="display:none;" >
				  <div class="followupQuestion"><h3>OK, what's the situation?</h3> 
                  <textarea rows="4" cols="35" id="ComplicatedAnswer"> </textarea>
                  </div>
                  
					<div style="display:inline-block" >
					  <button class="confirmbutton" onclick="ConfirmMUClick('Complicated')" style="background-color:Orange">Confirm</button>
					</div>
				</div>
			  </div>
			  <div class="answerbox">
				<button class="rentbutton" onclick="MUButtonClick('NotPaidButton')" id="NotPaidButton" style="background-color:Red">Has Not Paid</button>
				<div id="NotPaidConfirm" style="display:none;" >
				  <button class="confirmbutton" onclick="ConfirmMUClick('NotPaid')" id="ConfirmNotPaidButton" style="background-color:Red">Confirm</button>
				</div>
			  </div>
			</div>

			
			<div id="About" class="tabcontent">
			  <h2>What Rental Kharma does</h2>
			  <br>
			    <h3>Your tenant(s), <?php echo $TenantName ?>, has hired us to maintain a record of their rent payments to you.  We then report their rental payment history, good or bad, to Trans Union and Equifax 
				and it becomes a part of their credit report.  We use this to help them improve their credit score!  <a href="https://www.rentalkharma.com">Learn more</a></h3>
			</div>

		
			<div id="Details" class="tabcontent">
			  
			    <h2>Rent Details for <?php print $TenantName ?></h2>
				<div class="answerbox">
				  <?php 
				  $LastTenantName = "";
				  $TenantCount = 0;
				  if(is_array($MonthlyUpdateData))
				  {
					foreach ($MonthlyUpdateData as $MU_Row)
					 {
						 if ($MU_Row["TenantName"] != $LastTenantName)
						 {
							$LastTenantName = $MU_Row["TenantName"];
							if ($TenantCount > 0)
							  print "</ul>\r\n";
							$TenantCount++; 
							print "<h3> Payment History for ".$TenantName." at ".$MU_Row["USPSAddress1"]."</h3>\r\n";
							print "<ul>\r\n";
						 }
						if ($MU_Row["IsVerified"] == 1)
							print "<li>&bull;&nbsp;".$MU_Row["RentMonth"]." confirmed on ".$MU_Row["VerifiedDate"]."</li>\r\n";
						else 
							print "<li>&bull;&nbsp;".$MU_Row["RentMonth"]." <b>NOT confirmed</b>.</li>\r\n";
					 } 
					 print "<ul>\r\n";
				  }	 
					 ?>
			    </div>
			  </div>

		
		<div id="Contact" class="tabcontent">
		  <h3>Contact Rental Kharma Support</h3>
		  <a name="form1612304568" id="formAnchor1612304568"></a>
			<script type="text/javascript" src="https://fs30.formsite.com/include/form/embedManager.js?1612304568"></script>
			<script type="text/javascript">
			EmbedManager.embed({
				key: "https://fs30.formsite.com/res/showFormEmbed?EParam=iGs2D6QRb6KSoHptnLU28gfFJIaUFMUjngbtbHWZMa4%3D&1612304568",
				width: "100%",
				prePopulate: {"3":"<?php print $LLName ?>","8":"<?php print $MessageID ?>","9":"<?php print $LLID ?>"},
				mobileResponsive: true
			});
			</script>
		</div>
</div>
	
</div>
<div class="spinner-container" id="waitSpinner" style="display:none;" >
        <div class="spinner-text" id="spinnerText"><span id="waitMessageText">Submitting...<span><div class="spinner-text blinking">Don't close this window!</div></div> 
            <div id="spinnerInnerContainer" class="spinner-innerContainer">
            
                <span class="spinner-double-section-far" style="display:inline-block; vertical-align:middle; text-align: center"></span>
            </div>
        </div>

<script type="text/javascript" >

// Get the element with id="defaultOpen" and click on it
<?php if ($UnverifiedMonthCount == 0) {  	?>
	document.getElementById("alternateOpen").click();
<?php }  else {  ?>
	document.getElementById("defaultOpen").click();
<?php } ?>

function clearAllButtons(inputButton)
{
		
	OnTimeButton = document.getElementById("OnTimeButton");
	NotPaidButton = document.getElementById("NotPaidButton");
	LateButton = document.getElementById("LateButton");
	ComplicatedButton = document.getElementById("ComplicatedButton");
	MoveOutButton = document.getElementById("MoveOutButton");
	if (inputButton != OnTimeButton)
	{
		document.getElementById("OnTimeConfirm").style.display="none";
		document.getElementById("OnTimeConfirm").parentNode.style.border = "none";
		OnTimeButton.style.color="white";
		OnTimeButton.style.backgroundColor = "green";
	}
	if (inputButton != NotPaidButton)
	{
		document.getElementById("NotPaidConfirm").style.display="none";
		document.getElementById("NotPaidConfirm").parentNode.style.border = "none";
		NotPaidButton.style.color="white";
		NotPaidButton.style.backgroundColor="red";
	}
	if (inputButton != LateButton)
	{
		document.getElementById("LateConfirm").style.display="none";
		document.getElementById("LateConfirm").parentNode.style.border = "none";
		LateButton.style.color="white";
		LateButton.style.backgroundColor="orange";
	}
	if (inputButton != ComplicatedButton)
	{
		document.getElementById("ComplicatedConfirm").style.display="none";
		document.getElementById("ComplicatedConfirm").parentNode.style.border = "none";
		ComplicatedButton.style.color="white";
		ComplicatedButton.style.backgroundColor="orange";
	}
	if (inputButton != MoveOutButton)
	{
		document.getElementById("MoveOutConfirm").style.display="none";
		document.getElementById("MoveOutConfirm").parentNode.style.border = "none";
		MoveOutButton.style.color="white";
		MoveOutButton.style.backgroundColor="orange";
	}
}

function clearAllContactButtons(inputButton)
{
		
	EmailButton = document.getElementById("EmailButton");
	TextButton= document.getElementById("TextButton");
	PhoneButton = document.getElementById("PhoneButton");
	FaxButton = document.getElementById("FaxButton");
	
	if (inputButton != EmailButton)
	{
		document.getElementById("EmailConfirm").style.display="none";
		document.getElementById("EmailConfirm").parentNode.style.border = "none";
		EmailButton.style.color="white";
		EmailButton.style.backgroundColor = "green";
	}
	if (inputButton != TextButton)
	{
		document.getElementById("TextConfirm").style.display="none";
		document.getElementById("TextConfirm").parentNode.style.border = "none";
		TextButton.style.color="white";
		TextButton.style.backgroundColor="green";
	}
	if (inputButton != PhoneButton)
	{
		document.getElementById("PhoneConfirm").style.display="none";
		document.getElementById("PhoneConfirm").parentNode.style.border = "none";
		PhoneButton.style.color="white";
		PhoneButton.style.backgroundColor="green";
	}
	if (inputButton != FaxButton)
	{
		document.getElementById("FaxConfirm").style.display="none";
		document.getElementById("FaxConfirm").parentNode.style.border = "none";
		FaxButton.style.color="white";
		FaxButton.style.backgroundColor="green";
	}
	
}

function MUButtonClick(elementName)
{
	
	buttonClicked = document.getElementById(elementName);
	clearAllButtons(buttonClicked);
	confirmDivName = elementName.replace("Button","Confirm");
	confirmDiv = document.getElementById(confirmDivName);
	parentDiv = confirmDiv.parentNode;
	var isPressed = (buttonClicked.style.color=="black");
	if (isPressed)
	{
		confirmDiv.style.display = "none";
		buttonClicked.style.color="white";
		parentDiv.style.border = "none";
		var curColor = buttonClicked.style.backgroundColor;
		var newColor;
		switch (curColor.toLowerCase())
		{
			case "lime": newColor = "green"; break;
			case "gold": newColor = "orange"; break;
			case "lightpink": newColor = "red"; break;
		}
		buttonClicked.style.backgroundColor = newColor;
	} else
	{
		confirmDiv.style.display = "block";
		buttonClicked.style.color="black";
		parentDiv.style.border ="1px solid black";
		var curColor = buttonClicked.style.backgroundColor;
		switch (curColor.toLowerCase())
		{
			case "green": newColor = "lime"; break;
			case "orange": newColor = "gold"; break;
			case "red": newColor = "lightpink"; break;
		}
		buttonClicked.style.backgroundColor = newColor;
	}
}

function ContactButtonClick(elementName)
{
	
	buttonClicked = document.getElementById(elementName);
	clearAllContactButtons(buttonClicked);
	confirmDivName = elementName.replace("Button","Confirm");
	confirmDiv = document.getElementById(confirmDivName);
	parentDiv = confirmDiv.parentNode;
	var isPressed = (buttonClicked.style.color=="black");
	if (isPressed)
	{
		confirmDiv.style.display = "none";
		buttonClicked.style.color="white";
		parentDiv.style.border = "none";
		var curColor = buttonClicked.style.backgroundColor;
		var newColor;
		switch (curColor.toLowerCase())
		{
			case "lime": newColor = "green"; break;
			case "gold": newColor = "orange"; break;
			case "lightpink": newColor = "red"; break;
		}
		buttonClicked.style.backgroundColor = newColor;
	} else
	{
		confirmDiv.style.display = "block";
		buttonClicked.style.color="black";
		parentDiv.style.border ="1px solid black";
		var curColor = buttonClicked.style.backgroundColor;
		switch (curColor.toLowerCase())
		{
			case "green": newColor = "lime"; break;
			case "orange": newColor = "gold"; break;
			case "red": newColor = "lightpink"; break;
		}
		buttonClicked.style.backgroundColor = newColor;
	}
}

function ConfirmMUClick(ConfirmType)
{
 //ConfirmType MoveOut|OnTime|NotPaid|Complicated|Late	
	//var params = {};
    var postingData = new FormData();
    //jsondata.append("val1", "this");
    //jsondata.append("val2", "that");

	 switch (ConfirmType)
	 {
		 case "OnTime":
		   var _messageID = $("#MessageID").val();
		   var params = { result: ConfirmType, "MessageID":_messageID, "Method":"<?php print $Method ?>"};
           postingData.append("result", ConfirmType);
           postingData.append("MessageID", _messageID);
           postingData.append("Method", "<?php print $Method ?>");
		   break;
		 case "NotPaid":
		 var _messageID = $("#MessageID").val();
		   var params = { result: ConfirmType, "MessageID":_messageID, "Method":"<?php print $Method ?>"};
           postingData.append("result", ConfirmType);
           postingData.append("MessageID", _messageID);
           postingData.append("Method", "<?php print $Method ?>");
		   break;
		 case "Late":
		 var _messageID = $("#MessageID").val();
		   var _lateAmount = $("#Lateness").val();
		   var params = { result: ConfirmType, lateAmount:_lateAmount, "MessageID":_messageID, "Method":"<?php print $Method ?>" };
           postingData.append("result", ConfirmType);
           postingData.append("lateAmount", _lateAmount);
           postingData.append("MessageID", _messageID);
           postingData.append("Method", "<?php print $Method ?>");
		   break;
		 case "MoveOut":
		   var _moveOutDate = $("#MoveOutDate").val();
		   var _moveOutStatus = $("#LeaseStatusCode").val();
		   var _moveOutStatusText =  $("#LeaseStatusCode option:selected").text();
		   var _messageID = $("#MessageID").val();
		   var _moveOutDetails = $("#MoveOutDetails").val();
		   if (!isDate(_moveOutDate))
		   {
			   alert("Please enter a move-out date.");
			   return;
		   }
		   if (_moveOutStatus == "99" && _moveOutDetails.trim() == "")
		   {
			   alert("You selected 'Other' as their status upon move-out.  Please tell us a little more about what's going on in the text box.");
			   return;
		   }
		   var params = { result: ConfirmType, "moveOutDate":_moveOutDate, "moveOutStatus":_moveOutStatus , "moveOutStatusText":_moveOutStatusText , "MessageID":_messageID, "Method":"<?php print $Method ?>", "complicatedAnswer":_moveOutDetails};
           postingData.append("result", ConfirmType);
           postingData.append("moveOutDate", _moveOutDate);
           postingData.append("moveOutStatus", _moveOutStatus);
           postingData.append("moveOutStatusText", _moveOutStatusText);
           postingData.append("MessageID", _messageID);
           postingData.append("Method", "<?php print $Method ?>");
           postingData.append("complicatedAnswer", _moveOutDetails);
		   break;
		 case "Complicated":
		 var _messageID = $("#MessageID").val();
		   var _textBox = $("#ComplicatedAnswer").val();
		   var _PropertyManagerID = $("#PropertyManagerID").val();
		   var params = { result: ConfirmType, "complicatedAnswer":_textBox,  "MessageID":_messageID, "Method":"<?php print $Method ?>" };
           postingData.append("result", ConfirmType);
           postingData.append("complicatedAnswer", _textBox);
           postingData.append("MessageID", _messageID);
           postingData.append("Method", "<?php print $Method ?>");
		   break;
	 }
	//alert("Parameters: " + JSON.stringify(params)); 
    showSpinner('Please wait while we process this..');
    //var posting = $.post( "MU_Confirm_2017_c.php", params );
	//	 
	//	  // Put the results in a div
	//	  posting.done(function( data, status ) {
    //            hideSpinner();
	//		  //alert(data);
	//		  //if (data.includes("successfully"))
	//		  //{
	//			  alert(data);
	//		  //}
	//	  });

          $.ajax({
            url: "MU_Confirm_2017_c.php",
            type: 'POST',
            data: params,
            success: function(data) { 
                hideSpinner();
                alert(data); 
            },
            error: function(xhr, status, error) {
                hideSpinner();
                alert('ERROR: ' + xhr.responseText);
                

            }
        }); 
		
 
}

// function ConfirmClick(ContactType)
// {
	// // confirmtype: Fax|Text|Email|Phone
	  // var _messageID = $("#MessageID").val();
	 // switch (ContactType)
	// {
		 // case "Phone":
			// var _ContactInfo = $("#PhoneNumber").val();
			// break;
		 // case "Text":
			// var _ContactInfo = $("#TextNumber").val();
			// break;
		 // case "Email":
			// var _ContactInfo = $("#EmailAddress").val();
			// break;
		 // case "Fax":
			// var _ContactInfo = $("#FaxNumber").val();
			// break;
	// }
	// var params = { "ContactType": ContactType, "ContactInfo":_ContactInfo, "MessageID":_messageID };
	// //alert("Parameters: " + JSON.stringify(params)); 
	// var posting = $.post( "MU_Preferences_2017_c.php", params );
		// // Put the results in a div
		// posting.done(function( data, status ) {
		// //alert(data);
		// //if (data.includes("successfully"))
		// //{
			// // showBlock(event, 'Signups');
			// alert(data);
		// //}
	// });
// }


function showBlock(evt, divName) {
	const mq = window.matchMedia( "(max-width:600px)" );
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
		if (mq.matches)
		{
			tablinks[i].style.display = "none";
		}
    }
    document.getElementById(divName).style.display = "block";
	evt.currentTarget.className += " active";
	if (mq.matches)
    {
		evt.currentTarget.style.display = "block";
	}
    
	
}


/* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */
function doHamburger() {
    var i, tablinks;
	tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].style.display = "block";
    }
    var x = document.getElementById("myTopnav");
    if (x.className === "topnav") {
        x.className += " responsive";
    } else {
        x.className = "topnav";
    }
} 

function closeHamburger() {
    var x = document.getElementById("myTopnav");
        x.className = "topnav";
} 

function ValidateData()
	{
		frm = document.getElementById("frmPassword");
				if(frm.old_pass.value=='')
		{
			$('#div_info_msg').css("color","#CC0000");
			$('#div_info_msg').html("Please enter your Old Password!");
			frm.old_pass.focus();
			return false;
		}	
		else if(frm.new_pass.value=='')
		{
			$('#div_info_msg').css("color","#CC0000");
			$('#div_info_msg').html("Please enter your New Password!");
			frm.new_pass.focus();
			return false;
		}
		else if(frm.new_pass.value.length<6)
		{
			$('#div_info_msg').css("color","#CC0000");
			$('#div_info_msg').html("Your new password needs to be at least 6 characters!");
			frm.new_pass.focus();
			return false;
		}	
		else if(frm.new_pass.value!=frm.cnew_pass.value)
		{
			$('#div_info_msg').css("color","#CC0000");
			$('#div_info_msg').html("Your new passwords don't match!  Please try again.");
			frm.cnew_pass.focus();
			return false;
		}	
		return true;
	}
	
function isDate(d)
{
	
	d2 = moment(d, 'YYYY-MM-DD');
	return d2.isValid();
	
}	
	var picker = new Pikaday(
    {
        field: document.getElementById('MoveOutDate'),
        firstDay: 1,
        minDate: new Date(2010,01,01),
        maxDate: new Date(2026, 12, 31),
        yearRange: [2014,2026],
		
    });
	
$( document ).ready(function() {
	
    
	});
	
//showSpinner('Please wait while we process your registration...');
 
function showSpinner(waitMessage = '')
{
    var modalBox = $('#waitSpinner');
    if (waitMessage != '')
    {
        $('#waitMessageText').text(waitMessage);
    }
    modalBox.css("visibility", "hidden");
    modalBox.css("display", "block");

    
    var modalHeight = modalBox.height();
    var modalWidth = modalBox.width();
    var windowHeight = $(window).height();
    var windowWidth = $(window).width();
    var topMargin= (windowHeight - modalHeight)/2;
    var leftMargin = (windowWidth - modalWidth)/2;
    modalBox.css("top", Math.max(0, topMargin ));
    modalBox.css("left", Math.max(0,  leftMargin));

    // now to center the spinny thing
    var spinnerContainer = $('#spinnerInnerContainer');
    var spinnerMessageContainer = $('#spinnerText');
	spinnerContainer.css("margin:auto");
    

    modalBox.css("visibility", "visible");
    

}

function hideSpinner()
{
    var modalBox = $('#waitSpinner');
    modalBox.css("display", "none");
}

function alignSpinner()
{
    var modalBox = $('#waitSpinner');
    if (modalBox.css('display') == 'block') {
    
        var modalHeight = modalBox.outerHeight();
        var modalWidth = modalBox.outerWidth();
        var windowHeight = $(window).height();
        var windowWidth = $(window).width();
        var topMargin= (windowHeight - modalHeight)/2;
        var leftMargin = (windowWidth - modalWidth)/2;
        modalBox.css("top", Math.max(0, topMargin ));
        modalBox.css("left", Math.max(0,  leftMargin));
    }
    

}

</script>
     
</body>
</html> 