/*
 * jQuery 1.2.6 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
 * $Rev: 5685 $
 */
/* Copyright (c) 2007 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Version: 1.0.2
 * Requires jQuery 1.1.3+
 * Docs: http://docs.jquery.com/Plugins/livequery
 */
(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type))fn2=fn,fn=type,type=undefined;$.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))return(q=query)&&false;});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;$.livequery.run(q.id);return this;},expire:function(type,fn,fn2){var self=this;if($.isFunction(type))fn2=fn,fn=type,type=undefined;$.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);});return this;}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2)fn2.$lqguid=fn2.$lqguid||$.livequery.guid++;return this;};$.livequery.prototype={stop:function(){var query=this;if(this.type)this.elements.unbind(this.type,this.fn);else if(this.fn2)this.elements.each(function(i,el){query.fn2.apply(el);});this.elements=[];this.stopped=true;},run:function(){if(this.stopped)return;var query=this;var oEls=this.elements,els=$(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);if(oEls.length>0)$.each(oEls,function(i,el){if($.inArray(el,els)<0)$.event.remove(el,query.type,query.fn);});}else{nEls.each(function(){query.fn.apply(this);});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;while(length--)$.livequery.queries[$.livequery.queue.shift()].run();}},pause:function(){$.livequery.running=false;},play:function(){$.livequery.running=true;$.livequery.run();},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n])return;var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r;}});},run:function(id){if(id!=undefined){if($.inArray(id,$.livequery.queue)<0)$.livequery.queue.push(id);}else
$.each($.livequery.queries,function(id){if($.inArray(id,$.livequery.queue)<0)$.livequery.queue.push(id);});if($.livequery.timeout)clearTimeout($.livequery.timeout);$.livequery.timeout=setTimeout($.livequery.checkQueue,20);},stop:function(id){if(id!=undefined)$.livequery.queries[id].stop();else
$.each($.livequery.queries,function(id){$.livequery.queries[id].stop();});}});$.livequery.registerPlugin('append','prepend','after','before','wrap','attr','removeAttr','addClass','removeClass','toggleClass','empty','remove');$(function(){$.livequery.play();});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector)r.context=a.context,r.selector=a.selector;if(typeof a=='string')r.context=c||document,r.selector=a;return r;};$.prototype.init.prototype=$.prototype;})(jQuery);

/* jquery.block 
 * Version 1.26  (07/05/2007)
 * @requires jQuery v1.1.1
 * Examples at: http://malsup.com/jquery/block/  */
(function($) {

$.blockUI = function(msg, css) {
    $.blockUI.impl.install(window, msg, css);
};

// expose version number so other plugins can interogate
$.blockUI.version = 1.26;

/**
 * unblockUI removes the UI block that was put in place by blockUI
 *
 * @example  $.unblockUI();
 * @desc unblocks the page
 *
 * @name unblockUI
 * @cat Plugins/blockUI
 */
$.unblockUI = function() {
    $.blockUI.impl.remove(window);
};

$.fn.block = function(msg, css) {
    return this.each(function() {
		if (!this.$pos_checked) {
            if ($.css(this,"position") == 'static')
                this.style.position = 'relative';
            if ($.browser.msie) this.style.zoom = 1; // force 'hasLayout' in IE
            this.$pos_checked = 1;
        }
        $.blockUI.impl.install(this, msg, css);
    });
};

$.fn.unblock = function() {
    return this.each(function() {
        $.blockUI.impl.remove(this);
    });
};

$.fn.displayBox = function(css, fn, isFlash) {
    var msg = this[0];
    if (!msg) return;
    var $msg = $(msg);
    css = css || {};

    var w = $msg.width()  || $msg.attr('width')  || css.width  || $.blockUI.defaults.displayBoxCSS.width;
    var h = $msg.height() || $msg.attr('height') || css.height || $.blockUI.defaults.displayBoxCSS.height ;
    if (w[w.length-1] == '%') {
        var ww = document.documentElement.clientWidth || document.body.clientWidth;
        w = parseInt(w) || 100;
        w = (w * ww) / 100;
    }
    if (h[h.length-1] == '%') {
        var hh = document.documentElement.clientHeight || document.body.clientHeight;
        h = parseInt(h) || 100;
        h = (h * hh) / 100;
    }
    
    var ml = '-' + parseInt(w)/2 + 'px';
    var mt = '-' + parseInt(h)/2 + 'px';
    
    // supress opacity on overlay if displaying flash content on mac/ff platform
    var ua = navigator.userAgent.toLowerCase();
    var noalpha = isFlash && /mac/.test(ua) && /firefox/.test(ua);

    $.blockUI.impl.install(window, msg, { width: w, height: h, marginTop: mt, marginLeft: ml }, fn || 1, noalpha);
};

// override these in your code to change the default messages and styles
$.blockUI.defaults = {
    // the message displayed when blocking the entire page
    pageMessage:    '<h1>Please wait...</h1>',
    // the message displayed when blocking an element
    elementMessage: '', // none
    // styles for the overlay iframe
    overlayCSS:  { backgroundColor: '#fff', opacity: '0.5' },
    // styles for the message when blocking the entire page
    pageMessageCSS:    { width:'250px', margin:'-50px 0 0 -125px', top:'50%', left:'50%', textAlign:'center', color:'#000', backgroundColor:'#fff', border:'3px solid #aaa' },
    // styles for the message when blocking an element
    elementMessageCSS: { width:'250px', padding:'10px', textAlign:'center', backgroundColor:'#fff'},
    // styles for the displayBox
    displayBoxCSS: { width: '400px', height: '400px', top:'50%', left:'50%' },
    // allow body element to be stetched in ie6
    ie6Stretch: 1,
    // supress tab nav from leaving blocking content?
    allowTabToLeave: 0,
    // Title attribute for overlay when using displayBox
    closeMessage: 'Click to close'
};

// the gory details
$.blockUI.impl = {
    box: null,
    boxCallback: null,
    pageBlock: null,
    pageBlockEls: [],
    op8: window.opera && window.opera.version() < 9,
    ffLinux: $.browser.mozilla && /Linux/.test(navigator.platform),
    ie6: $.browser.msie && /6.0/.test(navigator.userAgent),
    install: function(el, msg, css, displayMode, noalpha) {
        this.boxCallback = typeof displayMode == 'function' ? displayMode : null;
        this.box = displayMode ? msg : null;
        var full = (el == window);
        noalpha = noalpha || this.op8 || this.ffLinux;
       
        if (full && this.pageBlock) this.remove(window);
        // check to see if we were only passed the css object (a literal)
        if (msg && typeof msg == 'object' && !msg.jquery && !msg.nodeType) {
            css = msg;
            msg = null;
        }
        msg = msg ? (msg.nodeType ? $(msg) : msg) : full ? $.blockUI.defaults.pageMessage : $.blockUI.defaults.elementMessage;
        if (displayMode)
            var basecss = jQuery.extend({}, $.blockUI.defaults.displayBoxCSS);
        else
            var basecss = jQuery.extend({}, full ? $.blockUI.defaults.pageMessageCSS : $.blockUI.defaults.elementMessageCSS);
        css = jQuery.extend(basecss, css || {});
        var f = ($.browser.msie) ? $('<iframe class="blockUI" style="filter:alpha(opacity=50);z-index:1000;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="javascript:false;document.write(\'\');"></iframe>')
                                 : $('<div class="blockUI" style="display:none"></div>');
        var w = $('<div class="blockUI" style="z-index:1001;cursor:wait;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
        var m = full ? $('<div class="blockUI blockMsg" style="z-index:1002;cursor:wait;padding:0;position:fixed"></div>')
                     : $('<div class="blockUI" style="display:none;z-index:1002;cursor:wait;position:absolute"></div>');
        w.css('position', full ? 'fixed' : 'absolute');
        if (msg) m.css(css);
        if (!noalpha) w.css($.blockUI.defaults.overlayCSS);
        if (this.op8) w.css({ width:''+el.clientWidth,height:''+el.clientHeight }); // lame
        if ($.browser.msie) f.css('opacity','0.0');

        $([f[0],w[0],m[0]]).appendTo(full ? 'body' : el);

        // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
        var expr = $.browser.msie && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
        if (this.ie6 || expr) { 
            // stretch content area if it's short
            if (full && $.blockUI.defaults.ie6Stretch && $.boxModel)
                $('html,body').css('height','100%');

            // fix ie6 problem when blocked element has a border width
            if ((this.ie6 || !$.boxModel) && !full) {
                var t = this.sz(el,'borderTopWidth'), l = this.sz(el,'borderLeftWidth');
                var fixT = t ? '(0 - '+t+')' : 0;
                var fixL = l ? '(0 - '+l+')' : 0;
            }
            
            // simulate fixed position
            $.each([f,w,m], function(i,o) {
                var s = o[0].style;
                s.position = 'absolute';
                if (i < 2) {
                    full ? s.setExpression('height','document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + "px"') 
                         : s.setExpression('height','this.parentNode.offsetHeight + "px"');
                    full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
                         : s.setExpression('width','this.parentNode.offsetWidth + "px"');
                    if (fixL) s.setExpression('left', fixL);
                    if (fixT) s.setExpression('top', fixT);
                }
                else {
                    if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
                    s.marginTop = 0;
                }
            });
        }
        if (displayMode) {
            w.css('cursor','default').attr('title', $.blockUI.defaults.closeMessage);
            m.css('cursor','default'); 
            $([f[0],w[0],m[0]]).removeClass('blockUI').addClass('displayBox');
            $().click($.blockUI.impl.boxHandler).bind('keypress', $.blockUI.impl.boxHandler);
        }
        else
            this.bind(1, el);
        m.append(msg).show();
        if (msg.jquery) msg.show();
        if (displayMode) return;
        if (full) {
            this.pageBlock = m[0];
            this.pageBlockEls = $(':input:enabled:visible',this.pageBlock);
            setTimeout(this.focus, 20);
        }
        else this.center(m[0]);
    },
    remove: function(el) {
        this.bind(0, el);
        var full = el == window;
        if (full) {
            $('body').children().filter('.blockUI').remove();
            this.pageBlock = this.pageBlockEls = null;
        }
        else $('.blockUI', el).remove();
    },
    boxRemove: function(el) {
        $().unbind('click',$.blockUI.impl.boxHandler).unbind('keypress', $.blockUI.impl.boxHandler);
        if (this.boxCallback)
            this.boxCallback(this.box);
        $('body .displayBox').hide().remove();
    },
    // event handler to suppress keyboard/mouse events when blocking
    handler: function(e) {
        if (e.keyCode && e.keyCode == 9) {
            if ($.blockUI.impl.pageBlock && !$.blockUI.defaults.allowTabToLeave) {
                var els = $.blockUI.impl.pageBlockEls;
                var fwd = !e.shiftKey && e.target == els[els.length-1];
                var back = e.shiftKey && e.target == els[0];
                if (fwd || back) {
                    setTimeout(function(){$.blockUI.impl.focus(back)},10);
                    return false;
                }
            }
        }
        if ($(e.target).parents('div.blockMsg').length > 0)
            return true;
        return $(e.target).parents().children().filter('div.blockUI').length == 0;
    },
    boxHandler: function(e) {
        if ((e.keyCode && e.keyCode == 27) || (e.type == 'click' && $(e.target).parents('div.blockMsg').length == 0))
            $.blockUI.impl.boxRemove();
        return true;
    },
    // bind/unbind the handler
    bind: function(b, el) {
        var full = el == window;
        // don't bother unbinding if there is nothing to unbind
        if (!b && (full && !this.pageBlock || !full && !el.$blocked)) return;
        if (!full) el.$blocked = b;
        var $e = full ? $() : $(el).find('a,:input');
        $.each(['mousedown','mouseup','keydown','keypress','click'], function(i,o) {
            $e[b?'bind':'unbind'](o, $.blockUI.impl.handler);
        });
    },
    focus: function(back) {
        if (!$.blockUI.impl.pageBlockEls) return;
        var e = $.blockUI.impl.pageBlockEls[back===true ? $.blockUI.impl.pageBlockEls.length-1 : 0];
        if (e) e.focus();
    },
    center: function(el) {
		var p = el.parentNode, s = el.style;
        var l = ((p.offsetWidth - el.offsetWidth)/2) - this.sz(p,'borderLeftWidth');
        var t = ((p.offsetHeight - el.offsetHeight)/2) - this.sz(p,'borderTopWidth');
        s.left = l > 0 ? (l+'px') : '0';
        s.top  = t > 0 ? (t+'px') : '0';
    },
    sz: function(el, p) { return parseInt($.css(el,p))||0; }
};

/* jquery.fileupload */
jQuery.extend({
    createUploadIframe: function(id, uri)
	{
			//create frame
            var frameId = 'jUploadFrame' + id;
            
            if(window.ActiveXObject) {
                var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
                if(typeof uri== 'boolean'){
                    io.src = 'javascript:false';
                }
                else if(typeof uri== 'string'){
                    io.src = uri;
                }
            }
            else {
                var io = document.createElement('iframe');
                io.id = frameId;
                io.name = frameId;
            }
            io.style.position = 'absolute';
            io.style.top = '-1000px';
            io.style.left = '-1000px';

            document.body.appendChild(io);

            return io			
    },
    createUploadForm: function(id, fileElementId)
	{
		//create form	
		var formId = 'jUploadForm' + id;
		var fileId = 'jUploadFile' + id;
		var form = $('<form  action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');	
		var oldElement = $('#' + fileElementId);
		var newElement = $(oldElement).clone();
		$(oldElement).attr('id', fileId);
		$(oldElement).before(newElement);
		$(oldElement).appendTo(form);
		//set attributes
		$(form).css('position', 'absolute');
		$(form).css('top', '-1200px');
		$(form).css('left', '-1200px');
		$(form).appendTo('body');		
		return form;
    },

    ajaxFileUpload: function(s) {
        // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout		
        s = jQuery.extend({}, jQuery.ajaxSettings, s);
        var id = new Date().getTime()        
		var form = jQuery.createUploadForm(id, s.fileElementId);
		var io = jQuery.createUploadIframe(id, s.secureuri);
		var frameId = 'jUploadFrame' + id;
		var formId = 'jUploadForm' + id;		
        // Watch for a new set of requests
        if ( s.global && ! jQuery.active++ )
		{
			jQuery.event.trigger( "ajaxStart" );
		}            
        var requestDone = false;
        // Create the request object
        var xml = {}   
        if ( s.global )
            jQuery.event.trigger("ajaxSend", [xml, s]);
        // Wait for a response to come back
        var uploadCallback = function(isTimeout)
		{			
			var io = document.getElementById(frameId);
            try 
			{				
				if(io.contentWindow)
				{
					 xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
                	 xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
					 
				}else if(io.contentDocument)
				{
					 xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
                	xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
				}						
            }catch(e)
			{
				jQuery.handleError(s, xml, null, e);
			}
            if ( xml || isTimeout == "timeout") 
			{				
                requestDone = true;
                var status;
                try {
                    status = isTimeout != "timeout" ? "success" : "error";
                    // Make sure that the request was successful or notmodified
                    if ( status != "error" )
					{
                        // process the data (runs the xml through httpData regardless of callback)
                        var data = jQuery.uploadHttpData( xml, s.dataType );    
                        // If a local callback was specified, fire it and pass it the data
                        if ( s.success )
                            s.success( data, status );
    
                        // Fire the global callback
                        if( s.global )
                            jQuery.event.trigger( "ajaxSuccess", [xml, s] );
                    } else
                        jQuery.handleError(s, xml, status);
                } catch(e) 
				{
                    status = "error";
                    jQuery.handleError(s, xml, status, e);
                }

                // The request was completed
                if( s.global )
                    jQuery.event.trigger( "ajaxComplete", [xml, s] );

                // Handle the global AJAX counter
                if ( s.global && ! --jQuery.active )
                    jQuery.event.trigger( "ajaxStop" );

                // Process result
                if ( s.complete )
                    s.complete(xml, status);

                jQuery(io).unbind()

                setTimeout(function()
									{	try 
										{
											$(io).remove();
											$(form).remove();	
											
										} catch(e) 
										{
											jQuery.handleError(s, xml, null, e);
										}									

									}, 100)

                xml = null

            }
        }
        // Timeout checker
        if ( s.timeout > 0 ) 
		{
            setTimeout(function(){
                // Check to see if the request is still happening
                if( !requestDone ) uploadCallback( "timeout" );
            }, s.timeout);
        }
        try 
		{
           // var io = $('#' + frameId);
			var form = $('#' + formId);
			$(form).attr('action', s.url);
			$(form).attr('method', 'POST');
			$(form).attr('target', frameId);
            if(form.encoding)
			{
                form.encoding = 'multipart/form-data';				
            }
            else
			{				
                form.enctype = 'multipart/form-data';
            }			
            $(form).submit();

        } catch(e) 
		{			
            jQuery.handleError(s, xml, null, e);
        }
        if(window.attachEvent){
            document.getElementById(frameId).attachEvent('onload', uploadCallback);
        }
        else{
            document.getElementById(frameId).addEventListener('load', uploadCallback, false);
        } 		
        return {abort: function () {}};	

    },

    uploadHttpData: function( r, type ) {
        var data = !type;
        data = type == "xml" || data ? r.responseXML : r.responseText;
        // If the type is "script", eval it in global context
        if ( type == "script" )
            jQuery.globalEval( data );
        // Get the JavaScript object, if JSON is used.
        if ( type == "json" )
            eval( "data = " + data );
        // evaluate scripts within html
        if ( type == "html" )
            jQuery("<div>").html(data).evalScripts();
			//alert($('param', data).each(function(){alert($(this).attr('value'));}));
        return data;
    }
})

/* jquery.multiplefileupload */
/*
 ### jQuery Multiple File Upload Plugin ###
   http://www.fyneworks.com/jquery/multiple-file-upload/
 Project Page:
  http://jquery.com/plugins/project/MultiFile/
 24-June-2007: v1.22
                Now works perfectly in Opera, thanks to Adrian Wróbel <adrian [dot] wrobel [at] gmail.com>
*/
/* jquery.easing */ 
/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ */

jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/* jquery.easing.compatibility 
  jQuery Easing Compatibility v1 - http://gsgd.co.uk/sandbox/jquery.easing.php */
jQuery.extend( jQuery.easing,
{
	easeIn: function (x, t, b, c, d) {
		return jQuery.easing.easeInQuad(x, t, b, c, d);
	},
	easeOut: function (x, t, b, c, d) {
		return jQuery.easing.easeOutQuad(x, t, b, c, d);
	},
	easeInOut: function (x, t, b, c, d) {
		return jQuery.easing.easeInOutQuad(x, t, b, c, d);
	},
	expoin: function(x, t, b, c, d) {
		return jQuery.easing.easeInExpo(x, t, b, c, d);
	},
	expoout: function(x, t, b, c, d) {
		return jQuery.easing.easeOutExpo(x, t, b, c, d);
	},
	expoinout: function(x, t, b, c, d) {
		return jQuery.easing.easeInOutExpo(x, t, b, c, d);
	},
	bouncein: function(x, t, b, c, d) {
		return jQuery.easing.easeInBounce(x, t, b, c, d);
	},
	bounceout: function(x, t, b, c, d) {
		return jQuery.easing.easeOutBounce(x, t, b, c, d);
	},
	bounceinout: function(x, t, b, c, d) {
		return jQuery.easing.easeInOutBounce(x, t, b, c, d);
	},
	elasin: function(x, t, b, c, d) {
		return jQuery.easing.easeInElastic(x, t, b, c, d);
	},
	elasout: function(x, t, b, c, d) {
		return jQuery.easing.easeOutElastic(x, t, b, c, d);
	},
	elasinout: function(x, t, b, c, d) {
		return jQuery.easing.easeInOutElastic(x, t, b, c, d);
	},
	backin: function(x, t, b, c, d) {
		return jQuery.easing.easeInBack(x, t, b, c, d);
	},
	backout: function(x, t, b, c, d) {
		return jQuery.easing.easeOutBack(x, t, b, c, d);
	},
	backinout: function(x, t, b, c, d) {
		return jQuery.easing.easeInOutBack(x, t, b, c, d);
	}
});


/*  jQuery corner plugin version 1.92 (12/18/2007)  */

$.fn.corner = function(o) {
    var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent);
    function sz(el, p) { return parseInt($.css(el,p))||0; };
    function hex2(s) {
        var s = parseInt(s).toString(16);
        return ( s.length < 2 ) ? '0'+s : s;
    };
    function gpc(node) {
        for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) {
            var v = $.css(node,'backgroundColor');
            if ( v.indexOf('rgb') >= 0 ) { 
                if ($.browser.safari && v == 'rgba(0, 0, 0, 0)')
                    continue;
                var rgb = v.match(/\d+/g); 
                return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
            }
            if ( v && v != 'transparent' )
                return v;
        }
        return '#ffffff';
    };
    function getW(i) {
        switch(fx) {
        case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
        case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
        case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
        case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
        case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
        case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
        case 'curl':   return Math.round(width*(Math.atan(i)));
        case 'tear':   return Math.round(width*(Math.cos(i)));
        case 'wicked': return Math.round(width*(Math.tan(i)));
        case 'long':   return Math.round(width*(Math.sqrt(i)));
        case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
        case 'dog':    return (i&1) ? (i+1) : width;
        case 'dog2':   return (i&2) ? (i+1) : width;
        case 'dog3':   return (i&3) ? (i+1) : width;
        case 'fray':   return (i%2)*width;
        case 'notch':  return width; 
        case 'bevel':  return i+1;
        }
    };
    o = (o||"").toLowerCase();
    var keep = /keep/.test(o);                       // keep borders?
    var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
    var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
    var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
    var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
    var fx = ((o.match(re)||['round'])[0]);
    var edges = { T:0, B:1 };
    var opts = {
        TL:  /top|tl/.test(o),       TR:  /top|tr/.test(o),
        BL:  /bottom|bl/.test(o),    BR:  /bottom|br/.test(o)
    };
    if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
        opts = { TL:1, TR:1, BL:1, BR:1 };
    var strip = document.createElement('div');
    strip.style.overflow = 'hidden';
    strip.style.height = '1px';
    strip.style.backgroundColor = sc || 'transparent';
    strip.style.borderStyle = 'solid';
    return this.each(function(index){
        var pad = {
            T: parseInt($.css(this,'paddingTop'))||0,     R: parseInt($.css(this,'paddingRight'))||0,
            B: parseInt($.css(this,'paddingBottom'))||0,  L: parseInt($.css(this,'paddingLeft'))||0
        };

        if ($.browser.msie) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = $.curCSS(this, 'height');

        for (var j in edges) {
            var bot = edges[j];
            // only add stips if needed
            if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
                strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
                var d = document.createElement('div');
                $(d).addClass('jquery-corner');
                var ds = d.style;

                bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

                if (bot && cssHeight != 'auto') {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.bottom = ds.left = ds.padding = ds.margin = '0';
                    if ($.browser.msie)
                        ds.setExpression('width', 'this.parentNode.offsetWidth');
                    else
                        ds.width = '100%';
                }
                else if (!bot && $.browser.msie) {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
                    
                    // fix ie6 problem when blocked element has a border width
                    var bw = 0;
                    if (ie6 || !$.boxModel)
                        bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
                    ie6 ? ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"') : ds.width = '100%';
                }
                else {
                    ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
                                        (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
                }

                for (var i=0; i < width; i++) {
                    var w = Math.max(0,getW(i));
                    var e = strip.cloneNode(false);
                    e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                    bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                }
            }
        }
    });
};

$.fn.uncorner = function(o) { return $('.jquery-corner', this).remove(); };

/*
 * jqModal - Minimalist Modaling with jQuery
 * $Version: 2007.08.17 +r11
 * 
 */
$.fn.jqm=function(o){
var _o = {
zIndex: 3000,
overlay: 50,
overlayClass: 'jqmOverlay',
closeClass: 'jqmClose',
trigger: '.jqModal',
ajax: false,
target: false,
modal: false,
toTop: false,
onShow: false,
onHide: false,
onLoad: false
};
return this.each(function(){if(this._jqm)return; s++; this._jqm=s;
H[s]={c:$.extend(_o, o),a:false,w:$(this).addClass('jqmID'+s),s:s};
if(_o.trigger)$(this).jqmAddTrigger(_o.trigger);
});};

$.fn.jqmAddClose=function(e){hs(this,e,'jqmHide'); return this;};
$.fn.jqmAddTrigger=function(e){hs(this,e,'jqmShow'); return this;};
$.fn.jqmShow=function(t){return this.each(function(){if(!H[this._jqm].a)$.jqm.open(this._jqm,t)});};
$.fn.jqmHide=function(t){return this.each(function(){if(H[this._jqm].a)$.jqm.close(this._jqm,t)});};

$.jqm = {
hash:{},
open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(/^\d+$/.test(h.w.css('z-index')))?h.w.css('z-index'):c.zIndex,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});h.t=t;h.a=true;h.w.css('z-index',z);
 if(c.modal) {if(!A[0])F('bind');A.push(s);o.css('cursor','wait');}
 else if(c.overlay > 0)h.w.jqmAddClose(o);
 else o=false;

 h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):false;
 if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}

 if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;
  r.load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
 else if(cc)h.w.jqmAddClose($(cc,h.w));

 if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);	
 (c.onShow)?c.onShow(h):h.w.show();e(h);return false;
},
close:function(s){var h=H[s];h.a=false;
 if(A[0]){A.pop();if(!A[0])F('unbind');}
 if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
 if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return false;
}};
var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),
i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),
e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);},
f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(e){}},
F=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},
m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;},
hs=function(w,e,y){var s=[];w.each(function(){s.push(this._jqm)});
 $(e).each(function(){if(this[y])$.extend(this[y],s);else{this[y]=s;$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return false;});}});};

/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-07-11 23:15:17 -0500 (Wed, 11 Jul 2007) $
 * $Rev: 2324 $
 *
 * Version 2.1
 */
$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};


/*
 ### jQuery Multiple File Upload Plugin ###
 By Diego A., http://www.fyneworks.com, diego@fyneworks.com
 Website:
  http://www.fyneworks.com/jquery/multiple-file-upload/
 Project Page:
  http://jquery.com/plugins/project/MultiFile/
*/

	// Fix for Opera: 6-June-2007
	// Stop confusion between null, 'null' and 'undefined'
	function IsNull(i){
		return (i==null || i=='null' || i=='' || i=='undefined');
	};
	
	// extend jQuery - $.MultiFile hook
	$.extend($, {
		MultiFile: function( o /* Object */ ){
			return $("INPUT[@type='file'].multi").MultiFile(o);
		}
	});
	
	// extend jQuery function library
	$.extend($.fn, {
			
			// MultiFile function
			MultiFile: function( o /* Object */ ){
				if(this._MultiFile){ return $(this); }
				this._MultiFile = true;
				
				// DEBUGGING: disable plugin
				//return false;
				
				// Bind to each element in current jQuery object
				return $(this).each(function(i){
							// Remember our ancestors...
							var d = this;
							var x = $(d);
							
							//#########################################
							// Find basic configuration in class string
							// debug???
							d.debug = (d.className.indexOf('debug')>0);
							// limit number of files that can be selected?
							if(IsNull(d.max)){
								d.max = x.attr('maxlength');
								if(IsNull(d.max)){
									d.max = ((d.className.match(/\b((max|limit)\-[0-9]+)\b/gi) || [''])[0]);
									if(IsNull(d.max)){
										d.max = -1;
									}else{
										d.max = d.max.match(/[0-9]+/gi)[0];
									}
								}
							}
							d.max = new Number(d.max);
							// limit extensions?
							if(!d.accept){
								d.accept = (d.className.match(/\b(accept\-[\w\|]+)\b/gi)) || '';
								d.accept = new String(d.accept).replace(/^(accept|ext)\-/i,'');
							}
							//#########################################
							
							
							// Attach a bunch of events, jQuery style ;-)
							$.each("on,after".split(","), function(i,o){
								$.each("FileSelect,FileRemove,FileAppend".split(","), function(j,event){
									d[o+event] = function(e, v, m){ // default functions do absolutelly nothing...
										// if(d.debug) alert(''+o+event+'' +'\nElement:' +e.name+ '\nValue: ' +v+ '\nMaster: ' +m.name+ '');
									};
								});
							});
							// Setup a global event handler
							d.trigger = function(event, e){
									var f = d[event];
									if(f){
										var v = $(this).attr('value');
										var r = f(e, v, d);
										if(r!=null) return r;
									}
									return true;
							};
							
							
							// Initialize options
							if( typeof o == 'number' ){ o = {max:o}; };
							$.extend(d, d.data || {}, o);
							
							// Default properties - INTERNAL USE ONLY
							$.extend(d, {
								STRING: d.STRING || {}, // used to hold string constants
								n: 0, // How many elements are currently selected?
								k: 'multi', // Instance Key?
								f: function(z){ return d.k+'_'+String(i)+'_'+String(z); }
							});
							
							// Visible text strings...
							// $file = file name (with path), $ext = file extension
							d.STRING = $.extend({
								remove:'remove',
								denied:'You cannot select a $ext file.\nTry again...',
								selected:'File selected: $file'
							}, d.STRING);
							
							
							// Setup dynamic regular expression for extension validation
							// - thanks to John-Paul Bader: http://smyck.de/2006/08/11/javascript-dynamic-regular-expresions/
							if(String(d.accept).length>1){
								d.rxAccept = new RegExp('\\.('+(d.accept?d.accept:'')+')$','gi');
							};
							
							// Create wrapper to hold our file list
							d.w = d.k+'multi'+'_'+i; // Wrapper ID?
							x.wrap('<div id="'+d.w+'"></div>');
							
							// Bind a new element
							d.add = function( e, ii ){
								
								// Keep track of how many elements have been displayed
								d.n++;
								
								// Add reference to master element
								e.d = d;
								
								// Define element's ID and name (upload components need this!)
								e.i = ii;//d.I;
								e.id = d.f(e.i);
								e.name = (e.name || x.attr('name') || 'file') + (e.i>0?e.i:''); // same name as master element
								
								// If we've reached maximum number, disable input e
								if( (d.max != -1) && ((d.n-1) > (d.max)) ){ // d.n Starts at 1, so subtract 1 to find true count
									e.disabled = true;
								};
								
								// Remember most recent e
								d.current = e;
								
								/// now let's use jQuery
								e = $(e);
								
								// Triggered when a file is selected
								e.change(function(){
										
										//# Trigger Event! onFileSelect
										if(!d.trigger('onFileSelect', this, d)) return false;
										//# End Event!
										
										// check extension
										if(d.accept){
											var v = String(e.attr('value'));
											if(!v.match(d.rxAccept)){
												// Clear element value
												e.val('').attr('value', '');
												e.get(0).value = '';
												
												// OPERA BUG FIX - 2007-06-24
												// Thanks to Adrian Wróbel <adrian [dot] wrobel [at] gmail.com>
												// we add new input element and remove present one for browsers that can't clear value of input element
												var f = $('<input name="'+(x.attr('name') || '')+'" type="file"/>');
												d.n--;
												d.add(f.get(0), this.i);
												e.parent().prepend(f);
												e.remove();
												
												// Show error message
												// TO-DO: Some people have suggested alternative methods for displaying this message
												// such as inline HTML, lightbox, etc... maybe integrate with blockUI plugin?
												alert(d.STRING.denied.replace('$ext', String(v.match(/\.\w{1,4}$/gi))));
												
												return false;
											}
										};
										
										// Hide this element: display:none is evil!
										//this.style.display = 'block';
										this.style.position = 'absolute';
										this.style.left = '-1000px';
										
										// Create a new file input element
										var f = $('<input name="'+(x.attr('name') || '')+'" type="file"/>');
										
										// Add it to the form
										$(this).parent().prepend(f);
										
										// Update list
										d.list( this );
										
										// Bind functionality
										d.add( f.get(0), this.i+1 );
										
										//# Trigger Event! afterFileSelect
										if(!d.trigger('afterFileSelect', this, d)) return false;
										//# End Event!
										
								});
							
							};
							// Bind a new element
						
							// Add a new file to the list
							d.list = function( y ){
								
								//# Trigger Event! onFileAppend
								if(!d.trigger('onFileAppend', y, d)) return false;
								//# End Event!
								
								// Insert HTML
								var
									t = $('#'+d.w),
									r = $('<div></div>'),
									v = $(y).attr('value')+'',
									a = $('<span class="file" title="'+d.STRING.selected.replace('$file', v)+'">'+v.match(/[^\/\\]+$/gi)[0]+'</span>'),
									b = $('<a href="#'+d.w+'">'+d.STRING.remove+'</a>');
								t.append(r);
								r.append('[',b,']&nbsp;',a);//.prepend(y.i+': ');
								b.click(function(){
									
										//# Trigger Event! onFileRemove
										if(!d.trigger('onFileRemove', y, d)) return false;
										//# End Event!
										
										d.n--;
										d.current.disabled = false;
										$('#'+d.f(y.i)).remove();
										$(this).parent().remove();
										
										//# Trigger Event! afterFileRemove
										if(!d.trigger('afterFileRemove', y, d)) return false;
										//# End Event!
										
										return false;
								});
								
								//# Trigger Event! afterFileAppend
								if(!d.trigger('afterFileAppend', y, d)) return false;
								//# End Event!
								
							};
							
							// Bind first file element
							if(!d.ft){ d.add(d, 0); d.ft = true; }
							d.I++;
							d.n++;
							
				});
				// each element
			
			}
			// MultiFile function
	
	});
	// extend jQuery function library

/*
 ### Default implementation ###
 The plugin will attach itself to file inputs
 with the class 'multi' when the page loads
	
	Use the jQuery start plugin to 
*/
if($.start){ $.start($.MultiFile) }
else $(function(){ $.MultiFile() });

/*# AVOID COLLISIONS #*/
})(jQuery);
;
/*
 * Facebox (for jQuery)
 * version: 1.2 (05/05/2008)
 * @requires jQuery v1.2 or later
 *
 * Examples at http://famspam.com/facebox/
 *
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
 *
 * Usage:
 *  
 *  jQuery(document).ready(function() {
 *    jQuery('a[rel*=facebox]').facebox() 
 *  })
 *
 *  <a href="#terms" rel="facebox">Terms</a>
 *    Loads the #terms div in the box
 *
 *  <a href="terms.html" rel="facebox">Terms</a>
 *    Loads the terms.html page in the box
 *
 *  <a href="terms.png" rel="facebox">Terms</a>
 *    Loads the terms.png image in the box
 *
 *
 *  You can also use it programmatically:
 * 
 *    jQuery.facebox('some html')
 *    jQuery.facebox('some html', 'my-groovy-style')
 *
 *  The above will open a facebox with "some html" as the content.
 *    
 *    jQuery.facebox(function($) { 
 *      $.get('blah.html', function(data) { $.facebox(data) })
 *    })
 *
 *  The above will show a loading screen before the passed function is called,
 *  allowing for a better ajaxy experience.
 *
 *  The facebox function can also display an ajax page, an image, or the contents of a div:
 *  
 *    jQuery.facebox({ ajax: 'remote.html' })
 *    jQuery.facebox({ ajax: 'remote.html' }, 'my-groovy-style')
 *    jQuery.facebox({ image: 'stairs.jpg' })
 *    jQuery.facebox({ image: 'stairs.jpg' }, 'my-groovy-style')
 *    jQuery.facebox({ div: '#box' })
 *    jQuery.facebox({ div: '#box' }, 'my-groovy-style')
 *
 *  Want to close the facebox?  Trigger the 'close.facebox' document event:
 *
 *    jQuery(document).trigger('close.facebox')
 *
 *  Facebox also has a bunch of other hooks:
 *
 *    loading.facebox
 *    beforeReveal.facebox
 *    reveal.facebox (aliased as 'afterReveal.facebox')
 *    init.facebox
 *
 *  Simply bind a function to any of these hooks:
 *
 *   $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
 *
 */
(function($) {
  $.facebox = function(data, klass) {
    $.facebox.loading()

    if (data.ajax) fillFaceboxFromAjax(data.ajax, klass)
    else if (data.image) fillFaceboxFromImage(data.image, klass)
    else if (data.div) fillFaceboxFromHref(data.div, klass)
    else if ($.isFunction(data)) data.call($)
    else $.facebox.reveal(data, klass)
  }

  /*
   * Public, $.facebox methods
   */

  $.extend($.facebox, {
    settings: {
      opacity      : 0,
      overlay      : true,
      /* Removing all hard references to an image
      loadingImage : '/images/facebox/loading.gif',
      closeImage   : '/images/facebox/closelabel.gif',*/
      imageTypes   : [ 'png', 'jpg', 'jpeg', 'gif' ],
      faceboxHtml  : '\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <table> \
          <tbody> \
            <tr> \
              <td class="tl"/><td class="b"/><td class="tr"/> \
            </tr> \
            <tr> \
              <td class="b"/> \
              <td class="body"> \
                <div class="content facebox"> \
                </div> \
                <div class="footer"> \
                  <a href="#" class="close"> \
                    Close \
                  </a> \
                </div> \
              </td> \
              <td class="b"/> \
            </tr> \
            <tr> \
              <td class="bl"/><td class="b"/><td class="br"/> \
            </tr> \
          </tbody> \
        </table> \
      </div> \
    </div>'
    },

    loading: function() {
      init()
      if ($('#facebox .loading').length == 1) return true
      showOverlay()

      $('#facebox .content').empty()
      $('#facebox .body').children().hide().end().
        append('<div class="loading">Loading&hellip;</div>')

      $('#facebox').css({
        top:	getPageScroll()[1] + (getPageHeight() / 10),
        left:	$(window).width() / 2 - 205 
      }).show()

      $(document).bind('keydown.facebox', function(e) {
        if (e.keyCode == 27) $.facebox.close()
        return true
      })
      $(document).trigger('loading.facebox')
    },

    reveal: function(data, klass) {
      $(document).trigger('beforeReveal.facebox')
      if (klass) $('#facebox .content').addClass(klass)
      $('#facebox .content').append(data)
      $('#facebox .loading').remove()
      $('#facebox .body').children().fadeIn('normal')
      $('#facebox').css('left', $(window).width() / 2 - ($('#facebox table').width() / 2))
      $(document).trigger('reveal.facebox').trigger('afterReveal.facebox')
    },

    close: function() {
      $(document).trigger('close.facebox')
      return false
    }
  })

  /*
   * Public, $.fn methods
   */

  $.fn.facebox = function(settings) {
    init(settings)

    function clickHandler(e) {
      $.facebox.loading(true)
      try {
      	var failme = window.parent.document.body;
      } catch (err) {
      	$('#facebox').css({top:	e.pageY})
      }
      
      // support for rel="facebox.inline_popup" syntax, to add a class
      // also supports deprecated "facebox[.inline_popup]" syntax
      var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
      if (klass) klass = klass[1]

      fillFaceboxFromHref(this.href, klass)
      return false
    }

    return this.bind('click.facebox', clickHandler)
  }

  /*
   * Private methods
   */

  // called one time to setup facebox on this page
  function init(settings) {
    if ($.facebox.settings.inited) return true
    else $.facebox.settings.inited = true

    $(document).trigger('init.facebox')
    makeCompatible()

    var imageTypes = $.facebox.settings.imageTypes.join('|')
    $.facebox.settings.imageTypesRegexp = new RegExp('\.(' + imageTypes + ')$', 'i')

    if (settings) $.extend($.facebox.settings, settings)
    $('body').append($.facebox.settings.faceboxHtml)

    /* Removing all hard references to an image
    var preload = [ new Image(), new Image() ]
    preload[0].src = $.facebox.settings.closeImage
    preload[1].src = $.facebox.settings.loadingImage

    $('#facebox').find('.b:first, .bl, .br, .tl, .tr').each(function() {
      preload.push(new Image())
      preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
    })  
    
    $('#facebox .close_image').attr('src', $.facebox.settings.closeImage)
    */
    $('#facebox .close').click($.facebox.close);
  }
  
  // getPageScroll() by quirksmode.com
  function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;	
    }
    return new Array(xScroll,yScroll) 
  }

  // Adapted from getPageSize() by quirksmode.com
  function getPageHeight() {
    var windowHeight
    if (self.innerHeight) {	// all except Explorer
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowHeight = document.body.clientHeight;
    }	
    return windowHeight
  }

  // Backwards compatibility
  function makeCompatible() {
    var $s = $.facebox.settings
	
	/* Removing all hard references to an image
    $s.loadingImage = $s.loading_image || $s.loadingImage
    $s.closeImage = $s.close_image || $s.closeImage
    */
    $s.imageTypes = $s.image_types || $s.imageTypes
    $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml
  }

  // Figures out what you want to display and displays it
  // formats are:
  //     div: #id
  //   image: blah.extension
  //    ajax: anything else
  function fillFaceboxFromHref(href, klass) {
    // div
    if (href.match(/#/)) {
      var url    = window.location.href.split('#')[0]
      var target = href.replace(url,'')
      $.facebox.reveal($(target).show().replaceWith("<div id='facebox_moved'></div>"), klass)

    // image
    } else if (href.match($.facebox.settings.imageTypesRegexp)) {
      fillFaceboxFromImage(href, klass)
    // ajax
    } else {
      fillFaceboxFromAjax(href, klass)
    }
  }

  function fillFaceboxFromImage(href, klass) {
    var image = new Image()
    image.onload = function() {
      $.facebox.reveal('<div class="image"><img src="' + cdnroot + image.src + '" /></div>', klass)
    }
    image.src = href
  }

  function fillFaceboxFromAjax(href, klass) {
    $.get(href, function(data) { $.facebox.reveal(data, klass) })
  }

  function skipOverlay() {
    return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null 
  }

  function showOverlay() {
    if (skipOverlay()) return

    if ($('facebox_overlay').length == 0)
      $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')

    $('#facebox_overlay').hide().addClass("facebox_overlayBG")
      .css('opacity', $.facebox.settings.opacity)
                .css('width', $(document).width())
                .css('height', $(document).height())
      .click(function() { $(document).trigger('close.facebox') ; })
      .fadeIn(200)
    return false
  } 

  function hideOverlay() {
    if (skipOverlay()) return

    $('#facebox_overlay').fadeOut(200, function(){
      $("#facebox_overlay").removeClass("facebox_overlayBG")
      $("#facebox_overlay").addClass("facebox_hide") 
      $("#facebox_overlay").remove()
    })
    
    return false
  }

  /*
   * Bindings
   */

  $(document).bind('close.facebox', function() {
    $(document).unbind('keydown.facebox')
    $('#facebox').fadeOut(function() {
      if ($('#facebox_moved').length == 0) $('#facebox .content').removeClass().addClass('content').addClass('facebox')
      else $('#facebox_moved').replaceWith($('#facebox .content').children().hide())
      hideOverlay()
      $('#facebox .loading').remove()
    })
  })

})(jQuery);

jQuery(document).ready(function($){
  $('a[rel*=facebox]').facebox() 
})

;
/* BASICS */

function reloadPage() {
	window.location.reload(true);	
}

function loadFrame(target,url,params,callback) {
	$j(target).load(url,params,callback);
	return false;
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

/*****************************
    COOKIE FUNCTIONS
*****************************/
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        if (days == -1) {
            date.setFullYear(1970,1,1);
        } else {
            date.setTime(date.getTime()+(days*24*60*60*1000));
        }
        var expires = "; expires="+date.toGMTString();
    }else {
        var expires = "";
    }
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');

    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
/* END COOKIE FUNCTIONS */
/**
 *Manipulate an image href
 */
function changeimghref(href_name, href, img_name, title, alt, src){
    if (document.images) {
        document.images[img_name].title = title;
        document.images[img_name].alt = alt;
        document.images[img_name].src = src;
        document.getElementById(href_name).href = href;
   }
}
function CheckIfAgreedCTAC() {
	     if(document.getElementById("TCAgree").checked==false) {
		   alert("You must agree to the Terms and Conditions in order to add or edit a contest.");
		   return false;
		 }
}

function showTermsAndCondition(page){
	var TOS = window.open(root+page, "Addictionary", "width=600,height=800,scrollbars=1");
	TOS.focus();
}

function objby(rkey, rval){
	switch (rkey){
		case 'id':
			return document.getElementById(rval);
		case 'name':
			return document.getElementsByName(rval);
	}
}

function setStateMenu(action)  {
	$j("#state_browsemenu").val(action);
	setStateOption('');
	setStatePagen('');
}
function getStateMenu()	{ return $j("#state_browsemenu").val();}

function setStateOption(action){ 
	$j("#state_browseoption").val(action);
	setStatePagen(null);
}
function getStateOption()      { return $j("#state_browseoption").val();}

function setStatePagen(action) {$j("#state_browsepagen").val(action);}

function getStatePagen()       { return $j("#state_browsepagen").val();}

function onHolidazeClick(clickPage) {
	trackAJAXCall(clickPage + "/holidaze");
	window.open("http://www.cafepress.com/addictionary", "_blank");
	return;
}

function startThrobber(msg,css,obj) {
	return;
	if (msg == undefined) { 
		msg = "Please wait a moment ..";
	}
	if (css == undefined) {
		css = { width: '300px' };
	}
	var html = "<table class=\"throbber\" style='border:none;padding:4px' cellspacing='0'><tr><td><span class=\"loading\">Loading&hellip;</span></td><td>&nbsp;" + msg + "</td></tr></table>";
	if (obj == undefined || obj == null) {
	   $j.blockUI(html,css);
	} else if (obj.block) {
		var html = "<table class=\"throbber\" style='border:solid 2px #eeeeee;padding:4px' cellspacing='0';><tr><td><span class=\"loading\">Loading&hellip;</span></td><td>&nbsp;" + msg + "</td></tr></table>";
		obj.block(html,css);
	}
}

// In order for this function to work, you need a div with an id of throbber.
function startThrobberInline(msg, buttonid, throbberid) {
	if (throbberid == undefined) {
		throbberid = 'throbber';
	}
	var throbberdiv = $j('#'+throbberid);
	$j('#'+buttonid).hide();
	
	throbberdiv.prepend("<table class=\"throbber\" cellspacing='0' style='border: medium none ; margin-left: 20px; display:inline;'><tr><td><span class=\"loading\">Loading&hellip;</span></td><td>&nbsp;" + msg + "</td></tr></table>");
}

// In order for this function to work, you need a div with an id of throbber.
function stopThrobberInline(throbberid) {
	if (throbberid == undefined) {
		throbberid = 'throbber';
	}
	$j($j('#'+throbberid).children()[0]).remove();
}


function stopThrobber(obj) {
	if (obj == undefined) {
		$j.unblockUI();
	} else if (obj.unblock) {
		obj.unblock();
	}
}

function startPageThrobber(msg, throbberid) {
	var throbberdiv = $j('#'+throbberid);		
	throbberdiv.html("<table class=\"throbber\" cellspacing='0' style='border: border:none; display:block;'><tr><td><span class=\"loading\">Loading&hellip;</span></td><td>&nbsp;" + msg + "</td></tr></table>");
}

function stopPageThrobber(throbberid) {
	var throbberdiv = $j('#'+throbberid);	
	throbberdiv.html("");
}

function showModal(msg, type) {
	jQuery.facebox(msg);
}

function showModalLogin(msg) {
	
	var msglogin = "You need to <a id='linklogin' href='"+root+"Members/LoginPage'>login</a> or <a id='linkjoin' href='"+root+"User/Register'>join Addictionary</a> in order to " + msg;
	showModal(msglogin, 'small');
}

function showModalLoginArgs(args,message) {

	if (message == null) {
		message = "select your favorite words";
	}
	
	var msglogin = "You need to <a id='linklogin' href='"+root+"Members/LoginPage/" + args
						 + "'>login</a> or <a id='linkjoin' href='"+root+"User/Register'>join Addictionary</a> to " + message;
	
	showModal(msglogin, 'small');
}

function showModalLoginArgsEx(msg,args,loginCallback) {
	
	var msglogin = "You need to <a id='linklogin' href='"+root+"Members/LoginPage/" + args+ "' " + 
					(loginCallback == null ? '' : "onclick='return " + loginCallback + "();'") + ">login</a> or <a id='linkjoin' href='"+root+"User/Register'>join Addictionary</a> in order to " + msg;

	showModal(msglogin, 'small');
}

function showModalValidationForm(fields) {
	var msgvalidate = "<h4>You forgot to enter the following field(s): </h4>";
	msgvalidate += "<ul>";
	
	for(var i=0; i < fields.length; i++) {
		msgvalidate += "<li>" + fields[i] + "</li>";
	}
	msgvalidate += "</ul>";
	
	
	showModal(msgvalidate, 'medium');
}

function showModalError(msg) {

	/* ToDo: reevaluate need for this
	var msgError = "<h2>Error</h2>";
	msgError += msg;
	*/
	
	showModal(msg, 'medium');
}

function showModalWarning(msg) {

	/* ToDo: reevaluate need for this
	var msgWarning = "<h2>Warning</h2>";
	msgWarning += msg;
	*/

	showModal(msg, 'medium');
}

function showModalConfirm(msg, callback, parameters, taccept, tcancel) {
	
	if (taccept) $j("#jqmPopupConfirm #accept").val(taccept);
	if (tcancel) $j("#jqmPopupConfirm #cancel").val(tcancel);
	$j("#jqmPopupConfirm #divmsg").html(msg);
	
	$j('#jqmPopupConfirm').bgiframe();		// fix for ie6 z-index bug
	$j('#jqmPopupConfirm').jqm({modal: true}).jqmShow();
	
	$j("#jqmPopupConfirm #accept").click(function() {
		if (parameters) {
			if ((typeof parameters == 'object') && (parameters.constructor == Array)) {
				(parameters.length == 2) ? callback(parameters[0], parameters[1]) : callback(parameters);
			} else {
				callback(parameters);
			}
		} else {
			(typeof callback == 'string') ? window.location.href = callback : callback();
		}
		$j('#jqmPopupConfirm').jqmHide();
	});
	
	$j("#jqmPopupConfirm #cancel").click(function() {
		$j('#jqmPopupConfirm').jqmHide();
	});
}

function showModalSendEmailToFriends(args) {
	
	var url = root + 'ajax_url/send_email_box.php?' + args;
	
	$j('#jqmPopupBig').bgiframe();		// fix for ie6 z-index bug
	$j('#jqmPopupBig').jqm({ajax: url, target: $j("#jqmPopupBig #divmsg")}).jqmShow();
	
}


function showAddWordPopup(silo_id) { 

	if (silo_id == null || silo_id == undefined) { 
		return false;
	}	
	var url = root + 'ajax_url/addword_box.php?silo_id=' + silo_id;
	$j('#jqmPopupAddWord').bgiframe();		// fix for ie6 z-index bug
	$j('#jqmPopupAddWord').jqm({ajax: url, target: $j("#jqmPopupAddWord #divmsg")}).jqmShow();
	return false;
}

function showModalSubmit(type, args, requireUser) {

	var popup 		= $j('#jqmPopupSubmit');
	var username 	= $j('#jqmPopupSubmit #username');
	var password 	= $j('#jqmPopupSubmit #password');
	var signature 	= $j('#jqmPopupSubmit #signature');
	var email 		= $j('#jqmPopupSubmit #email');
	var btnSubmit	= $j('#jqmPopupSubmit #btnSubmit');
	var btnCancel	= $j('#jqmPopupSubmit #btnCancel');
	var registered	= $j('#jqmPopupSubmit #registered')[0];
	var editable	= $j('#jqmPopupSubmit [@name=editableType]');
	var login		= $j('#jqmPopupSubmit #loginb');

	var cleanLoginUserInput = function() {
		username.val('');
		password.val('');
		signature.val('');
		email.val('');
	}
	
	// Hide all editable parts to later show type specific part
	editable.hide();

	// pre-load/pre-submit type specific actions
	switch (type){

		case 'tags':
			var cleanTypeUserInput = function() {
				$j('#jqmPopupSubmit #tags').val('');
			}
			$j('#jqmPopupSubmit #editableTags').show();
			if (!requireUser) login.hide();
			break;
			
		default:
			break;
	}

	// Show popup
	popup.bgiframe();		// fix for ie6 z-index bug
	popup.jqm({modal: true}).jqmShow();

	btnSubmit.click(function() {
		
		if (requireUser && registered && registered.checked) {
			
			// Login Action
			var response = $j.ajax({
				type: 'POST',
				url: root + 'ajax_url/login.php',
				data: 'username='+username.val()+'&password='+password.val(),
				async: false
			}).responseText;
			
			if (response == '') {
				showModalError('Please enter a valid username and password');
				cleanLoginUserInput();
				//username.focus(); //ToDo: fix error popup so this can be use
				return false;
			}
		}

		// post-submit type specific actions
		switch (type){
			
			case 'tags':
				var tags = $j('#jqmPopupSubmit #tags').val();
				var url = root + 'ajax_url/tags.php';
				var data = 'action=add&tags=' + tags + '&' + args;
				var success = function() {
					window.location.reload(false);
				}
				if (requireUser && registered && !registered.checked) {
					showModalError('We are sorry, for the moment you can\'t submit tags if you are not registered');
					cleanLoginUserInput();
					return false;
				}
				break;
			
			default:
				break;
		}
		
		$j.ajax({
			url: url,
			data: data,
			async: false,
			success: success
		});
		
		popup.jqmHide();
	});
	
	btnCancel.click(function() {
		popup.jqmHide();
		cleanTypeUserInput();
		cleanLoginUserInput();
	});
}

/* showModal popup handling */

function sendToFacebox(url, inputdata) {
	jQuery.get(url, inputdata, function(data){jQuery.facebox(data)});
}

function convertFormDataToJSON(elem){
	var json = [];
	for (var i=0; i<elem.length; i++){
		json[i] = new Object();
		json[i].name = elem[i].name;
		json[i].value = elem[i].value;
	}
	return json;
}

function addErrorMsg(element, msg){
	var count = element.length;
	element[count] = new Array();
	element[count].name = 'errormsg';
	element[count].value = msg;
	return element;
}
/* END MESSAGES */ 


/* FAVORITES 
classimageid is an optional arg.  If the classimageid is supplied, the image will
change on the element with the supplied CLASS id.   Otherwise, it will change the
image on the favImage'Word' id.  Sometimes there is more than one of these
on a page and then you will need to send the class with an id so that we can 
change all of them at once.
*/
function starFavoriteWord(obj, word, classimageid) {
	var url = root + 'Ajax/Ajax/FavoriteWord';
	
    var action = 'add';
    var favorite = $j(obj).attr('isFav');
    
    //If the imageid is supplied, use it.
	//otherwise use the element with the supplied id.
    if (typeof classimageid == 'undefined') {
    	var img = document.getElementById('favImage'+word);
    } else {
    	var img = $j('.'+classimageid);
    }
    
    if (favorite === "1") {
    	action = 'del';
    }
    
    $j.ajax({
             url: url,
             data: "action=" + action + "&word_id="+word,
             success: function(z) {  
			//update image.	
			if (favorite === "1") {
				obj.setAttribute("isFav", 0); 
				//If the imageid is supplied, use it.
				//otherwise use the element with the supplied id.
			    if (typeof classimageid == 'undefined') {
			    	img.setAttribute("src", "/images/bkg_favorite.gif"); 
			    } else {
			    	img.attr('src', '/images/bkg_favorite.gif');
			    }
				
			} else {
			    obj.setAttribute("isFav", 1);
			    //If the imageid is supplied, use it.
				//otherwise use the element with the supplied id.
			    if (typeof classimageid == 'undefined') {
			    	img.setAttribute("src", "/images/bkg_favorite_on.gif");  
			    } else {
			    	img.attr('src', '/images/bkg_favorite_on.gif');
			    }
			    
			}
    	}  
   });
	return false;
}

function delFavoriteWord(obj, word) {

	startThrobber("Updating your favorites....",{ width:"300px" });

	var td = obj.parentNode.parentNode;

	var action = 'del';
	var url = root + 'Ajax/Ajax/FavoriteWord';

	var success = function(msg){
		stopThrobber();
		if (msg.substring(0,7) == 'success') {
			$j(td).hide();
			if ($j(td).siblings('tr:visible').length == 0)
				$j('#sendfavbutton').hide();
		}
		else{
			showModalError(msg);
        }
        // - track ajax call via google analytics urchin tracker
        trackAJAXCall('favorites/delfavoriteword');
	}
	//var failure = function(t){ alert(msg); }
		
	$j.ajax({
		url: url,
		data: "action="+action+"&word_id="+word,
		success: success
	});
}
/* END FAVORITES */

/* SEARCH */
function clearSearchText(e) {
//if the text is Search the Addictionary, then clear the text
   	if ($j(e).attr('value') == 'Search the Addictionary') {
   		document.getElementById("search_text").value = '';
   	}
}
/* END SEARCH */

/* STATS */

var ratingcontext = 0;
function hitCountWordID(word_id, silo_id) {
	return true;
}
function hitCountDefID(id, silo_id) {
	var cookiename = "hitcount_"+id+"_"+silo_id ;
	var cookieval = readCookie(cookiename);
	if (!cookieval) {
		var response =  $j.ajax({
			                url:  root + 'ajax_url/hitcount.php',
			                async:false,	
			                data: "defid=" + id + "&silo_id=" + silo_id
			             }).responseText;
		if (response == "success"){
			createCookie(cookiename,id,0);
			return true;
		}
		else {return false;}
	}
	return true;
}

/* END BASICS */

function approveDef(defId,rd) {
	$j.ajax({url: root + 'Ajax/Ajax/approveDefinition',
		data: 'defId='+ defId,
		success: function (response) {
			if (response=="success"){
				if (rd) {
		//				window.location.reload();
						rd();
				}
			} else {
				var msg = "There was a problem trying to approve the definition";
				showModal(msg, 'small');
			}
            // - track ajax call via google analytics urchin tracker
            trackAJAXCall('addictapix/approvedefinition');
		}
	});
	return false;	
}

function unapproveDef(defId,rd) {
	$j.ajax({url: root + 'Ajax/Ajax/unapproveDefinition',
			data: 'defId='+ defId,
			success: function (response) {
				if (response=="success"){
					if (rd) {
		//				window.location.reload();
						rd();
					}
				} else {
					var msg = "There was a problem trying to approve the definition";
					showModal(msg, 'small');
				}
                // - track ajax call via google analytics urchin tracker
                trackAJAXCall('addictapix/unapprovedefinition');
			}
	});
	return false;
}

function hideComment(commentId) {

	$j('#inner-container').css('cursor', 'wait');

	$j.ajax({
			url: root + 'Ajax/Ajax/hidecommentbyid',
			data: 'commentid='+ commentId,
			success: function (z) {
			//	stopThrobber();
				if (z){
					$j('#inner-container').css('cursor', 'default');
					var msg = "The comment was removed from the front page.  Close dialog to reload page.";
					showModal(msg, 'small');
					window.location.reload();
					
				} else {
					var msg = "There was a problem trying to remove the comment from the front page";
					showModal(msg, 'small');
				}
                // - track ajax call via google analytics urchin tracker
                trackAJAXCall('wordprofile/hidecomment');
			}
	});
	return false;
}


function adminApproveComment(comment_id,rd) {
	$j.ajax({url: root + 'Ajax/Ajax/approveComment',
		data: 'comment_id='+ comment_id,
		success: function (response) {
			if (response=="success"){
				if (rd) {
		//				window.location.reload();
						rd();
				}
			} else {
				var msg = "There was a problem trying to approve the comment";
				showModal(msg, 'small');
			}
            // - track ajax call via google analytics urchin tracker
            trackAJAXCall('admincomments/approvecomment');
		}
	});
	return false;	
}

function adminUnapproveComment(comment_id,rd) {
	$j.ajax({url: root + 'Ajax/Ajax/unapproveComment',
			data: 'comment_id='+ comment_id,
			success: function (response) {
				if (response=="success"){
					if (rd) {
		//				window.location.reload();
						rd();
					}
				} else {
					var msg = "There was a problem trying to unapprove the comment";
					showModal(msg, 'small');
				}
                // - track ajax call via google analytics urchin tracker
                trackAJAXCall('admincomments/unapprovecomment');
			}
	});
	return false;
}

function adminRemoveComment(comment_id) {
	$j.ajax({url: root + 'Ajax/Ajax/adminDeleteComment',
			data: 'comment_id='+ comment_id,
			success: function (response) {
				if (response=="success"){
					if (rd) {
		//				window.location.reload();
						rd();
					}
				} else {
					var msg = "There was a problem trying to remove the comment";
					showModal(msg, 'small');
				}
                // - track ajax call via google analytics urchin tracker
                trackAJAXCall('admincomments/removecomment');
			}
	});
	return false;
}


function removeComment(commentId) {

	$j('#inner-container').css('cursor', 'wait');

	$j.ajax({
			url: root + 'Ajax/Ajax/removecommentbyid',
			data: 'commentid='+ commentId,
			success: function (z) {
			//	stopThrobber();
				if (z){
					$j('#inner-container').css('cursor', 'default');
					var msg = "The comment was deleted successfully.  Close dialog to reload page.";
					showModal(msg, 'small');
					window.location.reload();
					
				} else {
					var msg = "There was a problem trying to remove the comment";
					showModal(msg, 'small');
				}
                // - track ajax call via google analytics urchin tracker
                trackAJAXCall('wordprofile/removecomment');
			}
	});
	return false;
}


function removeCommentByData(comment, defid, username, userid) {

	$j('#inner-container').css('cursor', 'wait');

	$j.ajax({
			url: root + 'Ajax/Ajax/removecommentbydata',
			data: 'comment='+ comment + '&defid='+ defid +'&username=' + username + '&userid=' + userid,
			success: function (z) {
				if (z){
					$j('#inner-container').css('cursor', 'default');
					var msg = "The comment was deleted successfully.  Close dialog to reload page.";
					showModal(msg, 'small');
					window.location.reload();
					
				} else {
					var msg = "There was a problem trying to remove the comment";
					showModal(msg, 'small');
				}
                // - track ajax call via google analytics urchin tracker
                trackAJAXCall('chatterbox/removecomment');
			}
	});
	return false;
}


function removeDef(defId,rd) {

	$j('#inner-container').css('cursor', 'wait');

	$j.ajax({
			url: root + 'Ajax/Ajax/removeDefinition',
			data: 'defId='+ defId,
			success: function (response) {
			//	stopThrobber();
				if (response == 'success'){
					$j('#inner-container').css('cursor', 'default');
					window.location.reload();
					if (rd) {
						rd();
					}
				} else {
					var msg = "There was a problem trying to remove the definition";
					showModal(msg, 'small');
				}
                // - track ajax call via google analytics urchin tracker
                trackAJAXCall('addictapix/removedefinition');
			}
	});
	return false;
}
function doPullover(jqo,word_id,def_id,target_silo_id,source_silo_id) {
	if (def_id < 0) {
		$j("input[@name=definition_hidden]",$j("#wordbox" + word_id)).each(function(i) {
			if (def_id < 0 ) { 
				def_id = $j(this).val();
			} else {
				def_id += "_" + $j(this).val();
			}
		});	
	} 
	if (target_silo_id > 0) {
			var response = $j.ajax({
				url: root + 'ajax_url/pullover.php',
				data: 'w='+ word_id + '&d='+ def_id +'&ts=' + target_silo_id + '&ss=' + source_silo_id,
				async: false,
				success: function (response) {
					if (response>=0){
						if (jqo) { 
							jqo.hide();
						}
					} else{
						var msg = "There was a problem trying to pull over the Word";
						showModal(msg, 'small');
					}
				}
			});
		
		} else {
			alert("Wrong target SILO");
			return false;
		}
		return true;
}

function pullover(jqo,word_id,def_id)  {
	//resolve target silo id
	var silosCount = $j("#user_silos_count").val();
	if (silosCount > 1) {
		$j("ul[@name=pullover_menuitems]").css("top","-99999px");
		var ul = jqo.next("ul");
		if (ul.css("top") == "20px") {
			ul.css("top","-99999px");
		}
		else {
			ul.css({top:"20px",width:"200px"});
			$j("a[@name=pulloverlink]").each(function(i) { 
				if (this.id != jqo[0].id) {
					$j(this).hide();
				}
			});
		}
		return false;
	} else { 
		return doPullover(jqo,word_id,def_id,$j("#user_silos_id0").val(),1);
	}
}

function cancelPullOverMenu() {
	 $j("a[@name=pulloverlink]").show();
	 $j("ul[@name=pullover_menuitems]").css("top","-99999px");
	 return false;
}
/* Added livequery  by Santiago Castillo */
$j(".rait_list").livequery(function () {
	if (!window.root) {return false;}
	$j(this).hover(function() {$j("ul[@name=rating_ul]",this).find("img").attr("name","ratingstar");},
				  function() {$j("ul[@name=rating_ul]",this).find("img").attr("name","__ratingstar__");});
});

/* Added livequery  by Santiago Castillo */
$j("img[name=ratingstar]").livequery("click",function(event) {
	
	if (!window.root) {return false;}
			
	//get the image index 
	var i       = $j(this).id.substring(2,3) - 1;
	var el_id   = $j(this).parent().parent().get(0).id.substring(10);
	var el_ids  = el_id.split("_");
	var defid   = el_ids[0];
	var silo_id = el_ids[1];
	//check to see is user is logged in
	var logged = $j("#logged_in").val();
	if (logged == "") {
		showModalLoginArgs("rateDefinition?towtContest=no&defid=" + defid + "&rating=" + (i+1));
		return;
	} 
	var rating2 = readCookie("rating" + el_id);				
	$j("#rt6_" + el_id).val(i+1);
	//thrased cookie when leaving the site - logoff or closing the browser
	createCookie("rating" + el_id, i+1);
	var response =  $j.ajax({
                    url:  root + 'Ajax/Ajax/rateWord',
                    async:false,	
                    data: "towtContest=no&defid=" + defid + "&rating=" + (i+1) + "&cookie=" + rating2 + "&silo_id=" + silo_id,
                             success: function (response) {
                                 // - track ajax call via google analytics urchin tracker
                                 trackAJAXCall('wordstats/rateword');
                             }
                   }).responseText;
 	var ratingValues = response.split(",");
    if (parseInt(ratingValues[0]) > 0 && parseInt(ratingValues[1]) > 0) {
 		$j("span[@id=ratinglabel_"+el_id+"]").text('RATINGS / AVG:');
		$j("span[@id=score_"+el_id+"]").text(parseFloat(ratingValues[0]).toFixed(2));  		    
			    $j("span[@id=ratingcount_"+el_id+"]").text(ratingValues[1]);
			    $j("tr[@id=tr_yourrate_"+el_id+"]").show();
			    $j("span[@id=yourrate_"+el_id+"]").text(i+1);
	    }
	$j("img[@name=ratingstar]").attr("scr",staroff.src).each(function(j) {	
			this.src = staron.src; //root + "/images/star-on.gif";
			if (j >= i) { 
				return false;
			}
		});
	return false;
});


/*$j("a,img,object").livequery(function(i) {
	
	//$j(this).Tooltip({showURL: false,delay: 0});
	//if ($j(this).attr("class") == "thickboxhack") {
	//	tb_init(this);
	//}
	
},null);*/

/* END STATS */ 

/* word pï¿½ge */

function storeSubmitPage() {
		var word        = $j("#word").val();
		var definition  = $j("#definition").val();
		var example     = $j("#example").val();
		var dedication  = $j("#dedication").val();
		var category    = $j("#category").val();
		var type        = $j("#wordtype").val();
		var tag       = $j("#tags").val();
		var contest     = $j("#hidcontest").val();
		var tobaw_id    = $j("#hidtobaw_id").val();
		var altdef      = $j("#hidaltdefinition").val();
				
		if (word != ''){
			createCookie("submit_word",word,0);
		}
		if(definition != '') {	
			createCookie("submit_definition",definition,0);
		}
		if (example != '') {
			createCookie("submit_example",example,0);
		}
		if (dedication!='') {
			createCookie("submit_dedication",dedication,0);
		}
		
		if(category!='') {
			createCookie("submit_cat",category,0);
		}
		if (type != '') {
			createCookie("submit_type",type,0);
		}
		if (tag != '') {
			createCookie("submit_tag",tag,0);
		}
		if (contest != '' || contest > 0) {
			createCookie("submit_contest",contest,0);
		}
		if (tobaw_id != '' || tobaw_id > 0) {
			createCookie("submit_tobaw_id",tobaw_id,0);
		}
		if (altdef != '' || altdef > 0) {
			createCookie("submit_altdef",altdef_id,0);			
		}
		return true;
}  

/* DropDown Menus Setup */
	  
$j.fn.hoverClass = function(c) {
	return this.each(function(){
		$j(this).hover( 
			function() { $j(this).addClass(c);  },
			function() { $j(this).removeClass(c); }
		);
	});
};	  

//setup the make a word form
function initTobaw( $area ){

var $addButton = $j('.tobaw .submission a.button_add');

$j('.tobaw form.submission')
	.unbind('submit.add_tobaw')
	.bind('submit.add_tobaw', function(e){
		e.preventDefault();
		$addButton.trigger('mousedown.add_tobaw').trigger('click');
	});
$addButton
	.unbind('mousedown.add_tobaw')
	.bind('mousedown.add_tobaw',function(e){
		$this = $j(this);
		if( !$this.attr('origHref') ){
			$this.attr('origHref',$this.attr('href'));
		}
		var $word = $this.prev('#tobaw_word');
		var sAction = $this.attr('origHref');
		
		if( !$word.hasClass('watermarked') ){
			sAction += '&' + $word.attr('name') + '=' + $word.val();
		}
		$this.attr('href',sAction);
	
	}); 		

	initWatermarks( $area );
	
}	
 
function initWatermarks( $area ){
	if( $j().watermark ){
		var $area = $area || $j('html');
		$j($area).find('.watermark:input').watermark( {mode:'blank', style:{color:'#999'}} );
	}
} 

function initFacebox(){
	if( $j().facebox ){
		$j("a[rel*=facebox][href^=#]").facebox();
		$j(document).bind('reveal.facebox', function() {
			$j(".facebox a[rel*=facebox]").facebox();
		}); 
	}		
}

$j(document).ready(function(){
	$j("#navigation li.dropdown").hover(
		function(){ $j("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
	$j("#navigation li.dropdown").hoverClass ("sfHover");
	
	initFacebox();
	initTobaw();
 });
 
 

;
// - Track ajax request to google analytics urchin tracker.

function trackAJAXCall(groupKey){
	if (typeof window._tracker == 'function') {
		window._tracker(groupKey);
	}
}

function addTracker(type, func) {
	//make sure we have an array of loaded trackers
	if (typeof window._trackers == 'undefined') {
		window._trackers = new Array();
	}
	//make sure we don't load the tracker a second time
	if (typeof window._trackers[type] != 'undefined') {
		return;
	}
	
	window._trackers[type] = true;
	var oldTracker = window._tracker;
	if (typeof window._tracker != 'function') {
		window._tracker = func;
	} else {
		window._tracker = function(groupKey) {
			if (typeof oldTracker != 'undefined') {
				oldTracker(groupKey);
			}
			func(groupKey);
		}
	}
}
;
