(function($){
    $.log = function(message) {
        if (window.console) {
            if (window.console.debug)
                window.console.debug(message);
            else if (window.console.log)
                window.console.log(message);
        }
    //else
    //alert(message);
    };
    $.debug = $.log;
    $.fn.debug = function() {
        $.debug($(this));
        return $(this);
    }
})(jQuery);


var Content = {
    
    toggleExpander : function(l) {
        var link = $(l);
        var content = link.parent().next();
        if(content.is(':visible')) {
            //hide content and update expand text
            content.slideUp(function() {
                //change label
                link.parent().removeClass('open', 1000);
                $('#main').height('');
                $('#left').height($('#main').height());
            });
        } else {
            //show content
            content.slideDown(function() {
                //change label
                $.log("changing css to collapse");$.log(link);
                link.parent().addClass('open', 1000);
                $('#main').height('');
                $('#left').height($('#main').height());
            });
        }
    }
    
};

var Site = {
        
    ajaxloader : '<div id="ajax-loader">Loading<br /><img src="/images/ajax_loader.gif" alt="Loading..." width="62" height="13" longdesc="Loading content..." /></div>',
    ajaxloaderexists : 0,
    notifyexists : 0,
    notifyvisible : 0,
    loaded: 0,
    ajaxloaded: 1,

    init : function() {
    	$('div.columnize').columnize({ columns: 3, minHeight: 200 });
        $('div.columnize2').columnize({ columns: 2 });
        $("h3.to_hide a").click();
        Site.fixHeight();
        Site.menuScroll();
        Rollover.attachHide();
    },

    fixHeight : function(booster) {
        // set some initial values
        $('#main').css({height:'auto'});
        $('#left').css({height:'auto'});
        
        var h = ($('#left-holder').outerHeight() > $('#main').outerHeight()) ? $('#left-holder').outerHeight() : $('#main').outerHeight();
        $('#main').height(h);
        //console.log($('#left-holder').outerHeight());
        var height = ($('#main').outerHeight() > $('#left').outerHeight()) ? $('#main').outerHeight() : $('#left').outerHeight();
        if (booster) {
            height += booster;
        }
        $('#left').height(height);


    },
    
    menuScroll : function() {
        if ($('#left-holder').length) {
            $('#left-holder' ).scrollFollow({
                container: 'left',
                easing : 'easeOutQuart'
            });
        }
    },

    /**
     * loader toggles the fast loader
     * You can also specify the state "on" or "off
     * null will toggle
     */
    loader : function(method) {
        // first check if #ajax-loader exists
        if (Site.ajaxloaderexists === 0) {
            if ($('#ajax-loader').length < 1) {
                // create it
                $('body').append(Site.ajaxloader);
                Site.ajaxloaderexists = 1;
            } else Site.ajaxloaderexists = 1;
        }

        // otherwise toggle
        if (method !== undefined) { if (method === 'on') {$('html').css({cursor:'wait'});$('#ajax-loader').css('display','block');} else { $('html').css({cursor:'default'});$('#ajax-loader').fadeOut(250); }return false;}

        if ($('#ajax-loader').is(':hidden')) { $('html').css({cursor:'wait'});$('#ajax-loader').css('display','block'); }
        else { $('html').css({cursor:'default'}); $('#ajax-loader').fadeOut(250); }
        return true;
    },

    notify : function(text, type) {
        var delay = 750;
        if (Site.notifyvisible === 1) return false;
        if (type == '') type = 'default';
        if (Site.notifyexists === 0) {
            if ($('#notify-info').length < 1) {
                // create it
                $('body').append('<div id="notify-info"></div>');
                Site.notifyexists = 1;
            } else Site.notifyexists = 1;
        }
        var clwidth = window.document.body.clientWidth;
        var windowh = (typeof window.innerHeight != 'undefined') ? window.innerHeight : document.body.offsetHeight;
        $('#notify-info').empty().text(text).removeClass().addClass(type);
        Site.notifyvisible =1;
        var w = Math.round($('#notify-info').outerWidth(true) / 2);
        $('#notify-info').css({display:'block',top: ((windowh/2)-100)+'px', left: ((clwidth/2)-w)+'px'})
        .animate({top: (windowh/2)+'px', opacity: 0.8}, 500, 'easeInOutExpo', function() {
            setTimeout(function(){$('#notify-info').animate({top: ((windowh/2)+300)+'px', opacity: 0}, 500, 'easeInOutQuint', function(){$('#notify-info').remove();Site.notifyexists=0;});Site.notifyvisible =0;}, delay);
        });
        return false;
    }
}

var LocationAPI = {

    getLocation : function() {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(function(position) {
                result = {
                    latitude : position.coords.latitude,
                    longitude : position.coords.longitude
                };
                return result;
            });
            } else return null
    }
}

var Tools = {
    print : function() {
        window.print();
        return false;
    },
    bookmark : function() {
        var url = window.location.href;
		var title = document.title;
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
            window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
            return false; // do nothing
		} else { 
			Site.notify('Unfortunately, this browser does not support the requested action,'
            + ' please bookmark this page manually.','error');
		}
        return false;
    }
};
var Rollover = {
    hideDelay : 500,
    hideTimer : null,
    attached : null,
    
    show : function(handler) {
        Rollover.attachEvents();
        var target = $(handler).attr('rel');
        if ($('#links').data('tab') == target) return false;
        
        else if ($('#links').data('tab') != null) {
            $('#rollover .tab').fadeOut(0);
            $('#rollover-'+target).fadeIn(0);
            $('#links li').removeClass('sel');
            $('#links').data('tab',target);
            $(handler).addClass('sel');
            /*var i = 0;
            var so = $('#rollover .tab').length;
            
            $('#rollover .tab').fadeOut(0, function(){
                i++;
                if (i == so) {
                    $('#rollover-'+target).fadeIn(0);
                    $('#links a').removeClass('sel');
                    $('#links').data('tab',target);
                    $(handler).addClass('sel');
                }
            });*/
        }
        else {
            $('#links').data('tab',target);
            $('#links li').css('background-image','url(/images/front/tabs/divider-right.png)');
            $('#links li:last-child').css('background-image','url(/images/front/tabs/divider-right-end.png)');
            $('#links li a').css('background-image','url(/images/front/tabs/divider-left.png)');
            $('#rollover-'+target).css('display','block');
            $('#rollover').css('display','block').slideUp(0);
            $('#rollover').slideDown(250,"easeOutExpo");
            $(handler).addClass('sel');
        }
        return false;
    },
    
    attachEvents : function() {
        if (Rollover.attached) return false;
        
        $('#links').live('mouseover', function(e) {
            if (Rollover.hideTimer)
                clearTimeout(Rollover.hideTimer);
        });
        
        $('#rollover').live('mouseover', function(e) {
            if (Rollover.hideTimer)
                clearTimeout(Rollover.hideTimer);
        });
        
        $('#rollover').live('mouseout', function(e) {
            if (Rollover.hideTimer)
                clearTimeout(Rollover.hideTimer);
                
            Rollover.hideTimer = setTimeout(function() {
                Rollover.hide();
            }, Rollover.hideDelay);
        });
        
        Rollover.attached = true;
        return false;
    },
        
    
    attachHide : function() {
        if (!$('#main').length) return false;
        $('#main').click(function() {
            if ($('#rollover:hidden'))
                Rollover.hide();
        });
        return true;
    },
    
    hide : function() {
		$('#links').removeData('tab');
		$('#links .sel').removeClass('sel');
		$('#rollover').slideUp({duration:250, easing:"easeInExpo", complete: function(){
			$('#links li').css('background-image','url(/images/front/tabs/divider-right-wht.png)');
			$('#links li:last-child').css('background-image','url(/images/front/tabs/divider-right-wht-end.png)');
			$('#links li a').css('background-image','url(/images/front/tabs/divider-left-wht.png)');
			$('#rollover .tab').css('display','none');
			$('#rollover').css('display','none');
		}});
        return false;
    },
    hideFast : function() {
        $('#rollover .tab').css('display','none');
        $('#rollover').css('display','none');
        $('#links a').removeClass('sel');
        return false;
    },
    
    hideSubs : function() {
        $('#rollover .sub').css('display','none');
    },
    
    showSub : function(handler) {
        Rollover.hideSubs();
        var target = $(handler).attr('rel');
        //$(handler).addClass('sel');
        //$('#rollover').css('display','block').slideUp(0);
        $('#'+target).css('display','block').slideUp(0);
        $('#'+target).slideDown(125,"easeOutExpo");
        return false;
    }
};

var Slideshow = {
    current : 0,
    active : '',
    timer : 7000,
    event : null,
    wut : 0,
    
    init : function() {
    	$('#slideshow-image img:first').addClass('active');
    
        // remove the stuff if there is only one image
        if ($('#slideshow-image img').length == 1) {
            // remove the menu
            $('#slideshow-menu').remove();
            return false;
        }
        // create the ul
        if ($('#slideshow-menu ul').length < 1)
            $('#slideshow-menu').append('<ul></ul>');
        var s = '';
        $('#slideshow-image img').each(function(i,v) {
            if (i == 0) s = 'class="sel"'; else s = '';
            $('#slideshow-menu ul').append('<li '+s+' onclick="return Slideshow.change(\''+i+'\');"></li>');
            //console.log('i: '+i+' v: '+v);
        });
        Slideshow.startSlideshow();
        return false;
    },
    
    doswitch : function() {
        Slideshow.active = $('#slideshow-image img.active');
        var next = $("#slideshow-image img").index($('.active')) + 1;
        var pic = $('#slideshow-image img:eq('+next+')');
        if (!pic.length) {
            pic = $('#slideshow-image img:eq(0)');
            next = 0;
        }
        $('#slideshow-menu ul li').removeClass('sel');$('#slideshow-menu ul li:eq('+next+')').addClass('sel');
        $(pic).css({opacity:0.0}).addClass('new').animate({opacity: 1.0}, Slideshow.timer / 4, function() {
            $(pic).removeClass('new').addClass('active');
            $(Slideshow.active).removeClass('active');
        });
    },
    
    startSlideshow : function() {
        Slideshow.event = setInterval(function(){
            Slideshow.doswitch();
        },Slideshow.timer);
    },
    
    change : function(i) {
        if (typeof Slideshow.event == "number") clearTimeout(Slideshow.event); Slideshow.startSlideshow();
        
        Slideshow.active= $('#slideshow-image img.active');
        var pic = $('#slideshow-image img:eq('+i+')');
        $('#slideshow-menu ul li').removeClass('sel');$('#slideshow-menu ul li:eq('+i+')').addClass('sel');
        $(pic).css({opacity:0.0}).addClass('new').animate({opacity: 1.0}, 750, function() {
            $(pic).removeClass('new').addClass('active');
            $(Slideshow.active).removeClass('active');
        });
    }
};


var Careers = {    
    error: function(msg) {
        Site.notify(msg, 'error');
        return false;
    },
    
    init : function() {
        if (!$('#people').length) return Careers.error('Missing <div id="people"> .. </div>');
        
        Careers.scan();
    },
    
    scan : function() {
        var count = 0;
        $('#people .person').each(function(i,v) {
            count++;
            var name = $(this).find('span.name');
            var position = $(this).find('span.menu_job');
            var overlay = $(this).find('span.overlay');
            var menu_title = $(this).find('span.menu_title');
            var text = $(this).find('div.text');
            var img = $(this).find('img');
            if (!$(name).length || !$(overlay).length || !$(text).length || !$(img).length) return Careers.error('Missing name, overlay, text or img');
            // we got here so we win
            
            // insert image first
            if (i == 0) $(img).appendTo('#careers-image').attr('id','person-image-'+i).addClass('active');
            else $(img).attr('id','person-image-'+i).appendTo('#careers-image');
            
            // calc if it's longer than 100
            var sty = ($(name).text().length > 90) ? 'style="font-size:12px;"' : '';
            // insert overlay
            $('<div id="person-overlay-'+i+'"><span class="name" '+sty+'>'+$(name).html()+'</span><p>'+$(overlay).html()+'</p></div>').appendTo('#overlay-holder');
            $('#person-overlay-'+i).hide();
            if (i == 0) $('#person-overlay-'+i).show();
            
            // now add to the menu
            $('<li class="active"><a href="#" id="person-link-'+i+'" onclick="return Careers.show('+i+');">'+$(menu_title).text()+'<span style="display:block;padding-top:3px;font-size:9px;font-style:italic;color:#666">'+$(position).text()+'</span></a></li>').appendTo('#careers-menu ul');
            if (i == 0) $('#person-link-'+i).addClass('sel');
            
            $('<div id="person-text-'+i+'" class="text">'+$(text).html()+'</div>').appendTo('#people-holder');
            $('#person-text-'+i).hide();
            if (i == 0) $('#person-text-'+i).show();
            
            // finally remove
            $(this).remove();
        });
        if (count < 8) {    // was 9 here and below
            for (count=count;count<8;count++) {
                $('<li><a href="#" onclick="return false;">&nbsp;</a></li>').appendTo('#careers-menu ul');
            }
        }
        $('#main').height(1000);
        $('#left').height('auto');
        Site.fixHeight();
        return false;
    },
    
    show : function(id,link) {
        // show pic
        Careers.changePic(id);
        $("#overlay-holder div").hide();
        $('#person-overlay-'+id).fadeIn(750);
        
        if ($('#person-text-'+id).length) {
            $('#people-holder .text').hide();
            $('#person-text-'+id).fadeIn(750);
        }
        
        $('#careers-menu ul li a').removeClass('sel');
        if (link)
            $(link).addClass('sel');
        else
            $('#person-link-'+id).addClass('sel');
            
        Site.fixHeight();
        return false;
    },
    
    changePic : function(i) {
        var active = $('#careers-image img.active');
        var pic = $('#careers-image img:eq('+i+')');
        $(pic).css({opacity:0.0}).addClass('new').animate({opacity: 1.0}, 750, function() {
            $(pic).removeClass('new').addClass('active');
            $(active).removeClass('active');
        });
    }
    
};


var Search = {
    
    filter : function(form) {
        var url = $(form).attr('action');
		var data = $(form).serialize();
        data += '&ajax=1';
		$.ajax({
			type: "POST",
			url: url,
			data: data,
			dataType: 'html',
			beforeSend: function(){},
			complete: function(req,status){
            },
			success: function(data) {
                $('#main').animate({opacity: 0},250, function() {
                    $('#main').html(data);
                    $('#main').animate({opacity:1},250);
                    $('#main').height('auto');
                    $('#left').height('auto');
                    Site.fixHeight();
                });
                $.scrollTo(0, 500);
			}
		});
        return false;
    }
}


var ExpandMenu = {

    menu : "left-menu",

        expandSibling : function(l) {
            var c = $('#' + this.menu);
            var link = $(l);
            $('a.open', c).removeClass('open');
    
            link.addClass('open');
            //remove open class from any other links
    
            var ul = link.next();
    
            if(ul.hasClass("showing")) {
                ul.slideUp().removeClass("showing");
                link.removeClass('open');
            }
            else {
                $("ul.showing", c).slideUp().removeClass("showing");
                ul.slideDown();
                ul.addClass("showing");
                //ul.prev().removeClass('open');
            }
    },
    
    init : function(fullurl) {
        var m = $("#" + this.menu);
        var sub = $("a[href='"+fullurl+"']", m).closest('ul.sub-menu');
        sub.addClass('showing');
        //add open class to outter li
        sub.prev().addClass('open');
        
        // now try secondary
        var sub = $("a[href='"+fullurl+"']", m).next('ul.sub-menu');
        sub.addClass('showing');
        //add open class to outter li
        sub.prev().addClass('open');
        Site.fixHeight();
        
    }
}

var Error = {
    ask : function(data) {

        Boxy.alert(data.message, ["OK"], function(val) {
            //alert("You chose: " + val);

            return false;
        }, {
            title: "Could not send enquiry :-("
        });
    }
}

var Forms = {
    holder : null,

    submit : function(formid, holder, hideForm){
        if (!holder) holder = 'holder';
        Forms.holder = holder;
        var url = $(formid).attr('action');
        var data = $(formid).serialize();
        data += '&ajax=1';
		$.ajax({
			type: "POST",
			url: url,
			data: data,
			dataType: 'json',
			beforeSend: function(){Site.loader('on');$(formid).find('div.buttons input[type="submit"]').attr('disabled', 'true').val('Sending..');},
			complete: function(req,status){
                if (status == 'error') {
                    Site.notify('Problem submitting form, check your internet connection', 'error');
                }
                Site.loader('off')
            },
			success: function(data) {
                           
                            Forms.process(data, hideForm);

			}
		});
        return false;
    },

    oldSubmit : function(formid, holder){
        if (!holder) holder = 'main';
        Forms.holder = holder;
        var url = $(formid).attr('action');
		var data = $(formid).serialize();
        data += '&ajax=1';
		$.ajax({
			type: "POST",
			url: url,
			data: data,
			dataType: 'html',
			beforeSend: function(){Site.loader('on');$(formid).find('div.buttons input[type="submit"]').attr('disabled', 'true').val('Sending..');},
			complete: function(req,status){
                if (status == 'error') {
                    Site.notify('Problem submitting form, check your internet connection', 'error');
                }
                Site.loader('off')
            },
			success: function(data) {
                $('#'+holder).html(data);
			}
		});
        return false;
    },

    /** process the data returned by our form submission
     * we are looking for
     * [1]      redirect    (string)
     * [2]      worked      (bool)
     * [2]      message     (string)
     * [3]      html        (big ass string)
     */
    process : function(data, hideForm) {
        
        var message = $('#post_message');

        // make sure we are given the right stuff
        if (!data || typeof data != 'object') return false;

        // first we check for data.modal == 1
        if (typeof data.modal != 'undefined' && data.modal == 1) {
            Error.ask(data);
        }
        else {
            // first we check for worked and display stuff accordingly
            if (typeof data.worked != 'undefined') {
                //var msgclass = (data.worked == 1) ? 'success' : 'error';

                    //alert("hideform = " + hideForm);
                    if(data.worked ==1) {
                        //reset form
                        if(!hideForm) {
                        $(':input',$('#' + Forms.holder))
                         .not(':button, :submit, :reset, :hidden')
                         .val('')
                         .removeAttr('checked')
                         .removeAttr('selected')

                         $('#' + Forms.holder).find('div.buttons input[type="submit"]').removeAttr('disabled').val('Done')
                         message.html(data.message).fadeIn();
                        } else {
                            //hide the form
                            $('form',$('#' + Forms.holder)).fadeOut(function() {
                                message.html(data.message).fadeIn();
                            });
                        }
                        
                    }
                    else {
                       message.html(data.message).fadeIn();
                       $('#' + Forms.holder).find('div.buttons input[type="submit"]').removeAttr('disabled').val('Submit')
                    }
                
            }
            // then we check for a redirect, optionally delay it by 3 secs if message is defined
     
        }

         return false;
    }
};





/**
 * jquery.scrollFollow.js
 * Copyright (c) 2008 Net Perspective (http://kitchen.net-perspective.com/)
 * Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)
 * 
 * @author R.A. Ray
 *
 * @projectDescription	jQuery plugin for allowing an element to animate down as the user scrolls the page.
 * 
 * @version 0.4.0
 * 
 * @requires jquery.js (tested with 1.2.6)
 * @requires ui.core.js (tested with 1.5.2)
 * 
 * @optional jquery.cookie.js (http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/)
 * @optional jquery.easing.js (http://gsgd.co.uk/sandbox/jquery/easing/ - tested with 1.3)
 * 
 * @param speed		int - Duration of animation (in milliseconds)
 * 								default: 500
 * @param offset			int - Number of pixels box should remain from top of viewport
 * 								default: 0
 * @param easing		string - Any one of the easing options from the easing plugin - Requires jQuery Easing Plugin < http://gsgd.co.uk/sandbox/jquery/easing/ >
 * 								default: 'linear'
 * @param container	string - ID of the containing div
 * 								default: box's immediate parent
 * @param killSwitch	string - ID of the On/Off toggle element
 * 								default: 'killSwitch'
 * @param onText		string - killSwitch text to be displayed if sliding is enabled
 * 								default: 'Turn Slide Off'
 * @param offText		string - killSwitch text to be displayed if sliding is disabled
 * 								default: 'Turn Slide On'
 * @param relativeTo	string - Scroll animation can be relative to either the 'top' or 'bottom' of the viewport
 * 								default: 'top'
 * @param delay			int - Time between the end of the scroll and the beginning of the animation in milliseconds
 * 								default: 0
 */

( function( $ ) {
	
	$.scrollFollow = function ( box, options )
	{ 
		// Convert box into a jQuery object
		box = $( box );
		
		// 'box' is the object to be animated
		var position = box.css( 'position' );
		
		function ani()
		{		
			// The script runs on every scroll which really means many times during a scroll.
			// We don't want multiple slides to queue up.
			box.queue( [ ] );
		
			// A bunch of values we need to determine where to animate to
			var viewportHeight = parseInt( $( window ).height() );	
			var pageScroll =  parseInt( $( document ).scrollTop() );
			var parentTop =  parseInt( box.cont.offset().top );
			var parentHeight = parseInt( box.cont.attr( 'offsetHeight' ) );
			var boxHeight = parseInt( box.attr( 'offsetHeight' ) + ( parseInt( box.css( 'marginTop' ) ) || 0 ) + ( parseInt( box.css( 'marginBottom' ) ) || 0 ) );
			var aniTop;
			
			// Make sure the user wants the animation to happen
			if ( isActive )
			{
				// If the box should animate relative to the top of the window
				if ( options.relativeTo == 'top' )
				{
					// Don't animate until the top of the window is close enough to the top of the box
					if ( box.initialOffsetTop >= ( pageScroll + options.offset ) )
					{
						aniTop = box.initialTop;
					}
					else
					{
						aniTop = Math.min( ( Math.max( ( -parentTop ), ( pageScroll - box.initialOffsetTop + box.initialTop ) ) + options.offset ), ( parentHeight - boxHeight - box.paddingAdjustment ) );
					}
				}
				// If the box should animate relative to the bottom of the window
				else if ( options.relativeTo == 'bottom' )
				{
					// Don't animate until the bottom of the window is close enough to the bottom of the box
					if ( ( box.initialOffsetTop + boxHeight ) >= ( pageScroll + options.offset + viewportHeight ) )
					{
						aniTop = box.initialTop;
					}
					else
					{
						aniTop = Math.min( ( pageScroll + viewportHeight - boxHeight - options.offset ), ( parentHeight - boxHeight ) );
					}
				}
				
				// Checks to see if the relevant scroll was the last one
				// "-20" is to account for inaccuracy in the timeout
				if ( ( new Date().getTime() - box.lastScroll ) >= ( options.delay - 20 ) )
				{
					box.animate(
						{
							top: aniTop
						}, options.speed, options.easing
					);
				}
			}
		};
		
		// For user-initiated stopping of the slide
		var isActive = true;
		
		if ( $.cookie != undefined )
		{
			if( $.cookie( 'scrollFollowSetting' + box.attr( 'id' ) ) == 'false' )
			{
				var isActive = false;
				
				$( '#' + options.killSwitch ).text( options.offText )
					.toggle( 
						function ()
						{
							isActive = true;
							
							$( this ).text( options.onText );
							
							$.cookie( 'scrollFollowSetting' + box.attr( 'id' ), true, {expires: 365, path: '/'} );
							
							ani();
						},
						function ()
						{
							isActive = false;
							
							$( this ).text( options.offText );
							
							box.animate(
								{
									top: box.initialTop
								}, options.speed, options.easing
							);	
							
							$.cookie( 'scrollFollowSetting' + box.attr( 'id' ), false, {expires: 365, path: '/'} );
						}
					);
			}
			else
			{
				$( '#' + options.killSwitch ).text( options.onText )
					.toggle( 
						function ()
						{
							isActive = false;
							
							$( this ).text( options.offText );
							
							box.animate(
								{
									top: box.initialTop
								}, 0
							);	
							
							$.cookie( 'scrollFollowSetting' + box.attr( 'id' ), false, {expires: 365, path: '/'} );
						},
						function ()
						{
							isActive = true;
							
							$( this ).text( options.onText );
							
							$.cookie( 'scrollFollowSetting' + box.attr( 'id' ), true, {expires: 365, path: '/'} );
							
							ani();
						}
					);
			}
		}
		
		// If no parent ID was specified, and the immediate parent does not have an ID
		// options.container will be undefined. So we need to figure out the parent element.
		if ( options.container == '')
		{
			box.cont = box.parent();
		}
		else
		{
			box.cont = $( '#' + options.container );
		}
		
		// Finds the default positioning of the box.
		box.initialOffsetTop =  parseInt( box.offset().top );
		box.initialTop = parseInt( box.css( 'top' ) ) || 0;
		
		// Hack to fix different treatment of boxes positioned 'absolute' and 'relative'
		if ( box.css( 'position' ) == 'relative' )
		{
			box.paddingAdjustment = parseInt( box.cont.css( 'paddingTop' ) ) + parseInt( box.cont.css( 'paddingBottom' ) );
		}
		else
		{
			box.paddingAdjustment = 0;
		}
		
		// Animate the box when the page is scrolled
		$( window ).scroll( function ()
			{
				// Sets up the delay of the animation
				$.fn.scrollFollow.interval = setTimeout( function(){ani();} , options.delay );
				
				// To check against right before setting the animation
				box.lastScroll = new Date().getTime();
			}
		);
		
		// Animate the box when the page is resized
		$( window ).resize( function ()
			{
				// Sets up the delay of the animation
				$.fn.scrollFollow.interval = setTimeout( function(){ani();} , options.delay );
				
				// To check against right before setting the animation
				box.lastScroll = new Date().getTime();
			}
		);

		// Run an initial animation on page load
		box.lastScroll = 0;
		
		ani();
	};
	
	$.fn.scrollFollow = function ( options )
	{
		options = options || {};
		options.relativeTo = options.relativeTo || 'top';
		options.speed = options.speed || 500;
		options.offset = options.offset || 0;
		options.easing = options.easing || 'swing';
		options.container = options.container || this.parent().attr( 'id' );
		options.killSwitch = options.killSwitch || 'killSwitch';
		options.onText = options.onText || 'Turn Slide Off';
		options.offText = options.offText || 'Turn Slide On';
		options.delay = options.delay || 0;
		
		this.each( function() 
			{
				new $.scrollFollow( this, options );
			}
		);
		
		return this;
	};
})( jQuery );




/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // NOTE Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '.';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;
(function(d){
    var k=d.scrollTo=function(a,i,e){
        d(window).scrollTo(a,i,e)
        };

    k.defaults={
        axis:'xy',
        duration:parseFloat(d.fn.jquery)>=1.3?0:1
        };

    k.window=function(a){
        return d(window)._scrollable()
        };

    d.fn._scrollable=function(){
        return this.map(function(){
            var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;
            if(!i)return a;
            var e=(a.contentWindow||a).document||a.ownerDocument||a;
            return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement
            })
        };

    d.fn.scrollTo=function(n,j,b){
        if(typeof j=='object'){
            b=j;
            j=0
            }
            if(typeof b=='function')b={
            onAfter:b
        };

        if(n=='max')n=9e9;
        b=d.extend({},k.defaults,b);
        j=j||b.speed||b.duration;
        b.queue=b.queue&&b.axis.length>1;
        if(b.queue)j/=2;
        b.offset=p(b.offset);
        b.over=p(b.over);
        return this._scrollable().each(function(){
            var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');
            switch(typeof f){
                case'number':case'string':
                    if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){
                    f=p(f);
                    break
                }
                f=d(f,this);
                case'object':
                    if(f.is||f.style)s=(f=d(f)).offset()
                    }
                    d.each(b.axis.split(''),function(a,i){
                var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);
                if(s){
                    g[c]=s[h]+(u?0:l-r.offset()[h]);
                    if(b.margin){
                        g[c]-=parseInt(f.css('margin'+e))||0;
                        g[c]-=parseInt(f.css('border'+e+'Width'))||0
                        }
                        g[c]+=b.offset[h]||0;
                    if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]
                        }else{
                    var o=f[h];
                    g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o
                    }
                    if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);
                if(!a&&b.queue){
                    if(l!=g[c])t(b.onAfterFirst);
                    delete g[c]
                }
            });
        t(b.onAfter);
            function t(a){
            r.animate(g,j,b.easing,a&&function(){
                a.call(this,n,b)
                })
            }
        }).end()
    };

k.max=function(a,i){
    var e=i=='x'?'Width':'Height',h='scroll'+e;
    if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();
    var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;
    return Math.max(l[h],m[h])-Math.min(l[c],m[c])
    };

function p(a){
    return typeof a=='object'?a:{
        top:a,
        left:a
    }
}
})(jQuery);
/*
$.easing.elasout = 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;
	};
$.easing.easeInQuart = function (x, t, b, c, d) {
	return c*(t/=d)*t*t*t + b;
};
$.easing.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;
};
 */
// t: current time, b: begInnIng value, c: change In value, d: duration
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 Color Animations
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 */

(function(jQuery){

    // We override the animation for all of these color styles
    jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
        jQuery.fx.step[attr] = function(fx){
            if ( fx.state == 0 ) {
                fx.start = getColor( fx.elem, attr );
                fx.end = getRGB( fx.end );
            }

            fx.elem.style[attr] = "rgb(" + [
            Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
            Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
            Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
            ].join(",") + ")";
        }
    });

    // Color Conversion functions from highlightFade
    // By Blair Mitchelmore
    // http://jquery.offput.ca/highlightFade/

    // Parse strings looking for color tuples [255,255,255]
    function getRGB(color) {
        var result;
        // Check if we're already dealing with an array of colors
        if ( color && color.constructor == Array && color.length == 3 )
            return color;
        // Look for rgb(num,num,num)
        if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
            return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
        // Look for rgb(num%,num%,num%)
        if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
            return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
        // Look for #a0b1c2
        if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
            return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
        // Look for #fff
        if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
            return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
        // Otherwise, we're most likely dealing with a named color
        return colors[jQuery.trim(color).toLowerCase()];
    }
    function getColor(elem, attr) {
        var color;
        do {
            color = jQuery.curCSS(elem, attr);
            // Keep going until we find an element that has color, or we hit the body
            if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
                break;
            attr = "backgroundColor";
        } while ( elem = elem.parentNode );
        return getRGB(color);
    };

    // Some named colors to work with
    // From Interface by Stefan Petre
    // http://interface.eyecon.ro/

    var colors = {
        aqua:[0,255,255],
        azure:[240,255,255],
        beige:[245,245,220],
        black:[0,0,0],
        blue:[0,0,255],
        brown:[165,42,42],
        cyan:[0,255,255],
        darkblue:[0,0,139],
        darkcyan:[0,139,139],
        darkgrey:[169,169,169],
        darkgreen:[0,100,0],
        darkkhaki:[189,183,107],
        darkmagenta:[139,0,139],
        darkolivegreen:[85,107,47],
        darkorange:[255,140,0],
        darkorchid:[153,50,204],
        darkred:[139,0,0],
        darksalmon:[233,150,122],
        darkviolet:[148,0,211],
        fuchsia:[255,0,255],
        gold:[255,215,0],
        green:[0,128,0],
        indigo:[75,0,130],
        khaki:[240,230,140],
        lightblue:[173,216,230],
        lightcyan:[224,255,255],
        lightgreen:[144,238,144],
        lightgrey:[211,211,211],
        lightpink:[255,182,193],
        lightyellow:[255,255,224],
        lime:[0,255,0],
        magenta:[255,0,255],
        maroon:[128,0,0],
        navy:[0,0,128],
        olive:[128,128,0],
        orange:[255,165,0],
        pink:[255,192,203],
        purple:[128,0,128],
        violet:[128,0,128],
        red:[255,0,0],
        silver:[192,192,192],
        white:[255,255,255],
        yellow:[255,255,0]
    };

})(jQuery);

/* elastic for textbox */
(function(jQuery){
    jQuery.fn.extend({
        elastic:function(){
            var mimics=['paddingTop','paddingRight','paddingBottom','paddingLeft','fontSize','lineHeight','fontFamily','width','fontWeight'];
            return this.each(function(){
                if(this.type!='textarea'){
                    return false
                    }
                    var $textarea=jQuery(this),$twin=jQuery('<div />').css({
                    'position':'absolute',
                    'display':'none',
                    'word-wrap':'break-word'
                }),lineHeight=parseInt($textarea.css('line-height'),10)||parseInt($textarea.css('font-size'),'10'),minheight=parseInt($textarea.css('height'),10)||lineHeight*3,maxheight=parseInt($textarea.css('max-height'),10)||Number.MAX_VALUE,goalheight=0,i=0;
                if(maxheight<0){
                    maxheight=Number.MAX_VALUE
                    }
                    $twin.appendTo($textarea.parent());
                var i=mimics.length;
                while(i--){
                    $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()))
                    }
                    function setHeightAndOverflow(height,overflow){
                    curratedHeight=Math.floor(parseInt(height,10));
                    if($textarea.height()!=curratedHeight){
                        $textarea.css({
                            'height':curratedHeight+'px',
                            'overflow':overflow
                        })
                        }
                    }
                function update(){
                var textareaContent=$textarea.val().replace(/&/g,'&amp;').replace(/  /g,'&nbsp;').replace(/<|>/g,'&gt;').replace(/\n/g,'<br />');
                var twinContent=$twin.html();
                if(textareaContent+'&nbsp;'!=twinContent){
                    $twin.html(textareaContent+'&nbsp;');
                    if(Math.abs($twin.height()+lineHeight-$textarea.height())>3){
                        var goalheight=$twin.height()+lineHeight;
                        if(goalheight>=maxheight){
                            setHeightAndOverflow(maxheight,'auto')
                            }else if(goalheight<=minheight){
                            setHeightAndOverflow(minheight,'hidden')
                            }else{
                            setHeightAndOverflow(goalheight,'hidden')
                            }
                        }
                }
            }
        $textarea.css({
        'overflow':'hidden'
    });
    $textarea.keyup(function(){
        update()
        });
    $textarea.live('input paste',function(e){
        setTimeout(update,250)
        });
    update()
        })
}
})
})(jQuery);

/*
 * jQuery Autocomplete plugin 1.1
 *
 * Copyright (c) 2009 Jörn Zaefferer
 *
 * 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.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(3($){$.2e.1u({19:3(b,d){5 c=W b=="1B";d=$.1u({},$.M.1T,{Y:c?b:P,y:c?P:b,1J:c?$.M.1T.1J:10,X:d&&!d.1D?10:48},d);d.1y=d.1y||3(a){6 a};d.1v=d.1v||d.1R;6 A.I(3(){1M $.M(A,d)})},L:3(a){6 A.11("L",a)},1k:3(a){6 A.14("1k",[a])},2b:3(){6 A.14("2b")},28:3(a){6 A.14("28",[a])},24:3(){6 A.14("24")}});$.M=3(o,r){5 t={2Y:38,2S:40,2N:46,2I:9,2E:13,2B:27,2x:3I,2v:33,2p:34,2n:8};5 u=$(o).3r("19","3o").Q(r.2Q);5 p;5 m="";5 n=$.M.3c(r);5 s=0;5 k;5 h={1F:C};5 l=$.M.32(r,o,1Z,h);5 j;$.1Y.2X&&$(o.2U).11("45.19",3(){4(j){j=C;6 C}});u.11(($.1Y.2X?"43":"42")+".19",3(a){s=1;k=a.2M;3V(a.2M){O t.2Y:a.1d();4(l.N()){l.30()}w{12(0,D)}R;O t.2S:a.1d();4(l.N()){l.2D()}w{12(0,D)}R;O t.2v:a.1d();4(l.N()){l.2C()}w{12(0,D)}R;O t.2p:a.1d();4(l.N()){l.2A()}w{12(0,D)}R;O r.17&&$.1c(r.S)==","&&t.2x:O t.2I:O t.2E:4(1Z()){a.1d();j=D;6 C}R;O t.2B:l.Z();R;3J:1P(p);p=1O(12,r.1J);R}}).2t(3(){s++}).3E(3(){s=0;4(!h.1F){2r()}}).2q(3(){4(s++>1&&!l.N()){12(0,D)}}).11("1k",3(){5 c=(1r.7>1)?1r[1]:P;3 1N(q,a){5 b;4(a&&a.7){16(5 i=0;i<a.7;i++){4(a[i].L.J()==q.J()){b=a[i];R}}}4(W c=="3")c(b);w u.14("L",b&&[b.y,b.F])}$.I(15(u.K()),3(i,a){21(a,1N,1N)})}).11("2b",3(){n.1o()}).11("28",3(){$.1u(r,1r[1]);4("y"2h 1r[1])n.1e()}).11("24",3(){l.1p();u.1p();$(o.2U).1p(".19")});3 1Z(){5 e=l.2g();4(!e)6 C;5 v=e.L;m=v;4(r.17){5 b=15(u.K());4(b.7>1){5 f=r.S.7;5 c=$(o).18().1I;5 d,1H=0;$.I(b,3(i,a){1H+=a.7;4(c<=1H){d=i;6 C}1H+=f});b[d]=v;v=b.3f(r.S)}v+=r.S}u.K(v);1l();u.14("L",[e.y,e.F]);6 D}3 12(b,c){4(k==t.2N){l.Z();6}5 a=u.K();4(!c&&a==m)6;m=a;a=1m(a);4(a.7>=r.29){u.Q(r.26);4(!r.1s)a=a.J();21(a,3a,1l)}w{1q();l.Z()}};3 15(b){4(!b)6[""];4(!r.17)6[$.1c(b)];6 $.4h(b.23(r.S),3(a){6 $.1c(b).7?$.1c(a):P})}3 1m(a){4(!r.17)6 a;5 c=15(a);4(c.7==1)6 c[0];5 b=$(o).18().1I;4(b==a.7){c=15(a)}w{c=15(a.22(a.37(b),""))}6 c[c.7-1]}3 1G(q,a){4(r.1G&&(1m(u.K()).J()==q.J())&&k!=t.2n){u.K(u.K()+a.37(1m(m).7));$(o).18(m.7,m.7+a.7)}};3 2r(){1P(p);p=1O(1l,4g)};3 1l(){5 c=l.N();l.Z();1P(p);1q();4(r.36){u.1k(3(a){4(!a){4(r.17){5 b=15(u.K()).1n(0,-1);u.K(b.3f(r.S)+(b.7?r.S:""))}w{u.K("");u.14("L",P)}}})}};3 3a(q,a){4(a&&a.7&&s){1q();l.35(a,q);1G(q,a[0].F);l.20()}w{1l()}};3 21(f,d,g){4(!r.1s)f=f.J();5 e=n.31(f);4(e&&e.7){d(f,e)}w 4((W r.Y=="1B")&&(r.Y.7>0)){5 c={4f:+1M 4e()};$.I(r.2Z,3(a,b){c[a]=W b=="3"?b():b});$.4d({4c:"4b",4a:"19"+o.49,2V:r.2V,Y:r.Y,y:$.1u({q:1m(f),47:r.X},c),44:3(a){5 b=r.1A&&r.1A(a)||1A(a);n.1i(f,b);d(f,b)}})}w{l.2T();g(f)}};3 1A(c){5 d=[];5 b=c.23("\\n");16(5 i=0;i<b.7;i++){5 a=$.1c(b[i]);4(a){a=a.23("|");d[d.7]={y:a,F:a[0],L:r.1z&&r.1z(a,a[0])||a[0]}}}6 d};3 1q(){u.1h(r.26)}};$.M.1T={2Q:"41",2P:"3Z",26:"3Y",29:1,1J:3W,1s:C,1f:D,1w:C,1g:10,X:3U,36:C,2Z:{},1X:D,1R:3(a){6 a[0]},1v:P,1G:C,E:0,17:C,S:", ",1y:3(b,a){6 b.22(1M 3T("(?![^&;]+;)(?!<[^<>]*)("+a.22(/([\\^\\$\\(\\)\\[\\]\\{\\}\\*\\.\\+\\?\\|\\\\])/2K,"\\\\$1")+")(?![^<>]*>)(?![^&;]+;)","2K"),"<2J>$1</2J>")},1D:D,1E:3S};$.M.3c=3(g){5 h={};5 j=0;3 1f(s,a){4(!g.1s)s=s.J();5 i=s.2H(a);4(g.1w=="3R"){i=s.J().1k("\\\\b"+a.J())}4(i==-1)6 C;6 i==0||g.1w};3 1i(q,a){4(j>g.1g){1o()}4(!h[q]){j++}h[q]=a}3 1e(){4(!g.y)6 C;5 f={},2G=0;4(!g.Y)g.1g=1;f[""]=[];16(5 i=0,2F=g.y.7;i<2F;i++){5 c=g.y[i];c=(W c=="1B")?[c]:c;5 d=g.1v(c,i+1,g.y.7);4(d===C)1V;5 e=d.3Q(0).J();4(!f[e])f[e]=[];5 b={F:d,y:c,L:g.1z&&g.1z(c)||d};f[e].1U(b);4(2G++<g.X){f[""].1U(b)}};$.I(f,3(i,a){g.1g++;1i(i,a)})}1O(1e,25);3 1o(){h={};j=0}6{1o:1o,1i:1i,1e:1e,31:3(q){4(!g.1g||!j)6 P;4(!g.Y&&g.1w){5 a=[];16(5 k 2h h){4(k.7>0){5 c=h[k];$.I(c,3(i,x){4(1f(x.F,q)){a.1U(x)}})}}6 a}w 4(h[q]){6 h[q]}w 4(g.1f){16(5 i=q.7-1;i>=g.29;i--){5 c=h[q.3O(0,i)];4(c){5 a=[];$.I(c,3(i,x){4(1f(x.F,q)){a[a.7]=x}});6 a}}}6 P}}};$.M.32=3(e,g,f,k){5 h={H:"3N"};5 j,z=-1,y,1t="",1S=D,G,B;3 2y(){4(!1S)6;G=$("<3M/>").Z().Q(e.2P).T("3L","3K").1Q(1K.2w);B=$("<3H/>").1Q(G).3G(3(a){4(U(a).2u&&U(a).2u.3F()==\'2s\'){z=$("1L",B).1h(h.H).3D(U(a));$(U(a)).Q(h.H)}}).2q(3(a){$(U(a)).Q(h.H);f();g.2t();6 C}).3C(3(){k.1F=D}).3B(3(){k.1F=C});4(e.E>0)G.T("E",e.E);1S=C}3 U(a){5 b=a.U;3A(b&&b.3z!="2s")b=b.3y;4(!b)6[];6 b}3 V(b){j.1n(z,z+1).1h(h.H);2o(b);5 a=j.1n(z,z+1).Q(h.H);4(e.1D){5 c=0;j.1n(0,z).I(3(){c+=A.1a});4((c+a[0].1a-B.1b())>B[0].3x){B.1b(c+a[0].1a-B.3w())}w 4(c<B.1b()){B.1b(c)}}};3 2o(a){z+=a;4(z<0){z=j.1j()-1}w 4(z>=j.1j()){z=0}}3 2m(a){6 e.X&&e.X<a?e.X:a}3 2l(){B.2z();5 b=2m(y.7);16(5 i=0;i<b;i++){4(!y[i])1V;5 a=e.1R(y[i].y,i+1,b,y[i].F,1t);4(a===C)1V;5 c=$("<1L/>").3v(e.1y(a,1t)).Q(i%2==0?"3u":"3P").1Q(B)[0];$.y(c,"2k",y[i])}j=B.3t("1L");4(e.1X){j.1n(0,1).Q(h.H);z=0}4($.2e.2W)B.2W()}6{35:3(d,q){2y();y=d;1t=q;2l()},2D:3(){V(1)},30:3(){V(-1)},2C:3(){4(z!=0&&z-8<0){V(-z)}w{V(-8)}},2A:3(){4(z!=j.1j()-1&&z+8>j.1j()){V(j.1j()-1-z)}w{V(8)}},Z:3(){G&&G.Z();j&&j.1h(h.H);z=-1},N:3(){6 G&&G.3s(":N")},3q:3(){6 A.N()&&(j.2j("."+h.H)[0]||e.1X&&j[0])},20:3(){5 a=$(g).3p();G.T({E:W e.E=="1B"||e.E>0?e.E:$(g).E(),2i:a.2i+g.1a,1W:a.1W}).20();4(e.1D){B.1b(0);B.T({2L:e.1E,3n:\'3X\'});4($.1Y.3m&&W 1K.2w.3l.2L==="1x"){5 c=0;j.I(3(){c+=A.1a});5 b=c>e.1E;B.T(\'3k\',b?e.1E:c);4(!b){j.E(B.E()-2R(j.T("2O-1W"))-2R(j.T("2O-3j")))}}}},2g:3(){5 a=j&&j.2j("."+h.H).1h(h.H);6 a&&a.7&&$.y(a[0],"2k")},2T:3(){B&&B.2z()},1p:3(){G&&G.3i()}}};$.2e.18=3(b,f){4(b!==1x){6 A.I(3(){4(A.2d){5 a=A.2d();4(f===1x||b==f){a.4n("2c",b);a.3h()}w{a.4m(D);a.4l("2c",b);a.4k("2c",f);a.3h()}}w 4(A.3g){A.3g(b,f)}w 4(A.1C){A.1C=b;A.3e=f}})}5 c=A[0];4(c.2d){5 e=1K.18.4j(),3d=c.F,2a="<->",2f=e.3b.7;e.3b=2a;5 d=c.F.2H(2a);c.F=3d;A.18(d,d+2f);6{1I:d,39:d+2f}}w 4(c.1C!==1x){6{1I:c.1C,39:c.3e}}}})(4i);',62,272,'|||function|if|var|return|length|||||||||||||||||||||||||else||data|active|this|list|false|true|width|value|element|ACTIVE|each|toLowerCase|val|result|Autocompleter|visible|case|null|addClass|break|multipleSeparator|css|target|moveSelect|typeof|max|url|hide||bind|onChange||trigger|trimWords|for|multiple|selection|autocomplete|offsetHeight|scrollTop|trim|preventDefault|populate|matchSubset|cacheLength|removeClass|add|size|search|hideResultsNow|lastWord|slice|flush|unbind|stopLoading|arguments|matchCase|term|extend|formatMatch|matchContains|undefined|highlight|formatResult|parse|string|selectionStart|scroll|scrollHeight|mouseDownOnSelect|autoFill|progress|start|delay|document|li|new|findValueCallback|setTimeout|clearTimeout|appendTo|formatItem|needsInit|defaults|push|continue|left|selectFirst|browser|selectCurrent|show|request|replace|split|unautocomplete||loadingClass||setOptions|minChars|teststring|flushCache|character|createTextRange|fn|textLength|selected|in|top|filter|ac_data|fillList|limitNumberOfItems|BACKSPACE|movePosition|PAGEDOWN|click|hideResults|LI|focus|nodeName|PAGEUP|body|COMMA|init|empty|pageDown|ESC|pageUp|next|RETURN|ol|nullData|indexOf|TAB|strong|gi|maxHeight|keyCode|DEL|padding|resultsClass|inputClass|parseInt|DOWN|emptyList|form|dataType|bgiframe|opera|UP|extraParams|prev|load|Select|||display|mustMatch|substring||end|receiveData|text|Cache|orig|selectionEnd|join|setSelectionRange|select|remove|right|height|style|msie|overflow|off|offset|current|attr|is|find|ac_even|html|innerHeight|clientHeight|parentNode|tagName|while|mouseup|mousedown|index|blur|toUpperCase|mouseover|ul|188|default|absolute|position|div|ac_over|substr|ac_odd|charAt|word|180|RegExp|100|switch|400|auto|ac_loading|ac_results||ac_input|keydown|keypress|success|submit||limit|150|name|port|abort|mode|ajax|Date|timestamp|200|map|jQuery|createRange|moveEnd|moveStart|collapse|move'.split('|'),0,{}))

$.fn.shakeit = function(times) {
   if (times == undefined)
      times = 1;
   this.each(function(init) {
      var jqNode = $(this);
      jqNode.css({position:'relative'});
      var currentleft = (!isNaN(parseInt(jqNode.css('left')))) ? parseInt(jqNode.css('left')) : 0;
      //alert(currentleft);

      for (var x = 1; x <= times; x++ ) {
         jqNode
            .animate({left: currentleft -25}, 10)
            .animate({left: currentleft}, 50)
            .animate({left: currentleft +25}, 10)
            .animate({left: currentleft}, 50);
      }
   });
   return this;
}

