﻿//$(document).ready(loadShortcuts);

// disabled on 2/11 (see above)
/*
function loadShortcuts() {
    $(document).bind('keydown', 'alt+k', doSearchBox);
    $(document).bind('keydown', 'esc', killSearchBox);

    $('#dialogSearchWord').keyup(function(e) {
        //alert(e.keyCode);
        if (e.keyCode == 13) {
            //alert('Enter key was pressed.');
            //document.location.href='http://google.com';
            doSearch(document.getElementById('dialogSearchWord').value());
        }
    });
}
// was going to load the dialog box, but it's not active now
function doSearchBox() {
    //alert($("#dialogSearch").dialog('isOpen'));
    if (!$("#dialogSearch").dialog('isOpen')) {
        //alert('creating')
        $("#dialogSearch").dialog({
            bgiframe: true,
            height: 75,
            modal: true
        });
        $("#dialogSearch").dialog("open");
        $("#dialogSearchWord").val("").focus().css("background-color", "red");
    }

}

function killSearchBox() {
    //alert('escape');
    $("#dialogSearch").dialog("close");
}
*/

function parseAutoCompleteValue(target) {
    var val = String(target.value)
    var whitespaceIndex = Number(val.indexOf(" "));

    if (whitespaceIndex > -1 && val.length > 0) {
        //alert("going to parse now");
        var newVal = val.substring(0, whitespaceIndex);
        //alert("new value will be " + newVal);
        target.value = newVal;
    }
    else {
        //alert("Error Parsing Auto-Complete Value - please contact 270net");
        return target;
    }
}

function doSearch() {
    var kw = $("#txtQuery").val();
  
    var memberTypeId = $(".lstMemberTypeId :selected").val();
    var userStatusId = $(".lstUserStatusId :selected").val();
    var memberRegionId = $(".lstMemberRegionId :selected").val();
    var billingStatusId = $(".lstBillingStatusId :selected").val();

    //alert(memTypeId);

    window.location.href = "default.aspx?q=" + kw + "&membertypeid=" + memberTypeId + "&userstatusid=" + userStatusId + "&memberregionid=" + memberRegionId + "&billingstatusid=" + billingStatusId;
}

/* profile update stuff */
function switchPostalContainer(src) {
    //src is the command div tag.  let's figure out which index he is of all the cmd containers

    // reset both command and postal containers to their normal css state
    $(".addrCmd").removeClass("addrCmdSelected");
    $(".addrContainer").removeClass("addrContainerHighlighted");

    // the element passed into the function add additionally gets the cmdSelected class
    $(src).addClass("addrCmdSelected");

    // postal section commands should always equal the number of postall address containers (e.g. 4 cmds on left, 4 containers on right w/ diff addrs)
    // find the index of selected element in our collection of commands, get a reference, then add the highlighted class to the correct postal container
    var clickedIndex = $(".addrCmd").index(src);
    var targEle = $(".addrContainer").get(clickedIndex);
    $(targEle).addClass("addrContainerHighlighted");
}

function toggleEnabledStatus(src, targetContainer) {

    //alert(src.id);
    var selector = "#" + src.id + ":checked";
    //alert(selector);
    //alert($(selector).hide());

    if ($(selector).val() == null) {
        // enable all (show form)
        //alert('not checked - id = ' + targetContainer);

        ////$("#" + targetContainer + " input").attr("disabled", "");
        ////$("#" + targetContainer + " select").attr("disabled", "");
        $("#" + targetContainer).css("visibility", "visible");
    }
    else {
        // disable all children (hide form)
        //alert('checked - id = ' + targetContainer);
        ////$("#" + targetContainer + " input").attr("disabled", "disabled");
        ////$("#" + targetContainer + " select").attr("disabled", "disabled");
        $("#" + targetContainer).css("visibility", "hidden");
    }
}

function setupScreenName(lname, fname, nickname) {
    if ($("#" + nickname).val() == "") {
        // auto fill
        $("#" + nickname).val($("#" + fname).val() + '.' + $("#" + lname).val());
    }
}


/* end profile update stuff */

/* global help icon widget */
$(document).ready(function() {
    // get keyword text from data source
    //var tip = getKeywordText($(this), kw);
    // Create content using url as base
    
    $(".helpIcon").qtip(
                  {
                      //content: { text: 'loading...', url: "/modules/keywordlookup/getkeyword.ashx", data: { k: kw} },
                      show: 'mouseover',
                      hide: 'mouseout',
                      position: {
                          corner: {
                              target: 'topRight',
                              tooltip: 'bottomLeft'
                          }
                      },
                      style: {
                          tip: 'bottomLeft',
                          width: 450,
                          name: 'light', // Inherit from preset style
                          border: {
                              width: 2,
                              radius: 3,
                              color: '#185184'
                          }
                      }
                  }
                  );
});

/* end help icon widget */

// 1/12/10 FYI all these qtip hooks have a ugly loading text string to help with an IE 8 issue where the content doesnt get resized properly
// qtip does not have a release yet and i tried the latest /trunk file but it doesnt work properly
$(document).ready(function() {
    // get keyword text from data source
    //var tip = getKeywordText($(this), kw);
    // Create content using url as base
    //var kw = jQuery.trim($(this).html());
    $(".popupPayDistro").each(function() {
        $(this).qtip(
                  {
                      content: { text: 'loading... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...', url: "/modules/billingsystem/render.ashx", data: { c: 'payDistro', i: $(this).attr('title')} },
                      show: { when: 'click', solo: true },
                      hide: 'click',
                      position: {
                          corner: {
                              target: 'topMiddle',
                              tooltip: 'bottomMiddlet'
                          }
                      },
                      style: {
                          tip: 'bottomMiddle',
                          width: 'auto',
                          name: 'light', // Inherit from preset style
                          border: {
                              width: 2,
                              radius: 3,
                              color: '#185184'
                          }
                      }
                  }
                  );
                  // turn off href if we get this far
                  $(this).attr("href", "javascript:void (0)");
                  $(this).attr("target", "_self");
              });

   $(".popupCredDistro").each(function() {
                  $(this).qtip(
                  {
                      content: { text: 'loading... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...', url: "/modules/billingsystem/render.ashx", data: { c: 'credDistro', i: $(this).attr('title')} },
                      show: { when: 'click', solo: true },
                      hide: 'click',
                      position: {
                          corner: {
                              target: 'topMiddle',
                              tooltip: 'bottomMiddlet'
                          }
                      },
                      style: {
                          tip: 'bottomMiddle',
                          width: 'auto',
                          name: 'light', // Inherit from preset style
                          border: {
                              width: 2,
                              radius: 3,
                              color: '#185184'
                          }
                      }
                  }
                  );
                  // turn off href if we get this far
                  $(this).attr("href", "javascript:void (0)");
                  $(this).attr("target", "_self");
              });

       $(".popupInvoiceItem").each(function() {
                  $(this).qtip(
                  {
                      content: { text: 'loading... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...', url: "/modules/billingsystem/render.ashx", data: { c: 'invItemPayoff', i: $(this).attr('title')} },
                      show: { when: 'click', solo: true },
                      hide: 'click',
                      position: {
                          corner: {
                              target: 'topMiddle',
                              tooltip: 'bottomMiddlet'
                          }
                      },
                      style: {
                          tip: 'bottomMiddle',
                          width: 'auto',
                          name: 'light', // Inherit from preset style
                          border: {
                              width: 2,
                              radius: 3,
                              color: '#185184'
                          }
                      }
                  }
                  );
                  // turn off href if we get this far
                  $(this).attr("href", "javascript:void (0)");
                  $(this).attr("target", "_self");
              });

           $(".popupInvoicePayHistory").each(function() {
                  $(this).qtip(
                  {
                      content: { text: 'loading... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...', url: "/modules/billingsystem/render.ashx", data: { c: 'invPayoff', i: $(this).attr('title')} },
                      show: { when: 'click', solo: true },
                      hide: 'click',
                      position: {
                          corner: {
                              target: 'topMiddle',
                              tooltip: 'bottomMiddlet'
                          }
                      },
                      style: {
                          tip: 'bottomMiddle',
                          width: 'auto',
                          name: 'light', // Inherit from preset style
                          border: {
                              width: 2,
                              radius: 3,
                              color: '#185184'
                          }
                      }
                  }
                  );
                  // turn off href if we get this far
                  $(this).attr("href", "javascript:void (0)");
                  $(this).attr("target", "_self");
              });

              $(".popupInvoiceItems").each(function() {
                  $(this).qtip(
                  {
                      content: { text: 'loading... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...', url: "/modules/billingsystem/render.ashx", data: { c: 'invItems', i: $(this).attr('title')} },
                      show: { when: 'click', solo: true },
                      hide: 'click',
                      position: {
                          corner: {
                              target: 'topMiddle',
                              tooltip: 'bottomMiddlet'
                          }
                      },
                      style: {
                          tip: 'bottomMiddle',
                          width: 'auto',
                          name: 'light', // Inherit from preset style
                          border: {
                              width: 2,
                              radius: 3,
                              color: '#185184'
                          }
                      }
                  }
                  );
                  // turn off href if we get this far
                  $(this).attr("href", "javascript:void (0)");
                  $(this).attr("target", "_self");
              });
});