/*
** we're using the jQuery based javascript, but our design pattern will be
** the Yui object paradigm which is much better at stability and 
** expandability.
*/
var Ticode = (("undefined" == typeof Ticode) || (!Ticode)) ? {} : Ticode;

(
function ($)
{

/**
*
*  Javascript sprintf
*  http://www.webtoolkit.info/
*
*
**/
Ticode.sprintfWrapper =
{
    
  gexp:
    new RegExp(/(%([%]|(\-)?(\+|\x20)?(0)?(\d+)?(\.(\d)?)?([bcdfosxX])))/g)

, init : function ()
  {
    if (typeof arguments == "undefined")  { return null; }
    if (1 > arguments.length)		  { return null; }
    if (typeof arguments[0] != "string")  { return null; }
    if (typeof RegExp == "undefined")	  { return null; }

    var exp		= Ticode.sprintfWrapper.gexp
      , convert		= Ticode.sprintfWrapper.convert
      , string		= arguments[0]
      , matches		= new Array()
      , strings		= new Array()
      , convCount	= 0
      , stringPosStart	= 0
      , stringPosEnd	= 0
      , matchPosEnd	= 0
      , newString	= ''
      , match		= null
      , neg		= false
      , arg		= ''
      , code		= null
      , i		= null
      ;
    while (match = exp.exec(string))
    {
      if (match[9]) { convCount += 1; }

      stringPosStart	      = matchPosEnd;
      stringPosEnd	      = exp.lastIndex - match[0].length;
      strings[strings.length] = string.substring( stringPosStart,
						  stringPosEnd);
      neg = (0 > parseInt(arguments[convCount])) ? true : false;
      arg = String(arguments[convCount])


      matchPosEnd	      = exp.lastIndex;
      matches[matches.length] = { match:      match[0]
				, left:	      match[3] ? true : false
				, sign:	      match[4] || ''
				, pad:	      match[5] || ' '
				, min:	      match[6] || 0
				, precision:  match[8]
				, code:	      match[9] || '%'
				, negative:   neg
				, argument:   arg
				};
    }
    strings[strings.length] = string.substring(matchPosEnd);

    if (matches.length == 0)		    { return string;  }
    if (convCount > (arguments.length - 1)) { return null;    }

    match = i = null;

    for (i=0; i < matches.length; i++)
    {
      if      ('%' == matches[i].code)	{ substitution = '%' }
      else if ('b' == matches[i].code)
      {
	matches[i].argument =
	  String(Math.abs(parseInt(matches[i].argument)).toString(2));

	substitution = convert(matches[i], true);
      }
      else if ('c' == matches[i].code)
      {
	matches[i].argument =
	  String(
	    String.fromCharCode(
	      parseInt(Math.abs(parseInt(matches[i].argument)))));

	substitution = convert(matches[i], true);
      }
      else if ('d' == matches[i].code)
      {
	matches[i].argument =
	  String(Math.abs(parseInt(matches[i].argument)));

	substitution = convert(matches[i]);
      }
      else if ('f' == matches[i].code)
      {
	matches[i].argument =
	  String(
	    Math.abs(parseFloat(matches[i].argument)		    ).
	    toFixed(matches[i].precision ? matches[i].precision : 6));

	substitution = convert(matches[i]);
      }
      else if ('o' == matches[i].code)
      {
	matches[i].argument =
	  String(Math.abs(parseInt(matches[i].argument)).toString(8));

	substitution = convert(matches[i]);
      }
      else if ('s' == matches[i].code)
      {
	matches[i].argument =
	  matches[i].argument.
	    substring(0,
		      matches[i].precision ?
		      matches[i].precision : matches[i].argument.length);

	substitution = convert(matches[i], true);
      }
      else if ('x' == matches[i].code)
      {
	matches[i].argument =
	  String(Math.abs(parseInt(matches[i].argument)).toString(16));

	substitution = convert(matches[i]);
      }
      else if ('X' == matches[i].code)
      {
	matches[i].argument =
	  String(Math.abs(parseInt(matches[i].argument)).toString(16));
	  
	substitution = convert(matches[i]).toUpperCase();
      }
      else
      {
	substitution = matches[i].match;
      }
      newString += strings[i];
      newString += substitution;
    }
    newString += strings[i];

    return newString;
  }
  
, convert : function (match, nosign)
  {
    if (nosign) { match.sign = '';				  }
    else	{ match.sign = match.negative ? '-' : match.sign; }

    var l = match.min - match.argument.length + 1 - match.sign.length
      ;
    var pad = new Array((l < 0) ? 0 : l).join(match.pad)
      ;
    if (!match.left)
    {
      if (match.pad == '0' || nosign)
      {
	return match.sign + pad + match.argument;
      }
      else
      {
	return pad + match.sign + match.argument;
      }
    }
    else
    {
      if (match.pad == '0' || nosign)
      {
	return match.sign + match.argument + pad.replace(/0/g, ' ');
      }
      else
      {
	return match.sign + match.argument + pad;
      }
    }
  }
}

Ticode.System = function ()
{
  /*  
  ******************************************************************
  ** private variables available only to methods of the module.
  */
  var c_do  = false
    , w_do  = false
    , p_do  = false
    , s_do  = false
    , g_do  = false
    , dtop  = null
    ;
  /*  
  ** private shorthand variables to comon YUI/Prototype parts/utilities
  */

  /*  
  ** private shorthand variable for built YUI objects. set in init()
  */
  
  /*  
  ** constants used in this module.
  */

  /*  
  ** module state:
  */
  var once  = false
    , id    = 0
    ;
  /*  
  ** these are Dom refrences that won't change, they are set by direct
  ** calls when needed, and then used freely after that.
  */
  var chalkboard  = null
    ;

  /*  
  ** ******************************************************************
  ** private methods available only to other methods of the module.
  */

  /*
  ** generic page based event handler
  */
  var event_handler = function (ev)
  {
    var el  = null
      , val = 0
      , whc = 0;

    if ((!ev) || (!(el = ev.target)))
    {
      return;
    }
    el = $(el);

    while (el != dtop)
    {
      $('#debug').append('<h1>val = ' + val + ', id: ' + el[0]['id']
                        + '</h1><h2>"Graphics" for id = '
                        + '</h2><h2>"DIV" for tag Name = '
                        + ('DIV' == el[0]['tagName'])
                        + '</h2><h2>el.hasClass() = '
                        + el.hasClass('clickable') + '</h2><ul>'
                        + '<li>tagName: ' + el[0]['tagName'] + '</li>'
                        + '</ul>');
      /*
      ** handle click's
      */
      if (!el)
      {
        break;
      }
      if ('click' == ev.type)
      {
        if (('DIV' == el[0]['tagName']) && (el.hasClass('clickable')))
        {
          if ('clickhere' == el[0]['id'])
          {
            if (c_do)
            {
              $('#debug').append('<h4>here hiding</h4>');
              $('#show, #boxes, #grow1').hide('slow');
            }
            else
            {
              $('#debug').append('<h4>here showing</h4>');
              $('#show, #boxes, #grow1').show('slow');
            }
            c_do = !c_do
            break;
          }
          if (('Graphics'     == el[0]['id']) ||
              ('Web-Design'   == el[0]['id']) ||
              ('Programming'  == el[0]['id']) ||
              ('SEO'          == el[0]['id']))
          {
            $('#grow2, #grow3, #grow4, #grow5').hide('slow');

            if ('Graphics' == el[0]['id'])
            {
              whc = 'g_do';

              if (!(val = g_do))
              {
                $('#grow2').show('slow');
              }
            }
            else if ('Web-Design' == el[0]['id'])
            {
              whc = 'w_do';

              if (!(val = w_do))
              {
                $('#grow3').show('slow');
              }
            }
            else if ('Programming' == el[0]['id'])
            {
              whc = 'p_do';

              if (!(val = p_do))
              {
                $('#grow4').show('slow');
              }
            }
            else
            {
              whc = 's_do';

              if (!(val = s_do))
              {
                $('#grow5').show('slow');
              }
            }
            g_do = w_do = p_do = s_do = false;

            eval(whc + '  = !val');
            break;
          }
        }
      }
      else if ('change' == ev.type)
      {
      }
      else if ('keyup' == ev.type)
      {
      }
      val++;

      el = $(el).parent();
      if ((!(val % 10)) && (confirm('quit')))
      {
        break;
      }
    }
  };

  var that =
    /*
    ** publicly accessible variables where we store AJAX results by
    ** evaluating valid js pointing to these arrays.
    */
    { translations: [] // Ticode.System.translations[]

      /*
      ** Public Ticode.System.erudiate() -- Erudiate means to instruct or
      **				    teach us.  Here we mean teaching
      **    us about the contents of some obscure object in an easy to use
      **    jQuery dialog.  This function builds the dialog, or resets it.
      **
      **  @param  mixed	  obj	- The object to display.
      **  @param  string  name	- The name of the object we will display.
      **  @return null
      **  @side-effect	- Opens a dialog filled with information about the
      **		  object item.
      */
    , erudiate:	function (obj, name)
      {
	var content = null
	  ;
	if (!chalkboard) // Ticode object private scope item.
	{
	  chalkboard = $('<div id="tic_sys_chalkboard"></div>');

	  $(document).append(chalkboard);
	  $(chalkboard).dialog( { autoOpen: false 
				, modal:    true 
				, width:    539 
				, height:   254 
				});
	}
	content = that.imbue(obj, name);

	$(chalkboard).html(content.html());
	$(chalkboard).dialog('open');
      }

      /*
      ** Public Ticode.System.imbue() - Imbue is another word for 'to teach'
      **				or 'instuct'.  In this case we mean
      **    to show us the contents of some obscure object in an html layout
      **    that we ajaxify to expand on sub items by click.
      **
      **  @param  mixed	  obj	- The object to display.
      **  @param  string  name	- The name of the object we will display.
      **  @return object	- The jQuery HTML object for display.
      */
    , imbue:  function (obj, name)
      {
	var fieldset  = null
	  , legend    = null
	  , div	      = null
	  , index     = null
	  , item      = null
	  , ul	      = null
	  , part      = null
	  , d_id      = 'tic_sys-d-' + id
	  , click     = null
	  , b_id      = null
	  , expand    = null
	  ;
	click = function ()
	{
	  $('#' + d_id).toggle();
	};
	id++;

	fieldset  = $('<fieldset></fieldset>');
	legend	  = $('<legend>' + name + '</legend>');
	div	  = $('<div id="' + d_id + '"></div>');

	// Interior contents

	ul = $('<ul>' + (typeof obj) + ' contents:<br /></ul>');

	if (('object' == typeof obj) || ('array' == typeof obj))
	{
	  for (index in obj)
	  {
	    item = obj[index];

	    if (undefined == item)
	    {
	      part = $('<li><b>.' + index + '</b> = undefined</li>');
	    }
	    else if ('integer' == typeof item)
	    {
	      part = $('<li><b>.' + index + '</b> = ' + item + '</li>');
	    }
	    else if ('string' == typeof item)
	    {
	      part = $('<li><b>.' + index + '</b> = "' + item + '"</li>');
	    }
	    else if ('array' == typeof item)
	    {
	      b_id    = 'tic_sys-b-' + id;
	      expand  = function ()
	      {
		var content = that.imbue(item, index)
		  ;
		$('#' + b_id).parent().html(content);
	      };
	      id++;
	      part = $(	'<li><b id="' + b_id + '">.' + index +
			'</b> (array click to expand)</li>');

	      $('#:not(.ticode_system-processed)').click(expand).
		      addClass('ticode_system-processed');
	    }
	    else if ('object' == typeof item)
	    {
	      if (('nextSibling'    != index) && ('document'	!= index) &&
		  ('parentElement'  != index) && ('namespaces'	!= index) &&
		  ('parentTextEdit' != index) && ('ownerElement'!= index) &&
		  ('ownerDocument'  != index) && ('offsetParent'!= index) &&
		  ('previousSibling'!= index) && ('parentNode'	!= index))
	      {
		b_id    = 'tic_sys-b-' + id;
		expand  = function ()
		{
		  var content = that.imbue(item, index)
		    ;
		  $('#' + b_id).parent().html(content);
		};
		id++;
		part = $(	'<li><b id="' + b_id + '">.' + index +
			  '</b> (object click to expand)</li>');

		$('#:not(.ticode_system-processed)').click(expand).
			addClass('ticode_system-processed');
	      }
	    }
	    else 
	    {
	      part = $(	'<li><b>.' + index +
			'</b> item type of [' + (typeof item) +
			'] is not explicitly handled by function ' +
			'Ticode.System.imbue</li>');
	    }
	    $(ul).append(part);
	  }
	}
	else if ('integer' == typeof obj)
	{
	  $(ul).append('<em>' + obj + '</em>');
	}
	else if ('string' == typeof obj)
	{
	  $(ul).append('<i>"' + obj + '"</i>');
	}
	div.hide();

	$(legend).filter(':not(.ticode_system-processed)').click(click).
		  addClass('ticode_system-processed');

	$(fieldset).append(legend);
	$(fieldset).append(div);

	return fieldset;
      }
    };
      /*
      ** for finding .attr('style', 'background:#ee9933');
      */
        //attr('style', 'background:#ee9933');

  return that;

}(); // the parens here cause the anonymous func to execute and return

Drupal.behaviors.ticode_system  = 
{
  attach: function (context, settings)
  {
    if (undefined = Ticode.System.sprintf)
    {
      Ticode.System.sprintf = Ticode.sprintfWrapper.init;
    }

    $('form#system-modules fieldset.collapsible:not(.collapsed)')
      .addClass('collapsed');
  }
};

}
)(jQuery);

;
// $Id: collapse.js,v 1.32 2010/05/14 16:45:56 dries Exp $
(function ($) {

/**
 * Toggle the visibility of a fieldset using smooth animations.
 */
Drupal.toggleFieldset = function (fieldset) {
  var $fieldset = $(fieldset);
  if ($fieldset.is('.collapsed')) {
    var $content = $('> .fieldset-wrapper', fieldset).hide();
    $fieldset
      .removeClass('collapsed')
      .trigger({ type: 'collapsed', value: false })
      .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Hide'));
    $content.slideDown({
      duration: 'fast',
      easing: 'linear',
      complete: function () {
        Drupal.collapseScrollIntoView(fieldset);
        fieldset.animating = false;
      },
      step: function () {
        // Scroll the fieldset into view.
        Drupal.collapseScrollIntoView(fieldset);
      }
    });
  }
  else {
    $fieldset.trigger({ type: 'collapsed', value: true });
    $('> .fieldset-wrapper', fieldset).slideUp('fast', function () {
      $fieldset
        .addClass('collapsed')
        .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Show'));
      fieldset.animating = false;
    });
  }
};

/**
 * Scroll a given fieldset into view as much as possible.
 */
Drupal.collapseScrollIntoView = function (node) {
  var h = document.documentElement.clientHeight || document.body.clientHeight || 0;
  var offset = document.documentElement.scrollTop || document.body.scrollTop || 0;
  var posY = $(node).offset().top;
  var fudge = 55;
  if (posY + node.offsetHeight + fudge > h + offset) {
    if (node.offsetHeight > h) {
      window.scrollTo(0, posY);
    }
    else {
      window.scrollTo(0, posY + node.offsetHeight - h + fudge);
    }
  }
};

Drupal.behaviors.collapse = {
  attach: function (context, settings) {
    $('fieldset.collapsible', context).once('collapse', function () {
      var $fieldset = $(this);
      // Expand fieldset if there are errors inside, or if it contains an
      // element that is targeted by the uri fragment identifier. 
      var anchor = location.hash && location.hash != '#' ? ', ' + location.hash : '';
      if ($('.error' + anchor, $fieldset).length) {
        $fieldset.removeClass('collapsed');
      }

      var summary = $('<span class="summary"></span>');
      $fieldset.
        bind('summaryUpdated', function () {
          var text = $.trim($fieldset.drupalGetSummary());
          summary.html(text ? ' (' + text + ')' : '');
        })
        .trigger('summaryUpdated');

      // Turn the legend into a clickable link, but retain span.fieldset-legend
      // for CSS positioning.
      var $legend = $('> legend .fieldset-legend', this);

      $('<span class="fieldset-legend-prefix element-invisible"></span>')
        .append($fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide'))
        .prependTo($legend)
        .after(' ');

      // .wrapInner() does not retain bound events.
      var $link = $('<a class="fieldset-title" href="#"></a>')
        .prepend($legend.contents())
        .appendTo($legend)
        .click(function () {
          var fieldset = $fieldset.get(0);
          // Don't animate multiple times.
          if (!fieldset.animating) {
            fieldset.animating = true;
            Drupal.toggleFieldset(fieldset);
          }
          return false;
        });

      $legend.append(summary);
    });
  }
};

})(jQuery);
;
// $Id: googleanalytics.js,v 1.11.2.8 2011/02/06 19:22:05 hass Exp $
(function ($) {

$(document).ready(function() {

  // Accepts a string; returns the string with regex metacharacters escaped. The returned string
  // can safely be used at any point within a regex to match the provided literal string. Escaped
  // characters are [ ] { } ( ) * + ? - . , \ ^ $ # and whitespace. The character | is excluded
  // in this function as it's used to separate the domains names.
  RegExp.escapeDomains = function(text) {
    return text.replace(/[-[\]{}()*+?.,\\^$#\s]/g, "\\$&");
  }

  // Attach onclick event to document only and catch clicks on all elements.
  $(document.body).click(function(event) {
    // Catch only the first parent link of a clicked element.
    $(event.target).parents("a:first,area:first").andSelf().filter("a,area").each(function() {

      var ga = Drupal.settings.googleanalytics;
      // Expression to check for absolute internal links.
      var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
      // Expression to check for special links like gotwo.module /go/* links.
      var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
      // Expression to check for download links.
      var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");
      // Expression to check for the sites cross domains.
      var isCrossDomain = new RegExp("^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\/.*(" + RegExp.escapeDomains(ga.trackCrossDomains) + ")", "i");

      // Is the clicked URL internal?
      if (isInternal.test(this.href)) {
        // Is download tracking activated and the file extension configured for download tracking?
        if (ga.trackDownload && isDownload.test(this.href)) {
          // Download link clicked.
          var extension = isDownload.exec(this.href);
          _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]);
        }
        else if (isInternalSpecial.test(this.href)) {
          // Keep the internal URL for Google Analytics website overlay intact.
          _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]);
          setTimeout('document.location = "' + this.href + '"', 100);
        }
      }
      else {
        if (ga.trackMailto && $(this).is("a[href^=mailto:],area[href^=mailto:]")) {
          // Mailto link clicked.
          _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]);
        }
        else if (ga.trackOutbound && this.href) {
          if (ga.trackDomainMode == 2 && isCrossDomain.test(this.href)) {
            // Top-level cross domain clicked.
            _gaq.push(["_link", this.href]);
          }
          else if (ga.trackOutboundAsPageview) {
            // Track all external links as page views after URL cleanup.
            // Currently required, if click should be tracked as goal.
            _gaq.push(["_trackPageview", '/outbound/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--')]);
            setTimeout('document.location = "' + this.href + '"', 100);
          }
          else {
            // External link clicked.
            _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]);

            // First, delay the outbound click by a fraction of a second.
            // This delay will hardly be noticeable by the user, but it will provide the
            // browser more time load the tracking code. Without this method, it's possible
            // that a user can click on the outbound link before the tracking code loads,
            // in which case the event will not be recorded.
            // See http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55527
            setTimeout('document.location = "' + this.href + '"', 100);
          }
        }
      }
    });
  });
});

})(jQuery);
;

