function verifyDelete(link) {
        var answer = confirm("Delete ?");
        if (answer){
                window.location = link;
        }
}
function Validate(){
         document.editForm.submit();
}
function preview(){
         document.getElementById('sb').value='preview';
         document.editForm.submit();
}
function add_ph(){
   document.getElementById('phadd').innerHTML += '<textarea rows="8" name="ph[]" cols="95"></textarea><br/><br />';
}
function add_pha(){
   document.getElementById('phadd').innerHTML += '<select name="lock[]"><option value="0">Unlocked</option><option value="1">Locked</option></select><br /><textarea rows="8" name="ph[]" cols="95"></textarea><br /><br />';
}
function open_gallery(gallery,wid){
   void(window.open('gall.php?img_size=' + gallery , 'Gallery','width='+wid+',height=750,scrollbars=yes'))
}
function chphoto(psrc, pval){
   document.getElementById(psrc).src = document.getElementById(pval).value;
}
function generateLink(theID) {
    var marsha = document.getElementById('MARSHA['+theID+']').options[document.getElementById('MARSHA['+theID+']').options.selectedIndex].text
    var code = document.getElementById('code['+theID+']').value;
    ResLink = "https://marriott.com/reservation/availability.mi?propertyCode=" + marsha;
    if (code.length > 0) { ResLink = ResLink + "&cc=" + code; }
    ResLink = ResLink + "&mktcmp=w_marriottwest_" + marsha + "_x";
    document.getElementById('url['+theID+']').value = ResLink;
}
function addLink(){
   var tag;
   tag = document.getElementById('AddLinkTag').value;
   ajax_addTag(tag);
   document.getElementById('AddLinkTag').value = '';
}
function mktc(th){
   var marsha = th.options[th.selectedIndex].value;
   document.getElementById("mktcmp").value = "w_marriottwest_"+ marsha +"_x";
}
function more_opt(){
   var marsha = document.getElementById("propertyCode").options[document.getElementById("propertyCode").selectedIndex].value;
   window.open("https://www.marriott.com/reservation/availability.mi?propertyCode="+marsha+"&mktcmp="+"w_marriottwest_"+ marsha +"_x");
}
function SelectCityProperty(selObj){
        doURL = selObj.options[selObj.selectedIndex].value;
        if ((String(doURL).substring(0,4) == "http") || (String(doURL).substring(0,25) == "http://www.regionsite.com")) {
                window.open(doURL, "_blank")
        }else{
                window.location = doURL;
        }
}
function SelectCityProperty2(selObj){
        doURL = selObj.options[selObj.selectedIndex].value;
        window.location = doURL;
}
function sendto(country, brand, uri, popupCode){

           forwardUrl = 'https://www.marriott.com' + uri;



                //determine window type

                switch(popupCode)

                {

                        case "2":

                                var protocol = "http";

                                if (uri.substr(0, protocol.length) == protocol)

                                {

                                        window.open(uri, "_blank");

                                }

                                else

                                {

                                        window.open(forwardUrl, "_blank");

                                }

                                break;

                        case "3":

                                window.open(forwardUrl, "_blank");

                                break;

                        case "4":

                                window.open(forwardUrl, "_blank", "width=235,height=206,scrollbars=no,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "5":

                                window.open(forwardUrl, "_blank", "width=383,height=585,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "6":

                                window.open(forwardUrl, "_blank", "width=350,height=475,scrollbars=no,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "7":

                                window.open(forwardUrl, "_blank", "width=352,height=306,scrollbars=no,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "8":

                                window.open(forwardUrl, "_blank", "width=575,height=385,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "9":

                                window.open(forwardUrl, "_blank", "width=570,height=560,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "10":

                                window.opener.location(forwardUrl);

                                window.close();

                                break;

                        case "11":

                                window.open(forwardUrl, "_blank", "");

                                window.close();

                                break;

                        case "12":

                                window.open(forwardUrl, "imagePopUp", "width=590,height=413,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "13":

                                window.open(forwardUrl, "_blank", "width=700,height=500,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "14":

                                window.open(uri, "imagePopUp", "width=572,height=410,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "15":

                                window.open(forwardUrl, "_blank", "width=575,height=385,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes");

                                break;

                        case "16":

                                window.open(forwardUrl, "_blank", "width=610,height=535,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        case "17":

                                window.open(forwardUrl, "_blank", "width=500,height=480,scrollbars=no,menubar=no,toolbar=no,status=no,resizable=no");

                                break;

                        case "18":

                                window.open(forwardUrl, "imagePopUp", "width=590,height=472,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");

                                break;

                        default:

                                window.location.href = forwardUrl;

                                break;



                }

    }

// validates that the field value string has one or more characters in it
function isNotEmpty(elem) {
        var str = elem.value;
        var re = /.+/;
        if(!str.match(re)) {
                alert("Please fill in the required field.");
                setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
                return false;
        } else {
                return true;
        }
}
//validates that the entry is a positive or negative number
function isNumber(elem) {
        var str = elem.value;
        var re = /^[-]?\d*\.?\d*$/;
        str = str.toString();
        if (!str.match(re)) {
                alert("Enter only numbers into the field.");
                setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
                return false;
        }
        return true;
}
// validates that the entry is 16 characters long
function isLen16(elem) {
        var str = elem.value;
        var re = /\b.{16}\b/;
        if (!str.match(re)) {
                alert("Entry does not contain the required 16 characters.");
                setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
                return false;
        } else {
                return true;
        }
}
// validates that the entry is formatted as an e-mail address
function isEMailAddr(elem) {
        var str = elem.value;
        var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
        if (!str.match(re)) {
                alert("Verify the e-mail address format.");
                setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
                return false;
        } else {
                return true;
        }
}
// validate that the user made a selection other than default
function isChosen(select) {
        if (select.selectedIndex == 0) {
                alert("Please make a choice from the list.");
                return false;
        } else {
                return true;
        }
}

// validate that the user has checked one of the radio buttons
function isValidRadio(radio) {
        var valid = false;
        for (var i = 0; i < radio.length; i++) {
                if (radio[i].checked) {
                        return true;
                }
        }
        alert("Make a choice from the radio buttons.");
        return false;
}

function focusElement(formName, elemName) {
        var elem = document.forms[formName].elements[elemName];
        elem.focus();
        elem.select();
}

function isPhone(string) {
    if (string.search(/^[0-9][0-9][0-9]\-[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) != -1)
         return true;
     else
         alert("You must supply a valid phone number.");
         document.form2.phone1.focus()
         return false;
}

function checksignup(form) {
                if (isNotEmpty(form.emailAddress)) {
                        if (isChosen(form.country)) {
                                if (document.getElementById("country").options[document.getElementById("country").selectedIndex].value == 'US') {
                                      if (isNotEmpty(form.postalCode)) {
                                            return true;
                                      }
                                }else{
                                    return true;
                                }
                         }
              }
       return false;
}
function checkBRO(form){
   var select = form.propertyCode;
        if (select.selectedIndex == 0) {
                alert("Please select a property from the list.");
                return false;
        } else {
                return true;
        }
}
function showTerms(MARSHA) {
window.open('http://www.regionsite.com/meetings/terms.asp?MARSHA='+MARSHA ,'termsWin','scrollbars=yes,width=500,height=400')
}
function openRFP(MARSHA) {
window.open('http://www.regionsite.com/meetings/express_rfp.asp?props='+MARSHA+'&source=1183_'+MARSHA ,'rfpWin','scrollbars=yes,width=470,height=520')
}
function openCal(MARSHA) {
window.open('http://www.regionsite.com/meetings/calendar.asp?MARSHA='+MARSHA ,'calWin','scrollbars=yes,width=420,height=600')
}
function changePage(newLoc){
   nextPage = newLoc.options[newLoc.selectedIndex].value
   if (nextPage != ""){
      document.location.href = nextPage
   }
}