  var drawerLoaded = "rfpdrawer"; //specify drawer to toggle
  var drawerStatus = 0; //specify status of drawer
  
  function signalBack(signalData) {
    if (signalData) {
      new Ajax.Request(
        '/tk/sb.aspx',
        {
          method: 'get',
          parameters: 'url='+escape(window.location.href)+'&data='+escape(signalData)
        }
      )
    }
  }
  
  function changeParam(paramName,paramValue) {
    if (paramName && paramValue) {
      new Ajax.Request(
        '/tk/cp.aspx',
        {
          method: 'get',
          parameters: 'param='+escape(paramName)+'&val='+escape(paramValue)
        }
      )
    }
  }
  
  function drawerToggle () {
    if (drawerStatus == 0) {
      //open drawer
      new Effect.SlideDown(drawerLoaded, {queue:{position:'end',scope:'drawer'},scaleContent:false,duration:.75});
      drawerStatus = 1;
    } else if (drawerStatus == 1) {
      //close drawer
      new Effect.SlideUp(drawerLoaded, {queue:{position:'end',scope:'drawer'},scaleContent:false,duration:.75});
      drawerStatus = 0;
    }
    return false;
  }
  
  function drawerOpen(drawerSpec) {
    if (drawerStatus == 0) {
      // set drawer to correct contents, toggle to open
      drawerLoaded = drawerSpec;
      drawerToggle();
    } else if (drawerStatus == 1 && drawerLoaded != drawerSpec) {
      // close drawer, switch contents, toggle open
      drawerToggle();
      drawerLoaded = drawerSpec;
      setTimeout("drawerToggle()",850);
    } // other option is for correct drawer to be open.
  }
  
  function actionOver (actionElement) {
    $(actionElement).className += " over";
  }
  function actionOut (actionElement) {
    $(actionElement).className = "";
  }
  
  function imageSwap (imgObj, imgSrc) {
    imgObj.src = imgSrc;
  }
  
  function formNumberValidation (formField) {
    allowedChars = "0123456789.,-";
    tmpValue = "";
    for (i = 0; i < formField.value.length; i++) {
      if (allowedChars.indexOf(formField.value.charAt(i)) != -1) {
        tmpValue = tmpValue + formField.value.charAt(i);
      }
    }
    if (tmpValue != formField.value) {
      new Effect.Appear(formField.name+"_no");
      formField.value = tmpValue;
    }
  }
  
  function formValidateEmail (formField) {
    allowedChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@.-_";
    tmpValue = "";
    isValid = 0;
    for (i = 0; i < formField.value.length; i++) {
      if (allowedChars.indexOf(formField.value.charAt(i)) != -1) {
        tmpValue = tmpValue + formField.value.charAt(i);
      }
    }
    if (tmpValue != formField.value) {
      formField.value = tmpValue;
    }
    if (tmpValue.indexOf("@") > -1 && tmpValue.indexOf(".") > -1) {
      isValid = 1;
    }
    return isValid
  }
  
  function formValidateCue() {
    valid = 0;
    if (document.contact.name.value.length > 3) {
      valid = valid + 1;
    }
    if (document.contact.firm.value.length > 3) {
        valid = valid + 1;
    }
    if (formValidateEmail(document.contact.email) == 1) {
      valid = valid + 1;
    }
    if (document.contact.regarding.value.length > 0 ) {
        valid = valid + 1;
    }
    if (valid < 4) {
      document.contact.btnsend.disabled = true;
    } else {
      document.contact.btnsend.disabled = false;
    }
    
  }
  
  function markTime (timeSet,scope) {
    eval("curSet = document."+scope+".times.value;");
    if (curSet == "") {
      $(scope+"time"+timeSet).className = "active";
      curSet = timeSet;
    } else {
      if (curSet.indexOf(timeSet) > -1) {
        $(scope+"time"+timeSet).className = "";
        curSet = curSet.replace(timeSet,"");
      } else {
        $(scope+"time"+timeSet).className = "active";
        curSet = curSet + "," + timeSet;
      }
      curSet = curSet.replace(",,",",");
    }
    eval("document."+scope+".times.value = curSet;");
  }
  
  function loginPopup() {
    $('pu_login').style.top='0px';
    new Effect.Parallel(
      [
        new Effect.MoveBy('pu_login',100,0,{sync:true}),
        new Effect.Appear('pu_login',{sync:true})
      ], {duration:0.75}
    );
  }
  function loginPopout() {
    signalBack("diss_login");
    document.login.txtUserId.value = "";
    document.login.txtPassword.value = "";
    new Effect.DropOut('pu_login', {queue: {position:'end',scope:'popout'}});
  }
  function loginExecute() {
    if (document.login.txtUserId.value == "") {
      window.alert("Please enter your Orion User ID.");
      document.login.txtUserId.focus();
    } else if (document.login.txtPassword.value == "") {
      window.alert("Please enter your Orion Password.");
      document.login.txtPassword.focus();
    } else {
      document.login.submit();
    }
  }
  
  function preloadRFP () {
    //if drawer is open, execute close
    if (drawerStatus == 1) {
      new Effect.SlideUp(drawerLoaded, {queue:{position:'end',scope:'drawer'},scaleContent:false,duration:.75});
      drawerStatus = 0;
    }
    changeParam("rfp","1");
    
    new Ajax.Updater("rfpdc", "/tk/rfp.aspx", {asynchronous:true,evalScripts:true,onComplete: preloadRFPComplete,parameters:Form.serialize(document.rfp)});
  }
  function preloadRFPComplete (req) {
    $("rfpdc").innerHTML = req.responseText;
    setTimeout("drawerOpen(\"rfpdrawer\");",1200);
    setTimeout("new Effect.Fade('rfpResume');",1200);
  }
  function cancelRFP () {
    if (drawerStatus == 1) {
      //close drawer
      new Effect.SlideUp(drawerLoaded, {scaleContent:false,duration:.75});
      drawerStatus = 0;
      new Effect.Appear('rfpResume');
      setTimeout("new Effect.Appear('pu_rfp_reminder')",1000);
      setTimeout("new Effect.Fade('pu_rfp_reminder')",9000);
    }
    return false;
  }
  function executeRFP (execMode) {
    if (execMode == "quick") {
      $("dc_step_cancel").style.color = "#AAA";
      $("dc_step_cancel").innerHTML = "Cancel";
      $("dc_step_next").style.color = "#AAA";
      $("dc_step_next").innerHTML = "Next Step";
      // write changes & request new pane
      new Ajax.Updater('rfpdc', '/tk/rfp.aspx', {asynchronous:true,evalScripts:true,parameters:Form.serialize(document.rfp)});
    } else {
      new Effect.Appear('dc_form_loading');
      $("dc_step_cancel").style.color = "#AAA";
      $("dc_step_cancel").innerHTML = "Cancel";
      $("dc_step_next").style.color = "#AAA";
      $("dc_step_next").innerHTML = "Next Step";
      // write changes & request new pane
      setTimeout("new Ajax.Updater('rfpdc', '/tk/rfp.aspx', {asynchronous:true,evalScripts:true,parameters:Form.serialize(document.rfp)});",1500);
    }
  }
  
  function preloadCall () {
    signalBack("clk_next_call");
    if (drawerStatus == 1) {
      new Effect.SlideUp(drawerLoaded, {queue:{position:'end',scope:'drawer'},scaleContent:false,duration:.75});
      drawerStatus = 0;
    }
    new Ajax.Updater("calldc", "/tk/call.aspx", {asynchronous:true,evalScripts:true,onComplete: preloadCallComplete});
  }
  function preloadCallComplete (req) {
    $("calldc").innerHTML = req.responseText;
    setTimeout("drawerOpen(\"calldrawer\");",300);
  }
  
  function executeCall () {
    if (document.call.name.value == "") {
      window.alert("Please enter your name.");
      document.call.name.focus();
    } else if (document.call.phone.value == "") {
      window.alert("Please enter your phone number.");
      document.call.phone.focus();
  } else if (document.call.firm.value == "") {
  window.alert("Please enter your firm's name.");
  document.call.firm.focus();
    } else if (document.call.times.value == "") {
      window.alert("Please select at least one time for your call.");
    } else {
      new Effect.Appear('dc_call_loading');
      $("dc_call_cancel").style.color = "#AAA";
      $("dc_call_cancel").innerHTML = "Cancel";
      $("dc_call_submit").style.color = "#AAA";
      $("dc_call_submit").innerHTML = "Request Call";
      // write changes & request new pane
      setTimeout("new Ajax.Updater('calldc', '/tk/call.aspx', {asynchronous:true,evalScripts:true,parameters:Form.serialize(document.call)});",1500);
    }
  }
  
  function preloadDemo () {
    signalBack("clk_next_demo");
    if (drawerStatus == 1) {
      new Effect.SlideUp(drawerLoaded, {queue:{position:'end',scope:'drawer'},scaleContent:false,duration:.75});
      drawerStatus = 0;
    }
    new Ajax.Updater("demodc", "/tk/demo.aspx", {asynchronous:true,evalScripts:true,onComplete: preloadDemoComplete});
  }
  function preloadDemoComplete (req) {
    $("demodc").innerHTML = req.responseText;
    setTimeout("drawerOpen(\"demodrawer\");",300);
  }
  function executeDemo () {
    if (document.demo.name.value == "") {
      window.alert("Please enter your name.");
      document.demo.name.focus();
    } else if (document.demo.phone.value == "") {
      window.alert("Please enter your phone number.");
      document.demo.phone.focus();
    } else if (document.demo.email.value == "") {
      window.alert("Please enter your email address.");
      document.demo.email.focus();
    } else if (formValidateEmail(document.demo.email) == 0) {
      window.alert("Please enter a valid email address.");
      document.demo.email.focus();
    } else if (document.demo.times.value == "") {
      window.alert("Please select at least one time for your call.");
    } else {
      new Effect.Appear('dc_demo_loading');
      $("dc_demo_cancel").style.color = "#AAA";
      $("dc_demo_cancel").innerHTML = "Cancel";
      $("dc_demo_submit").style.color = "#AAA";
      $("dc_demo_submit").innerHTML = "Schedule Demo";
      // write changes & request new pane
      setTimeout("new Ajax.Updater('demodc', '/tk/demo.aspx', {asynchronous:true,evalScripts:true,parameters:Form.serialize(document.demo)});",1500);
    }
  }
  
  function executePuPtc (action) {
    if (action == "popup") {
      if (drawerStatus == 0) {
        new Effect.MoveBy('pu_ptc',400,0,{duration: 2.5});
      }
    } else if (action == "popout") {
      signalBack("pu_ptc_diss");
      changeParam("ptc","0");
      new Effect.MoveBy('pu_ptc',-400,0,{duration: .75});
    } else if (action == "docall") {
      signalBack("pu_ptc_clk_call");
      changeParam("ptc","0");
      new Effect.MoveBy('pu_ptc',-400,0,{duration: .75, afterFinish: preloadCall()});
      preloadCall();
    } else if (action == "dodemo") {
      signalBack("pu_ptc_clk_demo");
      changeParam("ptc","0");
      new Effect.MoveBy('pu_ptc',-400,0,{duration: .75, afterFinish: preloadDemo()});
    }
  }
  
  function externalLink (url) {
    confirmText = "Clicking this link will take you to a third-party web site.  This link is provided solely as a convenience to you and not as an endorsement by Orion Advisor Services, LLC of the content on this third-party web site, or any affiliation or association with its operators. We are not responsible for the content of linked third-party site, including, without limitation any link contained in a linked site, or any changes or updates to a linked site, and do not make any representations regarding the information, services, products or accuracy of any material contained on this third-party site.\n\nClick OK to continue to " + url + ".";
    if (window.confirm(confirmText)) {
      signalBack("clk_extlink_" + url);
      window.open("http://"+url,"_blank");
    }
  }
  
  function blogMore (bID) {
    $("postmore" + bID).style.display = "none";
    $("postless" + bID).style.display = "block";
    new Effect.BlindDown("postjump" + bID);
  }
  
  function blogLess (bID) {
    $("postless" + bID).style.display = "none";
    $("postmore" + bID).style.display = "block";
    new Effect.BlindUp("postjump" + bID);
  }