savecontrol = 0;
savecontrol2 = 0;
savecontrol3 = 0;
savecontrol4 = 0;
savecontrol5 = 0;
ajaxwarn = 0;
submithandler = 0;

function loginmain(){
if(document.brochure.Meeting_Code.value == ""){
alert("A meeting code is required, please enter a meeting code and click 'Submit'.")
}else{
document.brochure.submit();
}
}

function loginmain2(){
if(document.brochure.Meeting_Code.value == ""){
alert("A meeting code is required, please enter a meeting code and click 'Submit'.")
return false;
}else{
return true;
}
}

function checkemail(){
emailtxt = document.emailsend.emailtmp.value;
pwdtxt = document.emailsend.pwd.value;
indexofat = emailtxt.indexOf("@")
if (emailtxt == ""){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf("@") == -1){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf(".",indexofat) == -1){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf(" ") != -1){
alert("Please enter a valid e-mail address with no spaces and try again.")
}else if (pwdtxt == ""){
alert("Please enter a password and try again.")
} else {

//emailtxt1 = emailtxt.slice(0,indexofat) + "\@" + emailtxt.slice(indexofat+1)
emailtxt1 = emailtxt;
pwdtxt1 = pwdtxt;
document.emailsend.loginemail.value = emailtxt1
document.emailsend.pwd.value = pwdtxt1
//alert(emailtxt1)
document.emailsend.submit();
}
}

function checkemailcompany(){
emailtxt = document.emailsend.emailtmp.value;
indexofat = emailtxt.indexOf("@")
if (emailtxt == ""){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf("@") == -1){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf(".",indexofat) == -1){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf(" ") != -1){
alert("Please enter a valid e-mail address with no spaces and try again.")
}else {

//emailtxt1 = emailtxt.slice(0,indexofat) + "\@" + emailtxt.slice(indexofat+1)
emailtxt1 = emailtxt;
document.emailsend.elements[1].value = emailtxt1
//alert(emailtxt1)
document.emailsend.submit();
}
}

function testing(){
alert('hello');

}

function checkmeeting(){
meetcode = document.meetingcode.Meeting_webcode.value;

if(meetcode == ""){
alert('Please enter a meeting code.');
}else if(meetcode.length < 4){
alert('Please enter a valid meeting code and try again.');
}else {
document.meetingcode.submit();
}

}

function checkmeeting2(){
meetcode = document.meetingcode.Meeting_webcode.value;

if(meetcode == ""){
alert('Please enter a meeting code.');
return false
}else if(meetcode.length < 4){
alert('Please enter a valid meeting code and try again.');
return false
}else {
return true
}

}

function checkemailmeet(){
emailtxt = document.emailsend.emailtmp.value;
emailtxttwo = document.emailsend.emailtmptwo.value;
if (emailtxt == emailtxttwo){
if (emailtxt.indexOf("@") == -1){
alert("Please enter a valid e-mail address and try again.")
return false;
}
indexofat = emailtxt.indexOf("@")
if (emailtxt.indexOf(".",indexofat) == -1){
alert("Please enter a valid e-mail address and try again.")
return false;
}
if (emailtxt.indexOf(" ") != -1){
alert("Please enter a valid e-mail address with no spaces and try again.")
return false;
} else {

//emailtxt1 = emailtxt.slice(0,indexofat) + "\\@" + emailtxt.slice(indexofat+1)
document.emailsend.loginemail.value = emailtxt
//alert(emailtxt1)


return true;
}
}else{
alert("Both e-mail addresses do not match please enter them again and try again.")
return false;
}

}

function checkemailmeet2(){
emailtxt = document.emailsend.emailtmp.value;
emailtxttwo = document.emailsend.emailtmptwo.value;
if (emailtxt == emailtxttwo){
indexofat = emailtxt.indexOf("@")
if (emailtxt.indexOf("@") == -1){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf(".",indexofat) == -1){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf(" ") != -1){
alert("Please enter a valid e-mail address with no spaces and try again.")
} else {

//emailtxt1 = emailtxt.slice(0,indexofat) + "\\@" + emailtxt.slice(indexofat+1)

document.emailsend.loginemail.value = emailtxt
//alert(emailtxt1)

document.emailsend.submit();
}

}else{
alert("Both e-mail addresses do not match please enter them again and try again.")
}
}

function checkemailconfirm(){
emailtxt = document.emailsend.emailtmp.value;
pwd = document.emailsend.pwd.value;
indexofat = emailtxt.indexOf("@")
if (emailtxt.indexOf("@") == -1){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf(".",indexofat) == -1){
alert("Please enter a valid e-mail address and try again.")
}else if (emailtxt.indexOf(" ") != -1){
alert("Please enter a valid e-mail address with no spaces and try again.")
} else if (pwd == ""){
alert("The password can't be left empty.")
}else {

//emailtxt1 = emailtxt.slice(0,indexofat) + "\\@" + emailtxt.slice(indexofat+1)
document.emailsend.loginemail.value = emailtxt
//alert(emailtxt1)
document.emailsend.submit()
}
}

function checkpasscompanion(){
email = document.companioninfo.Email.value
if (email == ""){
alert('You must provide an email for your companion')
}else{
document.companioninfo.submit();
}
}

function checkpasscompanion2(formnum){
eval("document.companion"+formnum+".submit()");
}

function checkpasscompanion3(formnum){
email = eval("document.companion"+formnum+".Email.value");
if (email == ""){
alert('You must provide an email for your companion')
}else {
eval("document.companion"+formnum+".currentQuery.value = 'sendemail'");
eval("document.companion"+formnum+".submit()");
}
}

function checkpasscompanion4(formnum){
if (confirm("Delete this companion from your travel plans? This cannot be undone.")){
eval("document.companion"+formnum+".currentQuery.value = 'deletecompanion'");
eval("document.companion"+formnum+".submit()");
}
}

function navbar(action){
if(action == "home"){
document.tabbrowse.currentQuery.value = 'navbar';
document.tabbrowse.action = 'primrecdetail.php';
document.tabbrowse.submit()
}else if(action == "travel"){
document.tabbrowse.action = 'primrectravel.php';
document.tabbrowse.submit();
}else if(action == "travel2"){
document.tabbrowse.currentQuery.value = 'navbar';
document.tabbrowse.action = 'primrectravel.php';
document.tabbrowse.submit();
}else if(action == "mpref"){
document.tabbrowse.action = 'primrecmeetpref.php';
document.tabbrowse.submit();
}else if(action == "hpref"){
if(document.tabbrowse.currentQuery.value == 'out'){
alert("We're sorry. A connection error has occurred. Please quit your browser, wait a few minutes, and then try again.");
window.location.href = "http://www.w2igo.com";
}else{
document.tabbrowse.action = 'primrecarrange.php';
document.tabbrowse.submit();
}

}else if(action == "mealpref"){
document.tabbrowse.action = 'primrecmeals.php';
document.tabbrowse.submit();
}else if(action == "logout"){
document.location.href = 'index.php';
}else if(action == "finish"){
document.tabbrowse.action = 'finishconf.php';
document.tabbrowse.submit();
}else if(action == "sbkp"){
document.tabbrowse.action = 'scontactinfo.php';
document.tabbrowse.submit();
}
}

function navbar2(action){
if(action == "home"){
document.tabbrowse.currentQuery.value = 'navbar';
document.tabbrowse.action = 'secrecdetail.php';
document.tabbrowse.submit()
}else if(action == "travel"){
document.tabbrowse.action = 'secrectravel.php';
document.tabbrowse.submit();
}else if(action == "mpref"){
document.tabbrowse.action = 'secrecmeetpref.php';
document.tabbrowse.submit();
//nt.location.href = 'index.php';
}else if(action == "mealpref"){
document.tabbrowse.action = 'secrecmeals.php';
document.tabbrowse.submit();
}else if(action == "hpref"){
document.tabbrowse.action = 'secrecarrange.php';
document.tabbrowse.submit();
//nt.location.href = 'index.php';
}else if(action == "finish"){
document.tabbrowse.action = 'secfinishconf.php';
document.tabbrowse.submit();
}else if(action == "logout"){
document.location.href = 'index.php';
}else if(action == "sbkp"){
document.tabbrowse.action = 'secscontactinfo.php';
document.tabbrowse.submit();
}
}

function makevisible(formnum){

var edittoshow = 'hid'+formnum;
var linktoshow = 'linkh'+formnum;
document.getElementById(edittoshow).style.display="block";
document.getElementById(linktoshow).style.display="block";

var partohide = 'linkv'+formnum;
document.getElementById(partohide).style.display="none";

}

function makevisible2(formnum){

var edittoshow = 'hid'+formnum;
var linktoshow = 'linkh'+formnum;
document.getElementById(edittoshow).style.display="none";
document.getElementById(linktoshow).style.display="none";

var partohide = 'linkv'+formnum;
document.getElementById(partohide).style.display="block";

}

function showaddcompanion(){
document.getElementById('addcompanionform').style.display="block";
document.getElementById('addcompanion').style.display="none";
}

function canceladdcompanion(){
document.getElementById('addcompanionform').style.display="none";
document.getElementById('addcompanion').style.display="block";
}

function showactivitylist(){
document.getElementById('primaryactivities').style.display="block";
document.getElementById('linktohide').style.display="none";
}
function showactivitylist2(){
document.getElementById('primaryactivities').style.display="none";
document.getElementById('linktohide').style.display="block";
}

function checkpass2(formnum){
if(submithandler == 0){
submithandler = 1;
var totalactivities = 0
var maxactivtoparse = document.getElementById("maxnumofactivities").innerHTML
var maxnumactivity = parseInt(maxactivtoparse,10)
// get the number of items already selected by the user
for (y=0;y<=maxnumactivity;y++){
var formname = "listedactivity"+y
if(!document.getElementById(formname)){
}else{
totalactivities = totalactivities + 1
}
}

if (totalactivities < maxnumactivity){
eval("document.activitylist"+formnum+".submit()");
}else{
document.getElementById("maxactivitynumwarning").style.display = "block";
}
var totalactivities = 0
var maxnumactivity = 0
}
}

function checkpass2a(formnum,rows){
if (rows == 1){
eval("document.mealsitem"+formnum+".specialreq.value = document.mealrequest.meals_additional_requests.value");
eval("document.mealsitem"+formnum+".submit()");
}else{
eval("document.mealsitem"+formnum+".submit()");
}
}

function checkpass4(formnum){
if (confirm("Delete this activity from your activity list?")){
eval("document.listedactivity"+formnum+".submit()")
};
}

function checkpass5(formnum){
if (confirm("Delete this meal from your list?")){
eval("document.listedmeal"+formnum+".submit()")
};
}


function checkpass3(formnum){
email = eval("document.companion"+formnum+".Email.value");
pwdsec = eval("document.companion"+formnum+".secpwd.value");
if (email == ""){
alert('You must provide an email for your companion')
} else if (pwdsec == ""){
alert('You must provide a password for your companion')
}else {
eval("document.companion"+formnum+".currentQuery.value = 'sendemail'");
eval("document.companion"+formnum+".submit()");
}
}

function checkselectedvalue(){
theselected = document.personinfo.registered_as.selectedIndex
if(document.personinfo.registered_as.options[theselected].value == 'Child'){
document.getElementById('childage').style.display="block";
}else{
document.getElementById('childage').style.display="none";
}
}

function gotonextsteppag1(passp,addid,cc,companions, activities){
var alertedprim = 0;
if (document.personinfo.Badge_Name_First.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please provide a badge name and try again');
}

if (alertedprim == 0){
if (document.personinfo.registered_as.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please select a "Registering as" option and try again');
}
}

if (alertedprim == 0){
if (document.personinfo.Name_First.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your First Name and try again');
}
}

if (alertedprim == 0){
if (document.personinfo.Name_Last.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your Last Name and try again');
}
}

if (alertedprim == 0){
if (document.personinfo.Phone1.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your Telephone Number and try again');
}
}

if (alertedprim == 0){
if (document.personinfo.Phone1.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your Telephone Number and try again');
}
}

if (passp == 1){
if (alertedprim == 0){
if (document.personinfo.Passport_Number.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your Passport Number and try again');
}
}
}

if (addid == 1){
if (alertedprim == 0){
if (document.personinfo.Identification_Number.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your Additional ID Number and try again');
}
}
}

if (alertedprim == 0){
if (document.personinfo.Address_Street.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your Street Name and try again');
}
}

if (alertedprim == 0){
if (document.personinfo.Person_emergency_contact.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter an Emergency Contact Name and try again');
}
}

if (cc == 1){
if (alertedprim == 0){
if (document.personinfo.Person_CC_Num_www.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your Credit Card Number and try again');
}
}
if (alertedprim == 0){
if (document.personinfo.Person_CC_Exp.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your Credit Card Expiration and try again');
}
}
}

// verify a valid date of birth

if (alertedprim == 0){
if (document.personinfo.dob.value == ""){
savecontrol2 = 1;
alertedprim = 1;
alert('Please enter your date of birth and try again');
}else{

validdate = isDate(document.personinfo.dob.value);

if(!validdate){
 savecontrol2 = 1;
 alertedprim = 1;
 //alert('Please enter a valid date of birth and try again');
}

}
}

// sex is required so check here:

if (alertedprim == 0){
if (document.personinfo.sex[0].checked == false && document.personinfo.sex[1].checked == false){
savecontrol2 = 1;
alertedprim = 1;
alert('Please select either Female[F] or Male[M] and try again.');
}
}


if (alertedprim == 0){
nextpagepag1(companions, activities)
}

}

function nextpagepag1(companions, activities){

/*if (companions == 4){
if (savecontrol == 1){
alert('You made changes to your info, please save your info first by clicking on the "save my info" link found at the bottom of this page and try again');
}else{
if (savecontrol2 == 1){
document.personinfo.oktogonext.value = 'travel';
document.personinfo.submit();
} else {
navbar('travel');
}
}
}else
*/
//if (activities == 1){
//if (savecontrol == 1){
//alert('You made changes to your info, please save your info first by clicking on the "save my info" link found at the bottom of this page and try again');
//}else{
if (savecontrol2 == 1){
document.personinfo.oktogonext.value = 'sbkp';
document.personinfo.submit();
}else {
navbar('sbkp');
}
}
//}

/*else{
if (savecontrol == 1){
alert('You made changes to your info, please save your info first by clicking on the "save my info" link found at the bottom of this page and try again');
}
else{
if (savecontrol2 == 1){
document.personinfo.oktogonext.value = 'hpref';
document.personinfo.submit();
}else{
navbar('sbkp');
}
}
}*/
//}

function sendthis(){
navbar('hpref');
}
function sendthis2(){
navbar2('hpref');
}

function gotonextsteppag1s(passp,addid,cc,companions, activities){
var alerted = 0;
if (document.personinfo.Badge_Name_First.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please provide a badge name and try again');
}

if (alerted == 0){
if (document.personinfo.registered_as.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please select a "Registering as" option and try again');
}
}

if (alerted == 0){
if (document.personinfo.Name_First.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your First Name and try again');
}
}

if (alerted == 0){
if (document.personinfo.Name_Last.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your Last Name and try again');
}
}

if (alerted == 0){
if (document.personinfo.Phone1.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your Telephone Number and try again');
}
}

if (alerted == 0){
if (document.personinfo.Phone1.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your Telephone Number and try again');
}
}


if (passp == 1){
if (alerted == 0){
if (document.personinfo.Passport_Number.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your Passport Number and try again');
}
}
}


if (addid == 1){
if (alerted == 0){
if (document.personinfo.Identification_Number.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your Additional ID Number and try again');
}
}
}

if (alerted == 0){
if (document.personinfo.Address_Street.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your Street Name and try again');
}
}


if (alerted == 0){
if (document.personinfo.Person_emergency_contact.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter an Emergency Contact Name and try again');
}
}

if (cc == 1){
if (alerted == 0){
if (document.personinfo.Person_CC_Num_www.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your Credit Card Number and try again');
}
}

if (alerted == 0){
if (document.personinfo.Person_CC_Exp.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your Credit Card Expiration and try again');
}
}
}

if (alerted == 0){
theselected = document.personinfo.registered_as.selectedIndex
if(document.personinfo.registered_as.options[theselected].value == 'Child'){
if(document.personinfo.Child_Age.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter the child age and try again');
}
}
}

// verify a valid date of birth

if (alerted == 0){
if (document.personinfo.dob.value == ""){
savecontrol2 = 1;
alerted = 1;
alert('Please enter your date of birth and try again');
}else{

validdate = isDate(document.personinfo.dob.value);

if(!validdate){
 savecontrol2 = 1;
 alerted = 1;
 //alert('Please enter a valid date of birth and try again');
}

}
}

// sex is required so check here:

if (alerted == 0){
if (document.personinfo.sex[0].checked == false && document.personinfo.sex[1].checked == false){
savecontrol2 = 1;
alerted = 1;
alert('Please select either Female[F] or Male[M] and try again.');
}
}


if (alerted == 0){
nextpagepag1s(companions, activities)
}

}

function nextpagepag1s(companions, activities){
//if (savecontrol == 1){
//alert('You made changes to your info, please save your info first by clicking on the "save my info" link found at the bottom of this page and try again');
//}else{
if (savecontrol2 == 1){
document.personinfo.oktogonext.value = 'sbkp';
document.personinfo.submit();
}else {
navbar2('sbkp');
}
//}
}

function savelock(){
savecontrol2 = 1
}

function checkstatus(){
if (document.personinfo.oktogonext.value != ""){
action = document.personinfo.oktogonext.value
eval("navbar('"+action+"')")
}
}

function checkstatuss(){
if (document.personinfo.oktogonext.value != ""){
action = document.personinfo.oktogonext.value
eval("navbar2('"+action+"')")
}
}

function savelock2(){
savecontrol3 = 1
}

function savelock3(){
savecontrol4 = 1
}

function savelock4(){
savecontrol5 = 1
}

function promoadd(promid,therow){
if(submithandler == 0){
submithandler = 1;
var totalitems = 0
//alert(totalitems)
var maxnumtoparse = document.getElementById("maxnumofpromos").innerHTML
var maxnum = parseInt(maxnumtoparse,10)
// get the number of items already selected by the user
for (y=0;y<=maxnum;y++){
var formname = "promoinfo"+y
if(!document.getElementById(formname)){
}else{
totalitems = totalitems + 1
}
}
//alert(totalitems)
if (totalitems < maxnum){

if(savecontrol3 == 1){
document.flightinfo.itemrow.value = promid;
document.flightinfo.submit();
}else{
eval("document."+therow+".submit()")
}

}else{
document.getElementById("maxnumwarning").style.display = "block";
}
var totalitems = 0
var maxnum = 0
}
}


function hidewarning(){
document.getElementById("maxnightswarning").style.display = "none";
}


function nextpagefromflight(where){
if(!document.flightinfo.Hotel_Date_Arrive){
var dodatescheck = 0
}else{
var dodatescheck = 1
}

//alert(dodatescheck)

if(dodatescheck == 1){

var maxnumofnightsparse = document.getElementById("hotelmaxnights").innerHTML
var maxnumofnights = parseInt(maxnumofnightsparse,10)

var totalnumberofnights = entermaxdateauto();

if (maxnumofnights < totalnumberofnights){
document.getElementById("maxnightswarning").style.display = "block";
var stophere = 1
}else{
var stophere = 0
}
}else{
var stophere = 0
}

if ( stophere == 0){
if(document.flightinfo.Departing_To.value == ""){
alert("Please enter your Home City or Airport Traveling From")
}else{

if(savecontrol3 == 1){
if(document.cases.hasrecpromo.value == 'y'){
document.flightinfo.promoRec_par.value = document.promoadditionalreq.promos_additional_requests.value;
document.flightinfo.promoRec_recidtwo.value = document.promoadditionalreq.recidtwo.value;
}

if (where == 0){
document.flightinfo.okgo.value = 'mpref';
}else if(where == 1){
document.flightinfo.okgo.value = 'mealpref';
}else if (where == 2){
document.flightinfo.okgo.value = 'finish';
}else if (where == 3){
document.flightinfo.okgo.value = 'finish';
}

document.flightinfo.submit();

}else{

if (where == 0){
navbar('mpref');
}else if(where == 1){
navbar('mealpref');
}else if (where == 2){
navbar('finish');
}else if (where == 3){
navbar('finish');
}

}
}
}

}


function nextpagefromflight2(where){
if(document.flightinfo.Departing_To.value == ""){
alert("Please enter your Home City or Airport Traveling From")
}else{

if(savecontrol3 == 1){
if(document.cases.hasrecpromo.value == 'y'){
document.flightinfo.promoRec_par.value = document.promoadditionalreq.promos_additional_requests.value;
document.flightinfo.promoRec_recidtwo.value = document.promoadditionalreq.recidtwo.value;
}
if (where == 0){
document.flightinfo.okgo.value = 'mpref';
}else if(where == 1){
document.flightinfo.okgo.value = 'mealpref';
}else if (where == 3){
document.flightinfo.okgo.value = 'finish';
}
document.flightinfo.submit();
}else{

if (where == 0){
navbar2('mpref');
}else if(where == 1){
navbar2('mealpref');
}else if (where == 3){
navbar2('finish');
}

}
}
}


function saveallpref(){
if(document.cases.hasrecpromo.value == 'y'){
document.flightinfo.promoRec_par.value = document.promoadditionalreq.promos_additional_requests.value;
document.flightinfo.promoRec_recidtwo.value = document.promoadditionalreq.recidtwo.value;
}
document.flightinfo.submit();
}


function checkstatus2(){
if (document.flightinfo.okgo.value != ""){
action = document.flightinfo.okgo.value
eval("navbar('"+action+"')")
}
}

function checkstatus2s(){
if (document.flightinfo.okgo.value != ""){
action = document.flightinfo.okgo.value
eval("navbar2('"+action+"')")
}
}

var base64s =
 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

function encode(decStr){
decStr=escape(decStr);		//line add for chinese char
  var bits, dual, i = 0, encOut = '';
  while(decStr.length >= i + 3){
    bits =
    (decStr.charCodeAt(i++) & 0xff) <<16 |
    (decStr.charCodeAt(i++) & 0xff) <<8  |
     decStr.charCodeAt(i++) & 0xff;
    encOut +=
     base64s.charAt((bits & 0x00fc0000) >>18) +
     base64s.charAt((bits & 0x0003f000) >>12) +
     base64s.charAt((bits & 0x00000fc0) >> 6) +
     base64s.charAt((bits & 0x0000003f));
    }
  if(decStr.length -i > 0 && decStr.length -i < 3){
    dual = Boolean(decStr.length -i -1);
    bits =
     ((decStr.charCodeAt(i++) & 0xff) <<16) |
     (dual ? (decStr.charCodeAt(i) & 0xff) <<8 : 0);
    encOut +=
      base64s.charAt((bits & 0x00fc0000) >>18) +
      base64s.charAt((bits & 0x0003f000) >>12) +
      (dual ? base64s.charAt((bits & 0x00000fc0) >>6) : '=') +
      '=';
    }
  return encOut
  }

function decode(encStr) {
  var bits, decOut = '', i = 0;
  for(; i<encStr.length; i += 4){
    bits =
     (base64s.indexOf(encStr.charAt(i))    & 0xff) <<18 |
     (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 | 
     (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 |
      base64s.indexOf(encStr.charAt(i +3)) & 0xff;
    decOut += String.fromCharCode(
     (bits & 0xff0000) >>16, (bits & 0xff00) >>8, bits & 0xff);
    }
  if(encStr.charCodeAt(i -2) == 61)
    undecOut=decOut.substring(0, decOut.length -2);
  else if(encStr.charCodeAt(i -1) == 61)
    undecOut=decOut.substring(0, decOut.length -1);
  else undecOut=decOut;
  
  return unescape(undecOut);		//line add for chinese char
  }

function useradd(){
thecurrpass = document.docompare.comp.value;
thecurrpassdec = decode(thecurrpass);

pass = prompt("In order to add a new registration we require you to please enter your password:","");

if(thecurrpassdec == pass){
fn = prompt("Please enter the First Name of the person you want to register:","");
ln = prompt("Please enter the Last Name of the person you want to register:","");
if (fn == null || ln == null || fn == "" || ln == ""){
alert("Action has been canceled, both values are required.");
}else{
document.da.action = 'adduser.php';
document.da.fn.value = fn;
document.da.ln.value = ln;
document.da.currentQuery.value = 'adduser';
//alert(fn+" , "+ln);
document.da.submit();
}
}else{
alert("The password provided does not match our records, please try entering it again. If you do not remember your password click on the 'send my login info' link found at this page.");
}

}

function useraddtwo(){

fn = prompt("Please enter the First Name of the person you want to register:","");
ln = prompt("Please enter the Last Name of the person you want to register:","");
if (fn == null || ln == null || fn == "" || ln == ""){
alert("Action has been canceled, both values are required.");
}else{
document.da.action = 'adduser.php';
document.da.fn.value = fn;
document.da.ln.value = ln;
document.da.currentQuery.value = 'adduser';
//alert(fn+" , "+ln);
document.da.submit();
}
}

function viewusrs(){
thecurrpass = document.docompare.comp.value;
thecurrpassdec = decode(thecurrpass);

pass = prompt("In order to view the list of persons registered please provide your password:","");
if(thecurrpassdec == pass){
document.iamin.action = 'viewmltuser.php';
document.iamin.currentQuery.value = 'viewusrs';
document.iamin.submit();
}else{
alert("The password provided does not match our records, please try entering it again. If you do not remember your password click on the 'send my login info' link found at this page.");
}
}

function gofrommeals(){
if(savecontrol4 == 1){
document.mealrequest.oktogomeal.value = 'N';
document.mealrequest.submit();
}else{
navbar('finish');
}
}

function gotofinalpage(){
if(savecontrol4 == 1){
document.mealrequest.oktogomeal.value = 'N';
document.mealrequest.submit();
}else{
navbar('finish');
}
}

function gotofinalpage2(){
if(savecontrol4 == 1){
document.mealrequest.oktogomeal.value = 'N';
document.mealrequest.submit();
}else{
navbar2('finish');
}
}

function gofromactiv(page){
if(ajaxwarn == 0){
if(savecontrol5 == 1){
document.activityrequest.oktogoactiv.value = 'N';
document.activityrequest.submit();
}else{
if(page == 'meals'){
navbar('mealpref');
}else if(page == 'travel'){
navbar('finish');
}else{
navbar('finish');
}
}
}else{
alert("Please click on the 'save sub-activity changes button' first and try again.")
}
}

function gofromactiv2(page){
if(ajaxwarn == 0){
if(savecontrol5 == 1){
document.activityrequest.oktogoactiv.value = 'N';
document.activityrequest.submit();
}else{
if(page == 'meals'){
navbar2('mealpref');
}else{
navbar2('finish');
}
}
}else{
alert("Please click on the 'save sub-activity changes button' first and try again.")
}
}

function filloutprevdata(act){
if (act == "phone"){
if (!document.primuserdata.Company_Info1){
if (document.personinfo.Company_Info1.value == ""){
document.personinfo.Company_Info1.value = document.primuserdata.Company_Info1.value
}
}
if (!document.primuserdata.Company_Info2){
if (document.personinfo.Company_Info2.value == ""){
document.personinfo.Company_Info2.value = document.primuserdata.Company_Info2.value
}
}
if (!document.primuserdata.Company_Info3){
if (document.personinfo.Company_Info3.value == ""){
document.personinfo.Company_Info3.value = document.primuserdata.Company_Info3.value
}
}
if (!document.primuserdata.Company_Info4){
if (document.personinfo.Company_Info4.value == ""){
document.personinfo.Company_Info4.value = document.primuserdata.Company_Info4.value
}
}
if (!document.primuserdata.Company_Info5){
if (document.personinfo.Company_Info5.value == ""){
document.personinfo.Company_Info5.value = document.primuserdata.Company_Info5.value
}
}
if (!document.primuserdata.Company_Info6){
if (document.personinfo.Company_Info6.value == ""){
document.personinfo.Company_Info6.value = document.primuserdata.Company_Info6.value
}
}


if (document.personinfo.Phone1.value == ""){
document.personinfo.Phone1.value = document.primuserdata.Phone1.value
}
if (document.personinfo.Phone2_Cell.value == ""){
document.personinfo.Phone2_Cell.value = document.primuserdata.Phone2_Cell.value
}
if (document.personinfo.Phone3_Fax.value == ""){
document.personinfo.Phone3_Fax.value = document.primuserdata.Phone3_Fax.value
}
}

if (act == "address"){
if (document.personinfo.Address_Street.value == ""){
document.personinfo.Address_Street.value = document.primuserdata.Address_Street.value
}
if (document.personinfo.Address_City.value == ""){
document.personinfo.Address_City.value = document.primuserdata.Address_City.value
}
if (document.personinfo.Address_Zip.value == ""){
document.personinfo.Address_Zip.value = document.primuserdata.Address_Zip.value
}
}

if (act == "emergency"){
if (document.personinfo.Person_emergency_contact.value == ""){
document.personinfo.Person_emergency_contact.value = document.primuserdata.Person_emergency_contact.value
}
if (document.personinfo.Person_emergency_tel.value == ""){
document.personinfo.Person_emergency_tel.value = document.primuserdata.Person_emergency_tel.value
}
if (document.personinfo.Email_Emergency.value == ""){
document.personinfo.Email_Emergency.value = document.primuserdata.Email_Emergency.value
}

}

}

function checkcompanion(){
numberofcompanions = parseInt(document.counter.counter.value)
what = ""
for (x=1; x-1<numberofcompanions; x++){
//alert('running'+x)
eval ('editedrecord =document.edited'+x+'.edited.value')
if (editedrecord == ""){
what = 1
}
}

if (what == 0){
navbar('finish')
}else{
thisquestion = confirm("Have you entered your listed companion(s) information? if not, click 'cancel' and click on the link below your companion's email address. Otherwise if you click 'OK' you will finish your registration but you will have to come back and enter your companions information later.")
if (thisquestion == true){
navbar('finish')
}else{

}
}

}

function entermaxdateauto(){

    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24

var date1 = new Date(document.flightinfo.hot_Hotel_Date_Arrive.value)
var date2 = new Date(document.flightinfo.hot_Hotel_Date_Depart.value)


    // Convert both dates to milliseconds
    var date1_ms = date1.getTime()
    var date2_ms = date2.getTime()

    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms)
    
    // Convert back to days and return
    return totaldaysstay = Math.round(difference_ms/ONE_DAY)

}

function highlightme(activity,item){
ajaxwarn = 1;

formtohighlight = "subactivityform"+activity+"item"+item;

//alert(document.getElementById(formtohighlight).style.backgroundColor);
savebutton = "subactivityformsavebtn"+activity;
document.getElementById(savebutton).style.display = "block";
if(document.getElementById(formtohighlight).style.backgroundColor == "white"){
document.getElementById(formtohighlight).style.backgroundColor = "powderblue";
}else{
document.getElementById(formtohighlight).style.backgroundColor = "white";
}

}

// ajax stuff for subactivity updating.
/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}


function callServer(subactivity) {
  // Build the URL to connect to
  var buttontoupdate = "subactivityformsavebtn"+subactivity;
  var buttonupdating = "subactivityformsavebtn2"+subactivity;
  var checkeditems = "";
  
  document.getElementById(buttontoupdate).style.display = "none";
  document.getElementById(buttonupdating).style.display = "block";
  
  //document.getElementById("results").innerHTML="Saving...";
  var callingform = "document.subactivityform"+subactivity;

  var numofformelements = eval(callingform+".elements.length");
  
  
  for(x=1;x<numofformelements;x++){
  itemtocheck = eval(callingform+".elements["+x+"]");
  
  if(itemtocheck.checked == true){
  checkeditems = checkeditems + itemtocheck.value + "_";
  }
  
  }
  
  
  var options_chosen = checkeditems;
  var recordid = eval(callingform+".elements[0].value")
  var url = "savesubactivity.php?opts="+checkeditems+"&idrec="+recordid+"&fn="+subactivity+"&currentQuery=update";
  //alert(url);
  // Open a connection to the server
  xmlHttp.open("GET", url, true);

  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = updatePage;

  // Send the request
  xmlHttp.send(null);
}



function updatePage() {
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
    if (response != ""){
    //alert("done");
    // var buttonupdating = "subactivityformsavebtn2"+subactivity;
    //  document.getElementById(buttonupdating).style.display = "none";
    var buttonupdating = "subactivityformsavebtn2"+response;
    document.getElementById(buttonupdating).style.display = "none";
    ajaxwarn = 0;
    
   var callingform = "document.subactivityform"+response;
   var numofformelements = eval(callingform+".elements.length");
   
   for(x=1;x<numofformelements;x++){
  itemtoclear = "subactivityform"+response+"item"+x;
  
  document.getElementById(itemtoclear).style.backgroundColor = "white";
 }
   
    
     }
    
   // document.getElementById("results").innerHTML=formattedlist;
   // document.getElementById("zipCode").value = response;
  }
}


// end ajax



/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date of birth format should be : mm/dd/yyyy")
		return false
	}else if (strMonth.length<1 || month<1 || month>12){
		alert("Date of Birth: Please enter a valid month")
		return false
	}else if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Date of Birth: Please enter a valid day")
		return false
	}else if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Date of Birth: Please enter a valid 4 digit year.")
		return false
	}else if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date of birth and try again.")
		return false
	}
return true
}





