jQuery(document).ready(function() {
          // Jquery Tools Tabs
          $("ul.tabs").tabs("div.panes > div");
          $("ul.css-tabs").tabs("div.css-panes > div");
          // Jquery Tools Scrollable
          $(".scrollable").scrollable();
          // Jquery Tools Accordions
          $(".accordion").tabs(".pane", {tabs: 'h2', effect: 'slide'});
          $(".accordion-faq").tabs(".pane", {tabs: 'span', effect: 'slide'});
          // External links open in new windows
          $("a[rel='external']").bind("click.external", function(){  window.open(this.href);  return false;  });
          // Twitter Js
          $(".tweet").tweet({
            join_text: "auto",
            username: "leadcommerce",
            avatar_size: 0,
            count: 2,
            auto_join_text_default: "we said,",
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied",
            auto_join_text_url: "we were checking out",
            loading_text: "Loading tweets..."
          });
          // Pricing Movements
          /* $(function() {
          $("ul.pricing-col").mouseover(function(){
          $(this).removeClass().addClass("pricing-col-highlight");
          }).mouseout(function(){
          $(this).removeClass().addClass("pricing-col");
          })}); */
});

// simple hide no animation
function hide(id){  if (document.getElementById){  obj = document.getElementById(id);  obj.style.display = "none";  } }

// simple show no animation
function show(id){  if (document.getElementById){  obj = document.getElementById(id);  obj.style.display = ""; } }

// jquery hide, show and toggle
function ajaxshow(id){	$(id).fadeIn("slow");	}
function ajaxhide(id){	$(id).fadeOut("slow");	}
function toggle(id)  {	$(id).slideToggle("fast");  }

// cufon replacements
Cufon.replace(' h1, h2, h3', { hover: true, fontFamily: 'Zurich' });
Cufon.replace(' .applyfont', { textShadow: '1px 1px #ffffff', hover: true, fontFamily: 'Zurich' });
Cufon.replace(' span.tab_item', { textShadow: '1px 1px #ffffff', hover: true, fontFamily: 'Zurich' });
Cufon.replace(' .bubble-one h2, .bubble-one h3, .bubble-one-alt h2, .bubble-one-alt h3', { textShadow: '1px 1px #5b5b5b', hover: true, fontFamily: 'Zurich' });
Cufon.replace(' .bubble-two h2, .bubble-two h3', { textShadow: '1px 1px #125ea1', hover: true, fontFamily: 'Zurich' });
Cufon.replace(' .footer-big h3', { textShadow: '1px 1px #424242', fontFamily: 'Zurich' });
// Cufon.replace(' .mainmenu', {  hover: true , fontFamily: 'Arials' });
Cufon.replace(' .btn-big-action, .btn-small-action, .btn-big-action-second, .btn-big-action-fixed, .form-button', { textShadow: '1px 1px #5d5d5d', hover: true , fontFamily: 'Arials' });
Cufon.replace(' .btn-big-neutral,.btn-small-neutral, .btn-big-neutral-fixed', { textShadow: '1px 1px #618faf', hover: true , fontFamily: 'Arials' });
Cufon.replace(' ul.pricing-col li.tops h2, ul.pricing-col-highlight li.tops h2', { textShadow: '1px 1px #5d5d5d', hover: true, fontFamily: 'Zurich' });


// dd_roundies for damned IE, make rounded corners on some boxes
DD_roundies.addRule('.outer-rounded-box', '10px');
DD_roundies.addRule('.outer-rounded-box-bold', '12px');
DD_roundies.addRule('.inner-rounded-box-filled-grey', '10px');
DD_roundies.addRule('.inner-rounded-box-filled-white', '10px');
DD_roundies.addRule('.inner-rounded-box-gradient-up', '10px');
DD_roundies.addRule('.inner-rounded-box-gradient-down', '10px');
DD_roundies.addRule('.simple-rounded-box', '10px');
DD_roundies.addRule('form select', '5px');
DD_roundies.addRule('form input', '5px');
DD_roundies.addRule('form textarea', '5px');

// run dynamic bubbletips
$(window).bind('load', function() {
          var ix = 1;
          while($('#trigger' + ix + '_up').length > 0) {
          $('#trigger' + ix + '_up').bubbletip($('#tip' + ix + '_up'), {
          deltaDirection: 'up',
          deltaPosition: 50,
          offsetTop: 5,
          calculateOnShow: true
          });
          ix++;
}
});



var zChar = new Array(' ', '(', ')', '-', '.');
var maxphonelength = 14;
var phonevalue1;
var phonevalue2;
var cursorposition;

function ParseForNumber1(object){
  phonevalue1 = ParseChar(object.value, zChar);
}

function ParseForNumber2(object){
  phonevalue2 = ParseChar(object.value, zChar);
}

function backspacerUP(object,e) {
  if(e){
    e = e
  } else {
    e = window.event
  }
  if(e.which){
    var keycode = e.which
  } else {
    var keycode = e.keyCode
  }

  ParseForNumber1(object)

  if(keycode >= 48){
    ValidatePhone(object)
  }
}

function backspacerDOWN(object,e) {
  if(e){
    e = e
  } else {
    e = window.event
  }
  if(e.which){
    var keycode = e.which
  } else {
    var keycode = e.keyCode
  }
  ParseForNumber2(object)
}

function GetCursorPosition(){

  var t1 = phonevalue1;
  var t2 = phonevalue2;
  var bool = false
  for (i=0; i<t1.length; i++)
  {
    if (t1.substring(i,1) != t2.substring(i,1)) {
      if(!bool) {
        cursorposition=i
        window.status=cursorposition
        bool=true
      }
    }
  }
}

function ValidatePhone(object){

  var p = phonevalue1

  p = p.replace(/[^\d]*/gi,"")

  if (p.length < 3) {
    object.value=p
  } else if(p.length==3){
    pp=p;
    d4=p.indexOf('(')
    d5=p.indexOf(')')
    if(d4==-1){
      pp="("+pp;
    }
    if(d5==-1){
      pp=pp+")";
    }
    object.value = pp;
  } else if(p.length>3 && p.length < 7){
    p ="(" + p;
    l30=p.length;
    p30=p.substring(0,4);
    p30=p30+") "

    p31=p.substring(4,l30);
    pp=p30+p31;

    object.value = pp;

  } else if(p.length >= 7){
    p ="(" + p;
    l30=p.length;
    p30=p.substring(0,4);
    p30=p30+") "

    p31=p.substring(4,l30);
    pp=p30+p31;

    l40 = pp.length;
    p40 = pp.substring(0,9);
    p40 = p40 + "-"

    p41 = pp.substring(9,l40);
    ppp = p40 + p41;

    object.value = ppp.substring(0, maxphonelength);
  }

  GetCursorPosition()

  if(cursorposition >= 0){
    if (cursorposition == 0) {
      cursorposition = 2
    } else if (cursorposition <= 2) {
      cursorposition = cursorposition + 1
    } else if (cursorposition <= 4) {
      cursorposition = cursorposition + 3
    } else if (cursorposition == 5) {
      cursorposition = cursorposition + 3
    } else if (cursorposition == 6) {
      cursorposition = cursorposition + 3
    } else if (cursorposition == 7) {
      cursorposition = cursorposition + 4
    } else if (cursorposition == 8) {
      cursorposition = cursorposition + 4
      e1=object.value.indexOf(')')
      e2=object.value.indexOf('-')
      if (e1>-1 && e2>-1){
        if (e2-e1 == 4) {
          cursorposition = cursorposition - 1
        }
      }
    } else if (cursorposition == 9) {
      cursorposition = cursorposition + 4
    } else if (cursorposition < 11) {
      cursorposition = cursorposition + 3
    } else if (cursorposition == 11) {
      cursorposition = cursorposition + 1
    } else if (cursorposition == 12) {
      cursorposition = cursorposition + 1
    } else if (cursorposition >= 13) {
      cursorposition = cursorposition
    }

    var txtRange = object.createTextRange();
    txtRange.moveStart( "character", cursorposition);
    txtRange.moveEnd( "character", cursorposition - object.value.length);
    txtRange.select();
  }

}

function ParseChar(sStr, sChar)
{

  if (sChar.length == null)
  {
    zChar = new Array(sChar);
  }
    else zChar = sChar;

  for (i=0; i<zChar.length; i++)
  {
    sNewStr = "";

    var iStart = 0;
    var iEnd = sStr.indexOf(sChar[i]);

    while (iEnd != -1)
    {
      sNewStr += sStr.substring(iStart, iEnd);
      iStart = iEnd + 1;
      iEnd = sStr.indexOf(sChar[i], iStart);
    }
    sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length);

    sStr = sNewStr;
  }

  return sNewStr;
}
