function _surrenderHidePopup()
{
var displayElement = _oE( "popup" );
displayElement.style.visibility = "hidden";
_oE( "popup-content" ).innerHTML = "";
}
function _surrenderHideSubmit()
{
_oE( "submitting" ).style.visibility = "hidden";
_oE( "submitting-ok-button" ).style.visibility = "hidden";
}
function _surrenderShowPopup()
{
var displayElement = _oE( "popup" );
displayElement.style.visibility = "visible";
}
function _surrenderShowSubmit()
{
var displayElement = _oE( "submitting" );
displayElement.style.visibility = "visible";
}
function _surrenderSubmitForm()
{
var showPopup = false;
var popupContent = _oE( "popup-content" );
popupContent.innerHTML = "";
var name = _v( "a_name" );
var email = _v( "a_email" );
var phone = _v( "a_phone" );
var location = _v( "a_location" );
var rescueName = _v( "a_rescue_name" );
var catName = _v( "a_cat_name" );
var catDescription = _v( "a_cat_description" );
var catAge = _v( "a_cat_age" );
var catVettedNo = _c( "a_cat_vetted_no" );
var catVettedYes = _c( "a_cat_vetted_yes" );
var catVettedDetails = _v( "a_cat_vetted_details" );
var catFriend = _v( "a_cat_friend" );
var catRequirements = _v( "a_cat_reqs" );
var catHistory = _v( "a_cat_history" );
var transportGreely = _c( "a_trans_greely" );
var transportEmbrun = _c( "a_trans_embrun" );
var transportNone = _c( "a_trans_pickup" );
var iAccept = _c( "a_surrender_yes" );
if ( name == null )
{
showPopup = true;
popupContent.innerHTML += "Name
";
}
if ( phone == null )
{
showPopup = true;
popupContent.innerHTML += "Phone Number
";
}
if ( email == null )
{
showPopup = true;
popupContent.innerHTML += "Email Address
";
}
if ( location == null )
{
showPopup = true;
popupContent.innerHTML += "Location
";
}
if ( rescueName == null )
{
showPopup = true;
popupContent.innerHTML += "Are you affiliated with a rescue?
";
}
if ( catDescription == null )
{
showPopup = true;
popupContent.innerHTML += "Description of Cat
";
}
if ( catAge == null )
{
showPopup = true;
popupContent.innerHTML += "Approximate Age of Cat
";
}
if ( !(catVettedNo || catVettedYes) )
{
showPopup = true;
popupContent.innerHTML += "Has the cat been vetted/sterilized?
";
}
if ( !(transportGreely || transportEmbrun || transportNone) )
{
showPopup = true;
popupContent.innerHTML += "Are you able to transport to Greely or Embrun, or do you require a pick up?
";
}
if ( iAccept === false )
{
showPopup = true;
popupContent.innerHTML += "Please accept the terms of the Intake/Surrender form.
";
}
if ( showPopup )
{
_surrenderShowPopup();
return;
}
_oE( "submitting-ok-button" ).style.visibility = "hidden";
_oE( "submitting-title" ).innerHTML = "Submitting Your Information";
_oE( "submitting-content" ).innerHTML = "Please hang on while we submit your request.";
_surrenderShowSubmit();
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if ( this.status >= 400 )
{
_oE( "submitting-title" ).innerHTML = "We're Sorry";
_oE( "submitting-ok-button" ).style.visibility = "visible";
_oE( "submitting-content" ).innerHTML = "Something went wrong on our end handling your request. Please try again soon.";
}
else if ( this.status == 200 )
{
_oE( "submitting-title" ).innerHTML = "Thank You!";
_oE( "submitting-ok-button" ).style.visibility = "visible";
_oE( "submitting-content" ).innerHTML = "Your request has been received! Thank you! We will be in touch as soon as possible.";
}
};
xhttp.open( "POST", "/handle/surrenderform", true );
xhttp.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
var _catName = catName === null ? "None Submitted" : catName;
var _catFriend = catFriend === null ? "None Submitted" : catFriend;
var _catHistory = catHistory === null ? "None Submitted" : catHistory;
var _catRequirements = catRequirements === null ? "None Submitted" : catRequirements;
var _catVettedDetails = catVettedDetails === null ? "unknown" : catVettedDetails;
var transportChoice = transportGreely ? "greely" : transportEmbrun ? "embrun" : "pickup";
var data = "name=" + encodeURIComponent( name )
+ "&email=" + encodeURIComponent( email )
+ "&phone=" + encodeURIComponent( phone )
+ "&location=" + encodeURIComponent( location )
+ "&rsqname=" + encodeURIComponent( rescueName )
+ "&catname=" + encodeURIComponent( _catName )
+ "&catdesc=" + encodeURIComponent( catDescription )
+ "&catage=" + encodeURIComponent( catAge )
+ "&catvetted=" + encodeURIComponent( catVettedYes ? "Yes" : "No" )
+ "&catvetdetails=" + encodeURIComponent( _catVettedDetails )
+ "&catfriend=" + encodeURIComponent( _catFriend )
+ "&catreqs=" + encodeURIComponent( _catRequirements )
+ "&cathistory=" + encodeURIComponent( _catHistory )
+ "&cattransport=" + encodeURIComponent( transportChoice );
xhttp.send( data );
}
function _c( __id )
{
return _oE( __id ).checked === true;
}
function _v( __id )
{
var value = _oE( __id ).value;
if ( typeof value == "string" )
{
value = value.trim();
if ( value === "" )
{
value = null;
}
}
return _uton( value );
}
function _oE( __id )
{
var toReturn = document.getElementById( __id );
if ( _uton( toReturn ) == null )
{
return {};
}
return toReturn;
}
function _uton( _ )
{
if ( typeof _ === "undefined" )
{
return null;
}
return _;
}