/**
 * PeriodicalUpdater - jQuery plugin for timed, decaying ajax calls
 *
 * Smokejumper Version by Robert Fischer, Smokejumper IT
 * Based on version from http://www.360innovate.co.uk
 * 
 * Copyright (c) 2009 by the following:
 *   * Robert Fischer (http://smokejumperit.com)
 *   * 360innovate (http://www.360innovate.co.uk)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 2.0
 */

(function($) {
    $.PeriodicalUpdater = function(url, options, callback){

        var settings = jQuery.extend(true, {
            url: url,                // URL of ajax request
            method: 'get',          // method; get or post
            data: '',           		// array of values to be passed to the page - e.g. {name: "John", greeting: "hello"}
            minTimeout: 1000,       // starting value for the timeout in milliseconds
            maxTimeout: 8000,       // maximum length of time between requests
            multiplier: 2,          // if set to 2, timerInterval will double each time the response hasn't changed (up to maxTimeout)
            type: 'text'            // response type - text, xml, json etc
        }, options);

        // set some initial values, then begin
        var prevContent = null;
        var timerInterval = settings.minTimeout;

				// Function to boost the timer (nop unless multiplier > 1)
				var boostPeriod = function() { return; };
				if(settings.multiplier > 1) {
					boostPeriod = function() {
						timerInterval = timerInterval * settings.multiplier;

						if(timerInterval > settings.maxTimeout)
						{
								timerInterval = settings.maxTimeout;
						}
					};
				}

				var PeriodicalTimer = null; // Getting a handle on this for some reason

				// Construct the settings for $.ajax based on settings
				var ajaxSettings = jQuery.extend(true, {}, settings);
				if(settings.type && !ajaxSettings.dataType) ajaxSettings.dataType = settings.type;
				if(settings.sendData) ajaxSettings.data = settings.sendData;
				ajaxSettings.type = settings.method; // 'type' is used internally for jQuery.  Who knew?
				ajaxSettings.ifModified = false;
				ajaxSettings.cache = false;
				ajaxSettings.success = function(data) {
					if(prevContent && prevContent == data) {
						boostPeriod();
					} else {
						prevContent = data;
						timerInterval = settings.minTimeout;
						if(callback) { callback(data); }
					}
					PeriodicalTimer = setTimeout(getdata, timerInterval);
					if(settings.success) { settings.success(data); }
				};
				ajaxSettings.error = function (XMLHttpRequest, textStatus) {
					if ((textStatus == "notmodified") || (textStatus == "parsererror")) {
						boostPeriod();
					} else {
            if (console) console.log('somethingelse:' + textStatus);
						prevContent = null;
						timerInterval = settings.minTimeout;
					}
					PeriodicalTimer = setTimeout(getdata, timerInterval);
					if(settings.error) { settings.error(XMLHttpRequest, textStatus); }
				};

				// Make the first call
        $(function() { getdata(); });
				function getdata() {
						$.ajax(ajaxSettings);
        }
    };
})(jQuery);
/*
 * jQuery JSONP Core Plugin 1.0.6 (2009-07-15)
 * 
 * http://code.google.com/p/jquery-jsonp/
 *
 * Copyright (c) 2009 Julian Aubourg
 *
 * This document is licensed as free software under the terms of the
 * MIT License: http://www.opensource.org/licenses/mit-license.php
 */
(function($){
	
	// ###################### UTILITIES ##
	// Test a value is neither undefined nor null
	var defined = function(v) {
		return v!==undefined && v!==null;
	},
	
	// Head element (for faster use)
	head = $("head"),
	// Page cache
	pageCache = {},
	
	// ###################### DEFAULT OPTIONS ##
	xOptionsDefaults = {
		//beforeSend: undefined,
		//cache: false,
		callback: "C",
		//callbackParameter: undefined,
		//complete: undefined,
		//data: ""
		//dataFilter: undefined,
		//error: undefined,
		//pageCache: false,
		//success: undefined,
		//timeout: 0,		
		url: location.href
	},

	// ###################### MAIN FUNCTION ##
	jsonp = function(xOptions) {
		
		// Build data with default
		xOptions = $.extend({},xOptionsDefaults,xOptions);
		
		var beforeSendCallback = xOptions.beforeSend;

		// Call beforeSend if provided
		// (early abort if false returned)
		if (defined(beforeSendCallback)) {
			var aborted = 0;
			xOptions.abort = function() { aborted = 1; };
			if (beforeSendCallback(xOptions,xOptions)===false || aborted) return xOptions;
		}
		
		// Control entries & data type
		// + declare variables
		var
		empty="",
		amp="&",
		qMark="?",
		success = "success",
		error = "error",
		
		successCallback = xOptions.success,
		completeCallback = xOptions.complete,
		errorCallback = xOptions.error,
		
		dataFilter = xOptions.dataFilter,
		
		callbackParameter = xOptions.callbackParameter,
		
		successCallbackName = xOptions.callback,

		cacheFlag = xOptions.cache,
		pageCacheFlag = xOptions.pageCache,
		
		url = xOptions.url,
		data = xOptions.data,
		
		timeout = xOptions.timeout,
		
		// Keep current thread running
		later = function(functor) { setTimeout(functor,1); },
		
		// Various variable
		splitUrl,splitData,i,j;

		// Control entries
		url = defined(url)?url:empty;
		data = defined(data)?((typeof data)=="string"?data:$.param(data)):empty;
		
		// Add callback parameter if provided as option
		defined(callbackParameter)
			&& (data += (data==empty?empty:amp)+escape(callbackParameter)+"=?");
		
		// Add anticache parameter if needed
		!cacheFlag && !pageCacheFlag
			&& (data += (data==empty?empty:amp)+"_"+(new Date()).getTime()+"=");
		
		// Search for ? in url
		splitUrl = url.split(qMark);
		// Also in parameters if provided
		// (and merge array)
		if (data!=empty) {
			splitData = data.split(qMark);
			j = splitUrl.length-1;
			j && (splitUrl[j] += amp + splitData.shift());
			splitUrl = splitUrl.concat(splitData);
		}
		// If more than 2 ? replace the last one by the callback
		i = splitUrl.length-2;
		i && (splitUrl[i] += successCallbackName + splitUrl.pop());
		
		// Build the final url
		var finalUrl = splitUrl.join(qMark),
		
		// Utility function
		notifySuccess = function(json) {
			// Apply the data filter if provided
			defined(dataFilter) && (json = dataFilter(json));
			// Call success then complete
			defined(successCallback) && successCallback(json,success);
			defined(completeCallback) && completeCallback(xOptions,success);				
		},
	    notifyError = function(type) {
			// Call error then complete
			defined(errorCallback) && errorCallback(xOptions,type);
			defined(completeCallback) && completeCallback(xOptions,type);
	    },
	    
	    // Get from pageCache
	    pageCached = pageCache[finalUrl];
		
		// Check page cache
		if (pageCacheFlag && defined(pageCached)) {
			later(function() {
				// If an error was cached
				if (defined(pageCached.e)) notifyError(error);
				else notifySuccess(pageCached.s);
			});
			return xOptions;
		}
		
		// Create an iframe & add it to the document
		var frame = $("<iframe />").appendTo(head),
		
		// Get the iframe's window and document objects
		tmp = frame[0],
		window = tmp.contentWindow || tmp.contentDocument,
		document = window.document,
		
		// Flag to know if the request has been treated
		done = 0,
		
		// Declaration of cleanup function
		cleanUp,
		
		// Error function
		errorFunction = function (_,type) {
			// If pure error (not timeout), cache if needed
			pageCacheFlag && !defined(type) && (pageCache[finalUrl] = {e: 1}); 
			// Cleanup
			cleanUp();
			// Call error then complete
			notifyError(defined(type)?type:error);
		},
		
		// Cleaning function
		removeVariable = function(varName) {
			window[varName] = undefined;
			try { delete window[varName]; } catch(_) {}
		},
		
		// Error callback name
		errorCallbackName = successCallbackName=="E"?"X":"E";
		
		// Control if we actually retrieved the document
		if(!defined(document)) {
			document = window;
		    window = document.getParentNode();
		}
		
		// We have to open the document before
		// declaring variables in the iframe's window
		// Don't ask me why, I have no clue
		document.open();
		
		// Install callbacks
		
		window[successCallbackName] = function(json) {
			// Set as treated
			done = 1;
			pageCacheFlag && (pageCache[finalUrl] = {s: json});
			// Give hand back to frame
			// To finish gracefully
			later(function(){
				// Cleanup
				cleanUp();
				// Call success then complete
				notifySuccess(json);
			});
		};
		
		window[errorCallbackName] = function(state) {
			// If not treated, mark
			// then give hand back to iframe
			// for it to finish gracefully
			(!state || state=="complete") && !done++ && later(errorFunction);
		};
		
		// Clean up function (declaration)
		xOptions.abort = cleanUp = function() {
			removeVariable(errorCallbackName);
			removeVariable(successCallbackName);
			document.open()
			document.write(empty);
			document.close();
			frame.remove();
		};
		
		// Write to the iframe (sends the request)
		// We let the hand to current code to avoid
		// pre-emptive callbacks
		
		// We also install the timeout here to avoid
		// timeout before the code has been dumped to the frame
		// (in case of insanely short timeout values)
		later(function() {
			// Write to the document
			document.write([
				'<html><head><script src="',
				finalUrl,'" onload="',
				errorCallbackName,'()" onreadystatechange="',
				errorCallbackName,'(this.readyState)"></script></head><body onload="',
				errorCallbackName,'()"></body></html>'
			].join(empty)
			);
			// Close (makes some browsers happier)
			document.close();
			// If a timeout is needed, install it
			timeout>0 && setTimeout(function(){
					!done && errorFunction(empty,"timeout");
			},timeout);
		});
		
		return xOptions;
	}
	
	// ###################### SETUP FUNCTION ##
	jsonp.setup = function(xOptions) {
		$.extend(xOptionsDefaults,xOptions);
	};

	// ###################### INSTALL in jQuery ##
	$.jsonp = jsonp;
	
})(jQuery);
	
	/**
	 * jQuery SHA1 hash algorithm function
	 * 
	 * 	<code>
	 * 		Calculate the sha1 hash of a String 
	 * 		String $.sha1 ( String str )
	 * 	</code>
	 * 
	 * Calculates the sha1 hash of str using the US Secure Hash Algorithm 1.
	 * SHA-1 the Secure Hash Algorithm (SHA) was developed by NIST and is specified in the Secure Hash Standard (SHS, FIPS 180).
	 * This script is used to process variable length message into a fixed-length output using the SHA-1 algorithm. It is fully compatible with UTF-8 encoding.
	 * If you plan using UTF-8 encoding in your project don't forget to set the page encoding to UTF-8 (Content-Type meta tag).
	 * This function orginally get from the WebToolkit and rewrite for using as the jQuery plugin.
	 * 
	 * Example
	 * 	Code
	 * 		<code>
	 * 			$.sha1("I'm Persian."); 
	 * 		</code>
	 * 	Result
	 * 		<code>
	 * 			"1d302f9dc925d62fc859055999d2052e274513ed"
	 * 		</code>
	 * 
	 * @alias Muhammad Hussein Fattahizadeh < muhammad [AT] semnanweb [DOT] com >
	 * @link http://www.semnanweb.com/jquery-plugin/sha1.html
	 * @see http://www.webtoolkit.info/
	 * @license http://www.gnu.org/licenses/gpl.html [GNU General Public License]
	 * @param {jQuery} {sha1:function(string))
	 * @return string
	 */
	
	(function($){
		
		var rotateLeft = function(lValue, iShiftBits) {
			return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
		}
		
		var lsbHex = function(value) {
			var string = "";
			var i;
			var vh;
			var vl;
			for(i = 0;i <= 6;i += 2) {
				vh = (value>>>(i * 4 + 4))&0x0f;
				vl = (value>>>(i*4))&0x0f;
				string += vh.toString(16) + vl.toString(16);
			}
			return string;
		};
		
		var cvtHex = function(value) {
			var string = "";
			var i;
			var v;
			for(i = 7;i >= 0;i--) {
				v = (value>>>(i * 4))&0x0f;
				string += v.toString(16);
			}
			return string;
		};
		
		var uTF8Encode = function(string) {
			string = string.replace(/\x0d\x0a/g, "\x0a");
			var output = "";
			for (var n = 0; n < string.length; n++) {
				var c = string.charCodeAt(n);
				if (c < 128) {
					output += String.fromCharCode(c);
				} else if ((c > 127) && (c < 2048)) {
					output += String.fromCharCode((c >> 6) | 192);
					output += String.fromCharCode((c & 63) | 128);
				} else {
					output += String.fromCharCode((c >> 12) | 224);
					output += String.fromCharCode(((c >> 6) & 63) | 128);
					output += String.fromCharCode((c & 63) | 128);
				}
			}
			return output;
		};
		
		$.extend({
			sha1: function(string) {
				var blockstart;
				var i, j;
				var W = new Array(80);
				var H0 = 0x67452301;
				var H1 = 0xEFCDAB89;
				var H2 = 0x98BADCFE;
				var H3 = 0x10325476;
				var H4 = 0xC3D2E1F0;
				var A, B, C, D, E;
				var tempValue;
				string = uTF8Encode(string);
				var stringLength = string.length;
				var wordArray = new Array();
				for(i = 0;i < stringLength - 3;i += 4) {
					j = string.charCodeAt(i)<<24 | string.charCodeAt(i + 1)<<16 | string.charCodeAt(i + 2)<<8 | string.charCodeAt(i + 3);
					wordArray.push(j);
				}
				switch(stringLength % 4) {
					case 0:
						i = 0x080000000;
					break;
					case 1:
						i = string.charCodeAt(stringLength - 1)<<24 | 0x0800000;
					break;
					case 2:
						i = string.charCodeAt(stringLength - 2)<<24 | string.charCodeAt(stringLength - 1)<<16 | 0x08000;
					break;
					case 3:
						i = string.charCodeAt(stringLength - 3)<<24 | string.charCodeAt(stringLength - 2)<<16 | string.charCodeAt(stringLength - 1)<<8 | 0x80;
					break;
				}
				wordArray.push(i);
				while((wordArray.length % 16) != 14 ) wordArray.push(0);
				wordArray.push(stringLength>>>29);
				wordArray.push((stringLength<<3)&0x0ffffffff);
				for(blockstart = 0;blockstart < wordArray.length;blockstart += 16) {
					for(i = 0;i < 16;i++) W[i] = wordArray[blockstart+i];
					for(i = 16;i <= 79;i++) W[i] = rotateLeft(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1);
					A = H0;
					B = H1;
					C = H2;
					D = H3;
					E = H4;
					for(i = 0;i <= 19;i++) {
						tempValue = (rotateLeft(A, 5) + ((B&C) | (~B&D)) + E + W[i] + 0x5A827999) & 0x0ffffffff;
						E = D;
						D = C;
						C = rotateLeft(B, 30);
						B = A;
						A = tempValue;
					}
					for(i = 20;i <= 39;i++) {
						tempValue = (rotateLeft(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff;
						E = D;
						D = C;
						C = rotateLeft(B, 30);
						B = A;
						A = tempValue;
					}
					for(i = 40;i <= 59;i++) {
						tempValue = (rotateLeft(A, 5) + ((B&C) | (B&D) | (C&D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff;
						E = D;
						D = C;
						C = rotateLeft(B, 30);
						B = A;
						A = tempValue;
					}
					for(i = 60;i <= 79;i++) {
						tempValue = (rotateLeft(A, 5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff;
						E = D;
						D = C;
						C = rotateLeft(B, 30);
						B = A;
						A = tempValue;
					}
					H0 = (H0 + A) & 0x0ffffffff;
					H1 = (H1 + B) & 0x0ffffffff;
					H2 = (H2 + C) & 0x0ffffffff;
					H3 = (H3 + D) & 0x0ffffffff;
					H4 = (H4 + E) & 0x0ffffffff;
				}
				var tempValue = cvtHex(H0) + cvtHex(H1) + cvtHex(H2) + cvtHex(H3) + cvtHex(H4);
				return tempValue.toLowerCase();
			}
		});
	})(jQuery);
	
	/**
	 * jQuery SHA1 hash algorithm function
	 * 
	 * 	<code>
	 * 		Calculate the sha1 hash of a String 
	 * 		String $.sha1 ( String str )
	 * 	</code>
	 * 
	 * Calculates the sha1 hash of str using the US Secure Hash Algorithm 1.
	 * SHA-1 the Secure Hash Algorithm (SHA) was developed by NIST and is specified in the Secure Hash Standard (SHS, FIPS 180).
	 * This script is used to process variable length message into a fixed-length output using the SHA-1 algorithm. It is fully compatible with UTF-8 encoding.
	 * If you plan using UTF-8 encoding in your project don't forget to set the page encoding to UTF-8 (Content-Type meta tag).
	 * This function orginally get from the WebToolkit and rewrite for using as the jQuery plugin.
	 * 
	 * Example
	 * 	Code
	 * 		<code>
	 * 			$.sha1("I'm Persian."); 
	 * 		</code>
	 * 	Result
	 * 		<code>
	 * 			"1d302f9dc925d62fc859055999d2052e274513ed"
	 * 		</code>
	 * 
	 * @alias Muhammad Hussein Fattahizadeh < muhammad [AT] semnanweb [DOT] com >
	 * @link http://www.semnanweb.com/jquery-plugin/sha1.html
	 * @see http://www.webtoolkit.info/
	 * @license http://www.gnu.org/licenses/gpl.html [GNU General Public License]
	 * @param {jQuery} {sha1:function(string))
	 * @return string
	 */
	
	(function($){
		
		var rotateLeft = function(lValue, iShiftBits) {
			return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
		}
		
		var lsbHex = function(value) {
			var string = "";
			var i;
			var vh;
			var vl;
			for(i = 0;i <= 6;i += 2) {
				vh = (value>>>(i * 4 + 4))&0x0f;
				vl = (value>>>(i*4))&0x0f;
				string += vh.toString(16) + vl.toString(16);
			}
			return string;
		};
		
		var cvtHex = function(value) {
			var string = "";
			var i;
			var v;
			for(i = 7;i >= 0;i--) {
				v = (value>>>(i * 4))&0x0f;
				string += v.toString(16);
			}
			return string;
		};
		
		var uTF8Encode = function(string) {
			string = string.replace(/\x0d\x0a/g, "\x0a");
			var output = "";
			for (var n = 0; n < string.length; n++) {
				var c = string.charCodeAt(n);
				if (c < 128) {
					output += String.fromCharCode(c);
				} else if ((c > 127) && (c < 2048)) {
					output += String.fromCharCode((c >> 6) | 192);
					output += String.fromCharCode((c & 63) | 128);
				} else {
					output += String.fromCharCode((c >> 12) | 224);
					output += String.fromCharCode(((c >> 6) & 63) | 128);
					output += String.fromCharCode((c & 63) | 128);
				}
			}
			return output;
		};
		
		$.extend({
			sha1: function(string) {
				var blockstart;
				var i, j;
				var W = new Array(80);
				var H0 = 0x67452301;
				var H1 = 0xEFCDAB89;
				var H2 = 0x98BADCFE;
				var H3 = 0x10325476;
				var H4 = 0xC3D2E1F0;
				var A, B, C, D, E;
				var tempValue;
				string = uTF8Encode(string);
				var stringLength = string.length;
				var wordArray = new Array();
				for(i = 0;i < stringLength - 3;i += 4) {
					j = string.charCodeAt(i)<<24 | string.charCodeAt(i + 1)<<16 | string.charCodeAt(i + 2)<<8 | string.charCodeAt(i + 3);
					wordArray.push(j);
				}
				switch(stringLength % 4) {
					case 0:
						i = 0x080000000;
					break;
					case 1:
						i = string.charCodeAt(stringLength - 1)<<24 | 0x0800000;
					break;
					case 2:
						i = string.charCodeAt(stringLength - 2)<<24 | string.charCodeAt(stringLength - 1)<<16 | 0x08000;
					break;
					case 3:
						i = string.charCodeAt(stringLength - 3)<<24 | string.charCodeAt(stringLength - 2)<<16 | string.charCodeAt(stringLength - 1)<<8 | 0x80;
					break;
				}
				wordArray.push(i);
				while((wordArray.length % 16) != 14 ) wordArray.push(0);
				wordArray.push(stringLength>>>29);
				wordArray.push((stringLength<<3)&0x0ffffffff);
				for(blockstart = 0;blockstart < wordArray.length;blockstart += 16) {
					for(i = 0;i < 16;i++) W[i] = wordArray[blockstart+i];
					for(i = 16;i <= 79;i++) W[i] = rotateLeft(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1);
					A = H0;
					B = H1;
					C = H2;
					D = H3;
					E = H4;
					for(i = 0;i <= 19;i++) {
						tempValue = (rotateLeft(A, 5) + ((B&C) | (~B&D)) + E + W[i] + 0x5A827999) & 0x0ffffffff;
						E = D;
						D = C;
						C = rotateLeft(B, 30);
						B = A;
						A = tempValue;
					}
					for(i = 20;i <= 39;i++) {
						tempValue = (rotateLeft(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff;
						E = D;
						D = C;
						C = rotateLeft(B, 30);
						B = A;
						A = tempValue;
					}
					for(i = 40;i <= 59;i++) {
						tempValue = (rotateLeft(A, 5) + ((B&C) | (B&D) | (C&D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff;
						E = D;
						D = C;
						C = rotateLeft(B, 30);
						B = A;
						A = tempValue;
					}
					for(i = 60;i <= 79;i++) {
						tempValue = (rotateLeft(A, 5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff;
						E = D;
						D = C;
						C = rotateLeft(B, 30);
						B = A;
						A = tempValue;
					}
					H0 = (H0 + A) & 0x0ffffffff;
					H1 = (H1 + B) & 0x0ffffffff;
					H2 = (H2 + C) & 0x0ffffffff;
					H3 = (H3 + D) & 0x0ffffffff;
					H4 = (H4 + E) & 0x0ffffffff;
				}
				var tempValue = cvtHex(H0) + cvtHex(H1) + cvtHex(H2) + cvtHex(H3) + cvtHex(H4);
				return tempValue.toLowerCase();
			}
		});
	})(jQuery);
(function($){ 
     $.fn.extend({  
         limit: function(limit,commonParent) {
			var interval, f;
			var self = $(this);
			var element = self.parents(commonParent).find(".charsLeft");
			
			$(this).focus(function(){
				interval = window.setInterval(substring,100);
			});
			
			$(this).blur(function(){
				clearInterval(interval);
				substring();
			});
			
			function substring(){
				var val = $(self).val();
				var length = val.length;
				if(length > limit){
					$(self).val($(self).val().substring(0,limit));
				}
				if(element.html() != limit-length){
					element.html((limit-length<=0)?'0':limit-length);
				}
		  }
						
			substring();
			
        } 
    }); 
})(jQuery);
/*
 * jQuery Color Animations
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 */

(function(jQuery){

	// We override the animation for all of these color styles
	jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
		jQuery.fx.step[attr] = function(fx){
			if ( fx.state == 0 ) {
				fx.start = getColor( fx.elem, attr );
				fx.end = getRGB( fx.end );
			}

			fx.elem.style[attr] = "rgb(" + [
				Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
				Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
				Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
			].join(",") + ")";
		}
	});

	// Color Conversion functions from highlightFade
	// By Blair Mitchelmore
	// http://jquery.offput.ca/highlightFade/

	// Parse strings looking for color tuples [255,255,255]
	function getRGB(color) {
		var result;

		// Check if we're already dealing with an array of colors
		if ( color && color.constructor == Array && color.length == 3 )
			return color;

		// Look for rgb(num,num,num)
		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
			return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];

		// Look for rgb(num%,num%,num%)
		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
			return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];

		// Look for #a0b1c2
		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
			return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];

		// Look for #fff
		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
			return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];

		// Otherwise, we're most likely dealing with a named color
		return colors[jQuery.trim(color).toLowerCase()];
	}
	
	function getColor(elem, attr) {
		var color;

		do {
			color = jQuery.curCSS(elem, attr);

			// Keep going until we find an element that has color, or we hit the body
			if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
				break; 

			attr = "backgroundColor";
		} while ( elem = elem.parentNode );

		return getRGB(color);
	};
	
	// Some named colors to work with
	// From Interface by Stefan Petre
	// http://interface.eyecon.ro/

	var colors = {
		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]
	};
	
})(jQuery);
(function($){ 
	$.fn.extend({  
		ghost_text: function() {
			var self = $(this);
			var css_off = {"color":"#555"};
			var css_on = {"color":"#000"}
			self.data("ghost",self.val());
			
			self.css(css_off);
			
			self.focus(function(){
				self.css(css_on);
				if (self.val() == self.data("ghost"))
				{
					self.attr("value","");
				}
			});
			
			self.blur(function(){
				if (self.val()=="")
				{
					self.attr("value",self.data("ghost"));
					self.css(css_off);
				}
			});
			return self;
		}
	}); 
})(jQuery);
/**
 * @author Alexander Farkas
 * v. 1.1
 */
(function($){
	
	if(!document.defaultView || !document.defaultView.getComputedStyle){
		var oldCurCSS = jQuery.curCSS;
		jQuery.curCSS = function(elem, name, force){
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}
})(jQuery);

(function($) {
	
	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}
	
	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			
			var start = $.curCSS(fx.elem,'backgroundPosition');
			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}
			
			start = toArray(start);
			fx.start = [start[0],start[2]];
			
			var end = toArray(fx.options.curAnim.backgroundPosition);
			fx.end = [end[0],end[2]];
			
			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);
