// JavaScript Document
function switchCountry(){
 location.href=document.forms.frmCountry.selectCountry.value;
}
function switchAction(act){
 document.forms[0].action = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
 return true;
}
function switchActionExplicit(form, act) {
 document[form].action = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
 return true;
}
function switchActionSubmit(act){
 document.forms[0].action = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
 document.forms[0].submit();
 return true;
}
function switchLocation(act){
 location.href = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
 return true;
}
function helpWindow(url){
 helpWin = window.open(url, 'helpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=450,width=400');
 if(window.focus){ helpWin.focus(); }
}
function smallWindow(url){
 smallWin = window.open(url, 'smallWindow','scrollbars=yes,resizable=yes,toolbar=no,height=500,width=475');
 if(window.focus){ smallWin.focus(); }
}
function forceForward(){
 history.forward(+1);
}
function setAssocOptions(changedSel, assocSel, changedToAssoc, assocText){
 var changedValue = changedSel.options[changedSel.selectedIndex].value;//value of changed select
 if (changedValue != null){
  if (changedValue != ""){
   assocSel.disabled = false;
   var optionValues = changedToAssoc[changedValue];//lookup list of associated option values for value of changed select
  } else{
   assocSel.disabled = true;
   optionValues = "";
  }//end not empty if
  setOptions(assocSel, optionValues, assocText);
 }//end not null if
}//end function
function setOptions(select, optionValues, optionText, selectValue){
 select.options.length = 1;//clears the existing options except label
 var j = 0;
 for (var i=0; i < optionValues.length; i++){//build options
  j = i + 1;//increment option counter - since we always leave default 'select a whatever' message in list
  select.options[j] = new Option(optionText[optionValues[i]],optionValues[i]);
  if (selectValue != null && selectValue == select.options[j].value){//if the previous selected value is still in list preserve the selection
   select.options[j].selected = true;
  }//end previous selected value if
 }//end option loop
}
function isWhite(ch){
 //utility method to determine if a character in a string is whitespace / blank
 var white;
  white = " \t\n\r";
 return (white.indexOf(ch) != -1);
}
function disableControl(controlId){
 //controlId is a space delimited list of form control id(s) -
 //each control passed in should have a unique "id" attribute within their tag (should be same value as name tag)
 var items, count, index;
  items = [];
  count = 0;
  doAction = new String();
 while (controlId != ""){
  index = 0;
  while (index < controlId.length && isWhite(controlId.charAt(index))){
   index++;
  }
  if (index < controlId.length){
   var item = "";
   while (index < controlId.length && !isWhite(controlId.charAt(index))){
    item += controlId.charAt(index);
    index++;
   }
   items[count] = item
   count++;
  }
  controlId = controlId.substring(index+1, controlId.length);
  document.getElementById(item).disabled = true;
 }
 return items;
}
function enableControl(controlId){
 //controlId is a space delimited list of form control id(s) -
 //each control passed in should have a unique "id" attribute within their tag (should be same value as name tag)
 var items, count, index;
  items = [];
  count = 0;
 while (controlId != ""){
  index = 0;
  while (index < controlId.length && isWhite(controlId.charAt(index))){
   index++;
  }
  if (index < controlId.length){
   var item = "";
   while (index < controlId.length && !isWhite(controlId.charAt(index))){
    item += controlId.charAt(index);
    index++;
   }
   items[count] = item
   count++;
  }
  controlId = controlId.substring(index+1, controlId.length);
  document.getElementById(item).disabled = false;
 }
 return items;
}
function openWin(winurl,winname,w,h,features){ //link values: URL,Name,Width,Height,Features
 var win = null;
 var winl = (screen.width-w)/2;
 var wint = (screen.height-h)/2;
 if (winl < 0) winl = 0;
 if (wint < 0) wint = 0;
 var settings = 'height=' + h + ',';
 settings += 'width=' + w + ',';
 settings += 'top=' + wint + ',';
 settings += 'left=' + winl + ',';
 settings += features; //Features are: resizable,scrollbars,status,toolbar
 win = window.open(winurl,winname,settings);
 win.window.focus();
}
function setSubmitFocus(e,form,act,target){
 var key=e.keyCode || e.which;
 if (key==13){
  form.target = target;
  document.forms[0].action = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
  document.forms[0].submit();
  return true;
 }
}
function setSubmitFocusExplicit(e,frmName,act,target){
 var key=e.keyCode || e.which;
 if (key==13){
  document[frmName].target = target;
  document[frmName].action = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
  document[frmName].submit();
  return true;
 }
}
function setSubmitFocusExplicitHomePage(e,frmName,act,target,url){
 var key=e.keyCode || e.which;
 if (key==13){
  document[frmName].target = target;
  document[frmName].action = url +'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
  document[frmName].submit();
  return true;
 }
}
function setInputFocus(formName,formField){
 var myAction = 'document.' + formName + ' . ' + formField + ' . ' + ' focus();';
 eval(myAction);
}
function printFrame(frameName){
 frames[frameName].focus();
 frames[frameName].print();
}
function switchActionSubmitExplicit(frmName,act){
 document[frmName].action = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
 document[frmName].submit();
 return true;
}
function redirectLocation(locUrl){
 location.href = locUrl;
 return true;
}
function outboundSubmitExplicit(frmName,act){
 document[frmName].action = act;
 document[frmName].submit();
 return true;
}
function outboundSubmitExplicitTarget(frmName,act,target){
 document[frmName].target = target;
 document[frmName].action = act;
 document[frmName].submit();
 return true;
}
function setAssocLists(optIdx,tarObj,jsList,jsDel){
 var jsListArr = new Array(1);
 jsListArr = jsList.split(jsDel);
 tarObj.value = jsListArr[optIdx];
}
function changeValue(isChecked,sourceElement,targetElement){
 targetElement.value = "";
 if (isChecked){
  targetElement.value = sourceElement.value;
 }
}
function anchorNoResubmit (formIDName,anchorIDName) {
 if (document.getElementById) {
  var clickedOnce = 1;
  document.getElementById(anchorIDName).onclick = function() {
  if (clickedOnce==1) {
   return false;
  }
  clickedOnce=1;
  document.getElementById(formIDName).submit();
  };
 }
}
function changeValueLists(isChecked,srcForm,targetFormList,srcFieldName,targetFieldName){
 var items, count, index;
 items = [];
 count = 0;
 while (targetFormList != ""){
  index = 0;
  while (index < targetFormList.length && isWhite(targetFormList.charAt(index))){
   index++;
  }
  if (index < targetFormList.length){
   var item = "";
   while (index < targetFormList.length && !isWhite(targetFormList.charAt(index))){
    item += targetFormList.charAt(index);
    index++;
   }
   items[count] = item;
   count++;
  }
  targetFormList = targetFormList.substring(index+1, targetFormList.length);
  if(isChecked != "" || isChecked){
   document.forms[item][targetFieldName].value = document.forms[srcForm][srcFieldName].value;
  }
 }
 return items;
}
function initializeTimer(func,secs){
 var timer=setTimeout(func,secs*1000);
}
function setWindowStatusBar(value) {
 window.status=value;
}
function printWin() {
 window.print();
}
function closeWin() {
 window.close();
}
function languageSwitch(outboundURL,language) {
 if(language=="SPA"){
  location.href = outboundURL;
 }
 else{
   document.forms[0].submit()
 }
 return true;
}
function goDirection(act){
 var act = (typeof(act) == "undefined" || act == null) ? -1 : act;
 history.go(act);
}
function analyticDownloadTracking(rsid,obj,linkName,linkType){
 var s=s_gi(rsid);
 var linkType = (typeof(linkType) == "undefined" || linkType == null) ? 'd' : linkType;
 s.tl(obj,linkType,linkName);
}
function switchFormActionSubmitExplicit(form,act){
 document[form].action = act;
 document[form].submit();
 return true;
}
function selectAll(obj, chkBox){
 for(var i = 0; i < obj.form.length; i++){
  if(obj.form[i].type == 'checkbox' && obj.form[i].name == chkBox){
   obj.form[i].checked = obj.checked;
  }
 }
}
function getSelectedValue(frmField){
 return document.getElementById(frmField).value;
}
function switchClass(idList, className){
 var id = idList.split(",");
 var len = id.length;
 for(i = 0; i < len; i++){
  document.getElementById(id[i]).className = className;
 }
}
function resizeVerticalClassExplicit(id, className, rate, curHeight, tgtSize){
 if(tgtSize < 0 || rate <= 0){
  return false;
 }
 if(!curHeight && !tgtSize){
  curHeight = document.getElementById(id).offsetHeight;
  document.getElementById(id).className = className;
  document.getElementById(id).style.height = "";
  tgtSize = document.getElementById(id).offsetHeight;
  document.getElementById(id).style.height = curHeight + "px";
 }
 if(curHeight < tgtSize){
  curHeight += rate;
  if(curHeight > tgtSize){
   curHeight = tgtSize;
  }
 }
 else if(curHeight > tgtSize){
  curHeight -= rate;
  if(curHeight < tgtSize){
   curHeight = tgtSize;
  }
 }
 document.getElementById(id).style.height = curHeight + "px";
 if(curHeight != tgtSize){
  setTimeout("resizeVerticalClassExplicit('" + id + "', '" + className + "', " + rate + ", " + curHeight + ", " + tgtSize + ");", 30);
 }
 return true;
}
function copyValue(frm1, frm2) {
 if(document.getElementById(frm1)){
  var frm1Value = document.getElementById(frm1).value;
  var frm2Value = document.getElementById(frm2);
  if(frm1Value == frm2Value.value){
   frm2Value.value = "";
  }
  else{
   frm2Value.value = frm1Value;
  }
 }
}
function setAssocListsCompare(optIdx, tarObj, tarObj1, jsList, jsDel, str){
 var jsListArr = jsList.split(jsDel);
 tarObj.value = jsListArr[optIdx];
 tarObj1.value = "";
 if(jsListArr[optIdx] == str){
  tarObj1.value = jsListArr[optIdx];
 }
}
function changeElementValue(targetElement, targetValue){
 targetElement.value = targetValue;
}
function outboundExplicitTarget(frmName,act,target){
 document[frmName].target = target;
 document[frmName].action = act;
 return true;
}
function toggleBtnState(btnID, btnClass1, btnClass2, divID, divClass1, divClass2){
 var btnClass = btnClass1;
 var divClass = divClass1;
 if(document.getElementById(btnID).className == btnClass1){
  btnClass = btnClass2;
  divClass = divClass2;
 }
 switchClass(btnID, btnClass);
 if(divID){
  switchClass(divID, divClass);
 }
}
function toggleDisplay(divId){
 var div = document.getElementById(divId);
 div.style.display = (div.style.display=="block" ? "none" : "block");
}
function switchVariableValueExplicit(frm, target, newValue){
 document[frm][target].value = newValue;
}
function switchActionTargetSubmit(frm, act, target){
 document[frm].action = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
 document[frm].target = target;
 document[frm].submit();
 return true;
}
function clearForm(fieldName, defaultValue){
 if(fieldName.value == defaultValue){
  fieldName.value = "";
 }
}
function checkFormBlur(fieldName, defaultValue){
 if(fieldName.value == ""){
  fieldName.value = defaultValue;
 }
}
function outboundExplicitTargetMultiSelect(selVal, del){
 var a = selVal.split('' + del + '');
 var frmName = a[0];
 var act = a[1];
 var target = a[2];
 document[frmName].target = target;
 document[frmName].action = act;
 return true;
}
function closeWinParentSubmit(frmName, act){
 try{
  if(window.opener.document[frmName]){
   window.opener.document[frmName].action = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
   window.opener.document[frmName].submit();
   this.close();
   return true;
  }
  return false;
 }
 catch(e){
  return false;
 }
}
function getBannerURL(bUrl, siteType){
 var bannerUrl = decodeURIComponent(unescape(bUrl));
 var redirPrepend = "index.cfm?action=main.wpPartnerAnon&reDirectUrl=";
 var thickBoxParam = "&TB_iframe&height=275&width=615";
 var redirectUrl = "";
 var showLogInPrompt = document.forms.banners.showLogInPrompt.value;
 var baseURL = "http://spa.marketamerica.com/enes/"
 var portalID = document.forms.banners.portID.value;
 var redirGateway = bannerUrl.split("&gatewayUrl=");
 redirGateway = redirGateway[0] + "&gatewayUrl=";
 if(portalID.length > 0){
  portalID = portalID + "/";
 }
 if(siteType == 'EP'){
  redirGateway = "";
  if(showLogInPrompt == "0"){
   redirGateway = "index.cfm?action=gateway.redirectGatewayEP&gatewayUrl=";
  }
  redirPrepend = "index.cfm?action=main.epPartnerAnon&reDirectUrl=";
  thickBoxParam = "&TB_iframe&height=300&width=600";
 }
 bannerUrl = bannerUrl.replace(redirGateway, "");
 if(showLogInPrompt == "1"){
  redirectUrl = baseURL + portalID + redirPrepend + encodeURIComponent(redirGateway) + encodeURIComponent(bannerUrl) + thickBoxParam;
  tb_show("", redirectUrl, false);
 }
 else{
  redirectUrl = baseURL + portalID + redirGateway + encodeURIComponent(bannerUrl);
  window.open(redirectUrl);
 }
}
function getBannerMA(bUrl){
 var bannerUrl = "";
 var baseURL = "http://spa.marketamerica.com/enes/"
 var portalID = document.forms.banners.portID.value;
 if(portalID.length > 0){
  portalID = portalID + "/";
 }
 bannerUrl = baseURL + portalID + bUrl;
 window.location = bannerUrl;
}

function resizeVerticalClass(className, frm, fld){
 var id = document[frm][fld].value;
 var rate = 30;
 resizeVerticalClassExplicit(id, className, rate);
 return true;
}
function validateFormSubmitExplicit(form, act, fldName, validation, errID){
 var fieldArray = new Array();
 var validType = validation;
 var numRE = /^\d+$/;
 var actType = /^[A-Za-z]+\.[A-Za-z]+/;
 var testValid = 0;
 var i = 0;
 fieldArray = fldName.split(",");
 if(validType == "num"){
  for(i = 0; i < fieldArray.length; i++){
   fieldToValidate = document[form][fieldArray[i]].value;
   if(fieldToValidate.length){
    testValid = numRE.exec(fieldToValidate) && fieldToValidate != 0;
    if(testValid == null){
     break;
    }
   }
  }
 }
 if(testValid){
  if(actType.exec(act)){
   act = 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=' + act;
  }
  document[form].action = act;
  document[form].submit();
  return true;
 }
 else{
  document.getElementById(errID).style.display = "inline";
  document.getElementById(errID).focus;
  return false;
 }
}
function validateInputOnReturn(form, fldName, validation, errID, keyEvent){
 var fieldArray = new Array();
 var validType = validation;
 var numRE = /^\d+$/;
 var testValid = 0;
 var i = 0;
 if((keyEvent.keyCode == 13) || (keyEvent.keyCode == 10)){
  fieldArray = fldName.split(",");
  if(validType == "num"){
   for(i = 0; i < fieldArray.length; i++){
    fieldToValidate = document[form][fieldArray[i]].value;
    if(fieldToValidate.length){
     testValid = numRE.exec(fieldToValidate) && fieldToValidate != 0;
     if(testValid == null){
      break;
     }
    }
   }
  }
  if(testValid){
   document[form].submit();
   return true;
  }
  else{
   document.getElementById(errID).style.display = "inline";
   document.getElementById(errID).focus;
   return false;
  }
 }
}
function getFormFieldValueExplicit(frmName, fldName){
 return document[frmName][fldName].value
}
function checkUncheckAll(form, field, value) {
 if (!document.forms[form]) {
  return;
 }
 var checkBoxes = document.forms[form].elements[field];
 if (!checkBoxes) {
  return;
 }
 var countBoxes = checkBoxes.length;
 if (!countBoxes) {
  checkBoxes.checked = value;
 }
 for (var i = 0; i < countBoxes; i++) {
  checkBoxes[i].checked = value;
 }
}
function getSelectedIndexValue(frm, frmField){
 if(document[frm][frmField].selectedIndex != -1 && document[frm][frmField].options != null){
  return document[frm][frmField].options[document[frm][frmField].selectedIndex].value;
 }
 else{
  return "";
 }
}
function disableElementEvent(elemId, elemEvent){
 var elem = document.getElementById(elemId);
 var validEvents = "onclick,onchange,onfocus";
 var eventCollection = validEvents.split(",");
 for(var i = 0; i < eventCollection.length; i++){
  if(eventCollection[i] == elemEvent){
   elem[elemEvent] = "";
   return true;
  }
 }
 return false;
}
function toggleControls(frm, controls, attrib, delim){
  var attrib = (typeof(attrib) == "undefined" || attrib == null) ? "disabled" : attrib == "readonly" ? "readOnly" : "disabled";
  var delim = (typeof(delim) == "undefined" || delim == null) ? "," : delim;
  var objs = controls.split(delim);
  for(var i = 0; i < objs.length; i++){
   document[frm][objs[i]][attrib] = document[frm][objs[i]][attrib] == false ? true : false;
  }
 }
function mutualExclDisable(selectedVal, val1, val2, controlIds1, controlIds2){
 if(selectedVal == val1){
  enableControl(controlIds1);
  disableControl(controlIds2);
 }
 else if(selectedVal == val2){
  enableControl(controlIds2);
  disableControl(controlIds1);
 }
}
function setAssocListsCheckbox(optIdx, tarObj1, jsList1, jsDel1, tarObj2, jsList2, jsDel2){
 var jsListArr1 = new Array(1);
 var jsListArr2 = new Array(1);
 jsListArr1 = jsList1.split(jsDel1);
 tarObj1.value = jsListArr1[optIdx];
 jsListArr2 = jsList2.split(jsDel2);
 tarObj2.checked = "";
 if(jsListArr2[optIdx] == 1){
  tarObj2.checked = jsListArr2[optIdx];
 }
}
function switchFieldValue(idField, tagField, field){
 document.getElementById(idField).setAttribute(tagField, field);
}
function getCheckedValues(frm, frmField){
 var checkBoxes = document.forms[frm].elements[frmField];
 var checkVal = "";
 if(checkBoxes.length > 0){
  for(var i=0; i < checkBoxes.length; i++){
   if(checkBoxes[i].checked){
    checkVal = checkVal + checkBoxes[i].value + ",";
   }
  }
  if(checkVal.length = 0){
   checkVal = " ";
  }
  checkVal = checkVal.substring(0, checkVal.length -1);
 }
 else{
  checkVal = checkBoxes.value;
 }
 return checkVal;
}
function jsSafeGetSelectedValue(frmField){
 return escape(document.getElementById(frmField).value);
}
function validateFormFunctionCall(form, act, fldName, validation, errID){
 var fieldArray = new Array();
 var validType = validation;
 var alphaRE = /.+/;
 var numRE = /^\d+$/;
 var testValid = 0;
 var idValid = document.getElementById(errID);
 var i = 0;
 fieldArray = fldName.split(",");
 if(validType == "num"){
  for(i = 0; i < fieldArray.length; i++){
   fieldToValidate = document[form][fieldArray[i]].value;
   if(fieldToValidate.length){
    testValid = numRE.exec(fieldToValidate) && fieldToValidate != 0;
    if(testValid == null){
     break;
    }
   }
   else{
    testValid = 0;
    break;
   }
  }
 }
 if(validType == "alpha"){
  for(i = 0; i < fieldArray.length; i++){
   fieldToValidate = document[form][fieldArray[i]].value;
   if(fieldToValidate.length){
    testValid = alphaRE.exec(fieldToValidate) && fieldToValidate != 0;
    if(testValid == null){
     break;
    }
   }
   else{
    testValid = 0;
    break;
   }
  }
 }
 if(testValid){
  setTimeout(act, 1);
 }
 else{
  if(idValid == null){
   setTimeout(errID, 1);
  }
  else{
   idValid.style.display = "inline";
   idValid.focus;
   return false;
  }
 }
}
function mobileTabsToggle(parentDivId, tabDivId){
 var divs = document.getElementById(parentDivId).getElementsByTagName('div');
 var divsLen = divs.length;
 var prodName = "";
 for(var x = 0; x < divsLen; x++){
  prodName = divs[x].id;
  if(prodName == tabDivId){
   divs[x].style.display = "block";
  }
  else{
   if(prodName.lastIndexOf("prod") == 0 && prodName.lastIndexOf("1") != -1){
    divs[x].style.display = "none";
   }
  }
 }
}
function printIFrame(){
 try{
  document.execCommand('print', false, null);
 }
 catch(e){
  window.print();
 }
}
function getCustLandAFURL(afUrl, siteType, hasCashBack, omcmp){
 var redirGateway = (omcmp.length > 0) ? 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=gateway.redirectGateway&omcmp=' + omcmp + '&affiliateURL=' : 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=gateway.redirectGateway&affiliateURL=';
 var redirPrepend = (omcmp.length > 0) ? 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=main.wpPartnerAnon&omcmp=' + omcmp + '&affiliateURL=' : 'http://es.unfranchise.com/enes/sdmy/dunfranchise/lib/js/index.cfm?action=main.wpPartnerAnon&affiliateURL=';
 var thickBoxParam = '&TB_iframe&height=275&width=605';
 var hasCashBack = (hasCashBack == '1' || hasCashBack == 1) ? 1 : 0;
 var redirectUrl = baseURL + portID + '/';
 if(isSiteBranded == 1 || (isLoggedIn == 0 && hasCashBack == 1)){
  redirectUrl += redirPrepend + afUrl + thickBoxParam;
  tb_show("", redirectUrl, false);
 }
 else{
  redirectUrl += redirGateway + afUrl;
  window.open(redirectUrl);
 }
}