(function ($) {
  Drupal.behaviors.manipulateFormElements = {
    attach: function(context, settings) {
    // give the login form some love
    $('#user-login-form .login-submit-link').click(function(){
    	$('#user-login-form').submit();
    	return false;
    });
    }
  };
  Drupal.behaviors.correctActiveTrails = {
    attach: function(context, settings) {
      // fix menus that don't respect active trail because drupal links are stoopid
    $('#region-menu ul li.active').parents('li').addClass('active-trail');
    }
  };
})(jQuery);
;
/**
 * A simple querystring parser.
 * Example usage: var q = $.parseQuery(); q.fooreturns  "bar" if query contains "?foo=bar"; multiple values are added to an array. 
 * Values are unescaped by default and plus signs replaced with spaces, or an alternate processing function can be passed in the params object .
 * http://actingthemaggot.com/jquery
 *
 * Copyright (c) 2008 Michael Manning (http://actingthemaggot.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 **/
jQuery.parseQuery = function(qs,options) {
	var q = (typeof qs === 'string'?qs:window.location.search), o = {'f':function(v){return unescape(v).replace(/\+/g,' ');}}, options = (typeof qs === 'object' && typeof options === 'undefined')?qs:options, o = jQuery.extend({}, o, options), params = {};
	jQuery.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){
		p = p.split('=');
		p[1] = o.f(p[1]);
		params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1]),params[p[0]]):[params[p[0]],p[1]]):p[1];
	});
	return params;
};
// $Id: total980.js $
/*
** 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 ($)
{

Ticode.Total980 = function ()
{
  /*  
  ******************************************************************
  ** private variables available only to methods of the module.
  */

  /*  
  ** private shorthand variables to comon jQuery parts/utilities
  */

  /*  
  ** private shorthand variable for built jQuery objects. set in init()
  */

  /*  
  ** constants used in this module.
  */

  /*  
  ** module state:
  */

  /*  
  ** these are Dom refrences that won't change, they are set by direct
  ** calls when needed, and then used freely after that.
  */

  /*  
  ** ******************************************************************
  ** private methods available only to other methods of the module.
  */
  var that =
    /*
    ** publicly accessible variables where we store AJAX results by
    ** evaluating valid js pointing to these arrays.
    */
    { translations: [] // Ticode.Total980.translations[]

      /*
      ** public method Ticode.Total980.ie_widthfixer() -- Fix 100% width
      **						  bug on IE for
      **    the wrapper div that should have same size as body tag.
      */
    , ie_widthfixer: function ()
      {
	var page_width	= $(this).width();
	alert('set page width to '+page_width);
	$('#wrapper').width(page_width);
      }

      /*
      ** public method Ticode.Total980.switchingBoxes() - Prepares the
      **						  code that
      **    enables the collapse feature for vanishing/reappearing boxes.
      */
    , switchingBoxes: function()
      {
	var linkid  = $(this).attr('id');
	var myboxid = '#' + linkid + '-box';

	// Action when the user clicks the opener link.
	// Hide all boxes first, then show the selected one.
	//
	var opener  = function()
	{
	  $('.ghostbox').hide();
	  $(myboxid).show();
	  return false;
	};

	// Attach the proper event.
	//
	$(this).unbind();
	$(this).click(opener);

	// Be sure all boxes start as hidden
	// Ups.. don't do this, it is running for every .maplink in page.
	//
//	$('.ghostbox').hide();

	// There is a special case of a box we need to open, if
	// this is not it, close the box.
	//
	var q = $.parseQuery();
	var box_id  = q.openbox;

	if (linkid == box_id)
	{
	  $(myboxid).show();
	}
	else
	{
	  $(myboxid).hide();
	}
      }

      /*
      ** public method Ticode.Total980.views_id_fix() - Customize blocks
      **						created by views,
      **    to enable id and class (so they have a switchingBoxes enable
      **    tags).  Views doesn't allows us to add ids, and the position 
      **    of the class tags they allow us to set, is not the ideal in 
      **    the block.
      */
    , views_id_fix : function ()
      {
	$('#block-views-preformas-block').
	    children('.block-inner').
	    attr('id', 'preforma-box').
	    addClass('ghostbox boxed full');
      }
    };

      /*
      ** 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.customOmegaSubthemeJS =
{
  attach: function(context, settings)
  {
    $('body', context)	.once('total980', Ticode.Total980.views_id_fix);

    // We init the hs and then create other attached behaviors
    //
    $('.maplink', context)
		      .once('total980', Ticode.Total980.switchingBoxes);

    // fix the IE error with missing max width.
    //
    /*--NOTE: Fails... crap IE is not even setting body width correctly.
    $('body', context)
		      .once('total980', Ticode.Total980.ie_widthfixer);
    */
  }
};

}
)(jQuery);
;

