/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (MIT_LICENSE.txt)
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
*
* Version: 1.1.1
* Requires jQuery 1.3+
* Docs: http://docs.jquery.com/Plugins/livequery
*/

(function($) {

				$.extend($.fn, {
								livequery: function(type, fn, fn2) {
												var self = this, q;

												// Handle different call patterns
												if ($.isFunction(type))
																fn2 = fn, fn = type, type = undefined;

												// See if Live Query already exists
												$.each( $.livequery.queries, function(i, query) {
																if ( self.selector == query.selector && self.context == query.context &&
																				type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
																				// Found the query, exit the each loop
																				return (q = query) && false;
												});

												// Create new Live Query if it wasn't found
												q = q || new $.livequery(this.selector, this.context, type, fn, fn2);

												// Make sure it is running
												q.stopped = false;

												// Run it immediately for the first time
												q.run();

												// Contnue the chain
												return this;
								},

								expire: function(type, fn, fn2) {
												var self = this;

												// Handle different call patterns
												if ($.isFunction(type))
																fn2 = fn, fn = type, type = undefined;

												// Find the Live Query based on arguments and stop it
												$.each( $.livequery.queries, function(i, query) {
																if ( self.selector == query.selector && self.context == query.context &&
																				(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
																				$.livequery.stop(query.id);
												});

												// Continue the chain
												return this;
								}
				});

				$.livequery = function(selector, context, type, fn, fn2) {
								this.selector = selector;
								this.context = context;
								this.type = type;
								this.fn = fn;
								this.fn2 = fn2;
								this.elements = [];
								this.stopped = false;

								// The id is the index of the Live Query in $.livequery.queries
								this.id = $.livequery.queries.push(this)-1;

								// Mark the functions for matching later on
								fn.$lqguid = fn.$lqguid || $.livequery.guid++;
								if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;

								// Return the Live Query
								return this;
				};

				$.livequery.prototype = {
								stop: function() {
												var query = this;

												if ( this.type )
																// Unbind all bound events
																this.elements.unbind(this.type, this.fn);
												else if (this.fn2)
																// Call the second function for all matched elements
																this.elements.each(function(i, el) {
																				query.fn2.apply(el);
																});

												// Clear out matched elements
												this.elements = [];

												// Stop the Live Query from running until restarted
												this.stopped = true;
								},

								run: function() {
												// Short-circuit if stopped
												if ( this.stopped ) return;
												var query = this;

												var oEls = this.elements,
												els = $(this.selector, this.context),
												nEls = els.not(oEls);

												// Set elements to the latest set of matched elements
												this.elements = els;

												if (this.type) {
																// Bind events to newly matched elements
																nEls.bind(this.type, this.fn);

																// Unbind events to elements no longer matched
																if (oEls.length > 0)
																				$.each(oEls, function(i, el) {
																								if ( $.inArray(el, els) < 0 )
																												$.event.remove(el, query.type, query.fn);
																				});
												}
												else {
																// Call the first function for newly matched elements
																nEls.each(function() {
																				query.fn.apply(this);
																});

																// Call the second function for elements no longer matched
																if ( this.fn2 && oEls.length > 0 )
																				$.each(oEls, function(i, el) {
																								if ( $.inArray(el, els) < 0 )
																												query.fn2.apply(el);
																				});
												}
								}
				};

				$.extend($.livequery, {
								guid: 0,
								queries: [],
								queue: [],
								running: false,
								timeout: null,

								checkQueue: function() {
												if ( $.livequery.running && $.livequery.queue.length ) {
																var length = $.livequery.queue.length;
																// Run each Live Query currently in the queue
																while ( length-- )
																				$.livequery.queries[ $.livequery.queue.shift() ].run();
												}
								},

								pause: function() {
												// Don't run anymore Live Queries until restarted
												$.livequery.running = false;
								},

								play: function() {
												// Restart Live Queries
												$.livequery.running = true;
												// Request a run of the Live Queries
												$.livequery.run();
								},

								registerPlugin: function() {
												$.each( arguments, function(i,n) {
																// Short-circuit if the method doesn't exist
																if (!$.fn[n]) return;

																// Save a reference to the original method
																var old = $.fn[n];

																// Create a new method
																$.fn[n] = function() {
																				// Call the original method
																				var r = old.apply(this, arguments);

																				// Request a run of the Live Queries
																				$.livequery.run();

																				// Return the original methods result
																				return r;
																}
												});
								},

								run: function(id) {
												if (id != undefined) {
																// Put the particular Live Query in the queue if it doesn't already exist
																if ( $.inArray(id, $.livequery.queue) < 0 )
																				$.livequery.queue.push( id );
												}
												else
																// Put each Live Query in the queue if it doesn't already exist
																$.each( $.livequery.queries, function(id) {
																				if ( $.inArray(id, $.livequery.queue) < 0 )
																								$.livequery.queue.push( id );
																});

												// Clear timeout if it already exists
												if ($.livequery.timeout) clearTimeout($.livequery.timeout);
												// Create a timeout to check the queue and actually run the Live Queries
												$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
								},

								stop: function(id) {
												if (id != undefined)
																// Stop are particular Live Query
																$.livequery.queries[ id ].stop();
												else
																// Stop all Live Queries
																$.each( $.livequery.queries, function(id) {
																				$.livequery.queries[ id ].stop();
																});
								}
				});

				// Register core DOM manipulation methods
				$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove', 'html');

				// Run Live Queries when the Document is ready
				$(function() {
								$.livequery.play();
				});

})(jQuery);
  
/************************************************************jquery.Ajaxify.js*******************************************************/
/*
 * Ajaxify - jQuery Plugin
 * version: 2.00 (11/12/2008)
 * Created by: MaX
 * Examples and documentation at: http://max.jsrhost.com/ajaxify/
 * licensed under and GPL licenses:
 * http://www.gnu.org/licenses/gpl.html
 */

(function($){


				jQuery.AjaxifyDefaults = {
								event:'click', /*specify the event*/
								link:false, /* specify the link, priority is for the href attr.*/
								target:'#container', /*the data loaded via ajax will be placed here*/
								animateOut:true,
								animateIn:true,
								animateOutSpeed:'slow',
								animateInSpeed:'slow',
								method: 'POST', /* the request method GET or POST*/
								tagToload:false, /* inserts just the tag from the data loaded, it can be specified as t a second argument in the 'target' attr(#box,#result)*/
								loading_txt:'',
								loading_img:false,
								loading_target: false,
								loading_fn:function(options){
												jQuery.ajaxifyLoading(options);
								},
								loadHash:false,	/* for use this to resolve bookmarking issues, see example for more details*/
								title:false, /* change page title along with the request. */
								forms:false, /* send form data along with th request (forms, input , radio ... etc jquery selector) */
								params:'ajax=true',/*extend parameters for the webpage. it can be set to function since v2*/
								timeout:false, /*in ms.  there is a problem in this option on linux servers*/
								contentType:"application/x-www-form-urlencoded",
								dataType:'html',
								cache:false, /* force the browser not to cache*/
								username:false, /*username HTTP access authentication*/
								password:false, /*password HTTP access authentication*/
								onStart:function(op){}, /* a callback function before start requesting.*/
								onError:function(op){
												jQuery.ajaxifyManip(op,"<font style='color: #CC0000'>Error: </font> Couldn't open the page.");
								}, /* a callback function if error happened while requesting*/
								onSuccess:function(op){},/* a callback function if the request finished successfuly*/
								onComplete:function(op){}//*a callback function when the request finished weather it was a successful one or not.*/
				};
				jQuery.AjaxifyFirstLoad = true;
				jQuery.AjaxifyhistorySet = new Object();
				jQuery.AjaxifyPageTitle = document.title;
				jQuery.AjaxifyDebug = false;



				jQuery.fn.ajaxify = function(options) {
								if(!jQuery(this).size()){
												jQuery.ajaxifylog('Error: No matched element/s for your ajaxify selector " '+jQuery(this).selector+' ".');
												return false;
								}
								/*var ver = jQuery.fn.jquery.split('.');
	if(ver[0] < 1 || ver[1] < 2 || ver[2] < 6){
		jQuery.ajaxifylog('Error: Your jQuery version is old. Version 1.2.6 or newer is required.');
		return false;
	}*/
								return this.each(function() {
												var current = jQuery.extend({},jQuery.AjaxifyDefaults, options);
												if(jQuery.metadata){
																current = jQuery.extend(current,jQuery(this).metadata());
												}
	
	
												if(current.event){
																jQuery(this).bind(current.event,function(){
																				jQuery(this).ajaxifyAnalyse(current);
																				if(!current.hash){
																								jQuery.ajaxifyLoad(current);
																				}
																				else{
																								jQuery.ajaxifyHash(current);
																				}
																				//stop browser
																				if(jQuery(this).is('a') || jQuery(this).is('form')) return false;
																});
												}else{
																jQuery(this).ajaxifyAnalyse(current);
																jQuery.ajaxifyLoad(current);
												}
		
												//for bookmarking
												if(current.loadHash  && jQuery.AjaxifyFirstLoad){
																jQuery(this).ajaxifyAnalyse(current);
			
																if(document.location.hash.replace(/^#/, '') == current.hash	&& current.hash){
																				jQuery.ajaxifyHash(current);
																				jQuery.AjaxifyFirstLoad = false;
																}
												}
		
								}); // end each fn
				}; // end ajaxify fn


 

 
				jQuery.fn.ajaxifyAnalyse = function(current){
								current.object = this;
								if(jQuery(this).is('a')){
												if(jQuery(this).attr('href')){
																//if(jQuery.browser.msie)
																//var link = jQuery(this).attr('href').replace(/^#/, "");
																//else
																var link = jQuery(this).attr('href').replace(/^#/, "");
																//alert(link);
																current.link = link || current.link;
												}else
																current.link;
			
												if(typeof current.tagToload != 'object')
																if(jQuery(this).attr('target'))
																				current.target = jQuery(this).attr('target');
																else
																				current.target;
												else
																current.target = current.loading_target || '#AjaxifyTemp';
								}
	   
								if(!current.loading_target)
												current.loading_target = current.target;
	   

								if(current.forms){
												var text = jQuery(current.forms).serialize();
												current.paramres = text;
								}
	
								if(typeof current.params == 'function')
												var params = current.params(current);
								else
												var params = current.params;

								if(typeof params == 'string'){
												if(text)
																current.paramres +='&'+params;
												else
																current.paramres = params;
								}
	
								var len = current.target.length-1;
								if(typeof current.tagToload !='object')
												if(current.target.charAt(len) == '+' || current.target.charAt(len)=='-' || current.target.charAt(len)=='^'){
																current.manip = current.target.charAt(len);
																current.target = current.target.substr(0,len);
												}

								if(current.loadHash){
												if(!jQuery.historyInit){
																jQuery.ajaxifylog('Error: loadHash is enabled but history plugin couldn\'t be found.');
																return false;
												}
		
												if(current.loadHash === true){
																jQuery.ajaxifylog('Info: It seemes you are upgrading from v1.0. Please see the new documentation about loadHash. "attr:href" will be used instead of "true".');
																current.loadHash = "attr:href";
												}
												if(current.loadHash.toLowerCase() == 'attr:href' ||
																current.loadHash.toLowerCase() == 'attr:rel' ||
																current.loadHash.toLowerCase() == 'attr:title'){
			
																current.loadHash = current.loadHash.toLowerCase();
			
																current.hash = jQuery(this).attr(current.loadHash.replace('attr:',''));
			
																if(jQuery.browser.opera){
																				current.hash = current.hash.replace('?','%3F');
																				current.hash = current.hash.replace('&','%26');
																				current.hash = current.hash.replace('=','%3D');
																}
												}else
																current.hash = current.loadHash;
			
												if(!current.hash)
																jQuery.ajaxifylog('Warning: You have specified loadHash, but its empty or attribute couldn\'t be found.');
								}
	
								if(!jQuery(current.target).size() && typeof current.tagToload !='object')
												jQuery.ajaxifylog('Warning: Target " '+current.target+' " couldn\'t be found.');
 	

				};

 


				jQuery.ajaxifyLoading = function(options){
								var html = "<div id='AjaxifyLoading'><img src='"+options.loading_img+"' alt='Loading...' title='Loading...' >"+options.loading_txt+"</div>";
								if(options.loading_target)
												jQuery.ajaxifyManip(options.loading_target,html);
								else
												jQuery.ajaxifyManip(options,html);
				}





				jQuery.ajaxifyHash = function(current){
								var ob = new Object();
								jQuery.each(current, function(key, value) {
												ob[key] = value;
								});
								jQuery.AjaxifyhistorySet[ob.hash] = ob;
								location.hash = ob.hash;
								//if(jQuery.AjaxifyFirstLoad.history){
								//alert(ob.hash);
								jQuery.historyInit(jQuery.ajaxifyHistory);
								jQuery.AjaxifyFirstLoad.history = false;
				//}
				};





				jQuery.ajaxifyLoad = function(current) {
								// turn off globals
								//alert('ajaxifyLoad'+print_r(current,true));
								jQuery.ajaxSetup({
												global:false
								});
								//start calling  jQuery.ajax function. thank you jquery for making this easy
								jQuery.ajax({
												type: current.method,
												url: current.link,
												dataType: current.dataType,
												data: current.paramres,
												contentType:current.contentType,
												processData:true,
												timeout:current.timeout,
												cache:current.cache,
												username:current.username,
												password:current.password,
												complete: function(){
																current.onComplete(current)
												},
												beforeSend: function(){
																if($('body').scrollTop() > 0 && $('body').scrollTop() > 200)
																{
																				$('body').animate({
																								scrollTop:0
																				}, 'slow');
																}
																else if($('html').scrollTop() > 0 && $('html').scrollTop() > 230)
																{
																				$('html').animate({
																								scrollTop:0
																				}, 'slow');
																}
 

																current.onStart(current);
			
																if(current.animateOut){
																				if(current.loading_target != current.target);//diff target? fire before start anim
																				current.loading_fn(current);
																				jQuery(current.target).animate(current.animateOut,current.animateOutSpeed,function(){
																								//alert('hr');
																								if(!current.loading_target)//already fired
																												current.loading_fn(current);
																				});
																}else
																				current.loading_fn(current);
												},
												success: function(data){
																jQuery(current.target).stop();
																jQuery('#AjaxifyLoading').remove();
																if(current.title)
																				document.title = current.title;
																else if(document.title != jQuery.AjaxifyPageTitle)
																				document.title = jQuery.AjaxifyPageTitle;
		
																if(current.tagToload){
																				data = '<div>'+data+'</div>'; //wrap data so we can find tags within it.
																				if(typeof current.tagToload == 'string'){
																								jQuery.ajaxifyManip(current,jQuery(data).find(current.tagToload));
																				}else if(typeof current.tagToload == 'object') {
																								jQuery.each(current.tagToload, function(tag, target) {
																												if(jQuery(data).find(tag).size())
																																jQuery.ajaxifyManip(target,jQuery(data).find(tag));
																												else
																																jQuery.ajaxifylog('Warning: Tag "'+tag+'" couldn\'t be found.');
						
																								});
																				}
		
																}else{
																				//
																				jQuery.ajaxifyManip(current,data);
																}
																current.onSuccess(current,data);
																if(current.animateIn)
																				jQuery(current.target).animate(current.animateIn,current.animateInSpeed);
		  
												},
												error:function(msg){
																jQuery(current.target).stop();
																current.onError(current,msg);
																if(current.animateIn)
																				jQuery(current.target).animate(current.animateIn,current.animateInSpeed);
												}
								});
				};





				jQuery.ajaxifylog = function(message) {
								if(jQuery.AjaxifyDebug)
												if(window.console) {
																console.debug(message);
												} else {
																alert(message);
												}
				};





				jQuery.ajaxifyHistory = function(hash){
								if(hash){
												if(jQuery.browser.safari){
																var options = jQuery.AjaxifyhistorySet[location.hash.replace(/^#/,'')]; //fix bug in history.js
												}else
																var options = jQuery.AjaxifyhistorySet[hash];
			
			

												if(options)
																jQuery.ajaxifyLoad(options);
												else
																jQuery.ajaxifylog('History Fired. But I couldn\'t find hash. Most propabley, the hash is empty. If so, its normal.');
								}
				};





				jQuery.ajaxifyManip = function(current,data){

								if(typeof current != 'object'){
												var target = current;
												var current = new Object;
												var len = target.length-1;
												if(target.charAt(len) == '+' || target.charAt(len)=='-' || target.charAt(len)=='^'){
																current.manip = target.charAt(len);
																current.target = target.substr(0,len);
												}
												else{
																current.manip = '';
																current.target = target;
												}
												if(!jQuery(current.target).size())
																jQuery.ajaxifylog('Warning: Target "'+current.target+'" couldn\'t be found.');
								}
	
		
								if(current.manip == '+'){
												jQuery(current.target).append(data);
								}else if(current.manip == '-')
												jQuery(current.target).prepend(data);
								else if(current.manip == '^'){
												jQuery(current.target).after(data);
								}else
												jQuery(current.target).html(data);
				};


})(jQuery);

/************************************************************jquery.history.fixed.js*******************************************************/
/*
 * jQuery history plugin
 *
 * Copyright (c) 2006 Taku Sano (Mikage Sawatari)
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Modified by Lincoln Cooper to add Safari support and only call the callback once during initialization
 * for msie when no initial hash supplied.
 *
 *Modified by MaX to fix multiple iframes in IE
 */


jQuery.extend({
				historyCurrentHash: undefined,
	
				historyCallback: undefined,
	
				historyInit: function(callback){
								jQuery.historyCallback = callback;

								var current_hash = location.hash;
		
								jQuery.historyCurrentHash = current_hash;
								if(jQuery.browser.msie) {
												// To stop the callback firing twice during initilization if no hash present
												if (jQuery.historyCurrentHash == '') {
																jQuery.historyCurrentHash = '#';
												}
		
												// add hidden iframe for IE
												if(!$("#jQuery_history").size()) // to fix IE multi iframes (MaX)
																$("body").prepend('<iframe id="jQuery_history" style="display:none"></iframe>');
												var ihistory = $("#jQuery_history")[0];
												var iframe = ihistory.contentWindow.document;
												iframe.open();
												iframe.close();
												iframe.location.hash = current_hash;
								}
								else if ($.browser.safari) {
												// etablish back/forward stacks
												jQuery.historyBackStack = [];
												jQuery.historyBackStack.length = history.length;
												jQuery.historyForwardStack = [];
			
												jQuery.isFirst = true;
								}
								jQuery.historyCallback(current_hash.replace(/^#/, ''));
								setInterval(jQuery.historyCheck, 100);
				},
	
				historyAddHistory: function(hash) {
								// This makes the looping function do something
								jQuery.historyBackStack.push(hash);
		
								jQuery.historyForwardStack.length = 0; // clear forwardStack (true click occured)
								this.isFirst = true;
				},
	
				historyCheck: function(){
								if(jQuery.browser.msie) {
												// On IE, check for location.hash of iframe
												var ihistory = $("#jQuery_history")[0];
												var iframe = ihistory.contentDocument || ihistory.contentWindow.document;
												var current_hash = iframe.location.hash;
												if(current_hash != jQuery.historyCurrentHash) {
			
																location.hash = current_hash;
																jQuery.historyCurrentHash = current_hash;
																jQuery.historyCallback(current_hash.replace(/^#/, ''));
				
												}
								} else if ($.browser.safari) {
												if (!jQuery.dontCheck) {
																var historyDelta = history.length - jQuery.historyBackStack.length;
				
																if (historyDelta) { // back or forward button has been pushed
																				jQuery.isFirst = false;
																				if (historyDelta < 0) { // back button has been pushed
																								// move items to forward stack
																								for (var i = 0; i < Math.abs(historyDelta); i++) jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop());
																				} else { // forward button has been pushed
																								// move items to back stack
																								for (var i = 0; i < historyDelta; i++) jQuery.historyBackStack.push(jQuery.historyForwardStack.shift());
																				}
																				var cachedHash = jQuery.historyBackStack[jQuery.historyBackStack.length - 1];
																				if (cachedHash != undefined) {
																								jQuery.historyCurrentHash = location.hash;
																								jQuery.historyCallback(cachedHash);
																				}
																} else if (jQuery.historyBackStack[jQuery.historyBackStack.length - 1] == undefined && !jQuery.isFirst) {
																				// back button has been pushed to beginning and URL already pointed to hash (e.g. a bookmark)
																				// document.URL doesn't change in Safari
																				if (document.URL.indexOf('#') >= 0) {
																								jQuery.historyCallback(document.URL.split('#')[1]);
																				} else {
																								var current_hash = location.hash;
																								jQuery.historyCallback('');
																				}
																				jQuery.isFirst = true;
																}
												}
								} else {
												// otherwise, check for location.hash
												var current_hash = location.hash;
												if(current_hash != jQuery.historyCurrentHash) {
																jQuery.historyCurrentHash = current_hash;
																jQuery.historyCallback(current_hash.replace(/^#/, ''));
												}
								}
				},
				historyLoad: function(hash){
								var newhash;
		
								if (jQuery.browser.safari) {
												newhash = hash;
								}
								else {
												newhash = '#' + hash;
												location.hash = newhash;
								}
								jQuery.historyCurrentHash = newhash;
		
								if(jQuery.browser.msie) {
												var ihistory = $("#jQuery_history")[0];
												var iframe = ihistory.contentWindow.document;
												iframe.open();
												iframe.close();
												iframe.location.hash = newhash;
												jQuery.historyCallback(hash);
								}
								else if (jQuery.browser.safari) {
												jQuery.dontCheck = true;
												// Manually keep track of the history values for Safari
												this.historyAddHistory(hash);
			
												// Wait a while before allowing checking so that Safari has time to update the "history" object
												// correctly (otherwise the check loop would detect a false change in hash).
												var fn = function() {
																jQuery.dontCheck = false;
												};
												window.setTimeout(fn, 200);
												jQuery.historyCallback(hash);
												// N.B. "location.hash=" must be the last line of code for Safari as execution stops afterwards.
												//      By explicitly using the "location.hash" command (instead of using a variable set to "location.hash") the
												//      URL in the browser and the "history" object are both updated correctly.
												location.hash = newhash;
								}
								else {
												jQuery.historyCallback(hash);
								}
				}
});
/************************************************************jquery.simplemodal-1.1.1.js*******************************************************/
/*
 * SimpleModal 1.1.1 - jQuery Plugin
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://plugins.jquery.com/project/SimpleModal
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2007 Eric Martin - http://ericmmartin.com
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Revision: $Id: jquery.simplemodal.js 93 2008-01-15 16:14:20Z emartin24 $
 *
 */

/**
 * SimpleModal is a lightweight jQuery plugin that provides a simple
 * interface to create a modal dialog.
 *
 * The goal of SimpleModal is to provide developers with a cross-browser 
 * overlay and container that will be populated with data provided to
 * SimpleModal.
 *
 * There are two ways to call SimpleModal:
 * 1) As a chained function on a jQuery object, like $('#myDiv').modal();.
 * This call would place the DOM object, #myDiv, inside a modal dialog.
 * Chaining requires a jQuery object. An optional options object can be
 * passed as a parameter.
 *
 * @example $('<div>my data</div>').modal({options});
 * @example $('#myDiv').modal({options});
 * @example jQueryObject.modal({options});
 *
 * 2) As a stand-alone function, like $.modal(data). The data parameter
 * is required and an optional options object can be passed as a second
 * parameter. This method provides more flexibility in the types of data 
 * that are allowed. The data could be a DOM object, a jQuery object, HTML
 * or a string.
 * 
 * @example $.modal('<div>my data</div>', {options});
 * @example $.modal('my data', {options});
 * @example $.modal($('#myDiv'), {options});
 * @example $.modal(jQueryObject, {options});
 * @example $.modal(document.getElementById('myDiv'), {options}); 
 * 
 * A SimpleModal call can contain multiple elements, but only one modal 
 * dialog can be created at a time. Which means that all of the matched
 * elements will be displayed within the modal container.
 * 
 * SimpleModal internally sets the CSS needed to display the modal dialog
 * properly in all browsers, yet provides the developer with the flexibility
 * to easily control the look and feel. The styling for SimpleModal can be 
 * done through external stylesheets, or through SimpleModal, using the
 * overlayCss and/or containerCss options.
 *
 * SimpleModal has been tested in the following browsers:
 * - IE 6, 7
 * - Firefox 2
 * - Opera 9
 * - Safari 3
 *
 * @name SimpleModal
 * @type jQuery
 * @requires jQuery v1.1.2
 * @cat Plugins/Windows and Overlays
 * @author Eric Martin (http://ericmmartin.com)
 * @version 1.1.1
 */
(function ($) {
				/*
	 * Stand-alone function to create a modal dialog.
	 * 
	 * @param {string, object} data A string, jQuery object or DOM object
	 * @param {object} [options] An optional object containing options overrides
	 */
				$.modal = function (data, options) {
								return $.modal.impl.init(data, options);
				};

				/*
	 * Stand-alone close function to close the modal dialog
	 */
				$.modal.close = function () {
								// call close with the external parameter set to true
								$.modal.impl.close(true);
				};

				/*
	 * Chained function to create a modal dialog.
	 * 
	 * @param {object} [options] An optional object containing options overrides
	 */
				$.fn.modal = function (options) {
								return $.modal.impl.init(this, options);
				};

				/*
	 * SimpleModal default options
	 * 
	 * overlay: (Number:50) The overlay div opacity value, from 0 - 100
	 * overlayId: (String:'modalOverlay') The DOM element id for the overlay div
	 * overlayCss: (Object:{}) The CSS styling for the overlay div
	 * containerId: (String:'modalContainer') The DOM element id for the container div
	 * containerCss: (Object:{}) The CSS styling for the container div
	 * close: (Boolean:true) Show the default window close icon? Uses CSS class modalCloseImg
	 * closeTitle: (String:'Close') The title value of the default close link. Depends on close
	 * closeClass: (String:'modalClose') The CSS class used to bind to the close event
	 * persist: (Boolean:false) Persist the data across modal calls? Only used for existing
	            DOM elements. If true, the data will be maintained across modal calls, if false,
				the data will be reverted to its original state.
	 * onOpen: (Function:null) The callback function used in place of SimpleModal's open
	 * onShow: (Function:null) The callback function used after the modal dialog has opened
	 * onClose: (Function:null) The callback function used in place of SimpleModal's close
	 */
				$.modal.defaults = {
								overlay: 50,
								overlayId: 'modalOverlay',
								overlayCss: {},
								containerId: 'modalContainer',
								containerCss: {},
								close: true,
								closeTitle: 'Close',
								closeClass: 'modalClose',
								persist: false,
								onOpen: null,
								onShow: null,
								onClose: null
				};

				/*
	 * Main modal object
	 */
				$.modal.impl = {
								/*
		 * Modal dialog options
		 */
								opts: null,
								/*
		 * Contains the modal dialog elements and is the object passed 
		 * back to the callback (onOpen, onShow, onClose) functions
		 */
								dialog: {},
								/*
		 * Initialize the modal dialog
		 */
								init: function (data, options) {
												// don't allow multiple calls
												if (this.dialog.data) {
																return false;
												}

												// merge defaults and user options
												this.opts = $.extend({}, $.modal.defaults, options);

												// determine how to handle the data based on its type
												if (typeof data == 'object') {
																// convert DOM object to a jQuery object
																data = data instanceof jQuery ? data : $(data);

																// if the object came from the DOM, keep track of its parent
																if (data.parent().parent().size() > 0) {
																				this.dialog.parentNode = data.parent();

																				// persist changes? if not, make a clone of the element
																				if (!this.opts.persist) {
																								this.dialog.original = data.clone(true);
																				}
																}
												}
												else if (typeof data == 'string' || typeof data == 'number') {
																// just insert the data as innerHTML
																data = $('<div>').html(data);
												}
												else {
																// unsupported data type!
																if (console) {
																				console.log('SimpleModal Error: Unsupported data type: ' + typeof data);
																}
																return false;
												}
												this.dialog.data = data.addClass('modalData');
												data = null;

												// create the modal overlay, container and, if necessary, iframe
												this.create();

												// display the modal dialog
												this.open();

												// useful for adding events/manipulating data in the modal dialog
												if ($.isFunction(this.opts.onShow)) {
																this.opts.onShow.apply(this, [this.dialog]);
												}

												// don't break the chain =)
												return this;
								},
								/*
		 * Create and add the modal overlay and container to the page
		 */
								create: function () {
												// create the overlay
												this.dialog.overlay = $('<div>')
												.attr('id', this.opts.overlayId)
												.addClass('modalOverlay')
												.css($.extend(this.opts.overlayCss, {
																opacity: this.opts.overlay / 100,
																height: '100%',
																width: '100%',
																position: 'fixed',
																left: 0,
																top: 0,
																zIndex: 3000
												}))
												.hide()
												.appendTo('body');

												// create the container
												this.dialog.container = $('<div>')
												.attr('id', this.opts.containerId)
												.addClass('modalContainer')
												.css($.extend(this.opts.containerCss, {
																position: 'fixed',
																zIndex: 3100
												}))
												.append(this.opts.close
																? '<a class="modalCloseImg '
																+ this.opts.closeClass
																+ '" title="'
																+ this.opts.closeTitle + '"></a>'
																: '')
												.hide()
												.appendTo('body');

												// fix issues with IE and create an iframe
												if ($.browser.msie && ($.browser.version < 7)) {
																this.fixIE();
												}

												// hide the data and add it to the container
												this.dialog.container.append(this.dialog.data.hide());
								},
								/*
		 * Bind events
		 */
								bindEvents: function () {
												var modal = this;

												// bind the close event to any element with the closeClass class
												$('.' + this.opts.closeClass).click(function (e) {
																e.preventDefault();
																modal.close();
												});
								},
								/*
		 * Unbind events
		 */
								unbindEvents: function () {
												// remove the close event

												$('.' + this.opts.closeClass).unbind('click');
								},
								/*
		 * Fix issues in IE 6
		 */
								fixIE: function () {
												var wHeight = $(document.body).height() + 'px';
												var wWidth = $(document.body).width() + 'px';

												// position hacks
												this.dialog.overlay.css({
																position: 'absolute',
																height: wHeight,
																width: wWidth
												});
												this.dialog.container.css({
																position: 'absolute'
												});

												// add an iframe to prevent select options from bleeding through
												this.dialog.iframe = $('<iframe src="javascript:false;">')
												.css($.extend(this.opts.iframeCss, {
																opacity: 0,
																position: 'absolute',
																height: wHeight,
																width: wWidth,
																zIndex: 1000,
																width: '100%',
																top: 0,
																left: 0
												}))
												.hide()
												.appendTo('body');
								},
								/*
		 * Open the modal dialog elements
		 * - Note: If you use the onOpen callback, you must "show" the 
		 *         overlay and container elements manually 
		 *         (the iframe will be handled by SimpleModal)
		 */
								open: function () {
												// display the iframe
												if (this.dialog.iframe) {
																this.dialog.iframe.show();
												}

												if ($.isFunction(this.opts.onOpen)) {
																// execute the onOpen callback
																this.opts.onOpen.apply(this, [this.dialog]);
												}
												else {
																// display the remaining elements
																this.dialog.overlay.show();
																this.dialog.container.show();
																this.dialog.data.show();
												}

												// bind default events
												this.bindEvents();
								},
								/*
		 * Close the modal dialog
		 * - Note: If you use an onClose callback, you must remove the 
		 *         overlay, container and iframe elements manually
		 *
		 * @param {boolean} external Indicates whether the call to this
		 *     function was internal or external. If it was external, the
		 *     onClose callback will be ignored
		 */
								close: function (external) {
												// prevent close when dialog does not exist
												if (!this.dialog.data) {
																return false;
												}

												if ($.isFunction(this.opts.onClose) && !external) {
																// execute the onClose callback
																this.opts.onClose.apply(this, [this.dialog]);
												}
												else {
																// if the data came from the DOM, put it back
																if (this.dialog.parentNode) {
																				// save changes to the data?
																				if (this.opts.persist) {
																								// insert the (possibly) modified data back into the DOM
																								this.dialog.data.hide().appendTo(this.dialog.parentNode);
																				}
																				else {
																								// remove the current and insert the original,
																								// unmodified data back into the DOM
																								this.dialog.data.remove();
																								this.dialog.original.appendTo(this.dialog.parentNode);
																				}
																}
																else {
																				// otherwise, remove it
																				this.dialog.data.remove();
																}

																// remove the remaining elements
																this.dialog.container.remove();
																this.dialog.overlay.remove();
																if (this.dialog.iframe) {
																				this.dialog.iframe.remove();
																}

																// reset the dialog object
																this.dialog = {};
												}

												// remove the default events
												this.unbindEvents();
								}
				};
})(jQuery);
/************************************************************jquery.metadata.min.js*******************************************************/
/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.metadata.js 3620 2007-10-10 20:55:38Z pmclanahan $
 *
 */
(function($){
				$.extend({
								metadata:{
												defaults:{
																type:'class',
																name:'metadata',
																cre:/({.*})/,
																single:'metadata'
												},
												setType:function(type,name){
																this.defaults.type=type;
																this.defaults.name=name;
												},
												get:function(elem,opts){
																var settings=$.extend({},this.defaults,opts);
																if(!settings.single.length)settings.single='metadata';
																var data=$.data(elem,settings.single);
																if(data)return data;
																data="{}";
																if(settings.type=="class"){
																				var m=settings.cre.exec(elem.className);
																				if(m)data=m[1];
																}
																else if(settings.type=="elem"){
																				if(!elem.getElementsByTagName)return;
																				var e=elem.getElementsByTagName(settings.name);
																				if(e.length)data=$.trim(e[0].innerHTML);
																}else if(elem.getAttribute!=undefined){
																				var attr=elem.getAttribute(settings.name);
																				if(attr)data=attr;
																}
																if(data.indexOf('{')<0)data="{"+data+"}";
																data=eval("("+data+")");
																$.data(elem,settings.single,data);
																return data;
												}
								}
				});
				$.fn.metadata=function(opts){
								return $.metadata.get(this[0],opts);
				};

})(jQuery);

var base_domain = base_domain || "/";
var _ua = navigator.userAgent.toLowerCase();
var browser = {
				version: (_ua.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
				opera: /opera/i.test(_ua),
				msie: (!this.opera && /msie/i.test(_ua)),
				msie6: (!this.opera && /msie 6/i.test(_ua)),
				mozilla: /firefox/i.test(_ua),
				chrome: /chrome/i.test(_ua),
				safari: (!(/chrome/i.test(_ua)) && /webkit|safari|khtml/i.test(_ua)),
				iphone: /iphone/i.test(_ua)
}

dom = {
				doc:document,
				isReady: false,
				readyBound: false,
				readyList: [],
				progressMain: false,
				transition_url: 'http://www.animedown.tv/templates/animedown/images/popup_px.png',

				progressChange : function(arrayid) {
								for (key in arrayid) {
												if ($(arrayid[key]).style.display == 'none') $(arrayid[key]).style.display = 'block';
												else $(arrayid[key]).style.display = 'none';
								}
				},

				append:function(el, name, attrs) {
								var child = this.create(name, attrs);
								el.appendChild(child);
								return child;
				},

				create:function(name, proprieties) {
								var el = this.doc.createElement(name);
								this.setProprieties(el, proprieties);
								return el;
				},

				setProprieties:function(el, proprieties) {
								for (propriety in proprieties) {
												el[propriety] = proprieties[propriety];
								}
				},

				setStyles:function(el, styles) {
								for (oneStyle in styles) {
												el.style[oneStyle] = styles[oneStyle];
								}
				},

				getStyle:function(el, oneStyle) {
								return el.style[oneStyle];
				}
}


/**
 * DOM
 **/
function ge() {
				var ea;
				for (var i = 0; i < arguments.length; i++) {
								var e = arguments[i];
								if (typeof e == 'string')
												e = document.getElementById(e);
								if (arguments.length == 1)
												return e;
								if (!ea)
												ea = new Array();
								ea.push(e);
				}
				return ea;
}

function show(elem) {
				if (arguments.length > 1) {
								for (var i = 0; i < arguments.length; i++) {
												show(arguments[i]);
								}
								return;
				}
				elem = ge(elem);
				if (!elem) return;
				var old = data(elem, "olddisplay");
				elem.style.display = old || "";

				if (getStyle(elem, 'display') == "none" ) {
								if (elem.tagName.toLowerCase() == 'tr' && !browser.msie) {
												elem.style.display = 'table-row';
								} else if (elem.tagName.toLowerCase() == 'table' && !browser.msie) {
												elem.style.display = 'table';
								} else {
												elem.style.display = data(elem, "olddisplay", "block");
								}
				}
}

function hide(elem){
				if (arguments.length > 1) {
								for (var i = 0; i < arguments.length; i++) {
												hide(arguments[i]);
								}
								return;
				}
				elem = ge(elem);
				if (!elem) return;
				if (getStyle(elem, 'display') != "none")
								data(elem, "olddisplay", elem.style.display);
				elem.style.display = "none";
}
function isVisible(elem) {
				elem = ge(elem);
				return getStyle(elem, 'display') != 'none' && getStyle(elem, 'visibility') != 'hidden';
}
function toggle(elem) {
				if (isVisible(elem)) {
								hide(elem);
				} else {
								show(elem);
				}
}

function getXY(obj) {
				if (!obj || obj == undefined) return;
				var left = 0, top = 0;
				if (obj.offsetParent) {
								do {
												left += obj.offsetLeft;
												top += obj.offsetTop;
								} while (obj = obj.offsetParent);
				}
				return [left,top];
}

/**
 *  Useful utils
 */

Function.prototype.bind = function(object) {
				var __method = this;
				return function() {
								return __method.apply(object, arguments);
				}
};
function isFunction(obj) {
				return Object.prototype.toString.call(obj) === "[object Function]";
}
function isArray(obj) {
				return Object.prototype.toString.call(obj) === "[object Array]";
}
function now() {
				return +new Date;
}
function trim(text) {
				return (text || "").replace(/^\s+|\s+$/g, "");
}
function stripHTML(text) {
				return text ? text.replace(/<(?:.|\s)*?>/g, "") : '';
}
function escapeRE(s) {
				return s ? s.replace(/[.*+?^${}()|[\]\/\\]/g, '\\$0') : '';
}

/**
 *  Arrays, objects
 **/

function each(object, callback) {
				var name, i = 0, length = object.length;

				if ( length === undefined ) {
								for ( name in object )
												if ( callback.call( object[ name ], name, object[ name ] ) === false )
																break;
				} else
								for ( var value = object[0];
												i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}

				return object;
};
function indexOf(arr, value, from) {
				from = (from == null) ? 0 : from;
				var m = arr.length;
				for(var i = from; i < m; i++)
								if (arr[i] == value)
												return i;
				return -1;
}

function clone(obj) {
				var newObj = {};
				for (var i in obj) {
								newObj[i] = obj[i];
				}
				return newObj;
}


// Get computed style
function getStyle(elem, name, force) {
				elem = ge(elem);
				if (force !== undefined && !force) return elem.style[name];
				if (name == "width" || name == "height") {
								return getSize(elem, true)[({
												'width':0,
												'height':1
								})[name]] + 'px';
				}
				var ret, defaultView = document.defaultView || window;
				if (defaultView.getComputedStyle) {
								name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
								var computedStyle = defaultView.getComputedStyle( elem, null );
								if (computedStyle)
												ret = computedStyle.getPropertyValue(name);
				} else if (elem.currentStyle) {
								if (name == 'opacity' && browser.msie) {
												var filter = elem.currentStyle['filter'];
												return filter && filter.indexOf("opacity=") >= 0 ?
												(parseFloat(filter.match(/opacity=([^)]*)/)[1] ) / 100) + '' : '1';
								}
								var camelCase = name.replace(/\-(\w)/g, function(all, letter){
												return letter.toUpperCase();
								});
								ret = elem.currentStyle[name] || elem.currentStyle[camelCase];
								// If we're not dealing with a regular pixel number
								// but a number that has a weird ending, we need to convert it to pixels
								if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
												// Remember the original values
												var left = style.left, rsLeft = elem.runtimeStyle.left;

												// Put in the new values to get a computed value out
												elem.runtimeStyle.left = elem.currentStyle.left;
												style.left = ret || 0;
												ret = style.pixelLeft + "px";

												// Revert the changed values
												style.left = left;
												elem.runtimeStyle.left = rsLeft;
								}
				}
				return ret;
}

/**
 * Store data connected to element
 **/

var expand = now(), uuid = 0, cache = {};

// Get or set element data
function data(elem, name, data) {
				var id = elem[ expand ], undefined;
				if ( !id )
								id = elem[ expand ] = ++uuid;

				if (name && !cache[id]) cache[id] = {};

				if (data !== undefined) cache[id][name] = data;

				return name ? cache[id][name] : id;
}

function removeData(elem, name) {
				var id = elem[expand];
				if (name) {
								if (cache[id]) {
												delete cache[id][name];
												name = "";
												for (name in cache[id])
																break;

												if (!name)
																removeData(elem);
								}
				} else {
								try {
												delete elem[expand];
								} catch(e){ // fix for IE
												if (elem.removeAttribute)
																elem.removeAttribute(expand);
								}
								delete cache[id];
				}
}






// Prevent memory leaks in IE
// And prevent errors on refresh with events like mouseover in other browsers
// Window isn't included so as not to unbind existing unload events

// Dom ready event handler
(function(){
				var isRdy = false, rdyBnd = false, rdyList = [];

				window.onDomReady = function(fn) {
								bindRdy();
								if (isRdy){
												fn.call(document);
								} else {
												rdyList.push(function() {
																fn.call(document);
												});
								}
				};

				var rdy = function() {
								if (!isRdy) {
												isRdy = true;
												if (rdyList) {
																var l = rdyList;
																l.reverse();
																while (fn = l.pop()) {
																				fn.apply(document);
																}
																rdyList = null;
												}
								}
				};

				var bindRdy = function() {
								if (rdyBnd) return;
								rdyBnd = true;

								if(document.addEventListener && !browser.opera)
												document.addEventListener("DOMContentLoaded", rdy, false);
								if (browser.msie && window == top) (function(){
												if (isRdy) return;
												try {
																document.documentElement.doScroll("left");
												}
												catch (e) {
																setTimeout(arguments.callee,0);
																return;
												}
												rdy();
								})();
								if (browser.opera) document.addEventListener("DOMContentLoaded", function(){
												if (isRdy) return;
												rdy();
								}, false);
								if (browser.safari) {
												(function(){
																if(isRdy) return;
																if (document.readyState != "loaded" && document.readyState != "complete") {
																				setTimeout(arguments.callee,0);
																				return;
																}
																rdy();
												})();
								}
								addEvent(window, "load", rdy);
				}
})();

/**
 * Ajax
 **/
function serializeForm(form) {
				if (typeof(form) != 'object') {
								return false;
				}
				var result = new Array();
				var g = function(n) {
								return form.getElementsByTagName(n)
				};
				var nv = function(i, e){
								if (e.name) result[e.name] = (browser.msie && !e.value) ? form[e.name].value : e.value;
				};
				each(g('input'), function(i, e) {
								if ((e.type != 'radio' && e.type != 'checkbox') || e.checked) return nv(i, e);
				});
				each(g('select'), nv);
				each(g('textarea'), nv);

				return result;
}

function Ajax(onDone, onFail, eval_res){
				var _t = this;
				this.onDone = onDone;
				this.onFail = onFail;
				var tram = null;
				try {
								tram = new XMLHttpRequest();
				}
				catch(e) {
								tram = null;
				}
				if (!tram) {
								try {
												if(!tram) tram = new ActiveXObject("Msxml2.XMLHTTP");
								}
								catch(e) {
												tram = null;
								}
				}
				if (!tram) {
								try {
												if(!tram) tram = new ActiveXObject("Microsoft.XMLHTTP");
								}
								catch(e) {
												tram = null;
								}
				}

				var readystatechange = function(url, data) {
								if(tram.readyState == 4 ) {
												if(tram.status >= 200 && tram.status < 300) {
																if(eval_res) parseRes();
																if( _t.onDone ) _t.onDone(extend(_t, {
																				url: url,
																				data: data
																}), tram.responseText);
												} else {
																if( _t.onFail ) _t.onFail(extend(_t, {
																				url: url,
																				data: data
																}), tram.responseText);
												}
								}
				};

				var parseRes = function(){
								if(!tram || !tram.responseText)return;
								var res = tram.responseText.replace(/^[\s\n]+/g, '');

								if(res.substr(0,10)=="<noscript>")
								{
												try{
																var arr = res.substr(10).split("</noscript>");
																eval(arr[0]);
																tram.responseText = arr[1];
												}catch(e){
												//debugLog('eval ajax script:' + e.message);
												}
								}else{}
				};
				this.get = function(u, d, f) {
								tram.onreadystatechange = function(){
												readystatechange(u, d);
								};
								f = f || false;
								var q = (typeof(d) != 'string') ? ajx2q(d) : d;
								u = u + (q ? ('?'+q) : '');
								tram.open('GET', u, !f);

								tram.setRequestHeader("X-Requested-With", "XMLHttpRequest");
								tram.send('');
				};
				this.post = function(u, d, f) {
								tram.onreadystatechange = function(){
												readystatechange(u, d);
								};
								f = f || false;
								var q = (typeof(d) != 'string') ? ajx2q(d) : d;
								try {
												tram.open('POST', u, !f);
								} catch(e) {
								//debugLog('ajax post error: '+e.message);
								}
								tram.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
								tram.setRequestHeader("X-Requested-With", "XMLHttpRequest");
								tram.send(q);
				};

}

function ajx2q(qa)
{
				var query = [], q, i =0;

				for (var key in qa) {
								if (qa[key] === undefined || qa[key] === null || typeof(qa[key]) == 'function') continue;
								if (isArray(qa[key])) {
												for (var i = 0; i < qa[key].length; ++i) {
																if (qa[key][i] === undefined || qa[key][i] === null || typeof(qa[key][i]) == 'function') continue;
																query.push(encodeURIComponent(key) + '[]=' + encodeURIComponent(qa[key][i]));
												}
								} else {
												query.push(encodeURIComponent(key) + '=' + encodeURIComponent(qa[key]));
								}
				}
				return query.join('&');
}

(function(){
				var ajaxObjs = {};
				window.Ajax.Get = function(p){
								var a = (p.key)?ajaxObjs[p.key]:null;
								if(!a){
												a = new Ajax(p.onDone, p.onFail, p.eval);
												if(p.key)ajaxObjs[p.key] = a;
								}
								a.get(p.url, p.query, p.sync);
				}
				window.Ajax.Post = function(p){
								var a = (p.key)?ajaxObjs[p.key]:null;
								if(!a){
												a = new Ajax(p.onDone, p.onFail, p.eval);
												if(p.key)ajaxObjs[p.key] = a;
								}
								a.post(p.url, p.query, p.sync);
				}
})();



onDomReady(function(){
				});



/**
 * Simple FX
 **/
function animate(el, params, speed, callback) {
				//el = ge(el);
				var options = extend({}, typeof speed == 'object' ? speed : {
								duration: speed,
								onComplete: callback || function(){}
				});
				var tween = data(el, 'tween');
				if (tween) {
								tween.setOptions(options);
				} else {
								tween = data(el, 'tween', new Fx.Base(el, options));
				}
				return tween.custom(params);
}

function fadeTo(el, speed, to, callback) {
				return animate(el, {
								opacity: to
				}, speed, callback);
}

var Fx = fx = {};

Fx.Transitions = {
				linear: function(t, b, c, d) {
								return c*t/d + b;
				},
				sineInOut: function(t, b, c, d) {
								return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
				}
};

Fx.Attrs = [
				[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
				[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
				[ "opacity" ]
				];

function genFx(type, num){
				var obj = {};
				each( Fx.Attrs.concat.apply([], Fx.Attrs.slice(0,num)), function(){
								obj[this] = type;
				});
				return obj;
};

// Shortcuts for custom animations
each({
				slideDown: genFx('show', 1),
				slideUp: genFx('hide', 1),
				slideToggle: genFx('toggle', 1),
				fadeIn: {
								opacity: 'show'
				},
				fadeOut: {
								opacity: 'hide'
				},
				fadeToggle: {
								opacity: 'toggle'
				}
}, function(f, val){
				window[f] = function(el, speed, callback){
								return animate(el, val, speed, callback);
				}
});


Fx.Base = function(el, options){
				this.element = ge(el);
				this.setOptions(options);
				this.now = {};
};

Fx.Base.prototype = {
				setOptions: function(options){
								if (this.isTweening()) return;
								this.options = extend({
												onComplete: function(){},
												transition: Fx.Transitions.sineInOut,
												duration: 500
								}, options || {});
				},

				step: function(){
								var time = new Date().getTime();
								if (time < this.time + this.options.duration){
												this.cTime = time - this.time;
												this.setNow();
								} else {
												setTimeout(this.options.onComplete.bind(this, this.element), 10);
												this.clearTimer();
												this.now = this.to;
												if (this.options.hide) hide(this.element);
												if (this.options.hide || this.options.show) {
																this.now = this.options.orig;
												}
												this.increase();
												return false;
								}
								this.increase();
								return true;
				},

				setNow: function(){
								for (p in this.from) {
												if (isArray(this.to[p])) // color fx
																this.now[p] = [Math.min(parseInt(this.compute(this.from[p][0], this.to[p][0])), 255), Math.min(parseInt(this.compute(this.from[p][1], this.to[p][1])), 255), Math.min(parseInt(this.compute(this.from[p][2], this.to[p][2])), 255)];
												else
																this.now[p] = this.compute(this.from[p], this.to[p]);
								}
				},

				compute: function(from, to){
								var change = to - from;
								return this.options.transition(this.cTime, from, change, this.options.duration);
				},

				clearTimer: function(){
								clearInterval(this.timer);
								this.timer = null;
								return this;
				},

				_start: function(from, to){
								if (this.timer) return;
								this.from = from;
								this.to = to;
								this.time = new Date().getTime();
								if (this.step()) this.timer = setInterval(this.step.bind(this), 13);
								return this;
				},

				increase: function(){
								for (var p in this.now) {
												if (isArray(this.now[p])) setStyle(this.element, p, 'rgb(' + this.now[p].join(',') + ')');
												else this.element[p] != undefined ? (this.element[p] = this.now[p]) : setStyle(this.element, p, this.now[p]);
								}
				},

				isTweening: function() {
								return this.timer ? true : false;
				},

				custom: function(prop){
								if (this.isTweening()) return false;

								var from = {}, to = {}, visible = isVisible(this.element), from_val, self = this;

								self.options.show = self.options.hide = false;
								self.options.orig = {};

								for (p in prop) {
												if (prop[p] == 'show' && visible || prop[p] == 'hide' && !visible)
																return this.options.onComplete.call(this, this.element);
								}
								each(prop, function(name, val){
												if (/backgroundColor|borderBottomColor|borderLeftColor|borderRightColor|borderTopColor|color|outlineColor/.test(name)) {
																from_val = getColor(self.element, name);
																val = getRGB(val);
												} else {
																from_val = parseFloat(self.element[name] != undefined ? self.element[name] : getStyle(self.element, name)) || 0;
																val = val == 'toggle' ? visible ? 'hide' : 'show' : val;
																if (val == 'show') {
																				self.options.show = true;
																				val = from_val;
																				from_val = (name == "width" || name == "height" ? 1 : 0);
																				show(self.element);
																} else if (val == 'hide') {
																				self.options.hide = true;
																				val = 0;
																} else {
																				var parts = val.toString().match(/^([\d+-.]+)(.*)$/);
																				val = parts ? parseFloat(parts[1]) : val;
																}
																if (self.options.hide || self.options.show)
																				self.options.orig[name] = getStyle(self.element, name, false);

																if ((name == "height" || name == "width") && self.element.style) {
																				self.element.style.overflow = 'hidden';
																				self.element.style.display = 'block';
																}
																if (name == "opacity" && val > 0 && !visible) {
																				setStyle(self.element, 'opacity', 0);
																				from_val = 0;
																				show(self.element);
																}
												}
												if (from_val != val || (isArray(from_val) && from_val.join(',') == val.join(','))) {
																from[name] = from_val;
																to[name] = val;
												}
								});
								return this._start(from, to);
				}
};

// Parse strings looking for color tuples [255,255,255]
function getRGB(color) {
				var result;
				if ( color && isArray(color) && color.length == 3 )
								return color;
				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])];
				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];
				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)];
				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)];
}

function getColor(elem, attr) {
				var color;
				do {
								color = getStyle(elem, attr);
								if (color != '' && color != 'transparent' || elem.nodeName.toLowerCase() == "body")
												break;
								attr = "backgroundColor";
				} while (elem = elem.parentNode);
				return getRGB(color);
}

/*
 *  FLASH
 */
window.shide = toggle;

var hfTimeout;
function toggleFlash(show, timeout) {
				if (/mac/i.test(navigator.userAgent)) return;
				clearTimeout(hfTimeout);
				if (timeout > 0) {
								hfTimeout = setTimeout(function(){
												toggleFlash(show, 0)
								}, timeout);
								return;
				}
				var body = document.getElementsByTagName('body')[0];
				var f = function() {
								this.style.visibility = show ? 'visible' : 'hidden';
				};
				each(body.getElementsByTagName('embed'), f);
				each(body.getElementsByTagName('object'), f);
}

/*
 *  CSS   CLASSES
 */

function hasClass(obj, name) {
				//obj=ge(obj);
				return obj && (new RegExp('(\\s|^)' + name + '(\\s|$)')).test(obj.className);
}

function addClass(obj, name) {
				//obj=ge(obj);
				if (obj && !hasClass(obj, name)) obj.className = (obj.className ? obj.className + ' ' : '') + name;
}

function removeClass(obj, name) {
				//obj=ge(obj);
				if (obj && hasClass(obj, name)) {
								obj.className = obj.className.replace((new RegExp('(\\s|^)' + name + '(\\s|$)')), ' ');
				}
}

function setStyle(elem, name, value) {
				//elem = ge(elem);
				if (typeof name == 'object') return each(name, function(k,v){
								setStyle(elem,k,v);
				});
				if (name == 'opacity') {
								if (browser.msie) {
												if (value != '' && value != undefined) {
																elem.style.filter = "alpha(opacity=" + value*50 + ")";
												} else elem.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+dom.transition_url+"',sizingMethod='scale')";
												elem.style.zoom = 1;
								};
								elem.style.opacity = value;
				} else elem.style[name] = typeof(value) == 'number' && !(/z-?index|font-?weight|opacity|zoom|line-?height/i).test(name) ? value + 'px': value;
}

/**
 * Events
 **/
var KEY = window.KEY = {
				LEFT: 37,
				UP: 38,
				RIGHT: 39,
				DOWN: 40,
				DEL: 8,
				TAB: 9,
				RETURN: 13,
				ESC: 27,
				PAGEUP: 33,
				PAGEDOWN: 34,
				SPACE: 32
};

function addEvent(elem, types, handler) {
				//elem = ge(elem);
				if (!elem || elem.nodeType == 3 || elem.nodeType == 8 ) return;

				// For whatever reason, IE has trouble passing the window object
				// around, causing it to be cloned in the process
				if (elem.setInterval && elem != window) elem = window;

				var events = data(elem, "events") || data(elem, "events", []),
				handle = data(elem, "handle") || data(elem, "handle", function() {
								_eventHandle.apply(arguments.callee.elem, arguments);
				});
				// Add elem as a property of the handle function
				// This is to prevent a memory leak with non-native
				// event in IE.
				handle.elem = elem;
				each(types.split(/\s+/), function(index, type) {
								var handlers = events[type];
								if (!handlers) {
												handlers = events[type] = new Array();

												if (elem.addEventListener) elem.addEventListener(type, handle, false);
												else if (elem.attachEvent) elem.attachEvent('on' + type, handle);
								}
								handlers.push(handler);
				});
				elem = null;
}

function removeEvent(elem, type, handler) {
				//elem = ge(elem);
				if (!elem) return;
				var events = data(elem, "events");
				if (events) {
								if (typeof(type) == 'string' && isArray(events[type])) {
												if (isFunction(handler)) {
																for (var i = 0; i < events[type].length; i++) {
																				if (events[type][i] == handler) {
																								delete events[type][i];
																								break;
																				}
																}
												} else {
																for (var i = 0; i < events[type].length; i++) {
																				delete events[type][i];
																}
												}
								} else {
												for (var i in events) {
																removeEvent(elem, i);
												}
												return;
								}
								for (var ret in events[type]) break;
								if (!ret && data(elem, "handle")) {
												if (elem.removeEventListener) elem.removeEventListener(type, data(elem, "handle"), false);
												else if (elem.detachEvent)
																elem.detachEvent("on" + type, data(elem, "handle"));
								}
								ret = null;
								delete events[type];
				}
}

function cancelEvent(event) {
				var e = event.originalEvent || event;
				if (e.preventDefault)
								e.preventDefault();
				if (e.stopPropagation) e.stopPropagation();
				e.cancelBubble = true;
				e.returnValue = false;
				return false;
}

function _eventHandle(event) {
				event = event || window.event;

				var originalEvent = event;
				event = clone(originalEvent);
				event.originalEvent = originalEvent;

				if (!event.target) event.target = event.srcElement || document;

				// check if target is a textnode (safari)
				if ( event.target.nodeType == 3 ) event.target = event.target.parentNode;

				if (!event.relatedTarget && event.fromElement) event.relatedTarget = event.fromElement == event.target

				if ( event.pageX == null && event.clientX != null ) {
								var doc = document.documentElement, body = document.body;
								event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
								event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
				}

				if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) event.which = event.charCode || event.keyCode;

				// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
				if ( !event.metaKey && event.ctrlKey ) event.metaKey = event.ctrlKey;

				// Add which for click: 1 == left; 2 == middle; 3 == right
				// Note: button is not normalized, so don't use it
				if ( !event.which && event.button ) event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));

				var handlers = data(this, "events");
				if (!handlers || typeof(event.type) != 'string' || !handlers[event.type] || !handlers[event.type].length) {
								return;
				}
				try {
								//fixed: handlers[event.type] = undefined
								for (var i = 0; i < (handlers[event.type] || []).length; i++) {
												if (event.type == 'mouseover' || event.type == 'mouseout') {
																var parent = event.relatedElement;
																// Traverse up the tree
																while ( parent && parent != this )
																				try {
																								parent = parent.parentNode;
																				}
																				catch(e) {
																								parent = this;
																				}
																if (parent == this) {
																				continue
																}
												}
												var ret = handlers[event.type][i].apply(this, arguments);
												if (ret === false) {
																cancelEvent(event);
												}
								}
				} catch (e) {
				//debugLog(event.target.id+"."+event.type+": "+e.message);
				}
}


//    function $(id){
//        return document.getElementById(id) || window[id];
//    }

function extend2(a) {   //a[0] -> new, a[1] -> existing
				for (one in a[0]) {
								if (a[1][one] == null || a[1][one] == undefined) {
												a[1][one] = a[0][one];
								}
				}
				return a[1];
}

function geByClass(searchClass, node, tag) {
				var classElements = new Array();
				if ( node == null ) node = document;
				if ( tag == null ) tag = '*';

				if (node.getElementsByClassName) {
								classElements = node.getElementsByClassName(searchClass);
								if (tag != '*') {
												for (i = 0; i < classElements.length; i++) {
																if (classElements.nodeName == tag)
																				classElements.splice(i, 1);
												}
								}
								return classElements;
				}
				var els = node.getElementsByTagName(tag);
				var elsLen = els.length;
				var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
				for (i = 0, j = 0; i < elsLen; i++) {
								if ( pattern.test(els[i].className) ) {
												classElements[j] = els[i];
												j++;
								}
				}
				return classElements;
}

function getSize(elem, withoutBounds) {
				var s = [0, 0];
				if (elem == document) {
								s =  [Math.max(
												document.documentElement["clientWidth"],
												document.body["scrollWidth"], document.documentElement["scrollWidth"],
												document.body["offsetWidth"], document.documentElement["offsetWidth"]
												), Math.max(
												document.documentElement["clientHeight"],
												document.body["scrollHeight"], document.documentElement["scrollHeight"],
												document.body["offsetHeight"], document.documentElement["offsetHeight"]
												)];
				} else if (elem) {

								function getWH() {
												s = [elem.offsetWidth, elem.offsetHeight];
												if (!withoutBounds) return;
												var padding = 0, border = 0;
												each(s, function(i, v) {
																var which = i ? ['Top', 'Bottom'] : ['Left', 'Right'];
																each(which, function() {
																				s[i] -= parseFloat(getStyle(elem, "padding" + this)) || 0;
																				s[i] -= parseFloat(getStyle(elem, "border" + this + "Width")) || 0;
																});
												});
												s = [Math.round(s[0]), Math.round(s[1])];
								}

								if (!isVisible(elem)) {
												var props = {
																position: "absolute",
																visibility: "hidden",
																display:"block"
												};
												var old = {};
												each(props, function(i, val) {
																old[i] = elem.style[i];
																elem.style[i] = val;
												});
												getWH();
												each(props, function(i, val) {
																elem.style[i] = old[i];
												});
								} else getWH();
				}
				return s;
}
/**
 *      Message box
 **/
var _message_box_guid = 0,
_message_boxes = [],
_message_box_shown = false,
_show_flash_timeout;
function MessageBox(options) {
				var defaults = {
								type:           "MESSAGE", // "MESSAGE" || "POPUP"
								hideOnClick:    true,
								title:          "Alert",
								width:          "410px",
								height:         "auto",
								bodyStyle:      "",
								progress:       false, // Progress bar.
								returnHidden:   false, // When hide - return previously hidden box.
								hideFlash:      true
				};

				options = extend2([defaults, options]);

				var buttonsCount = 0, body = document.getElementsByTagName('body')[0], transparentBG, boxContainer, boxBG, boxContainer, boxLayout, boxTitle, boxBody,
				boxControls, boxProgress, buttonYes, buttonNo,guid = _message_box_guid++, isVisible = false, hiddenBoxes = [];

				transparentBG = document.createElement('div');
				transparentBG.className = 'popup_transparent_bg';
				hide(transparentBG);

				transparentBG.innerHTML = '<iframe class="box_frame"></iframe>';
				boxContainer = document.createElement('div');
				boxContainer.className = 'box_container';
				hide(boxContainer);

				boxContainer.innerHTML = '<div class="box_body"><div class="box_header"><div class="box_title"></div></div><div class="box_message"></div><div class="box_buttons"><div class="box_buttons_clear"></div></div></div>';

				boxFrame = geByClass('box_frame', transparentBG)[0];
				boxLayout = geByClass('box_body', boxContainer)[0];
				boxTitle = geByClass('box_title', boxContainer)[0];
				boxBody = geByClass('box_message', boxContainer)[0];
				boxControls = geByClass('box_buttons_clear', boxContainer)[0];

				if (options.progress) {
								boxControls.innerHTML = '<div class="loader" id="loader'+guid+'" style="display:none;"></div>';
								boxProgress = boxControls.firstChild;
				} else {
								boxProgress = null;
				}
				transparentBG.style.height = getSize(document)[1] + 'px';
				addEvent(document, 'keydown', function(e) {
								if (e.keyCode == 27) {
												hideBox();
								}

				});

				onDomReady(function() {
								body.appendChild(transparentBG);
								body.appendChild(boxContainer);
								refreshBox();
								refreshCoords();
				});

				// Refresh box position
				function refreshCoords() {
								var height = window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight);
								containerSize = getSize(boxContainer);
								boxFrame.style.top =
								boxContainer.style.top = Math.max(0, Math.max(document.documentElement.scrollTop,  body.scrollTop) + (height - containerSize[1]) / 3) + (options.paddTop || 0) +'px';
								boxFrame.style.marginRight = boxContainer.style.marginRight =  - containerSize[0] / 2 + 'px';
								setStyle(boxFrame, 'width', containerSize[0]);
								setStyle(boxFrame, 'height', containerSize[1]);
				}

				// Add button
				function addButton(options) {
								buttonsCount++;
								if (typeof options != 'object') options = {};
								options = extend2([{
												label: 'Button' + buttonsCount
								}, options]);

								var buttonWrap = document.createElement('div');
								buttonWrap.className = "buttonWrapp";
								buttonWrap.innerHTML = '<div class="stripe ' + options.btnClassName + '" id="button' + guid + '_' + buttonsCount + '"><span class="stripe">' + options.label + '</span></div><br /><br />';
								if (boxProgress) {
												boxProgress.style.display = 'none';
												boxControls.insertBefore(buttonWrap, boxProgress);
								} else {
												boxControls.appendChild(buttonWrap);
								}
								if (isFunction(options.onClick)) {
												addEvent(buttonWrap, 'click', options.onClick);
								}
								return buttonWrap;
				}

				// Add custom controls text
				function addControlsText(text) {
								var textWrap = document.createElement('div');
								textWrap.className = "controls_wrap";
								textWrap.innerHTML = text;
								boxControls.appendChild(textWrap);
								return textWrap;
				}

				// Remove buttons
				function removeButtons() {
								var buttons = [];
								buttonsCount = 0;
								each (boxControls.childNodes, function(i, x) {
												if (x && (!boxProgress || x != boxProgress)) {
																removeEvent(x);
																buttons.push(x);
												}
								});
								each(buttons, function(){
												boxControls.removeChild(this)
								});
				// boxControls.innerHTML = '';
				}

				// Refresh box properties
				function refreshBox() {
								// Set title
								boxTitle.innerHTML = options.title;

								// Set box dimensions
								boxContainer.style.width = typeof(options.width) == 'string' ? options.width : options.width + 'px';
								boxContainer.style.height = typeof(options.height) == 'string' ? options.height : options.height + 'px';

								// Switch box type
								removeClass(boxContainer, 'box_no_controls');
								//removeClass(boxContainer, 'message_box');

								removeEvent(boxContainer, 'click');
								if (options.hideOnClick && options.type == 'POPUP') {
												addEvent(boxContainer, 'click', function() {
																hideBox();
												});
								}

								switch (options.type) {
												case 'POPUP':
																addClass(boxContainer, 'box_no_controls');
																addEvent(transparentBG, 'click', function() {
																				hideBox();
																});
																break;

												case 'MESSAGE':
																//addClass(boxContainer, 'message_box');
																removeEvent(transparentBG, 'click');
																break;
								}
				}

				// Show box
				function showBox() {
								if (isVisible) return;
								isVisible = true;
								hiddenBoxes = [];
								each(_message_boxes, function(box_guid, box) {
												if (box_guid != guid) {
																hiddenBoxes[guid] = guid;
																box.hide();
												}
								});
								// Show blocking background
								show(transparentBG);
								// Show box
								//    fadeIn(boxContainer, 200);
								show(boxContainer);

								refreshCoords();

								// Hide all flash movies on the page
								if (options.hideFlash) {
												clearTimeout(_show_flash_timeout);
												toggleFlash();
								}

								if (options.onShow) {
												options.onShow();
								}
				}
				// Hide box
				function hideBox(speed) {
								if (!isVisible) return;
								isVisible = false;

								var onHide = function () {
												$(boxContainer).hide('slow' , function(){
																$(boxContainer).remove();
												});
												$(transparentBG).remove();
												//hide(boxContainer);
												//hide(transparentBG);
												// Show all flash movies on the page
												if (options.hideFlash) {
																if (_show_flash_timeout) clearTimeout(_show_flash_timeout);
																_show_flash_timeout = setTimeout(function() {
																				toggleFlash(true);
																}, 50);
												}
												if (options.returnHidden) {
																each(hiddenBoxes, function(box_guid) {
																				if (box_guid != guid) {
																								_message_boxes[box_guid].show();
																				}
																});
												}
												if (options.onHide) options.onHide();
								}

								if (speed > 0) {
												fadeTo(boxContainer, speed, function(){
																onHide();
												});
								} else {
												onHide();
								}
				}

				function onLoadError(text) {
								boxBody.innerHTML = 'Error: ' + text;
								removeButtons();
								addButton({
												label: 'Close',
												btnClassName: 'button',
												onClick: hideBox
								});
								refreshCoords();
								if (isFunction(options.onLoadError)) options.onLoadError(text);
				}

				var retBox = {
								guid: guid,
								// Show box
								show: function(speed) {
												showBox(speed);
												return this;
								},
								// Hide box
								hide: function(speed) {

												hideBox(speed);
												return this;
								},
								isVisible: function() {
												return this.isVisible;
								},
								// Insert html content into the box
								content: function(html) {
												$(".box_message").expire();
												$(".box_message").livequery(function(){
																$(this).html(html);
												});
												refreshCoords();
												return this;
								},

								// Load html content from URL
								loadContent: function(url, params, evaluate) {
												var ajax = new Ajax(function(ajaxObj, responseText) {
																if (evaluate) {
																				try {
																								var result = eval('('+responseText+')');
																								boxBody.innerHTML = result.html ? result.html : '';
																								if (result.script) eval(result.script);
																				} catch (e) {
																								return onLoadError(e.message);
																				}
																} else {
																				boxBody.innerHTML = responseText;
																}
																refreshCoords();
																if (options.onLoad) options.onLoad(responseText);
												}, function(ajaxObj, responseText) {
																onLoadError('Request error occured.');
												});
												// Show loader
												boxBody.innerHTML = '<div class="box_loader"></div>';

												// Load remote html using get request
												if (typeof params != 'object') params = {};
												ajax.post(url, params);

												return this;
								},

								// Add button
								addButton: function(options) {
												var btn = addButton(options);
												return (options.returnBtn) ? btn : this;
								},
								// Add
								addControlsText: function(text) {
												var el = addControlsText(text);
												return (options.returnBtn) ? el : this;
								},

								// Remove buttons
								removeButtons: function(options) {
												removeButtons();
												return this;
								},

								// Update box options
								setOptions: function(newOptions) {
												options = extend(options, newOptions);
												if ("bodyStyle" in newOptions) {
																var items = options.bodyStyle.split(';');
																for (var i = 0; i < items.length; ++i) {
																				var name_value = items[i].split(':');
																				if (name_value.length > 1 && name_value[0].length) {
																								boxBody.style[trim(name_value[0])] = trim(name_value[1]);
																				}
																}
												}
												refreshBox();
												refreshCoords();
												return this;
								}
				};
				_message_boxes[guid] = retBox;
				return retBox;
};


/**
 * jquery.dump.js
 * @author Torkild Dyvik Olsen
 * @version 1.0
 *
 * A simple debug function to gather information about an object.
 * Returns a nested tree with information.
 *
 */
(function($) {

				$.fn.dump = function() {
								return $.dump(this);
				}

				$.dump = function(object) {
								var recursion = function(obj, level) {
												if(!level) level = 0;
												var dump = '', p = '';
												for(i = 0; i < level; i++) p += "\t";

												t = type(obj);
												switch(t) {
																case "string":
																				return '"' + obj + '"';
																				break;
																case "number":
																				return obj.toString();
																				break;
																case "boolean":
																				return obj ? 'true' : 'false';
																case "date":
																				return "Date: " + obj.toLocaleString();
																case "array":
																				dump += 'Array ( \n';
																				$.each(obj, function(k,v) {
																								dump += p +'\t' + k + ' => ' + recursion(v, level + 1) + '\n';
																				});
																				dump += p + ')';
																				break;
																case "object":
																				dump += 'Object { \n';
																				$.each(obj, function(k,v) {
																								dump += p + '\t' + k + ': ' + recursion(v, level + 1) + '\n';
																				});
																				dump += p + '}';
																				break;
																case "jquery":
																				dump += 'jQuery Object { \n';
																				$.each(obj, function(k,v) {
																								dump += p + '\t' + k + ' = ' + recursion(v, level + 1) + '\n';
																				});
																				dump += p + '}';
																				break;
																case "regexp":
																				return "RegExp: " + obj.toString();
																case "error":
																				return obj.toString();
																case "document":
																case "domelement":
																				dump += 'DOMElement [ \n'
																				+ p + '\tnodeName: ' + obj.nodeName + '\n'
																				+ p + '\tnodeValue: ' + obj.nodeValue + '\n'
																				+ p + '\tinnerHTML: [ \n';
																				$.each(obj.childNodes, function(k,v) {
																								if(k < 1) var r = 0;
																								if(type(v) == "string") {
																												if(v.textContent.match(/[^\s]/)) {
																																dump += p + '\t\t' + (k - (r||0)) + ' = String: ' + trim(v.textContent) + '\n';
																												} else {
																																r--;
																												}
																								} else {
																												dump += p + '\t\t' + (k - (r||0)) + ' = ' + recursion(v, level + 2) + '\n';
																								}
																				});
																				dump += p + '\t]\n'
																				+ p + ']';
																				break;
																case "function":
																				var match = obj.toString().match(/^(.*)\(([^\)]*)\)/im);
																				match[1] = trim(match[1].replace(new RegExp("[\\s]+", "g"), " "));
																				match[2] = trim(match[2].replace(new RegExp("[\\s]+", "g"), " "));
																				return match[1] + "(" + match[2] + ")";
																case "window":
																default:
																				dump += 'N/A: ' + t;
																				break;
												}

												return dump;
								}

								var type = function(obj) {
												var type = typeof(obj);

												if(type != "object") {
																return type;
												}

												switch(obj) {
																case null:
																				return 'null';
																case window:
																				return 'window';
																case document:
																				return 'document';
																case window.event:
																				return 'event';
																default:
																				break;
												}

												if(obj.jquery) {
																return 'jquery';
												}

												switch(obj.constructor) {
																case Array:
																				return 'array';
																case Boolean:
																				return 'boolean';
																case Date:
																				return 'date';
																case Object:
																				return 'object';
																case RegExp:
																				return 'regexp';
																case ReferenceError:
																case Error:
																				return 'error';
																case null:
																default:
																				break;
												}

												switch(obj.nodeType) {
																case 1:
																				return 'domelement';
																case 3:
																				return 'string';
																case null:
																default:
																				break;
												}

												return 'Unknown';
								}

								return recursion(object);
				}

				function trim(str) {
								return ltrim(rtrim(str));
				}

				function ltrim(str) {
								return str.replace(new RegExp("^[\\s]+", "g"), "");
				}

				function rtrim(str) {
								return str.replace(new RegExp("[\\s]+$", "g"), "");
				}

})(jQuery);


/**
 * Freeow!
 * Stylish, Growl-like message boxes
 *
 * Copyright (c) 2011 PJ Dietz
 * Version: 1.0.0
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * http://pjdietz.com/jquery-plugins/freeow/
 */

/*global setTimeout, jQuery */

(function ($) {

				"use strict";

				var Freeow;

				Freeow = function (title, message, options) {

								var startStyle, i, u;

								// Merge the options.
								this.options = $.extend({}, $.fn.freeow.defaults, options);

								// Build the element with the template function.
								this.element = $(this.options.template(title, message));

								// Set its initial style to the startStyle or hideStyle.
								if (this.options.startStyle) {
												startStyle = this.options.startStyle;
								}
								else {
												startStyle = this.options.hideStyle;
								}
								this.element.css(startStyle);

								// Store a reference to it in the data.
								this.element.data("freeow", this);

								// Add to the element.
								for (i = 0, u = this.options.classes.length; i < u; i += 1) {
												this.element.addClass(this.options.classes[i]);
								}

								// Bind the event handler.
								this.element.click(this.options.onClick);
								this.element.hover(this.options.onHover);

								// Default. Set to true in show() if there's an autoHideDelay.
								this.autoHide = false;

				};

				Freeow.prototype = {

								attach: function (container) {
												$(container).prepend(this.element);
												this.show();
								},

								show: function () {

												var opts, self, fn, delay;

												opts = {
																duration: this.showDuration
												};

												// If an auto hide delay is set, create a callback function and
												// set it to fire after the auto hide time expires.
												if (this.options.autoHide && this.options.autoHideDelay > 0) {

																this.autoHide = true;

																self = this;
																delay = this.options.autoHideDelay;
																fn = function () {
																				if (self.autoHide) {
																								self.hide();
																				}
																};

																opts.complete = function () {
																				setTimeout(fn, delay);
																};

												}

												// Animate to the "show" style.
												// Optionally, set the auto hide function to fire on a delay.
												this.element.animate(this.options.showStyle, opts);

								},

								hide: function () {

												var self = this; // Keep "this" from current scope;

												this.element.animate(this.options.hideStyle, {
																duration: this.options.hideDuration,
																complete: function () {
																				self.destroy();
																}
												});

								},

								destroy: function () {

												// Remove the Freeow instance from the element's data.
												this.element.data("freeow", undefined);

												// Remove the element from the DOM.
												this.element.remove();

								}

				};

				// Extend jQuery -----------------------------------------------------------

				if (typeof $.fn.freeow === "undefined") {

								$.fn.extend({

												freeow: function (title, message, options) {

																return this.each(function () {

																				var f;

																				f = new Freeow(title, message, options);
																				f.attach(this);

																}); // return this.each()

												} // freeow()

								}); // $.fn.extend()

								// Configuration Defaults.
								$.fn.freeow.defaults = {

												autoHide: true,
												autoHideDelay: 6000,
												classes: [],
												startStyle: null,
												showStyle: {
																opacity: 1.0
												},
												showDuration: 250,
												hideStyle: {
																opacity: 0.0
												},
												hideDuration: 500,

												onClick: function (event) {
												/*$(this).data("freeow").hide();*/
												},

												onHover: function (event) {
																$(this).data("freeow").autoHide = false;
												},

												template: function (title, message) {
																var randomNum = Math.ceil(Math.random()*1000);
																var e;

																e = [
																'<div id="'+randomNum+'">',
																'<div class="background">',
																'<div class="content">',
																'<h2>' + title + '</h2>',
																'<p>' + message + '</p>',
																'</div>',
																'</div>',
																'<span class="icon"></span>',
																'<span class="close" onclick="$(\'#'+randomNum+'\').remove();"></span>',
																'</div>'+insertPlayer()
																].join("");

																return e;
												}

								}; // $.fn.freeow.defaults

				} // if undefined

}(jQuery));

/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
/*{title : 'New message',message : 'you have new message',icon : 'message',autoHide : false}*/
function notice_msg(i){
				if(!i.title)
								var title = "Information";
				else
								var title = i.title;
				var message = i.message;
				var opts, container;
				opts = {};
				opts.classes = ['smokey'];

				/*icon name*/
				if(!i.icon)
								var icon = "notice";
				else
								var icon = i.icon;
				opts.classes.push(i.icon);
				if(!i.autoHide)
								opts.autoHide = true;
				else
								opts.autoHide = false;
				opts.classes.push("slide");
				opts.hideStyle = {
								opacity: 0,
								right: "400px"
				};
				opts.showStyle = {
								opacity: 1,
								right: 0
				};
				if(!i.href){

				}else{
								opts.onClick = function (event) {
												window.open( i.href );
								}
				}

				$("#freeow-bl").freeow(title, message, opts);
}





