// basic jQuery extensions
$.extend($,
{
	// for debugging purposes - caution - writes to global space
	log : function()
	{
		// firebug lite for IE console (debug purposes only)
		if ($.browser.msie && window.DEBUG_IE ) // 
			document.write( "<script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'><\/script>" );
			
		window.log = function(){
			try{
				if(!window.LOG_OFF) console.log.apply(console,arguments);
			} catch(error)
			{
				console = { log:function(){return} };
			}
		};
		return window.log;
	}(),
	
	// get a timer, pass old timer for time since then
	time : function(t)
	{
		var d = (new Date()).getTime();
		return ( t? d-t  : d );
	},
	
	// Original Author: Rafael Lima (http://rafael.adm.br)
	cssBrowserSelect : (function()
	{
		var ua=navigator.userAgent.toLowerCase(),
			is=function(t){ return ua.indexOf(t) != -1; },
			h=document.getElementsByTagName('html')[0],
			b=( !(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua) )? ('ie ie'+RegExp.$1):
				is('gecko/')? 'gecko':
					is('opera/9')? 'opera opera9':
						/opera (\d)/.test(ua)? 'opera opera'+RegExp.$1:
							is('konqueror')? 'konqueror':
								is('applewebkit/')? 'webkit safari':
									is('mozilla/')? 'gecko':'',
			os=( is('x11')||is('linux') )? ' linux':
				is('mac')? ' mac':
					is('win')? ' win':
						'',
			c=b+os+' js';
		
		h.className += h.className?' '+c:c;
		
		return true;
	})(),
	
	// fading in group
	fadeGroup : function(group,selector){
		
		var group = $(group);

		group.mouseenter(function(e){

			$(this).stop(true).fadeTo(300,1);
			group.not($(this)).stop(true).fadeTo(300,0.5);

		}).mouseleave(function(e){

			group.filter(selector).stop(true).fadeTo(300,1);
			group.not(selector).stop(true).fadeTo(300,0.5);

		}).mouseleave();
		
	}
	
});

/*
Title:      jQuery.relativeDate
Description:Formats a date relative to current time (eg '3 mins ago')
Developer:  Antenna Praxis (http://theantenna.net)
Date:       May 2009
Version:    0.1
Usage:      
Notes:      
To Do:      
License:    Dual licensed under the MIT and GPL licenses:
            http://www.opensource.org/licenses/mit-license.php,
            http://www.gnu.org/licenses/gpl.html
*/

(function($) {
	
	var a_minute = 60 *1000,
		an_hour = a_minute*60,
		a_day = an_hour*24,
		a_month = a_day*30, // averaged
		a_year = a_day*365,
		years,months,days,hours,minutes,secs,
		_plural = "s",
		_seperator = " ",
		_now = new Date();
	
	$.relativeDate = function(date, now)
	{
		//log(date);
		//years = months = days = hours = minutes = secs = 0;
		
		if(typeof date == "string") date = new Date(date);
		secs = (now || _now).getTime() - date.getTime();
	
		years = Math.floor(secs/a_year);
		secs = secs%a_year;
		months = Math.floor(secs/a_month);
		
		secs = secs%a_month;
		days = Math.floor(secs/a_day);
		secs = secs%a_day;
		hours = Math.floor(secs/an_hour);
		secs = secs%an_hour;
		minutes = Math.ceil(secs/a_minute); // 1 minute min
		
		return formattedDate();
	};
	
	var formattedDate = function()
	{
		if(years > 0) return displayDate(years,' year');
		else if(months > 0) return displayDate(months + (days>15? 1 : 0),' month');
		else if(days > 0) return displayDate(days + (hours>12? 1 : 0),' day');
		else if(hours > 0) return displayDate(hours + (minutes>30? 1 : 0),' hour') ;
		else return displayDate(minutes ,' minute');
	},
	
	displayDate = function(num, string, seperator, plural)
	{
		plural = plural || _plural,
		seperator = seperator || _seperator;
		return (num? (num!=1? num+string+plural+seperator : num+string+seperator) : "");
	}
	
	
})(jQuery);


// http://plugins.jquery.com/files/jquery.cookie.js.txt - packed
(function(){
jQuery.cookie=function(a,b,c){if(typeof b!='undefined'){c=c||{};if(b===null){b='';c.expires=-1}var d='';if(c.expires&&(typeof c.expires=='number'||c.expires.toUTCString)){var e;if(typeof c.expires=='number'){e=new Date();e.setTime(e.getTime()+(c.expires*24*60*60*1000))}else{e=c.expires}d='; expires='+e.toUTCString()}var f=c.path?'; path='+(c.path):'';var g=c.domain?'; domain='+(c.domain):'';var h=c.secure?'; secure':'';document.cookie=[a,'=',encodeURIComponent(b),d,f,g,h].join('')}else{var j=null;if(document.cookie&&document.cookie!=''){var k=document.cookie.split(';');for(var i=0;i<k.length;i++){var l=jQuery.trim(k[i]);if(l.substring(0,a.length+1)==(a+'=')){j=decodeURIComponent(l.substring(a.length+1));break}}}return j}};
})();


// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){
  var cache = {};
 
  this.tmpl = function tmpl(str, data){
    // Figure out if we're getting a template, or if we need to
    // load the template - and be sure to cache the result.
    var fn = !/\W/.test(str) ?
      cache[str] = cache[str] ||
        tmpl(document.getElementById(str).innerHTML) :
     
      // Generate a reusable function that will serve as a template
      // generator (and which will be cached).
      new Function("obj",
        "var p=[],print=function(){p.push.apply(p,arguments);};" +
       
        // Introduce the data as local variables using with(){}
        "with(obj){p.push('" +
       
        // Convert the template into pure JavaScript
        str
          .replace(/[\r\t\n]/g, " ")
          .split("<%").join("\t")
          .replace(/((^|%>)[^\t]*)'/g, "$1\r")
          .replace(/\t=(.*?)%>/g, "',$1,'")
          .split("\t").join("');")
          .split("%>").join("p.push('")
          .split("\r").join("\\'")
      + "');}return p.join('');");
   
    // Provide some basic currying to the user
    return data ? fn( data ) : fn;
  };
})();


/*
 * jQuery Color Animations
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 */

(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);




/*
 * jQuery hashchange event - v1.2 - 2/11/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
























