//<![CDATA[
// These are some global variables for rotating promotions
var totpromos = 0;
var curpromo = 1;
var rotatepromos = (totpromos > 1);

// These are some global variables for rotating property images
var totimg = 0;
var curimg = 1;
var rotateimages = false;
var picprop = "";
var picloaded = false;

// These are some global variables for rotating attractions
var totatts = 0;
var curatt = 1;
var rotateatts = (totatts > 1);

// These are some global variables for rotating APG scenic images on homepage
var totapgimgs = 17;
var apgimg = 1;
var rotateapgimages = false;
var apgloaded = false;
var apgurl = "http://patriotgetaways.com/images/main"

// These are some global variables for rotating property thumbnails
var curthumb = 1;
var rotatethumbs = false;
var thumb1loaded = false;
var thumb2loaded = false;
var thumb3loaded = false;
var thumb4loaded = false;
var tforward = true;

// Disable right-clicking.
var message="Thank you for visiting our site.";
function click(e) {
  if (document.all) {
    if (event.button==2||event.button==3) {
      alert(message);
      return false;
    }
  }
  if (document.layers) {
    if (e.which == 3) {
      alert(message);
      return false;
    }
  }
}

if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
}

document.onmousedown=click;
document.oncontextmenu=new Function("alert(message);return false");



function MakeArray(n) {
        this.length = n
        return this
}

function SetNameLocation(Name,Row,Column)
{
   document.LANSA._NAME.value=Name;
   document.LANSA._ROW.value=Row;
   document.LANSA._COLUMN.value=Column;
   document.LANSA._CALFLD.value=Name;
}



function HandleEvent(Proc,Func)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;
   document.LANSA.submit();
}

function CompletedForm()
{
  var FormComplete = false;

  if (document.LANSA['ARENTRY2  '].value == 'Y') {
    document.LANSA['ARENTRY2  '].value = 'W';
  }

  if (document.LANSA['ARENTRY2  '].value == 'Z') {
    document.LANSA['ARENTRY2  '].value = 'X';
  }

  FormComplete = contToSSL4();

  if (FormComplete) {
    if (document.LANSA['ARENTRY2  '].value == 'W') {
      document.LANSA['ARENTRY2  '].value = 'Y';
    }

    if (document.LANSA['ARENTRY2  '].value == 'X') {
      document.LANSA['ARENTRY2  '].value = 'Z';
    }
  }

  return FormComplete
}

function CompletedForm2()
{
  var FormComplete = false;

  if (document.LANSA['ARENTRY2  '].value == 'Y') {
    document.LANSA['ARENTRY2  '].value = 'W';
  }

  if (document.LANSA['ARENTRY2  '].value == 'Z') {
    document.LANSA['ARENTRY2  '].value = 'X';
  }

  FormComplete = contToSSL5();

  if (FormComplete) {
    if (document.LANSA['ARENTRY2  '].value == 'W') {
      document.LANSA['ARENTRY2  '].value = 'Y';
    }

    if (document.LANSA['ARENTRY2  '].value == 'X') {
      document.LANSA['ARENTRY2  '].value = 'Z';
    }
  }

  return FormComplete
}

function contToSSL() {
	if (document.LANSA['ARENTRY2  '].value == 'X') {
//		return CheckReservationSelected();
	}
	else {
	if((document.LANSA['ARVFIRS   '].value =="")||(document.LANSA['ARVLAST   '].value =="")||(document.LANSA['ARVADDR   '].value =="")||
		(document.LANSA['ARVCITY   '].value =="")||(document.LANSA['LRVSTA    '].value =="NA")||(document.LANSA['AAGPOST   '].value =="")||
		(document.LANSA['LRVCNTR   '].value =="")||(document.LANSA['ARVPHON   '].value =="")||(document.LANSA['LRVMAIL   '].value ==""))
		{
			validForm1()
			validForm2()
			validForm3()
			validForm4()
			validForm5()
			validForm6()
			validForm7()
			validForm8()
			validForm9()
			return false
		}
		else
		{
			return true
		}
		}
	}

function contToSSL2(){
	if((document.LANSA['ARVFIRS   '].value =="")||(document.LANSA['ARVLAST   '].value =="")||(document.LANSA['ARVADDR   '].value =="")||
		(document.LANSA['ARVCITY   '].value =="")||(document.LANSA['LRVSTA    '].value =="NA")||(document.LANSA['AAGPOST   '].value =="")||
		(document.LANSA['LRVCNTR   '].value =="")||(document.LANSA['ARVPHON   '].value =="")||(document.LANSA['LRVMAIL   '].value ==""))
		{
			validForm1()
			validForm2()
			validForm3()
			validForm4()
			validForm5()
			validForm6()
			validForm7()
			validForm8()
			validForm9()
			return false
		}
		else
		{
			HandleEvent('PSEARCH','PRESV02')
			return true
		}
	}

function contToSSL3(){
  var CompletedEntry = CompletedForm()

  CompletedEntry = CompletedEntry && validForm13()

  if (CompletedEntry) {
    HandleEvent('WEBMISC','WEBM004')
  }
  return CompletedEntry
}

function contToSSL3t(){
  var CompletedEntry = CompletedForm()

  CompletedEntry = CompletedEntry && validForm13()

  if (CompletedEntry) {
    HandleEvent('WEBMISC','WEBMT04')
  }
  return CompletedEntry
}

function contToSSL4(){
  var CompletedEntry = true

if (document.LANSA['ARENTRY2  '].value == 'W') {
  CompletedEntry = validForm10()
  CompletedEntry = CompletedEntry && validForm11()
  CompletedEntry = CompletedEntry && validForm12()
  CompletedEntry = CompletedEntry && validForm16()
  CompletedEntry = CompletedEntry && validForm1()
  CompletedEntry = CompletedEntry && validForm2()
  CompletedEntry = CompletedEntry && validForm3()
  CompletedEntry = CompletedEntry && validForm4()
  CompletedEntry = CompletedEntry && validForm5()
  CompletedEntry = CompletedEntry && validForm6()
  CompletedEntry = CompletedEntry && validForm7()
  CompletedEntry = CompletedEntry && validForm8()
  CompletedEntry = CompletedEntry && validForm9()
}

if (document.LANSA['ARENTRY2  '].value == 'X') {
  CompletedEntry = validForm14()
  CompletedEntry = CompletedEntry && validForm15()
  CompletedEntry = CompletedEntry && validForm1()
  CompletedEntry = CompletedEntry && validForm2()
  CompletedEntry = CompletedEntry && validForm3()
  CompletedEntry = CompletedEntry && validForm4()
  CompletedEntry = CompletedEntry && validForm5()
  CompletedEntry = CompletedEntry && validForm6()
  CompletedEntry = CompletedEntry && validForm7()
  CompletedEntry = CompletedEntry && validForm8()
  CompletedEntry = CompletedEntry && validForm9()
}

  return CompletedEntry
}

function contToSSL5(){
  var CompletedEntry = true

  CompletedEntry = validForm1()
  CompletedEntry = CompletedEntry && validForm2()
  CompletedEntry = CompletedEntry && validForm3()
  CompletedEntry = CompletedEntry && validForm4()
  CompletedEntry = CompletedEntry && validForm5()
  CompletedEntry = CompletedEntry && validForm6()
  CompletedEntry = CompletedEntry && validForm7()
  CompletedEntry = CompletedEntry && validForm8()
//  CompletedEntry = CompletedEntry && validForm17()

  return CompletedEntry
}

function LTrim(sString){
  while (sString.substring(0,1) == ' '){
    sString = sString.substring(1, sString.length);
  }
  return sString;
}

function validForm1() {
	document.LANSA['ARVFIRS   '].value = document.LANSA['ARVFIRS   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');
	document.LANSA['ARVFIRS   '].value = LTrim(document.LANSA['ARVFIRS   '].value);
	if(document.LANSA['ARVFIRS   '].value =="") {
		alert("You must enter your first name.")
		return false
		}
	return true
	}

function validForm2() {
	document.LANSA['ARVLAST   '].value = document.LANSA['ARVLAST   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');
	document.LANSA['ARVLAST   '].value = LTrim(document.LANSA['ARVLAST   '].value);
	if(document.LANSA['ARVLAST   '].value =="") {
		alert("You must enter your last name.")
		return false
		}
	return true
	}

function validForm3() {
	document.LANSA['ARVADDR   '].value = document.LANSA['ARVADDR   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');
	document.LANSA['ARVADDR   '].value = LTrim(document.LANSA['ARVADDR   '].value);
	if(document.LANSA['ARVADDR   '].value =="") {
		alert("You must enter your address.")
		return false
		}
	return true
	}

function validForm4() {
	document.LANSA['ARVCITY   '].value = document.LANSA['ARVCITY   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');
	document.LANSA['ARVCITY   '].value = LTrim(document.LANSA['ARVCITY   '].value);
	if(document.LANSA['ARVCITY   '].value =="") {
		alert("You must enter your city.")
		return false
		}
	return true
	}

function validForm5() {
	if(document.LANSA['LRVSTA    '].value == "NA") {
		if(document.LANSA['LRVCNTR   '].value == "USA") {
			alert("You must enter your state.")
			return false
			}
		if(document.LANSA['LRVCNTR   '].value == "CANADA") {
			alert("You must enter your province.")
			return false
			}
		}
	return true
	}

function validForm6() {
//	document.LANSA['AAGPOST   '].value = document.LANSA['AAGPOST   '].value.replace(/ /g,'');
	document.LANSA['AAGPOST   '].value = document.LANSA['AAGPOST   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');
	document.LANSA['AAGPOST   '].value = LTrim(document.LANSA['AAGPOST   '].value);
	if(document.LANSA['AAGPOST   '].value =="") {
		alert("You must enter your postal code.")
		return false
		}
	return true
	}

function validForm7() {
	if(document.LANSA['LRVCNTR   '].value =="") {
		alert("You must enter your country.")
		return false
		}
	return true
	}

function validForm8() {
//	document.LANSA['ARVPHON   '].value = document.LANSA['ARVPHON   '].value.replace(/ /g,'');
	document.LANSA['ARVPHON   '].value = document.LANSA['ARVPHON   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');
	document.LANSA['ARVPHON   '].value = LTrim(document.LANSA['ARVPHON   '].value);
	if(document.LANSA['ARVPHON   '].value =="") {
		alert("You must enter your complete phone number.")
		return false
		}
	return true
	}

function validForm9() {
  var Counter = 0
  var DigitString = "0123456789"
  var FaxNum = ""
  document.LANSA['LRVMAIL   '].value = document.LANSA['LRVMAIL   '].value.replace(/ /g,'');
  document.LANSA['LRVMAIL   '].value = document.LANSA['LRVMAIL   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');
  while (Counter < document.LANSA['ARVFPHO   '].value.length) {
    if (DigitString.indexOf(document.LANSA['ARVFPHO   '].value.charAt(Counter)) > -1) {
      FaxNum = FaxNum + document.LANSA['ARVFPHO   '].value.charAt(Counter);
    }
    Counter++;
  }
  document.LANSA['ARVFPHO   '].value = FaxNum;
  if ((!validEmail(document.LANSA['LRVMAIL   '].value)) && (document.LANSA['ARVFPHO   '].value.length < 8)) {
    alert("You must enter either your VALID e-mail address or a complete fax number. Please check your entries.")
    return false
  }
  return true
}

function validForm10() {
  var Counter = 0
  var DigitString = "0123456789"
  var CompleteCCN = true
  var Digit = 0
  var DblDigit = false
  var CheckSum = 0

  if(document.LANSA['ACCNUM    '].value =="") {
    alert("You must enter your credit card number.")
    CompleteCCN = false
  }
  else {
    if (document.LANSA['ACCNUM    '].value.length < 15) {
      alert("You have not entered your complete credit card number.")
      CompleteCCN = false
    }
    else {
      while (Counter < document.LANSA['ACCNUM    '].value.length && CompleteCCN) {
        if (DigitString.indexOf(document.LANSA['ACCNUM    '].value.charAt(Counter)) == -1) {
          alert("Position " + (Counter + 1) + " of your credit card number contains an invalid character.  You may only use the digits 0 through 9.");
          CompleteCCN = false;
        }
        Counter++;
      }
// Check credit card number against the Mod 10 test for credit card numbers.
      if (CompleteCCN) {
        for (Counter = document.LANSA['ACCNUM    '].value.length - 1; Counter > -1; Counter--) {
          Digit = parseInt(document.LANSA['ACCNUM    '].value.charAt(Counter))
          if (DblDigit) {
            Digit = Digit * 2
            if (Digit > 9) {
              Digit = Digit - 9
            }
          }
          CheckSum = CheckSum + Digit
          DblDigit = !DblDigit
        }

        CompleteCCN = (CheckSum%10 == 0)

        if (!CompleteCCN) {
          alert("Your credit card number is invalid.  Please enter a valid credit card number.");
        }
      }
    }
  }
  return CompleteCCN
}

function validForm11() {
	if(document.LANSA['LCCMO     '].value =="") {
		alert("You must enter the expiration month of your credit card.")
		return false
		}
	return true
	}

function validForm12() {
	if(document.LANSA['SCCYR     '].value == "") {
		alert("You must enter the expiration year of your credit card.")
		return false
		}
	return true
	}

function validForm13() {
// Remove spaces and non-breaking spaces from initials.
	document.LANSA['ARVIATA   '].value = document.LANSA['ARVIATA   '].value.replace(/ /g,'');
	document.LANSA['ARVIATA   '].value = document.LANSA['ARVIATA   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');

	if(document.LANSA['ARVIATA   '].value == "") {
		alert("You must enter your initials to acknowledge that you agree to our terms and conditions.")
		return false
		}
	return true
	}

function validForm14() {
  var Counter = 0
  var DigitString = "0123456789"
  var CompleteRN = true
  var Digit = 0
  if(document.LANSA['STRROUT   '].value.length < 9) {
    alert("The routing number of your bank must have exactly 9 digits.")
    return false
  }
  else {
    while (Counter < document.LANSA['STRROUT   '].value.length && CompleteRN) {
      if (DigitString.indexOf(document.LANSA['STRROUT   '].value.charAt(Counter)) == -1) {
        alert("Position " + (Counter + 1) + " of your bank routing number contains an invalid character.  You may only use the digits 0 through 9.");
        CompleteRN = false;
      }
      Counter++;
    }
  }
  return CompleteRN
}

function validForm15() {
  var Counter = 0
  var DigitString = "0123456789"
  var CompleteAcct = true
  var Digit = 0
  if(document.LANSA['STRACCT   '].value == "") {
    alert("You must enter your checking account number.")
    return false
  }
  else {
    while (Counter < document.LANSA['STRACCT   '].value.length && CompleteAcct) {
      if (DigitString.indexOf(document.LANSA['STRACCT   '].value.charAt(Counter)) == -1) {
        alert("Position " + (Counter + 1) + " of your account number contains an invalid character.  You may only use the digits 0 through 9.");
        CompleteAcct = false;
      }
      Counter++;
    }
  }
  return CompleteAcct
}

function validForm16() {
  var Counter = 0
  var DigitString = "0123456789"
  var CompleteCVV = true
  var Digit = 0

  if(document.LANSA['STRCVV2   '].value == "") {
    alert("You must enter your CVV number.")
    return false
  }
  else {
    while (Counter < document.LANSA['STRCVV2   '].value.length && CompleteCVV) {
      if (DigitString.indexOf(document.LANSA['STRCVV2   '].value.charAt(Counter)) == -1) {
        alert("Position " + (Counter + 1) + " of your CVV number contains an invalid character.  You may only use the digits 0 through 9.");
        CompleteCVV = false;
      }
      Counter++;
    }
  }
  return CompleteCVV
}

function validForm17() {
  document.LANSA['LRVMAIL   '].value = document.LANSA['LRVMAIL   '].value.replace(/ /g,'');
  document.LANSA['LRVMAIL   '].value = document.LANSA['LRVMAIL   '].value.replace(RegExp(String.fromCharCode(160), 'g'),'');
  if (!validEmail(document.LANSA['LRVMAIL   '].value)) {
    alert("You must enter a valid e-mail address.")
    return false
  }
  return true
}

function Registration() {
  var CompletedEntry = true;

  CompletedEntry = CompletedEntry && validForm1();
  CompletedEntry = CompletedEntry && validForm2();
  CompletedEntry = CompletedEntry && validForm3();
  CompletedEntry = CompletedEntry && validForm4();
  CompletedEntry = CompletedEntry && validForm5();
  CompletedEntry = CompletedEntry && validForm6();
  CompletedEntry = CompletedEntry && validForm7();
  CompletedEntry = CompletedEntry && validForm17();
  if (CompletedEntry) {
    HandleEvent('REGISTER','ENTRY');
  }
  return CompletedEntry;
}


function ChangePropURL(BaseURL,PropNum) {
  window.location = BaseURL + "/propdetails/" + PropNum + ".html"
}

function SelectReservation(dptmn,dptdy,dptyr,ddate,rate,caldr,sub,prcfee,specdesc,discamt,prpcen,prdfre,caldy,mpcode,prmdis,spcrat,spcdis) {

	document.LANSA['PDPTMN    '].value = dptmn;
	document.LANSA['PDPTDY    '].value = dptdy;
	document.LANSA['PDPTYR    '].value = dptyr;
	document.LANSA['PDDATE    '].value = ddate;
	document.LANSA['PRATE     '].value = rate;
	document.LANSA['SCALDR    '].value = caldr;
	document.LANSA['PSUBTOTAL '].value = sub;
	document.LANSA['SPRCFEE   '].value = prcfee;
	document.LANSA['ASPECDESC '].value = specdesc;
	document.LANSA['PDISCAMT  '].value = discamt;
	document.LANSA['SPRPCEN   '].value = prpcen;
	document.LANSA['SPRDFRE   '].value = prdfre;
	document.LANSA['SCALDY    '].value = caldy;
	document.LANSA['AMPCODE   '].value = mpcode;
	document.LANSA['PPRMDIS   '].value = prmdis;
	document.LANSA['PSPCRAT   '].value = spcrat;
	document.LANSA['PSPCDIS   '].value = spcdis;
}

function SelReservation(dptmn,dptdy,dptyr,ddate,rate,caldr,sub,prcfee,specdesc,discamt,prpcen,prdfre,caldy,mpcode) {

	document.LANSA['PDPTMN    '].value = dptmn;
	document.LANSA['PDPTDY    '].value = dptdy;
	document.LANSA['PDPTYR    '].value = dptyr;
	document.LANSA['PDDATE    '].value = ddate;
	document.LANSA['PRATE     '].value = rate;
	document.LANSA['SCALDR    '].value = caldr;
	document.LANSA['PSUBTOTAL '].value = sub;
	document.LANSA['SPRCFEE   '].value = prcfee;
	document.LANSA['ASPECDESC '].value = specdesc;
	document.LANSA['PDISCAMT  '].value = discamt;
	document.LANSA['SPRPCEN   '].value = prpcen;
	document.LANSA['SPRDFRE   '].value = prdfre;
	document.LANSA['SCALDY    '].value = caldy;
	document.LANSA['AMPCODE   '].value = mpcode;
}

function CheckReservationSelected(Proc,Func) {
var Counter = 0
var IsSelected = false

	if (document.LANSA.radio1.length == null) {
	  document.LANSA.radio1.checked = true;
              document.LANSA.radio1.onclick();
	  IsSelected = document.LANSA.radio1.checked;
	}
	else {
	  while (Counter < document.LANSA.radio1.length && !IsSelected) {
                if (document.LANSA.radio1[Counter].checked) {
	      IsSelected = true;
                  document.LANSA.radio1[Counter].onclick();
                }
	    Counter++;
	  }
	}

	if (!IsSelected) {
	  alert("You must select one reservation option before proceeding. An option is selected by clicking on the round button beside it.");
	}
	else {
              HandleEvent(Proc,Func);
	}
}

function CheckForBidCabin() {

  if (document.LANSA['SDDPROPDRO'].value == "") {
    alert("Please select a cabin from the list of cabins.")
  }
  else {
    HandleEvent('SALES1','BIDDING');
  }
}

function CalcCCCharge() {
  var NightRate
  var TotTxRate
  var SubTotal
  var Taxes
  var Webprcfee
  var CleanFee
  var Rem
  var s

  NightRate = parseInt(document.LANSA.ABIDC.value)

  if (isNaN(NightRate)) {
    NightRate = 0
  }

  if (NightRate == 0) {
    document.LANSA.ABIDC.value = ""
  }
  else {
    if (NightRate < 0) {
      NightRate = Math.abs(NightRate)
    }
    s = String(NightRate)
    if (s.length < document.LANSA.ABIDC.value.length) {
      document.LANSA.ABIDC.value = s
    }
  }
  s = ""

  TotTxRate = parseFloat(document.LANSA.PTOTTXRATE.value)

  if (isNaN(TotTxRate)) {
    TotTxRate = 0
  }

  Webprcfee = parseFloat(document.LANSA.SWEBPRCFEE.value)

  if (isNaN(Webprcfee)) {
    Webprcfee = 0
  }

  CleanFee = parseFloat(document.LANSA['SPRCFEE   '].value)

  if (isNaN(CleanFee)) {
    CleanFee = 0
  }

//  TotTxRate = TotTxRate / 100
  SubTotal = NightRate * document.LANSA['SCALDR    '].value
  Taxes = SubTotal * TotTxRate * 10
  Rem = Taxes%10
//  Taxes = parseInt(s)

  if (Rem >= 5) {
    Taxes = Taxes + 10 - Rem
  }
  else {
    Taxes = Taxes - Rem
  }

  document.LANSA.roomcharge.value = SubTotal + ".00"

// Create string containing taxes.  This is done to eliminate
// rounding errors.
  if (Taxes == 0) {
    s = "0.00"
  }
  else {
    s = String(Taxes)
    s = s.substring(0,s.length - 1)
    switch(s.length > 0) {
    case(s.length > 2):
      s = s.substring(0, s.length - 2) + "." + s.substring(s.length - 2, s.length);
      break
    case(s.length == 2):
      s = "0." + s;
      break
    case(s.length < 2):
      s = "0.0" + s;
      break
    }
  }
  document.LANSA.taxes.value = s

// Create string containing total.  This is done to eliminate
// rounding errors.
  s = String(Taxes + (SubTotal + Webprcfee + CleanFee) * 1000)
  s = s.substring(0,s.length - 1)
  if (s.length > 2) {
    s = s.substring(0, s.length - 2) + "." + s.substring(s.length - 2, s.length)
  }
  else {
    s = "0." + s
  }
  document.LANSA.total.value = s
}

// ********* Begin block of code to change the visibility of the tool tip boxes for the Rating **************

// initialize some global vars
var br, ver

// very basic check for browser type and version
if (navigator.appName == "Netscape") {
    br="ns"
}
ver = navigator.appVersion.substring(0,1)

// function to make tool tip visible
// popUpWin is NOT an object
function popUp(evt, currElem) {
	// if it's a netscape browser and not over version 4
    if (br == "ns" && ver <= 4) {
        popUpWin = document.layers[currElem]
        popUpWin.visibility = "visible"
    } else {
        popUpWin = document.getElementById(currElem)
        popUpWin.style.visibility = "visible"
    }
    window.status = ""
}

// function to make tool tip hidden
// popUpWin is NOT an object
function popDown(currElem) {
    if(br == "ns" && ver <= 4) {
        popUpWin = document.layers[currElem]
        popUpWin.visibility = "hidden"
    } else {
        popUpWin = document.getElementById(currElem)
        popUpWin.style.visibility = "hidden"
    }
}
// ********* End block of code to change the visibility of the tool tip boxes for the Rating **************

function PopulateAreas() {
  if (document.LANSA['LDDAREA   '] != null) {
    var pl = document.LANSA['LDDAREA   '].options;
    pl[0] = new Option(String.fromCharCode(160),"");


    optGroup = document.LANSA['LDDAREA   '].appendChild(document.createElement('optgroup'));
    optGroup.label = "AMENITIES";

    pl[1] = new Option("Boat Slips Available","BOAT SLIPS AVAILABLE");









    pl[2] = new Option("HOMES ON THE BEACH","HOMES ON THE BEACH");









    pl[3] = new Option("HOMES ON THE WATER","HOMES ON THE WATER");









    pl[4] = new Option("HOMES WITH PRIVATE POOLS","HOMES WITH PRIVATE POOLS");








    optGroup = document.LANSA['LDDAREA   '].appendChild(document.createElement('optgroup'));
    optGroup.label = "AREA";

    pl[5] = new Option("MARCO ISLAND ESTATE HOMES","MARCO ISLAND ESTATE HOMES");









    pl[6] = new Option("NAPLES","NAPLES");








    optGroup = document.LANSA['LDDAREA   '].appendChild(document.createElement('optgroup'));
    optGroup.label = "AREAS";

    pl[7] = new Option("Beach Access Condos","BEACH ACCESS CONDOS");









    pl[8] = new Option("Inland Condos","INLAND CONDOS");









    pl[9] = new Option("Inland Homes","INLAND HOMES");









    pl[10] = new Option("Naples Condos","NAPLES CONDOS");









    pl[11] = new Option("Ocean Front Condos","OCEAN FRONT CONDOS");









    pl[12] = new Option("River Front Condos","RIVER FRONT CONDOS");









    pl[13] = new Option("Waterfront Homes","WATERFRONT HOMES");






    document.LANSA['LDDAREA   '].selectedIndex = -1;
    document.LANSA['LDDAREA   '].selectedIndex = 0;
  }
}

function PopulateProperties() {
  if (document.LANSA['SDDPROPDRO'] != null) {
    var pl = document.LANSA['SDDPROPDRO'].options;
    pl[0] = new Option(String.fromCharCode(160),"");




    pl[1] = new Option("A304 RIVERSIDE CONDOS","10-25");








    pl[2] = new Option("B109 SOUTH SEAS EAST","10-13");








    pl[3] = new Option("B305 RIVERSIDE CONDOS","10-45");








    pl[4] = new Option("B606 RIVERSIDE CONDOS","10-17");








    pl[5] = new Option("C409 SOUTH SEAS EAST","10-12");








    pl[6] = new Option("E406 RIVERSIDE CONDOS","10-24");








    pl[7] = new Option("F-104 NAPLES BAY RESORT","10-11");








    pl[8] = new Option("F306 RIVERSIDE CONDOS","10-37");








    pl[9] = new Option("LA PENINSULA #622","10-38");








    pl[10] = new Option("1295 RIVERHEAD AVE","10-33");








    pl[11] = new Option("139 BALFOUR DR","10-36");








    pl[12] = new Option("1605 SOUTH SEAS, TOWER 4","10-20");








    pl[13] = new Option("1705 SOUTH SEAS, TOWER 4","10-8");








    pl[14] = new Option("1706 SOUTH SEAS, TOWER 4","10-30");








    pl[15] = new Option("1770 BARBADOS AVENUE","10-3");








    pl[16] = new Option("1819 MAYWOOD CT","10-35");








    pl[17] = new Option("212 GERANIUM COURT","10-1");








    pl[18] = new Option("257 SEMINOLE CT","10-31");








    pl[19] = new Option("401 SOUTH SEAS, TOWER 4","10-27");








    pl[20] = new Option("401 WATERLEAF COURT","10-9");








    pl[21] = new Option("404 FOREST GLEN","10-32");








    pl[22] = new Option("478 PERSIAN COURT","10-4");








    pl[23] = new Option("504 REGATTA @ VANDERBILT BEACH","10-23");








    pl[24] = new Option("602 MARCO TOWERS","10-16");




    document.LANSA['SDDPROPDRO'].selectedIndex = -1;
    document.LANSA['SDDPROPDRO'].selectedIndex = 0;
  }
}

function InitPicTags() {
  if (document.LANSA["PNUMPICS  "] != null) {
    totimg = document.LANSA["PNUMPICS  "].value;
    rotateimages = (totimg > 1);
    picNames = new MakeArray(totimg)
//    HoldPics = new MakeArray(totimg);
    for (curimg = 1; curimg <= totimg; curimg++) {
      picNames[curimg] = "http://patriotgetaways.com/images/P" + document.LANSA["SPRLOC    "].value + "-" + document.LANSA["SPRPROP   "].value + "-" + curimg + ".jpg"
//      HoldPics[curimg] = new Image();
//      HoldPics[curimg].src = picNames[curimg];
    }
    var pl = document.LANSA.picselect.options;
    for (curimg = 0; curimg < totimg; curimg++) {
      pl[curimg] = new Option("Picture " + (curimg + 1),curimg + 1);
    }
    curimg = 1;
    if (!rotateimages) {
      document.LANSA.pausepics.value="Disabled";
    }
    rotateimages = false;
//    setTimeout("RotateImage()",2000);
  }
}

function RotateImage() {
  if (rotateimages) {
    if (totimg > 1) {
//      if (document.images['big'].complete) {
      if (picloaded) {
        curimg = curimg + 1;
        if (curimg > totimg) {
          curimg = 1;
        }
        picloaded = false;
//        document.images['big'].src = HoldPics[curimg].src;
        document.images['big'].src = picNames[curimg];
        document.LANSA.picselect.value = curimg;
      }
      setTimeout("RotateImage()",2000);
    }
  }
}

function PauseRotation() {
  if (totimg > 1) {
    rotateimages = !rotateimages;
    if (rotateimages) {
      document.LANSA.pausepics.value="Pause Slideshow";
      RotateImage();
    }
    else {
      document.LANSA.pausepics.value="Play Slideshow";
    }
  }
  else {
    alert("Too few images to rotate.")
  }
}

function InitThumbnails() {
  var shownthumb = totimg;
  if (document.LANSA["PNUMPICS  "] != null) {
    rotatethumbs = (totimg > 4);
    curthumb = 1;
    if (totimg < 4) {
      for (shownthumb = 4; shownthumb > totimg; shownthumb--) {
        k = document.getElementById("link" + shownthumb);
        k.style.display = "none";
        k = document.getElementById("thumb" + shownthumb);
        k.style.display = "none";
      }
//      curthumb = shownthumb;
    }
//    if (!rotatethumbs) {
//      document.LANSA.pausethumbs.value="Disabled";
//    }
    rotatethumbs = false;
//    setTimeout("RotateThumbnails()",2000);
  }
}


function AdvanceThumbnails() {
  var ndx = curthumb;
  rotatethumbs = false;
    if (totimg > 4) {
      if (thumb1loaded && thumb2loaded && thumb3loaded && thumb4loaded) {
        thumb1loaded = false;
        thumb2loaded = false;
        thumb3loaded = false;
        thumb4loaded = false;
        if (!tforward) {
          ndx = ndx - 2;
          if (ndx == 0) ndx = totimg;
          if (ndx == -1) ndx = totimg - 1;
        }
        for (shownthumb = 1; shownthumb <= 4; shownthumb++) {
          ndx = ndx + 1;
          if (ndx > totimg) {
            ndx = 1;
          }
          k = document.getElementById("link" + shownthumb);
          k.href = picNames[ndx];
          k.title = "Photo " + ndx;
          k = document.getElementById("thumb" + shownthumb);
          k.src = picNames[ndx].replace(/images/g,'images\/150t');
          k.alt = "Photo " + ndx;
          if (ndx == 1) {
            k.style.border="3px green solid";
          }
          else {
            k.style.border="3px blue solid";
          }
        }
        if (tforward) {
          curthumb = curthumb + 1;
          if (curthumb > totimg) {
            curthumb = 1;
          }
        }
        else {
          curthumb = curthumb - 1;
          if (curthumb < 1) {
            curthumb = totimg;
          }
        }
      }
    }
    else {
      alert("Too few images to rotate.")
    }
}

function ShowBroadband(t) {
  if (curimg == 1) {
    document.images['big'].src = picNames[curimg];
  }
  j = document.getElementById("dialup");
  k = document.getElementById("broadb");
  if (k.style.display == "none") {
    j.style.display = "none";
    k.style.display = "block";
    t.value = "Return to Thumbnails";
  }
  else {
    j.style.display = "block";
    k.style.display = "none";
    t.value = "Broadband Users Click Here for Slideshow";
  }
}

function SelectPic(value) {
  var i = parseInt(value);
  rotateimages = false;
  if (isNaN(i)) {
    i = 0;
  }
  else {
    document.images['big'].src = picNames[i];
    if (totimg > 1) {
      document.LANSA.pausepics.value="Play Slideshow";
    }
  }
  curimg = i;
}

function OpenSesame(elementid) {
  var k = document.getElementById("tr" + elementid);
  k.style.background="#FFCC00";
  var j = document.getElementById(elementid);
  j.style.visibility='visible';
}

function CloseSesame(elementid) {
  var k = document.getElementById("tr" + elementid);
  k.style.background="#FFFFFF";
  var j = document.getElementById(elementid);
  j.style.visibility='hidden';
}

function InitPromotionsOLDVERSION() {
  curpromo = 1;
  var k = document.getElementById("promo" + curpromo);
  k.style.display = "block";
}

function InitPromotions() {
  if (document.LANSA["PCNTER    "] != null) {
    curpromo = 1;
    var k = document.getElementById("promo" + curpromo);
    k.style.display = "block";
    totpromos = document.LANSA["PCNTER    "].value;
    rotatepromos = (totpromos > 1);
    setTimeout("RotatePromo()",5000)
  }
}

function RotatePromo() {
  if (rotatepromos) {
    if (totpromos > 1) {
      var k = document.getElementById("promo" + curpromo);
      k.style.display = "none";
      curpromo = curpromo + 1;
      if (curpromo > totpromos) {
        curpromo = 1;
      }
      var k = document.getElementById("promo" + curpromo);
      k.style.display = "block";
      setTimeout("RotatePromo()",5000);
    }
  }
}

function PausePromo() {
  if (totpromos > 1) {
    rotatepromos = !rotatepromos;
    if (rotatepromos) {
      RotatePromo();
    }
  }
  else {
    alert("Too few promotional specials to rotate.")
  }
}

function SelectPromo(value) {
  var i = parseInt(value);
  rotatepromos = false;
  if (isNaN(i)) {
    i = 0;
  }
  else {
    var k = document.getElementById("promo" + curpromo);
    k.style.display = "none";
    var k = document.getElementById("promo" + i);
    k.style.display = "block";
  }
  curpromo = i;
}

function InitAttractions() {
  if (document.LANSA["PCTR4     "] != null) {
    totatts = document.LANSA["PCTR4     "].value;
    if (totatts > 0) {
      curatt = 1;
      var k = document.getElementById("attr" + curatt);
      k.style.display = "block";
      rotateatts = (totatts > 1);
      setTimeout("RotateAtt()",5000)
    }
  }
}

function RotateAtt() {
  if (rotateatts) {
    if (totatts > 1) {
      var k = document.getElementById("attr" + curatt);
      k.style.display = "none";
      curatt = curatt + 1;
      if (curatt > totatts) {
        curatt = 1;
      }
      var k = document.getElementById("attr" + curatt);
      k.style.display = "block";
      setTimeout("RotateAtt()",5000);
    }
  }
}

function MakeSecure(sValue) {
  var sAction = new String(document.LANSA.action);
  var sSearch = new RegExp("://", "gi");
  var iPos = sAction.search(sSearch);
  if (iPos == -1) {
    if (sValue == "") {
      document.LANSA.action='https://patriotgetaways.com' + document.LANSA.action;
    }
    if (sValue == "Y") {
      document.LANSA.action='https://www.1-gatlinburg-log-cabin-rentals-mountain-chalet-tn-vacation.com' + document.LANSA.action;
    }
    if (sValue == "NONE") {
      document.LANSA.action='https://208.62.113.131' + document.LANSA.action;
    }
  }
  else {
    document.LANSA.action = 'https' + sAction.substring(iPos,sAction.length);
  }
}





function bkmark() {
  r = document.getElementById("bookmark");
  if (r != null) {
    if (document.LANSA["ASITEFLAG "].value > "") {
      var url = "http://www.1-gatlinburg-log-cabin-rentals-mountain-chalet-tn-vacation.com";
      var title = "Marco Island by #1 Gatlinburg Log Cabin Rentals Mountain Chalet TN Vacation";
    }
    else {
      var url = "http://patriotgetaways.com";
      var title = "Marco Island by American Patriot Getaways";
    }
    if (document.all) { // Only true for MSIE
      s = "<textarea wrap=\"virtual\" readonly style=\"overflow:hidden;text-align:center;width:230;height:50;background-color:#1919C9;wordwrap:true;border-left:5px #504EC9 solid;border-top:5px #807FCD solid;"
      s = s + "border-right:5px #1010A0 solid;border-bottom:5px #0A0D6A solid;color:#FFFFFF;font-weight:bold;font-family:Georgia;font-size:10.0pt\" "
      s = s + "onMouseOver=\"window.status='Bookmark Now!'\" "
      s = s + "onMouseOut=\"window.status=''\" "
      s = s + "onclick=\"javascript:window.external.AddFavorite('" + url + "','" + title + "');" + "\">Click Here to Save Us in Your Favorites</textarea>"
    }
    else {
      s = "<textarea wrap=\"virtual\" readonly style=\"overflow:hidden;text-align:center;width:230;height:50;background-color:#1919C9;wordwrap:true;border-left:5px #504EC9 solid;border-top:5px #807FCD solid;"
      s = s + "border-right:5px #1010A0 solid;border-bottom:5px #0A0D6A solid;color:#FFFFFF;font-weight:bold;font-family:Georgia;font-size:10.0pt\">Press CTRL+D to Save Us in Your Favorites</textarea>"
    }
    r.innerHTML = s;
  }
}


function InitPage() {
  InitPromotions();
  bkmark();
  PopulateAreas();
  PopulateProperties();
  InitPicTags();
  InitThumbnails();
  InitAttractions();
  InitAPG();
  if (document.LANSA.IpixChanger != null) {
    ChangeIPIX(document.LANSA["ATOURPAGE "].value);
    document.LANSA.IpixChanger.value = document.LANSA["ATOURPAGE "].value;
  }
}

function extract ( urlStr ){
	var tmpstr = urlStr.split(":");
	if ( tmpstr[1].substring(0,5) == "//www")
		tmpstr[1] = tmpstr[1].substring(6,tmpstr[1].length);
	else
		tmpstr[1] = tmpstr[1].substring(2,tmpstr[1].length);
	return tmpstr;

}

function checkURL ( urlStr ){
	var tmp = new RegExp ("(http:\/\/)(www\.)?(([a-zA-Z0-9\-\_])+)([\.][a-zA-Z])");
	if (!tmp.test(urlStr) ){
		alert ( "String is NOT in good condition\nEX:\n  http://www.domain-name.com \n OR \n  http://domain-name.com");
		return false;
	}return true;

}

function capitalize( urlStr ){
	var i, str, t1, t2, finalstr = "";
	str = urlStr.split(" ");
	for( i = 0; i < str.length; i++ ){
		str[i] = (str[i].substring(0,1)).toUpperCase() + str[i].substring(1,str[i].length);
	}
	for ( i = 0; i < str.length; i++ ){
		if ( finalstr == "" ) finalstr = str[i];
		else finalstr = finalstr + " " + str[i];
	}
	return finalstr;
}

function display( clientURL, email, anchortitle, description ){
	var client0, client, anctitle;
	var test = checkURL ( clientURL );
	if (test){
		client0 = extract (clientURL);
		//client = client0[client0.length-2] + "." + client0[client0.length-1];
		client = client0[1];
		anctitle = capitalize ( anchortitle );
  	document.write("<h2 class='gatlinburg'>Link to " + client + "</h2>");
  	document.write("<p>Link popularity is fast becoming one of the highest weighted criteria used in ranking your site in the search engines. The more related sites linking to yours ");
  	document.write("the higher your sites ranking climbs in the search engine results. We like to link with sites that complement ours or can offer our clients a valid service. We will not exchange ");
  	document.write("links with any website that is unduly offensive or fraudulently boastful in its claims.<br><br>");
  	document.write("<strong>How do I swap links with " + client + " ?</strong><br><br>");
  	document.write("Exchanging links between our two sites is easy. <a href=\"mailto:" + email + "\">Send us an email</a> with a one or two sentence description of ");
  	document.write("your site and the exact URL. We'll review your site as soon as possible, validate the reciprocal link on your site and if we feel that your site provides good complementary content, ");
  	document.write("we will reciprocate the link.<br><br><b>To add " + client + " link to your website, simply use the following html code:</b><br><br>");
  	document.write("<div style=\"border-style:solid;border-width:2px;border-color:#343434;padding:5px;background-color:#dfdfdf;color:#000000;\">&lt;a href=\"" + clientURL + "\" title=\"" + anctitle + "\"&gt;" + anctitle + "&lt;/a&gt;&lt;br&gt;" );
  	document.write(description + "</div>");
  	document.write("<br><br>Thank you kindly,<br>" + client + "<br>");
  	document.write("<br><h3 class='gatlinburg'><div style='font-size:16px'>" + client + " Resources 1</div></div></h3><br>");
	}
	else{
		document.write ("<div style=\"font-size:14px;font-weight:bold;color:#ff0000;\">PLEASE CORRECT URL STRING ! </div>");
	}
}

function validEmail(email) {
	// Email address is sometimes required, and if it is entered,
	// it must be valid.

	// These characters can't be used in an email address
	invalidChars = ' /:,;<>()[]{}"\\'
	// If the email is empty, it's invalid
	if (email == "") {
		return false
	}

	// Check for invalid characters
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) != -1) {
			return false
		}
	}

	// If there is no "@", or "@" is the 1st character, then it's invalid
	atPos = email.indexOf("@",0)
	if (atPos < 1) {
		return false
	}

	// Only allow one @ sign
	if (email.indexOf("@",atPos+1) != -1) {
		return false
	}

	// If there is no period after the @ sign, it's invalid
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}

	// If the final period of the address is the last character,
	// then it's invalid. Positions start at 0. Length doesn't consider this.
	if (periodPos+1 == email.length) {
		return false
	}
	return true
}
function InitAPG() {
  if (document.images["apgmain"] != null) {
    totapgimgs = 17;
    rotateapgimages = (totapgimgs > 1);
    apgimg = 1;
    setTimeout("RotateAPG()",4000);
  }
}

function RotateAPG() {
  if (rotateapgimages) {
    if (apgloaded) {
      apgimg = apgimg + 1;
      if (apgimg > totapgimgs) {
        apgimg = 1;
      }
      apgloaded=false;
      document.images['apgmain'].src = apgurl + apgimg + ".jpg";
    }
    setTimeout("RotateAPG()",4000);
  }
}
//]]>
