MGZ.ajax = MGZ.path + "jQueryAjax.aspx";

$.ajaxSetup({
    url: MGZ.ajax,
    global: false,
    type: "GET",
    cache: false
});

$(function() {
    commentAbuse();

    $(".main_image .desc").show(); //Show Banner
    //$(".main_image .block").animate({ opacity: 0.85 }, 1); //Set Opacity
    $(".image_thumb ul li:first").addClass('active'); //Add the active class (highlights the very first list item by default)


    $('.main_image').cycle({
        fx: 'fade',
        speed: 1000,
        timeout: 5000, //5000
        after: function() {
            var index = $(".main_image li:visible").index();
            $(".image_thumb ul li").removeClass("active");
            $(".image_thumb ul li:visible").eq(index).addClass("active");
        },
        pager: "#pager"
    });

    $(".image_thumb ul li").click(function() {
        var i = $(this).index();
        $("#pager a").eq(i).trigger('click');

        //        //Set Variables
        //        var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
        //        var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
        //        var imgDesc = $(this).find('.block').html();  //Get HTML of the "block" container
        //        var imgDescHeight = $(".main_image").find('.block').height(); //Find the height of the "block"

        //        if ($(this).is(".active")) {  //If the list item is active/selected, then...
        //            return false; // Don't click through - Prevents repetitive animations on active/selected list-item
        //        } else { //If not active then...
        //            //Animate the Description
        //            $(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250, function() { //Pull the block down (negative bottom margin of its own height)
        //                $(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250); //swap the html of the block, then pull the block container back up and set opacity
        //                $(".main_image img").attr({ src: imgTitle, alt: imgAlt }); //Switch the main image (URL + alt tag)
        //            });
        //        }
        //        //Show active list-item
        //        $(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all list-items
        //        $(this).addClass('active');  //Add class of 'active' on the selected list
        //        return false;

    }).hover(function() { //Hover effects on list-item 
        $(this).addClass('hover'); //Add class "hover" on hover 
    }, function() {
        $(this).removeClass('hover'); //Remove class "hover" on hover out
    });

});

/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 50;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").not(".picturespage .screenshot, .noscreenshot .screenshot, .latestpics a").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='Loading preview...' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
	},
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
	});	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};




this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
	},
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
	});	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

// starting the script on page load
$(document).ready(function() {
    try {
        $.getJSON("http://twitter.com/statuses/user_timeline/" + tweeterUser + ".json?callback=?", function(data) {
        if (data.length > 0) {       
            $("#latest_twitter").html(
            $("#latest_twitter").html() +
            data[0].text +
            "<span class='pink'> " +
            DateDiff(new Date(), new Date(data[0].created_at)) +
            "</span>");
            }
        });
    } catch (exception) {

    }

    $('.signUpNews').click(function() {
        //remove previous 'email' params
        if (this.href.indexOf("&email=") != -1) {
            this.href = this.href.substr(0, this.href.indexOf("&email="));
        }
        //add 'email' param
        this.href += "&email=" + $("input[id$='txtEmail']").val();
        //clean textbox
        $("input[id$='txtEmail']").val("")
    });

    tooltip();

    screenshotPreview();

    if ($.browser.msie && $.browser.version < 7) {
        $.getScript(basePath + "scripts/DD_belatedPNG_0.0.7a.js", function() {
            $("img").each(function() {
                DD_belatedPNG.fixPng(this);
            });


        });
    }

    $(".picturespage ul, .newsgallery ul, .latestpics ul").each(function(i) {
        $("a", this).attr("rel", "gallery[" + i + "]")
    });



    /*****************************/
    /******  menu			*****/
    /*****************************/
    $("#globalnav ul li").fadeMenu(500, "div#globalnav ul li:hover ul");
    // $("#menu1 ul li").fadeMenu(500, "div#menu1 ul li:hover ul");




    //http://jqueryfordesigners.com/jquery-infinite-carousel/
    var autoscrolling = true;

    $('.infiniteCarousel').infiniteCarousel();


    /*****************************/
    /****** tool tips		*****/
    /*****************************/
    $("#smallgallerylinks li a").easyTooltip();

    /*****************************/
    /****** css fixes		*****/
    /****************************/
    //$("#smallgallerylinks li a").easyTooltip();
    $("#smallgallerylinks img, .pictures img, .pictures a, .featuredVidMini img").removeAttr("style");
    $(".picturespage .newsitem:last").next().css("clear", "both");
    $(".picturespage .mini:nth-child(4n)").css("clear", "left"); //not ie
    $(".picturespage .mini:nth-child(4n)").before("<br style='clear:both;' />"); //ie
    $("#globalnav li:has(li)").addClass("parent");
    $(".image_thumb").css("zoom", "1");

    /*****************************/
    /******   calendar	   *****/
    /*****************************/
    if (window.eventDates) {
        $('.calendar').empty()
						.addClass("activatedcalendar")
						.fullCalendar({
						    draggable: false,
						    events: eventDates,
						    rightToLeft: false
						});
    }
    $("button").click(function() { return false; });

    /*****************************/
    /******   lightbox      ******/
    /*****************************/
    window.lightboxSettings = {
        animationSpeed: 'normal', /* fast/slow/normal */
        padding: 40, /* padding for each side of the picture */
        opacity: 0.35, /* Value betwee 0 and 1 */
        showTitle: true, /* true/false */
        allowresize: true, /* true/false */
        counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
        theme: 'dark_square', /* light_rounded / dark_rounded / light_square / dark_square */
        callback: function() { }
    };
    $(".thickbox, #wrap .screenshot, [rel='prettyPhoto[iframes]'], .lightbox").prettyPhoto(window.lightboxSettings);

    $("[rel='prettyPhoto[ajax]']").prettyPhoto(window.lightboxSettings);

    var signUpNewsSettings = window.lightboxSettings;
    //    signUpNewsSettings.callbackBeforePopupShow = function() { $("input[id$='hdnEmail']").val($("input[id$='txtEmail']").val()); }
    $(".signUpNews").prettyPhoto(signUpNewsSettings);

    /*****************************/
    /******   on air		 *****/
    /*****************************/

    //Show and hide the schedule table
    /*$(".onairtablewrapper").hide();
    $("#showschedule").click(
    function(e) {
    e.preventDefault();
			
    $(".newsitem").hide();
    $(".onairtablewrapper").show();
			
    $("<a href='#' class='button jsbutton'>Back</a>")
    .appendTo(".onairtablewrapper")
    .click(function(e) {
    e.preventDefault();
    $(".onairtablewrapper").hide();
    $(".newsitem").show();
    $(this).remove();
    });
    }
    );*/

    //biobutton	
    $("#biography").hide();

    $(".biobutton").toggle(
		function(e) {
		    e.preventDefault();
		    $(".notbio").hide();
		    $("#biography").show();
		    $(this).text(" > Show Details");
		}, function(e) {
		    e.preventDefault();
		    $(".notbio").show();
		    $("#biography").hide();
		    $(this).text(" > Biography");
		}
	);






});         //EO PAGE LOAD



   
/*****************************/
/******   libs		   *****/
/*****************************/
$.fn.fadeMenu = function (t, selector) {	  
	//ss(selector).remove();  
	
	return this.each(function() {
				
		var $ul = $(this).find('ul:first');
		$ul.show().css({opacity: 0});
		$(this).hover(function(e){		   
				$ul.show()  
				   .animate({opacity: 1}, { queue: false, duration: t });  
			},function(e){
				$ul.hide();  
				  // .animate({opacity: 0}, { queue: false, duration: t });   
				
		});
	});
};		



/*
 * 	Easy Tooltip 1.0 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
(function($) {

	$.fn.easyTooltip = function(options){
	  
		// default configuration properties
		var defaults = {	
			xOffset: 10,		
			yOffset: 25,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {
			
			
			var title = $(this).attr("title");				
			$(this).hover(function(e){											 							   
				content = (options.content != "") ? options.content : title;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("title","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");		
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")						
						.css("display","none")
						.fadeIn("fast")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("title",title);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("title",title);
				});				
			}
		});
	  
	};

})(jQuery);

/*!
 * FullCalendar v1.2.1
 * http://arshaw.com/fullcalendar/
 *
 * use fullcalendar.css for basic styling
 * requires jQuery UI core and draggables ONLY if you plan to do drag & drop
 *
 * Copyright (c) 2009 Adam Shaw
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Date: 2009-05-31 13:56:02 -0700 (Sun, 31 May 2009)
 * Revision: 23
 */
 
(function($) {

	$.fn.fullCalendar = function(options) {
	
	
		//
		// Calls methods on a pre-existing instance
		//
		
		if (typeof options == 'string') {
			var args = Array.prototype.slice.call(arguments, 1);
			var res;
			this.each(function() {
				var r = $.data(this, 'fullCalendar')[options].apply(this, args);
				if (typeof res == 'undefined') res = r;
			});
			if (typeof res != 'undefined') {
				return res;
			}
			return this;
		}
		
		
		
		//
		// Process options
		//
		
		options = options || {};
		
		var r2l = options.rightToLeft;
		var dis, dit; // day index sign / translate
		if (r2l) {
			dis = -1;
			dit = 6;
			this.addClass('r2l');
		}else{
			dis = 1;
			dit = 0;
		}
		
		var showTime = typeof options.showTime == 'undefined' ? 'guess' : options.showTime;
		var bo = typeof options.buttons == 'undefined' ? true : options.buttons;
		var weekStart = (options.weekStart || 0) % 7;
		var timeFormat = options.timeFormat || 'gx';
		var titleFormat = options.titleFormat || (r2l ? 'Y F' : 'F Y');
		
		
		
		//
		// Rendering bug detection variables
		//
		
		var tdTopBug, trTopBug, tbodyTopBug, sniffBugs = true;
		
		
		
		this.each(function() {
		
		
			//
			// Instance variables
			//
			
			var date = options.year ? // holds the year & month of current month
				new Date(options.year, options.month || 0, 1) :
				new Date();
			var start, end; // first & last VISIBLE dates
			var today;
			var numWeeks;
			var ignoreResizes = false;
			
			var events = [];
			var eventSources = options.eventSources || [];
			if (options.events) eventSources.push(options.events);
			
			
			
			//
			// Month navigation functions
			//
		
			function refreshMonth() {
				clearEventElements();				
				render();
				//$("[rel='prettyPhoto[ajax]']").prettyPhoto(window.lightboxSettings);
			}
		
			function prevMonth() {
				addMonths(date, -1);
				refreshMonth();
				$("[rel='prettyPhoto[ajax]']").prettyPhoto(window.lightboxSettings);
			}
		
			function nextMonth() {
				addMonths(date, 1);
				refreshMonth();
				$("[rel='prettyPhoto[ajax]']").prettyPhoto(window.lightboxSettings);
			}
			
			function gotoToday() {
				date = new Date();
				refreshMonth();
				$("[rel='prettyPhoto[ajax]']").prettyPhoto(window.lightboxSettings);
			}
		
			function gotoMonth(year, month) {
				date = new Date(year, month, 1);
				refreshMonth();
				$("[rel='prettyPhoto[ajax]']").prettyPhoto(window.lightboxSettings);
			}
			
			function prevYear() {
				addYears(date, -1);
				refreshMonth();
				$("[rel='prettyPhoto[ajax]']").prettyPhoto(window.lightboxSettings);
			}
			
			function nextYear() {
				addYears(date, 1);
				refreshMonth();
				$("[rel='prettyPhoto[ajax]']").prettyPhoto(window.lightboxSettings);
			}
			
			
			
			//
			// Publicly accessible methods
			//
			
			$.data(this, 'fullCalendar', {
				refresh: refreshMonth,
				prevMonth: prevMonth,
				nextMonth: nextMonth,
				today: gotoToday,
				gotoMonth: gotoMonth,
				prevYear: prevYear,
				nextYear: nextYear,
				
				
				//
				// Event CRUD
				//
			
				addEvent: function(event) {
					events.push(normalizeEvent(event));
					clearEventElements();
					renderEvents();
				},
			
				updateEvent: function(event) {
					event.start = $.fullCalendar.parseDate(event.start);
					event.end = $.fullCalendar.parseDate(event.end);
					var startDelta = event.start - event._start;
					var msLength = event.end - event.start;
					event._start = cloneDate(event.start);
					for (var i=0; i<events.length; i++) {
						var e = events[i];
						if (e.id === event.id && e !== event) {
							e.start = new Date(e.start.getTime() + startDelta);
							e._start = cloneDate(e.start);
							e.end = new Date(e.start.getTime() + msLength);
							for (var k in event) {
								if (k && k != 'start' && k != 'end' && k.charAt(0) != '_') {
									e[k] = event[k];
								}
							}
						}
					}
					clearEventElements();
					renderEvents();
				},
			
				removeEvent: function(eventId) {
					if (typeof eventId == 'object') {
						eventId = eventId.id;
					}
					
					// remove from the 'events' array
					var newEvents = [];
					for (var i=0; i<events.length; i++) {
						if (events[i].id !== eventId) {
							newEvents.push(events[i]);
						}
					}
					events = newEvents;
					
					// remove from static event sources
					for (var i=0; i<eventSources.length; i++) {
						var src = eventSources[i];
						if (typeof src != 'string' && !$.isFunction(src)) {
							var newSrc = [];
							for (var j=0; j<src.length; j++) {
								if (src[j].id !== eventId) {
									newSrc.push(src[j]);
								}
							}
							eventSources[i] = newSrc;
						}
					}
					
					clearEventElements();
					renderEvents();
				},
			
				getEventsById: function(eventId) {
					var res = [];
					for (var i=0; i<events.length; i++) {
						if (events[i].id === eventId) {
							res.push(events[i]);
						}
					}
					return res;
				},
				
				
			
				//
				// Event Source CRUD
				//
			
				addEventSource: function(src) {
					eventSources.push(src);
					pushLoading();
					fetchEventSource(src, function() {
						popLoading();
						clearEventElements();
						renderEvents();
					});
				},
			
				removeEventSource: function(src) {
			
					// remove from 'eventSources' array
					var newSources = [];
					for (var i=0; i<eventSources.length; i++) {
						if (src !== eventSources[i]) {
							newSources.push(eventSources[i]);
						}
					}
					eventSources = newSources;
				
					// remove events from 'events' array
					var newEvents = [];
					for (var i=0; i<events.length; i++) {
						if (events[i].source !== src) {
							newEvents.push(events[i]);
						}
					}
					events = newEvents;
				
					clearEventElements();
					renderEvents();
				}
				
			});
			
			
			
			
			
			/*******************************************************************/
			//
			//		Header & Table Rendering
			//
			/*******************************************************************/
			
			
			//
			// Build one-time DOM elements (header, month container)
			//
		
			var titleElement, todayButton, monthElement, monthElementWidth;
			var header = $("<div class='full-calendar-header'/>").appendTo(this);
			
			if (bo) { // "button options"
				var buttons = $("<div class='full-calendar-buttons'/>").appendTo(header);
				if (bo == true || bo.today !== false) {
					todayButton = $("<button class='today' />")
						.append($("<span />").html(
							typeof bo.today == 'string' ?
								bo.today : "today"))
						.click(gotoToday);
					buttons.append(todayButton);
				}
				if (bo.prevYear) {
					var b = $("<button class='prev-year' />")
						.append($("<span />")
							.html(typeof bo.prevYear == 'string' ?
								bo.prevYear : "&laquo;"))
						.click(prevYear);
					if (r2l) buttons.prepend(b);
					else buttons.append(b);
				}
				if (bo == true || bo.prevMonth !== false) {
					var b = $("<button class='prev-month' />")
						.append($("<span />")
							.html(typeof bo.prevMonth == 'string' ?
								bo.prevMonth : (r2l ? "&gt;" : "&lt;")))
						.click(prevMonth);
					if (r2l) buttons.prepend(b);
					else buttons.append(b);
				}
				if (bo == true || bo.nextMonth !== false) {
					var b = $("<button class='next-month' />")
						.append($("<span />").html(typeof bo.nextMonth == 'string' ?
							bo.nextMonth : (r2l ? "&lt;" : "&gt;")))
						.click(nextMonth);
					if (r2l) buttons.prepend(b);
					else buttons.append(b);
				}
				if (bo.nextYear) {
					var b = $("<button class='next-year' />")
						.append($("<span />").html(typeof bo.nextYear == 'string'
							? bo.nextYear : "&raquo;"))
						.click(nextYear);
					if (r2l) buttons.prepend(b);
					else buttons.append(b);
				}
			}
			
			if (options.title !== false) {
				titleElement = $("<h2 class='full-calendar-title'/>").appendTo(header);
			}
		
			monthElement = $("<div class='full-calendar-month' style='position:relative'/>")
				.appendTo($("<div class='full-calendar-month-wrap'/>").appendTo(this));
			
			
			//
			// Build the TABLE cells for the current month. (calls event fetching & rendering code)
			//
			
			var thead, tbody, glass;
			
			function render() {
		
				ignoreResizes = true;
				date.setDate(1);
				clearTime(date);
				var year = date.getFullYear();
				var month = date.getMonth();
				var monthTitle = $.fullCalendar.formatDate(date, titleFormat);
				if (titleElement) titleElement.text(monthTitle);
			
				clearTime(date);
				start = cloneDate(date);
				addDays(start, -((start.getDay() - weekStart + 7) % 7));
				end = cloneDate(date);
				addMonths(end, 1);
				addDays(end, (7 - end.getDay() + weekStart) % 7);
				numWeeks = Math.round((end.getTime() - start.getTime()) / 604800000);
				if (options.fixedWeeks != false) {
					addDays(end, (6 - numWeeks) * 7);
					numWeeks = 6;
				}
			
				today = clearTime(new Date());
				if (todayButton) {
					if (today.getFullYear() == year && today.getMonth() == month) {
						todayButton.css('visibility', 'hidden');
					}else{
						todayButton.css('visibility', 'visible');
					}
				}
				
				var dayNames = $.fullCalendar.dayNames;
				var dayAbbrevs = $.fullCalendar.dayAbbrevs;
			
				if (!tbody) {
				
					// first time, build all cells from scratch
				
					var table = $("<table style='width:100%'/>").appendTo(monthElement);
				
					thead = "<thead><tr>";
					for (var i=0; i<7; i++) {
						var j = (i * dis + dit + weekStart) % 7;
						thead +=
							"<th class='" + dayAbbrevs[j].toLowerCase() +
							(i==0 ? ' first' : '') + "'>" +
							(options.abbrevDayHeadings!=false ? dayAbbrevs[j] : dayNames[j]) +
							"</th>";
					}
					thead = $(thead + "</tr></thead>").appendTo(table);
					
					tbody = "<tbody>";
					var d = cloneDate(start);
					for (var i=0; i<numWeeks; i++) {
						tbody += "<tr class='week"+(i+1)+"'>";
						var tds = "";
						for (var j=0; j<7; j++) {
							var s =
								"<td class='day " + dayAbbrevs[(j + weekStart) % 7].toLowerCase() +
								(j==dit ? ' first' : '') +
								(d.getMonth() == month ? '' : ' other-month') +
								(d.getTime() == today.getTime() ? ' today' : '') +
								"'><div class='day-number'>" + d.getDate() + "</div>" +
								"<div class='day-content'><div/></div></td>";
							if (r2l) tds = s + tds;
							else tds += s;
							addDays(d, 1);
						}
						tbody += tds + "</tr>";
					}
					tbody = $(tbody + "</tbody>").appendTo(table);
						
					// a protective coating over the TABLE
					// intercepts mouse clicks and prevents text-selection
					glass = $("<div style='position:absolute;top:0;left:0;z-index:1;width:100%' />")
						.appendTo(monthElement)
						.click(function(ev, ui) {
							if (options.dayClick) {
								buildDayGrid();
								var td = dayTD(ev.pageX, ev.pageY);
								if (td) return options.dayClick.call(td, dayDate(td));
							}
						});
				
				}else{
				
					// NOT first time, reuse as many cells as possible
			
					var diff = numWeeks - tbody.find('tr').length;
					if (diff < 0) {
						// remove extra rows
						tbody.find('tr:gt(' + (numWeeks-1) + ')').remove();
					}
					else if (diff > 0) {
						var trs = "";
						for (var i=0; i<diff; i++) {
							trs += "<tr class='week"+(numWeeks+i)+"'>";
							for (var j=0; j<7; j++) {
								trs +=
									"<td class='day " +
									dayAbbrevs[(j * dis + dit + weekStart) % 7].toLowerCase() +
									(j==0 ? ' first' : '') + "'>" +
									"<div class='day-number'></div>" +
									"<div class='day-content'><div/></div>" +
									"</td>";
							}
							trs += "</tr>";
						}
						if (trs) tbody.append(trs);
					}
				
					// re-label and re-class existing cells
					var d = cloneDate(start);
					tbody.find('tr').each(function() {
						for (var i=0; i<7; i++) {
							var td = this.childNodes[i * dis + dit];
							if (d.getMonth() == month) {
								$(td).removeClass('other-month');
							}else{
								$(td).addClass('other-month');
							}
							if (d.getTime() == today.getTime()) {
								$(td).addClass('today');
							}else{
								$(td).removeClass('today');
							}
							$(td.childNodes[0]).text(d.getDate());
							addDays(d, 1);
						}
					});
			
				}
			
				setCellSizes();
				
				if (sniffBugs) {
					// nasty bugs in opera 9.25
					// position() returning relative to direct parent
					var tr = tbody.find('tr');
					var td = tr.find('td');
					var trTop = tr.position().top;
					var tdTop = td.position().top;
					tdTopBug = tdTop < 0;
					trTopBug = trTop != tdTop;
					tbodyTopBug = tbody.position().top != trTop;
					sniffBugs = false;
				}
				
				fetchEvents(renderEvents);
				
				ignoreResizes = false;
			
				if (options.monthDisplay) {
					options.monthDisplay(date.getFullYear(), date.getMonth(), monthTitle);
				}
			
			}
			
			
			//
			// Adjust dimensions of the cells, based on container's width
			//
			
			function setCellSizes() {
				var tbodyw = tbody.width();
				var cellw = Math.floor(tbodyw / 7);
				var cellh = Math.round(cellw * .85);
				thead.find('th')
					.filter(':lt(6)').width(cellw).end()
					.filter(':eq(6)').width(tbodyw - cellw*6);
				tbody.find('td').height(cellh);
				glass.height(monthElement.height());
				monthElementWidth = monthElement.width();
			}
			
			
			
			
			
			
			/*******************************************************************/
			//
			//		Event Rendering
			//
			/*******************************************************************/
			
			
			//
			// Render the 'events' array. First, break up into segments
			//
			
			var eventMatrix = [];
		
			function renderEvents() {
				eventMatrix = [];
				var i = 0;
				var ws = cloneDate(start);
				var we = addDays(cloneDate(ws), 7);
				while (ws.getTime() < end.getTime()) {
					var segs = [];
					$.each(events, function(j, event) {
						if (event.end.getTime() > ws.getTime() && event.start.getTime() < we.getTime()) {
							var ss, se, isStart, isEnd;
							if (event.start.getTime() < ws.getTime()) {
								ss = cloneDate(ws);
								isStart = false;
							}else{
								ss = cloneDate(event.start);
								isStart = true;
							}
							if (event.end.getTime() > we.getTime()) {
								se = cloneDate(we);
								isEnd = false;
							}else{
								se = cloneDate(event.end);
								isEnd = true;
							}
							ss = clearTime(ss);
							se = clearTime((se.getHours()==0 && se.getMinutes()==0) ? se : addDays(se, 1));
							segs.push({
								event: event, start: ss, end: se,
								isStart: isStart, isEnd: isEnd, msLength: se - ss
							});
						}
					});
					segs.sort(segCmp);
					var levels = [];
					$.each(segs, function(j, seg) {
						var l = 0; // level index
						while (true) {
							var collide = false;
							if (levels[l]) {
								for (var k=0; k<levels[l].length; k++) {
									if (seg.end.getTime() > levels[l][k].start.getTime() &&
										seg.start.getTime() < levels[l][k].end.getTime()) {
											collide = true;
											break;
										}
								}
							}
							if (collide) {
								l++;
								continue;
							}else{
								break;
							}
						}
						if (levels[l]) levels[l].push(seg);
						else levels[l] = [seg];
					});
					eventMatrix[i] = levels;
					addDays(ws, 7);
					addDays(we, 7);
					i++;
				}
				_renderEvents();
			}
		
		
			//
			// Do the REAL rendering of the segments
			//
		
			var eventElements = []; // [[event, element], ...]
		
			function _renderEvents() {
				for (var i=0; i<eventMatrix.length; i++) {
					var levels = eventMatrix[i];
					var tr = tbody.find('tr:eq('+i+')');
					var td = tr.find('td:first');
					var innerDiv = td.find('div.day-content div').css('position', 'relative');
					var top = innerDiv.position().top;
					if (tdTopBug) top -= td.position().top;
					if (trTopBug) top += tr.position().top;
					if (tbodyTopBug) top += tbody.position().top;
					var height = 0;
					for (var j=0; j<levels.length; j++) {
						var segs = levels[j];
						var maxh = 0;
						for (var k=0; k<segs.length; k++) {
							var seg = segs[k];
							var event = seg.event;
							var left1, left2, roundW, roundE;
							if (r2l) {
								left2 = seg.isStart ?
									tr.find('td:eq('+((seg.start.getDay()-weekStart+7)%7*dis+dit)+') div.day-content div') :
									tbody;
								left1 = seg.isEnd ?
									tr.find('td:eq('+((seg.end.getDay()+6-weekStart)%7*dis+dit)+') div.day-content div').position().left :
									tbody.position().left;
								roundW = seg.isEnd;
								roundE = seg.isStart;
							}else{
								left1 = seg.isStart ?
									tr.find('td:eq('+((seg.start.getDay()-weekStart+7)%7)+') div.day-content div').position().left :
									tbody.position().left;
								left2 = seg.isEnd ?
									tr.find('td:eq('+((seg.end.getDay()+6-weekStart)%7)+') div.day-content div') :
									tbody;
								roundW = seg.isStart;
								roundE = seg.isEnd;
							}
							left2 = left2.position().left + left2.width();
							var cl = event.className;
							if (typeof cl == 'string') {
								cl = ' ' + cl;
							}
							else if (typeof cl == 'object') {
								cl = ' ' + cl.join(' ');
							}
							var element = $("<table class='event" + (cl || '') + "' />")
								.append("<tr>" +
									(roundW ? "<td class='nw'/>" : '') +
									"<td class='n'/>" +
									(roundE ? "<td class='ne'/>" : '') + "</tr>")
								.append("<tr>" +
									(roundW ? "<td class='w'/>" : '') +
									"<td class='c'/>" +
									(roundE ? "<td class='e'/>" : '') + "</tr>")
								.append("<tr>" +
									(roundW ? "<td class='sw'/>" : '') +
									"<td class='s'/>" +
									(roundE ? "<td class='se'/>" : '') + "</tr>");
							buildEventText(event, element.find('td.c'));
							if (options.eventRender) {
								var res = options.eventRender(event, element);
								if (typeof res != 'undefined') {
									if (res === false) continue;
									if (res !== true) element = $(res);
								}
							}
							element
								.css({
									position: 'absolute',
									top: top,
									left: left1,
									width: left2 - left1,
									'z-index': 3
								})
								.appendTo(monthElement);
							initEventElement(event, element);
							var h = element.outerHeight({margin:true});
							if (h > maxh) maxh = h;
						}
						height += maxh;
						top += maxh;
					}
					innerDiv.height(height);
				}
			}
			
			
			//
			// create the text-contents of an event segment
			//
			
			function buildEventText(event, element) {
				$("<a class='event-title' rel='prettyPhoto[ajax]' href='" + event.url + "?ajax=true&amp;width=600&amp;height=400' />")
					.text(event.title)
					.appendTo(element);
				var st = typeof event.showTime == 'undefined' ? showTime : event.showTime;
				if (st != false) {
					if (st == true || st == 'guess' &&
						(event.start.getHours() || event.start.getMinutes() ||
						 event.end.getHours() || event.end.getMinutes())) {
							var timeStr = $.fullCalendar.formatDate(event.start, timeFormat);
							var timeElement = $("<span class='event-time' />");
							if (r2l) element.append(timeElement.text(' ' + timeStr));
							else element.prepend(timeElement.text(timeStr + ' '));
						}
				}
			}
		
		
			//
			// Attach event handlers to an event segment
			//
		
			function initEventElement(event, element) {
				element.click(function(ev) {
					if (!element.hasClass('ui-draggable-dragging')) {
						if (options.eventClick) {
							var res = options.eventClick.call(this, event, ev);
							if (res === false) return false;
						}
						//if (event.url) window.location.href = event.url;
					}
				});
				if (options.eventMouseover)
					element.mouseover(function(ev) {
						options.eventMouseover.call(this, event, ev);
					});
				if (options.eventMouseout)
					element.mouseout(function(ev) {
						options.eventMouseout.call(this, event, ev);
					});
				if (typeof event.draggable != 'undefined') {
					if (event.draggable)
						draggableEvent(event, element);
				}
				else if (options.draggable) {
					draggableEvent(event, element);
				}
				eventElements.push([event, element]);
			}
			
			
			//
			// Remove all event segments from DOM
			//
			
			function clearEventElements() {
				for (var i=0; i<eventElements.length; i++)
					eventElements[i][1].remove();
				eventElements = [];
			}
		
		
		
		
		
		
		
			/*******************************************************************/
			//
			//		Drag & Drop		(and cell-coordinate stuff)
			//
			/*******************************************************************/
			
		
			//
			// Attach jQuery UI draggable
			//
		
			var dragStartTD, dragTD;
			var dayOverlay;
		
			function draggableEvent(event, element) {
				element.draggable({
					zIndex: 4,
					delay: 50,
					opacity: options.eventDragOpacity,
					revertDuration: options.eventRevertDuration,
					start: function(ev, ui) {
						// hide other elements with same event
						for (var i=0; i<eventElements.length; i++) {
							var x = eventElements[i];
							var xevent = x[0];
							if (x[1].get(0) != this && (xevent == event ||
								typeof xevent.id != 'undefined' && xevent.id == event.id))
									x[1].hide();
						}
						if (!dayOverlay)
							dayOverlay =
								$("<div class='over-day' style='position:absolute;z-index:2' />")
									.appendTo(monthElement);
						buildDayGrid();
						dragTD = dragStartTD = null;
						eventDrag(this, ev, ui);
						if (options.eventDragStart)
							options.eventDragStart.call(this, event, ev, ui);
					},
					drag: function(ev, ui) {
						eventDrag(this, ev, ui);
					},
					stop: function(ev, ui) {
						if (!dragTD || dragTD == dragStartTD) {
							// show all events
							for (var i=0; i<eventElements.length; i++)
								eventElements[i][1].show();
						}else{
							var delta = dayDelta(dragStartTD, dragTD);
							for (var i=0; i<events.length; i++) {
								if (event == events[i] || typeof event.id != 'undefined' && event.id == events[i].id) {
									addDays(events[i].start, delta, true);
									addDays(events[i].end, delta, true);
									events[i]._start = cloneDate(events[i].start);
								}
							}
							if (options.eventDrop) {
								options.eventDrop.call(this, event, delta, ev, ui);
							}
							clearEventElements();
							renderEvents();
						}
						dayOverlay.hide();
						if (options.eventDragStop) {
							options.eventDragStop.call(this, event, ev, ui);
						}
					}
				});
			}
			
			
			//
			// Called DURING dragging, on every mouse move
			//
		
			function eventDrag(node, ev, ui) {
				var oldTD = dragTD;
				dragTD = dayTD(ev.pageX, ev.pageY);
				if (!dragStartTD) dragStartTD = dragTD;
				if (dragTD != oldTD) {
					if (dragTD) {
						$(node).draggable('option', 'revert', dragTD==dragStartTD);
						dayOverlay.css({
							top: currTDY,
							left: currTDX,
							width: currTDW,
							height: currTDH,
							display: 'block'
						});
					}else{
						$(node).draggable('option', 'revert', true);
						dayOverlay.hide();
					}
				}
			}
		
		
			//
			// Record positions & dimensions of each TD
			//
		
			var dayX, dayY, dayX0, dayY0;
			var currTD, currR, currC;
			var currTDX, currTDY, currTDW, currTDH;
		
			function buildDayGrid() {
				var tr, td, o=monthElement.offset();
				dayX0 = o.left;
				dayY0 = o.top;
				dayY = [];
				tbody.find('tr').each(function() {
					tr = $(this);
					dayY.push(tr.position().top +
						(trTopBug ? tbody.position().top : 0));
				});
				dayY.push(dayY[dayY.length-1] + tr.height());
				dayX = [];
				tr.find('td').each(function() {
					td = $(this);
					dayX.push(td.position().left);
				});
				dayX.push(dayX[dayX.length-1] + td.width());
				currTD = null;
			}
			
			//
			// Returns TD underneath coordinate (optimized)
			//
		
			function dayTD(x, y) {
				var r=-1, c=-1;
				var rmax=dayY.length-1, cmax=dayX.length-1;
				while (r < rmax && y > dayY0 + dayY[r+1]) r++;
				while (c < cmax && x > dayX0 + dayX[c+1]) c++;
				if (r < 0 || r >= rmax || c < 0 || c >= cmax)
					return currTD = null;
				else if (!currTD || r != currR || c != currC) {
					currR = r;
					currC = c;
					currTD = tbody.find('tr:eq('+r+') td:eq('+c+')').get(0);
					currTDX = dayX[c];
					currTDY = dayY[r];
					currTDW = dayX[c+1] - currTDX;
					currTDH = dayY[r+1] - currTDY;
					return currTD;
				}
				return currTD;
			}
			
			//
			// Get a TD's date
			//
		
			function dayDate(td) {
				var i, trs = tbody.get(0).getElementsByTagName('tr');
				for (i=0; i<trs.length; i++) {
					var tr = trs[i];
					for (var j=0; j<7; j++) {
						if (tr.childNodes[j] == td) {
							var d = cloneDate(start);
							return addDays(d, i*7 + j*dis + dit);
						}
					}
				}
			}
			
			//
			// Return the # of days between 2 TD's
			//
		
			function dayDelta(td1, td2) {
				var i1, i2, trs = tbody.get(0).getElementsByTagName('tr');
				for (var i=0; i<trs.length; i++) {
					var tr = trs[i];
					for (var j=0; j<7; j++) {
						var td = tr.childNodes[j];
						if (td == td1) i1 = i*7 + j*dis + dit;
						if (td == td2) i2 = i*7 + j*dis + dit;
					}
				}
				return i2 - i1;
			}
			
			
			
			
			
			
			
			/*******************************************************************/
			//
			//		Event Sources & Fetching
			//
			/*******************************************************************/
			
			
			//
			// Fetch from ALL sources. Clear 'events' array and populate
			//
			
			function fetchEvents(callback) {
				events = [];
				if (eventSources.length > 0) {
					var queued = eventSources.length;
					var sourceDone = function() {
						if (--queued == 0) {
							popLoading();
							if (callback) {
								callback(events);
							}
						}
					};
					pushLoading();
					for (var i=0; i<eventSources.length; i++) {
						fetchEventSource(eventSources[i], sourceDone);
					}
				}
			}
			
			
			//
			// Fetch from a particular source. Append to the 'events' array
			//
			
			function fetchEventSource(src, callback) {
				var y = date.getFullYear();
				var m = date.getMonth();
				var reportEvents = function(a) {
					if (date.getFullYear() == y && date.getMonth() == m) {
						for (var i=0; i<a.length; i++) {
							normalizeEvent(a[i]);
							a[i].source = src;
						}
						events = events.concat(a);
					}
					if (callback) {
						callback(a);
					}
				};
				if (typeof src == 'string') {
					var params = {};
					params[options.startParam || 'start'] = Math.round(start.getTime() / 1000);
					params[options.endParam || 'end'] = Math.round(end.getTime() / 1000);
					params[options.cacheParam || '_'] = (new Date()).getTime();
					$.getJSON(src, params, reportEvents);
				}
				else if ($.isFunction(src)) {
					src(start, end, reportEvents);
				}
				else {
					reportEvents(src);
				}
			}
			
			
			//
			// methods for reporting loading state
			//
			
			var loadingLevel = 0;
			
			function pushLoading() {
				if (!loadingLevel++ && options.loading) {
					options.loading(true);
				}
			}
			
			function popLoading() {
				if (!--loadingLevel && options.loading) {
					options.loading(false);
				}
			}
			
			
			
			
			
			
			/*******************************************************************/
			//
			//		Begin "Main" Execution
			//
			/*******************************************************************/
		
			var e = $(this);
			var _e = this;
			var resizeID = 0;
			$(window).resize(function() {   // re-render table on window resize
				if (!ignoreResizes) {
					var rid = ++resizeID;   // add a delay
					setTimeout(function() {
						if (rid == resizeID) {
							// if calendar is visible
							if (e.css('display') != 'none') {
								// if the month width changed
								if (monthElement.width() != monthElementWidth) {
									clearEventElements();
									setCellSizes();
									_renderEvents();
									if (options.resize) options.resize.call(_e);
								}
							}
						}
					}, 200);
				}
			});
		
			// let's begin...
			if (e.css('display') != 'none') {
				render();
			}
			
			
			
			
		});
		
		return this;
	};
	
	
	
	
	/***************************************************************************/
	//
	//		Utilities
	//
	/***************************************************************************/
	
	
	//
	// event utils
	//
	
	function normalizeEvent(event) {
		if (event.date) {
			event.start = event.date;
			delete event.date;
		}
		event.start = $.fullCalendar.parseDate(event.start);
		event._start = cloneDate(event.start);
		event.end = $.fullCalendar.parseDate(event.end);
		if (!event.end || event.end <= event.start) {
			event.end = addDays(cloneDate(event.start), 1);
		}
		return event;
	}
	
	function segCmp(a, b) {
		return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
	}
	
	
	//
	// string utils
	//
	
	function zeroPad(n) {
		return (n < 10 ? '0' : '') + n;
	}
	
	
	//
	// date utils
	//
	
	function addMonths(d, n, keepTime) {
		d.setMonth(d.getMonth() + n);
		if (keepTime) return d;
		return clearTime(d);
	}
	
	function addYears(d, n, keepTime) {
		d.setFullYear(d.getFullYear() + n);
		if (keepTime) return d;
		return clearTime(d);
	}
	
	function addDays(d, n, keepTime) {
		d.setDate(d.getDate() + n);
		if (keepTime) return d;
		return clearTime(d);
	}
	
	function clearTime(d) {
		d.setHours(0); 
		d.setMinutes(0);
		d.setSeconds(0); 
		d.setMilliseconds(0);
		return d;
	}
	
	function cloneDate(d) {
		return new Date(+d);
	}
	
	
	//
	// globally accessible date formatting & parsing
	//
	
	$.fullCalendar = {
	
		monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'],
		monthAbbrevs: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
		dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
		dayAbbrevs: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
	
		formatDate: function(d, format) {
			var f = $.fullCalendar.dateFormatters;
			var s = '';
			for (var i=0; i<format.length; i++) {
				var c = format.charAt(i);
				if (f[c]) {
					s += f[c](d);
				}else{
					s += c;
				}
			}
			return s;
		},
		
		dateFormatters: {
			'a': function(d) { return d.getHours() < 12 ? 'am' : 'pm' },
			'A': function(d) { return d.getHours() < 12 ? 'AM' : 'PM' },
			'x': function(d) { return d.getHours() < 12 ? 'a' : 'p' },
			'X': function(d) { return d.getHours() < 12 ? 'A' : 'P' },
			'g': function(d) { return d.getHours() % 12 || 12 },
			'G': function(d) { return d.getHours() },
			'h': function(d) { return zeroPad(d.getHours() %12 || 12) },
			'H': function(d) { return zeroPad(d.getHours()) },
			'i': function(d) { return zeroPad(d.getMinutes()) },
			'F': function(d) { return $.fullCalendar.monthNames[d.getMonth()] },
			'm': function(d) { return zeroPad(d.getMonth() + 1) },
			'M': function(d) { return $.fullCalendar.monthAbbrevs[d.getMonth()] },
			'n': function(d) { return d.getMonth() + 1 },
			'Y': function(d) { return d.getFullYear() },
			'y': function(d) { return (d.getFullYear()+'').substring(2) },
			'c': function(d) {
				// ISO8601. derived from http://delete.me.uk/2005/03/iso8601.html
				return d.getUTCFullYear() +
					"-" + zeroPad(d.getUTCMonth() + 1) +
					"-" + zeroPad(d.getUTCDate()) +
					"T" + zeroPad(d.getUTCHours()) +
					":" + zeroPad(d.getUTCMinutes()) +
					":" + zeroPad(d.getUTCSeconds()) +
					"Z";
			}
		},
		
		parseDate: function(s) {
			if (typeof s == 'object')
				return s; // already a Date object
			if (typeof s == 'undefined')
				return null;
			if (typeof s == 'number')
				return new Date(s * 1000);
			return $.fullCalendar.parseISO8601(s, true) ||
			       Date.parse(s) ||
			       new Date(parseInt(s) * 1000);
		},
		
		parseISO8601: function(s, ignoreTimezone) {
			// derived from http://delete.me.uk/2005/03/iso8601.html
			var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
				"(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
				"(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
			var d = s.match(new RegExp(regexp));
			if (!d) return null;
			var offset = 0;
			var date = new Date(d[1], 0, 1);
			if (d[3]) { date.setMonth(d[3] - 1); }
			if (d[5]) { date.setDate(d[5]); }
			if (d[7]) { date.setHours(d[7]); }
			if (d[8]) { date.setMinutes(d[8]); }
			if (d[10]) { date.setSeconds(d[10]); }
			if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
			if (!ignoreTimezone) {
				if (d[14]) {
					offset = (Number(d[16]) * 60) + Number(d[17]);
					offset *= ((d[15] == '-') ? 1 : -1);
				}
				offset -= date.getTimezoneOffset();
			}
			return new Date(Number(date) + (offset * 60 * 1000));
		}
	
	};
	
	// additional FullCalendar "extensions" should be attached to $.fullCalendar

})(jQuery);
//EOI FULL CALENDAR

/* ------------------------------------------------------------------------
	Class: prettyPhoto
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 2.4.3
------------------------------------------------------------------------- */

var $pp_pic_holder;
var $ppt;

(function($) {
	$.fn.prettyPhoto = function(settings) {
		// global Variables
		var doresize = true;
		var percentBased = false;
		var imagesArray = [];
		var setPosition = 0; /* Position in the set */
		var pp_contentHeight;
		var pp_contentWidth;
		var pp_containerHeight;
		var pp_containerWidth;
		var pp_type = 'image';
	
		// Global elements
		var $caller;
		var $scrollPos = _getScroll();
	
		$(window).scroll(function(){ $scrollPos = _getScroll(); _centerPicture(); });
		$(window).resize(function(){ _centerPicture(); _resizeOverlay(); });
		$(document).keypress(function(e){
			switch(e.keyCode){
				case 37:
					if (setPosition == 1) return;
					changePicture('previous');
					break;
				case 39:
					if (setPosition == setCount) return;
					changePicture('next');
					break;
				case 27:
					close();
					break;
			};
	    });
 
	
		settings = jQuery.extend({
			animationSpeed: 'normal', /* fast/slow/normal */
			padding: 40, /* padding for each side of the picture */
			opacity: 0.80, /* Value between 0 and 1 */
			showTitle: true, /* true/false */
			allowresize: true, /* true/false */
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
			callback: function(){}
		}, settings);
		
		// Fallback to a supported theme for IE6
		if($.browser.msie && $.browser.version == 6){
			settings.theme = "light_square";
		}
	
		$(this).each(function(){
			var hasTitle = false;
			var isSet = false;
			var setCount = 0; /* Total images in the set */
			var arrayPosition = 0; /* Total position in the array */
			
			imagesArray[imagesArray.length] = this;
			$(this).bind('click',function(){
				open(this);
				return false;
			});
		});
	
		function open(el) {
			$caller = $(el);
		
			// Find out if the picture is part of a set
			theRel = $caller.attr('rel');
			galleryRegExp = /\[(?:.*)\]/;
			theGallery = galleryRegExp.exec(theRel);
		
			// Calculate the number of items in the set, and the position of the clicked picture.
			isSet = false;
			setCount = 0;
			
			_getFileType();
			
			for (i = 0; i < imagesArray.length; i++){
				if($(imagesArray[i]).attr('rel').indexOf(theGallery) != -1){
					setCount++;
					if(setCount > 1) isSet = true;

					if($(imagesArray[i]).attr('href') == $caller.attr('href')){
						setPosition = setCount;
						arrayPosition = i;
					};
				};
			};
		
			_buildOverlay();

			// Display the current position
			$pp_pic_holder.find('p.currentTextHolder').text(setPosition + settings.counter_separator_label + setCount);

			// Position the picture in the center of the viewing area
			_centerPicture();
		
			$('#pp_full_res').hide();
			$pp_pic_holder.find('.pp_loaderIcon').show();
		};
	
		showimage = function(width,height,containerWidth,containerHeight,contentHeight,contentWidth,resized){
			$('.pp_loaderIcon').hide();

			if($.browser.opera) {
				windowHeight = window.innerHeight;
				windowWidth = window.innerWidth;
			}else{
				windowHeight = $(window).height();
				windowWidth = $(window).width();
			};

			$pp_pic_holder.find('.pp_content').animate({'height':contentHeight},settings.animationSpeed);

			projectedTop = $scrollPos['scrollTop'] + ((windowHeight/2) - (containerHeight/2));
			if(projectedTop < 0) projectedTop = 0 + $pp_pic_holder.find('.ppt').height();

			// Resize the holder
			$pp_pic_holder.animate({
				'top': projectedTop,
				'left': ((windowWidth/2) - (containerWidth/2)),
				'width': containerWidth
			},settings.animationSpeed,function(){
				$pp_pic_holder.width(containerWidth);
				$pp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(height).width(width);

				// Fade the new image
				$pp_pic_holder.find('#pp_full_res').fadeIn(settings.animationSpeed,function(){
					$(this).find('object,embed').css('visibility','visible');
				});

				// Show the nav elements
				_showContent();
			
				// Fade the resizing link if the image is resized
				if(resized) $('a.pp_expand,a.pp_contract').fadeIn(settings.animationSpeed);
			});
		};
		
		function _showContent(){
			// Show the nav
			if(isSet && pp_type=="image") { $pp_pic_holder.find('.pp_hoverContainer').fadeIn(settings.animationSpeed); }else{ $pp_pic_holder.find('.pp_hoverContainer').hide(); }
			$pp_pic_holder.find('.pp_details').fadeIn(settings.animationSpeed);

            if (this.theRel == 'prettyPhoto[ajax]')
            {
                $pp_pic_holder.find('.pp_hoverContainer').hide();
            }

			// Show the title
			if(settings.showTitle && hasTitle){
				$ppt.css({
					'top' : $pp_pic_holder.offset().top - 22,
					'left' : $pp_pic_holder.offset().left + (settings.padding/2),
					'display' : 'none'
				});
			
				$ppt.fadeIn(settings.animationSpeed);
			};
		}
		
		function _hideContent(){
			// Fade out the current picture
			$pp_pic_holder.find('.pp_hoverContainer,.pp_details').fadeOut(settings.animationSpeed);
			$pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden');
			$pp_pic_holder.find('#pp_full_res').fadeOut(settings.animationSpeed,function(){
				$('.pp_loaderIcon').show();
			
				// Preload the image
				_preload();
			});
			
			// Hide the title
			$ppt.fadeOut(settings.animationSpeed);
		}
	
		function changePicture(direction){
			if(direction == 'previous') {
				arrayPosition--;
				setPosition--;
			}else{
				arrayPosition++;
				setPosition++;
			};

			// Allow the resizing of the images
			if(!doresize) doresize = true;

			_hideContent();
			$('a.pp_expand,a.pp_contract').fadeOut(settings.animationSpeed,function(){
				$(this).removeClass('pp_contract').addClass('pp_expand');
			});
		};
	
		function close(){
			$pp_pic_holder.find('object,embed').css('visibility','hidden');
			
			$('div.pp_pic_holder,div.ppt').fadeOut(settings.animationSpeed);
			
			$('div.pp_overlay').fadeOut(settings.animationSpeed, function(){
				$('div.pp_overlay,div.pp_pic_holder,div.ppt').remove();
			
				// To fix the bug with IE select boxes
				if($.browser.msie && $.browser.version == 6){
					$('select').css('visibility','visible');
				};
				
				settings.callback();
			});
			
			doresize = true;
		};
	
		function _checkPosition(){
			// If at the end, hide the next link
			if(setPosition == setCount) {
				$pp_pic_holder.find('a.pp_next').css('visibility','hidden');
				$pp_pic_holder.find('a.pp_arrow_next').addClass('disabled').unbind('click');
			}else{ 
				$pp_pic_holder.find('a.pp_next').css('visibility','visible');
				$pp_pic_holder.find('a.pp_arrow_next.disabled').removeClass('disabled').bind('click',function(){
					changePicture('next');
					return false;
				});
			};
		
			// If at the beginning, hide the previous link
			if(setPosition == 1) {
				$pp_pic_holder.find('a.pp_previous').css('visibility','hidden');
				$pp_pic_holder.find('a.pp_arrow_previous').addClass('disabled').unbind('click');
			}else{
				$pp_pic_holder.find('a.pp_previous').css('visibility','visible');
				$pp_pic_holder.find('a.pp_arrow_previous.disabled').removeClass('disabled').bind('click',function(){
					changePicture('previous');
					return false;
				});
			};
		
			// Change the current picture text
			$pp_pic_holder.find('p.currentTextHolder').text(setPosition + settings.counter_separator_label + setCount);
		
			$caller = (isSet) ? $(imagesArray[arrayPosition]) : $caller;
			_getFileType();

			if($caller.attr('title')){
				$pp_pic_holder.find('.pp_description').show().html(unescape($caller.attr('title')));
			}else{
				$pp_pic_holder.find('.pp_description').hide().text('');
			};
		
			if($caller.find('img').attr('alt') && settings.showTitle){
				hasTitle = true;
				$ppt.html(unescape($caller.find('img').attr('alt')));
			}else{
				hasTitle = false;
			};
		};
	
		function _fitToViewport(width,height){
			hasBeenResized = false;
		
			_getDimensions(width,height);
			
			// Define them in case there's no resize needed
			imageWidth = width;
			imageHeight = height;

			windowHeight = $(window).height();
			windowWidth = $(window).width();
		
			if( ((pp_containerWidth > windowWidth) || (pp_containerHeight > windowHeight)) && doresize && settings.allowresize && !percentBased) {
				hasBeenResized = true;
				notFitting = true;
			
				while (notFitting){
					if((pp_containerWidth > windowWidth)){
						imageWidth = (windowWidth - 200);
						imageHeight = (height/width) * imageWidth;
					}else if((pp_containerHeight > windowHeight)){
						imageHeight = (windowHeight - 200);
						imageWidth = (width/height) * imageHeight;
					}else{
						notFitting = false;
					};

					pp_containerHeight = imageHeight;
					pp_containerWidth = imageWidth;
				};
			
				_getDimensions(imageWidth,imageHeight);
			};

			return {
				width:imageWidth,
				height:imageHeight,
				containerHeight:pp_containerHeight,
				containerWidth:pp_containerWidth,
				contentHeight:pp_contentHeight,
				contentWidth:pp_contentWidth,
				resized:hasBeenResized
			};
		};
		
		function _getDimensions(width,height){
			$pp_pic_holder.find('.pp_details').width(width).find('.pp_description').width(width - parseFloat($pp_pic_holder.find('a.pp_close').css('width'))); /* To have the correct height */
			
			// Get the container size, to resize the holder to the right dimensions
			pp_contentHeight = height + $pp_pic_holder.find('.pp_details').height() + parseFloat($pp_pic_holder.find('.pp_details').css('marginTop')) + parseFloat($pp_pic_holder.find('.pp_details').css('marginBottom'));
			pp_contentWidth = width;
			pp_containerHeight = pp_contentHeight + $pp_pic_holder.find('.ppt').height() + $pp_pic_holder.find('.pp_top').height() + $pp_pic_holder.find('.pp_bottom').height();
			pp_containerWidth = width + settings.padding;
		}
	
		function _getFileType(){
			if ($caller.attr('href').match(/youtube\.com\/watch/i)) {
				pp_type = 'youtube';
			}else if($caller.attr('href').indexOf('.mov') != -1){ 
				pp_type = 'quicktime';
			}else if($caller.attr('href').indexOf('.swf') != -1){
				pp_type = 'flash';
			}else if($caller.attr('href').indexOf('iframe') != -1){
				pp_type = 'iframe';
			}else if($caller.attr('href').indexOf('ajax') != -1){
				pp_type = 'ajax';
			}else{
				pp_type = 'image';
			}
		}
	
		function _centerPicture(){
			if ($pp_pic_holder){ if($pp_pic_holder.size() == 0){ return; }}else{ return; }; //Make sure the gallery is open

			if($.browser.opera) {
				windowHeight = window.innerHeight;
				windowWidth = window.innerWidth;
			}else{
				windowHeight = $(window).height();
				windowWidth = $(window).width();
			};
		
			if(doresize) {
				$pHeight = $pp_pic_holder.height();
				$pWidth = $pp_pic_holder.width();
				$tHeight = $ppt.height();
				
				projectedTop = (windowHeight/2) + $scrollPos['scrollTop'] - ($pHeight/2);
				if(projectedTop < 0) projectedTop = 0 + $tHeight;
				
				$pp_pic_holder.css({
					'top': projectedTop,
					'left': (windowWidth/2) + $scrollPos['scrollLeft'] - ($pWidth/2)
				});
		
				$ppt.css({
					'top' : projectedTop - $tHeight,
					'left' : (windowWidth/2) + $scrollPos['scrollLeft'] - ($pWidth/2) + (settings.padding/2)
				});
			};
		};
	
		function _preload(){
			// Hide the next/previous links if on first or last images.
			_checkPosition();
		
			if(pp_type == 'image'){
				// Set the new image
				imgPreloader = new Image();
		
				// Preload the neighbour images
				nextImage = new Image();
				if(isSet && setPosition > setCount) nextImage.src = $(imagesArray[arrayPosition + 1]).attr('href');
				prevImage = new Image();
				if(isSet && imagesArray[arrayPosition - 1]) prevImage.src = $(imagesArray[arrayPosition - 1]).attr('href');

				pp_typeMarkup = '<img id="fullResImage" src="" />';				
				$pp_pic_holder.find('#pp_full_res')[0].innerHTML = pp_typeMarkup;

				$pp_pic_holder.find('.pp_content').css('overflow','hidden');
				$pp_pic_holder.find('#fullResImage').attr('src',$caller.attr('href'));

				imgPreloader.onload = function(){
					var correctSizes = _fitToViewport(imgPreloader.width,imgPreloader.height);
					imgPreloader.width = correctSizes['width'];
					imgPreloader.height = correctSizes['height'];
					showimage(imgPreloader.width,imgPreloader.height,correctSizes["containerWidth"],correctSizes["containerHeight"],correctSizes["contentHeight"],correctSizes["contentWidth"],correctSizes["resized"]);
				};
		
				imgPreloader.src = $caller.attr('href');
			}else{
				// Get the dimensions
				movie_width = ( parseFloat(grab_param('width',$caller.attr('href'))) ) ? grab_param('width',$caller.attr('href')) : "425";
				movie_height = ( parseFloat(grab_param('height',$caller.attr('href'))) ) ? grab_param('height',$caller.attr('href')) : "344";

				// If the size is % based
				if(movie_width.indexOf('%') != -1 || movie_height.indexOf('%') != -1){
					movie_height = ($(window).height() * parseFloat(movie_height) / 100) - 100;
					movie_width = ($(window).width() * parseFloat(movie_width) / 100) - 100;
					parsentBased = true;
				}else{
					movie_height = parseFloat(movie_height);
					movie_width = parseFloat(movie_width);
				}
				
				if(pp_type == 'quicktime'){ movie_height+=13; }
				
				// Fit them to viewport
				correctSizes = _fitToViewport(movie_width,movie_height);
				
				if(pp_type == 'youtube'){
					pp_typeMarkup = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+correctSizes['width']+'" height="'+correctSizes['height']+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.youtube.com/v/'+grab_param('v',$caller.attr('href'))+'" /><embed src="http://www.youtube.com/v/'+grab_param('v',$caller.attr('href'))+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+correctSizes['width']+'" height="'+correctSizes['height']+'"></embed></object>';
				}else if(pp_type == 'quicktime'){
					pp_typeMarkup = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+correctSizes['height']+'" width="'+correctSizes['width']+'"><param name="src" value="'+$caller.attr('href')+'"><param name="autoplay" value="true"><param name="type" value="video/quicktime"><embed src="'+$caller.attr('href')+'" height="'+correctSizes['height']+'" width="'+correctSizes['width']+'" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';
				}else if(pp_type == 'flash'){
					flash_vars = $caller.attr('href');
					flash_vars = flash_vars.substring($caller.attr('href').indexOf('flashvars') + 10,$caller.attr('href').length);

					filename = $caller.attr('href');
					filename = filename.substring(0,filename.indexOf('?'));

					pp_typeMarkup = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+correctSizes['width']+'" height="'+correctSizes['height']+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'+filename+'?'+flash_vars+'" /><embed src="'+filename+'?'+flash_vars+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+correctSizes['width']+'" height="'+correctSizes['height']+'"></embed></object>';
				}else if(pp_type == 'iframe'){
					movie_url = $caller.attr('href');
					movie_url = movie_url.substr(0,movie_url.indexOf('iframe')-1);

					pp_typeMarkup = '<iframe src ="'+movie_url+'" width="'+(correctSizes['width']-10)+'" height="'+(correctSizes['height']-10)+'" frameborder="no"></iframe>';
				}else if(pp_type == 'ajax'){
					movie_url = $caller.attr('href');
					//movie_url = movie_url.substr(0,movie_url.indexOf('ajax')-1);
                    
                    var ajexHtml = $.ajax({
                    url: movie_url,
                        success: settings.callbackBeforePopupShow,
                        async: false
                    }).responseText;
                 
					pp_typeMarkup = '<div class="content" id="ajaxContent" style="width:'+(correctSizes['width']-10)+'px;height:'+(correctSizes['height']-10)+'px;"> ' + ajexHtml + '</div>';
					
				}
				// Append HTML
				$pp_pic_holder.find('#pp_full_res')[0].innerHTML = pp_typeMarkup;
				
				// Show content
				showimage(correctSizes['width'],correctSizes['height'],correctSizes["containerWidth"],correctSizes["containerHeight"],correctSizes["contentHeight"],correctSizes["contentWidth"],correctSizes["resized"]);
			}
		};
	
		function _getScroll(){
			if (self.pageYOffset) {
				scrollTop = self.pageYOffset;
				scrollLeft = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				scrollTop = document.documentElement.scrollTop;
				scrollLeft = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				scrollTop = document.body.scrollTop;
				scrollLeft = document.body.scrollLeft;	
			}
			
			return {scrollTop:scrollTop,scrollLeft:scrollLeft};
		};
	
		function _resizeOverlay() {
			$('div.pp_overlay').css({
				'height':$(document).height(),
				'width':$(window).width()
			});
		};
	
		function _buildOverlay(){
			toInject = "";
			
			// Build the background overlay div
			toInject += "<div class='pp_overlay'></div>";
			
			// Define the markup to append, depending on the content type.
			if(pp_type == 'image'){
				pp_typeMarkup = '<img id="fullResImage" src="" />';
			}else{
				pp_typeMarkup = '';
			}
			
			// Basic HTML for the picture holder
			toInject += '<div class="pp_pic_holder"><div class="pp_top"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div><div class="pp_content"><a href="#" class="pp_expand" title="Expand the image">Expand</a><div class="pp_loaderIcon"></div><div class="pp_hoverContainer"><a class="pp_next" href="#">next</a><a class="pp_previous" href="#">previous</a></div><div id="pp_full_res">'+ pp_typeMarkup +'</div><div class="pp_details clearfix"><a class="pp_close" href="#">Close</a><p class="pp_description"></p><div class="pp_nav"><a href="#" class="pp_arrow_previous">Previous</a><p class="currentTextHolder">0'+settings.counter_separator_label+'0</p><a href="#" class="pp_arrow_next">Next</a></div></div></div><div class="pp_bottom"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div></div>';
			
			// Basic html for the title holder
			toInject += '<div class="ppt"></div>';
			
			$('body').append(toInject);
			
			// Set my global selectors
			$pp_pic_holder = $('.pp_pic_holder');
			$ppt = $('.ppt');
			
			$('div.pp_overlay').css('height',$(document).height()).bind('click',function(){
				close();
			});

			$pp_pic_holder.css({'opacity': 0}).addClass(settings.theme);

			$('a.pp_close').bind('click',function(){ close(); return false; });

			$('a.pp_expand').bind('click',function(){				
				$this = $(this);
				
				// Expand the image
				if($this.hasClass('pp_expand')){
					$this.removeClass('pp_expand').addClass('pp_contract');
					doresize = false;
				}else{
					$this.removeClass('pp_contract').addClass('pp_expand');
					doresize = true;
				};
			
				_hideContent();
				
				$pp_pic_holder.find('.pp_hoverContainer, #pp_full_res, .pp_details').fadeOut(settings.animationSpeed,function(){
					_preload();
				});
		
				return false;	
			});
		
			$pp_pic_holder.find('.pp_previous, .pp_arrow_previous').bind('click',function(){
				changePicture('previous');
				return false;
			});
		
			$pp_pic_holder.find('.pp_next, .pp_arrow_next').bind('click',function(){
				changePicture('next');
				return false;
			});

			$pp_pic_holder.find('.pp_hoverContainer').css({
				'margin-left': settings.padding/2
			});
		
			// If it's not a set, hide the links
			if(!isSet) {
				$pp_pic_holder.find('.pp_hoverContainer,.pp_nav').hide();
			};


			// To fix the bug with IE select boxes
			if($.browser.msie && $.browser.version == 6){
				$('body').addClass('ie6');
				$('select').css('visibility','hidden');
			};

			// Then fade it in
			$('div.pp_overlay').css('opacity',0).fadeTo(settings.animationSpeed,settings.opacity, function(){
				$pp_pic_holder.css('opacity',0).fadeIn(settings.animationSpeed,function(){
					$pp_pic_holder.attr('style','left:'+$pp_pic_holder.css('left')+';top:'+$pp_pic_holder.css('top')+';');
					_preload();
				});
			});
		};
	};
	
	function grab_param(name,url){
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( url );
	  if( results == null )
	    return "";
	  else
	    return results[1];
	}
})(jQuery);


/*
* jQuery Cycle Plugin (withOUT Transition Definitions)
* Examples and documentation at: http://jquery.malsup.com/cycle/
* Copyright (c) 2007-2009 M. Alsup
* Version: 2.72 (09-SEP-2009)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Requires: jQuery v1.2.6 or later
*
* Originally based on the work of:
*	1) Matt Oakes
*	2) Torsten Baldes (http://medienfreunde.com/lab/innerfade/)
*	3) Benjamin Sterling (http://www.benjaminsterling.com/experiments/jqShuffle/)
*/
(function($) { var ver = "2.72"; if ($.support == undefined) { $.support = { opacity: !($.browser.msie) }; } function debug(s) { if ($.fn.cycle.debug) { log(s); } } function log() { if (window.console && window.console.log) { window.console.log("[cycle] " + Array.prototype.join.call(arguments, " ")); } } $.fn.cycle = function(options, arg2) { var o = { s: this.selector, c: this.context }; if (this.length === 0 && options != "stop") { if (!$.isReady && o.s) { log("DOM not ready, queuing slideshow"); $(function() { $(o.s, o.c).cycle(options, arg2); }); return this; } log("terminating; zero elements found by selector" + ($.isReady ? "" : " (DOM not ready)")); return this; } return this.each(function() { var opts = handleArguments(this, options, arg2); if (opts === false) { return; } if (this.cycleTimeout) { clearTimeout(this.cycleTimeout); } this.cycleTimeout = this.cyclePause = 0; var $cont = $(this); var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); var els = $slides.get(); if (els.length < 2) { log("terminating; too few slides: " + els.length); return; } var opts2 = buildOptions($cont, $slides, els, opts, o); if (opts2 === false) { return; } var startTime = opts2.continuous ? 10 : getTimeout(opts2.currSlide, opts2.nextSlide, opts2, !opts2.rev); if (startTime) { startTime += (opts2.delay || 0); if (startTime < 10) { startTime = 10; } debug("first timeout: " + startTime); this.cycleTimeout = setTimeout(function() { go(els, opts2, 0, !opts2.rev); }, startTime); } }); }; function handleArguments(cont, options, arg2) { if (cont.cycleStop == undefined) { cont.cycleStop = 0; } if (options === undefined || options === null) { options = {}; } if (options.constructor == String) { switch (options) { case "stop": cont.cycleStop++; if (cont.cycleTimeout) { clearTimeout(cont.cycleTimeout); } cont.cycleTimeout = 0; $(cont).removeData("cycle.opts"); return false; case "pause": cont.cyclePause = 1; return false; case "resume": cont.cyclePause = 0; if (arg2 === true) { options = $(cont).data("cycle.opts"); if (!options) { log("options not found, can not resume"); return false; } if (cont.cycleTimeout) { clearTimeout(cont.cycleTimeout); cont.cycleTimeout = 0; } go(options.elements, options, 1, 1); } return false; case "prev": case "next": var opts = $(cont).data("cycle.opts"); if (!opts) { log('options not found, "prev/next" ignored'); return false; } $.fn.cycle[options](opts); return false; default: options = { fx: options }; } return options; } else { if (options.constructor == Number) { var num = options; options = $(cont).data("cycle.opts"); if (!options) { log("options not found, can not advance slide"); return false; } if (num < 0 || num >= options.elements.length) { log("invalid slide index: " + num); return false; } options.nextSlide = num; if (cont.cycleTimeout) { clearTimeout(cont.cycleTimeout); cont.cycleTimeout = 0; } if (typeof arg2 == "string") { options.oneTimeFx = arg2; } go(options.elements, options, 1, num >= options.currSlide); return false; } } return options; } function removeFilter(el, opts) { if (!$.support.opacity && opts.cleartype && el.style.filter) { try { el.style.removeAttribute("filter"); } catch (smother) { } } } function buildOptions($cont, $slides, els, options, o) { var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); if (opts.autostop) { opts.countdown = opts.autostopCount || els.length; } var cont = $cont[0]; $cont.data("cycle.opts", opts); opts.$cont = $cont; opts.stopCount = cont.cycleStop; opts.elements = els; opts.before = opts.before ? [opts.before] : []; opts.after = opts.after ? [opts.after] : []; opts.after.unshift(function() { opts.busy = 0; }); if (!$.support.opacity && opts.cleartype) { opts.after.push(function() { removeFilter(this, opts); }); } if (opts.continuous) { opts.after.push(function() { go(els, opts, 0, !opts.rev); }); } saveOriginalOpts(opts); if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) { clearTypeFix($slides); } if ($cont.css("position") == "static") { $cont.css("position", "relative"); } if (opts.width) { $cont.width(opts.width); } if (opts.height && opts.height != "auto") { $cont.height(opts.height); } if (opts.startingSlide) { opts.startingSlide = parseInt(opts.startingSlide); } if (opts.random) { opts.randomMap = []; for (var i = 0; i < els.length; i++) { opts.randomMap.push(i); } opts.randomMap.sort(function(a, b) { return Math.random() - 0.5; }); opts.randomIndex = 0; opts.startingSlide = opts.randomMap[0]; } else { if (opts.startingSlide >= els.length) { opts.startingSlide = 0; } } opts.currSlide = opts.startingSlide = opts.startingSlide || 0; var first = opts.startingSlide; $slides.css({ position: "absolute", top: 0, left: 0 }).hide().each(function(i) { var z = first ? i >= first ? els.length - (i - first) : first - i : els.length - i; $(this).css("z-index", z); }); $(els[first]).css("opacity", 1).show(); removeFilter(els[first], opts); if (opts.fit && opts.width) { $slides.width(opts.width); } if (opts.fit && opts.height && opts.height != "auto") { $slides.height(opts.height); } var reshape = opts.containerResize && !$cont.innerHeight(); if (reshape) { var maxw = 0, maxh = 0; for (var j = 0; j < els.length; j++) { var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); if (!w) { w = e.offsetWidth; } if (!h) { h = e.offsetHeight; } maxw = w > maxw ? w : maxw; maxh = h > maxh ? h : maxh; } if (maxw > 0 && maxh > 0) { $cont.css({ width: maxw + "px", height: maxh + "px" }); } } if (opts.pause) { $cont.hover(function() { this.cyclePause++; }, function() { this.cyclePause--; }); } if (supportMultiTransitions(opts) === false) { return false; } var requeue = false; options.requeueAttempts = options.requeueAttempts || 0; $slides.each(function() { var $el = $(this); this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height(); this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width(); if ($el.is("img")) { var loadingIE = ($.browser.msie && this.cycleW == 28 && this.cycleH == 30 && !this.complete); var loadingFF = ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete); var loadingOp = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete); var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete); if (loadingIE || loadingFF || loadingOp || loadingOther) { if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { log(options.requeueAttempts, " - img slide not loaded, requeuing slideshow: ", this.src, this.cycleW, this.cycleH); setTimeout(function() { $(o.s, o.c).cycle(options); }, opts.requeueTimeout); requeue = true; return false; } else { log("could not determine size of image: " + this.src, this.cycleW, this.cycleH); } } } return true; }); if (requeue) { return false; } opts.cssBefore = opts.cssBefore || {}; opts.animIn = opts.animIn || {}; opts.animOut = opts.animOut || {}; $slides.not(":eq(" + first + ")").css(opts.cssBefore); if (opts.cssFirst) { $($slides[first]).css(opts.cssFirst); } if (opts.timeout) { opts.timeout = parseInt(opts.timeout); if (opts.speed.constructor == String) { opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed); } if (!opts.sync) { opts.speed = opts.speed / 2; } while ((opts.timeout - opts.speed) < 250) { opts.timeout += opts.speed; } } if (opts.easing) { opts.easeIn = opts.easeOut = opts.easing; } if (!opts.speedIn) { opts.speedIn = opts.speed; } if (!opts.speedOut) { opts.speedOut = opts.speed; } opts.slideCount = els.length; opts.currSlide = opts.lastSlide = first; if (opts.random) { opts.nextSlide = opts.currSlide; if (++opts.randomIndex == els.length) { opts.randomIndex = 0; } opts.nextSlide = opts.randomMap[opts.randomIndex]; } else { opts.nextSlide = opts.startingSlide >= (els.length - 1) ? 0 : opts.startingSlide + 1; } if (!opts.multiFx) { var init = $.fn.cycle.transitions[opts.fx]; if ($.isFunction(init)) { init($cont, $slides, opts); } else { if (opts.fx != "custom" && !opts.multiFx) { log("unknown transition: " + opts.fx, "; slideshow terminating"); return false; } } } var e0 = $slides[first]; if (opts.before.length) { opts.before[0].apply(e0, [e0, e0, opts, true]); } if (opts.after.length > 1) { opts.after[1].apply(e0, [e0, e0, opts, true]); } if (opts.next) { $(opts.next).bind(opts.prevNextEvent, function() { return advance(opts, opts.rev ? -1 : 1); }); } if (opts.prev) { $(opts.prev).bind(opts.prevNextEvent, function() { return advance(opts, opts.rev ? 1 : -1); }); } if (opts.pager) { buildPager(els, opts); } exposeAddSlide(opts, els); return opts; } function saveOriginalOpts(opts) { opts.original = { before: [], after: [] }; opts.original.cssBefore = $.extend({}, opts.cssBefore); opts.original.cssAfter = $.extend({}, opts.cssAfter); opts.original.animIn = $.extend({}, opts.animIn); opts.original.animOut = $.extend({}, opts.animOut); $.each(opts.before, function() { opts.original.before.push(this); }); $.each(opts.after, function() { opts.original.after.push(this); }); } function supportMultiTransitions(opts) { var i, tx, txs = $.fn.cycle.transitions; if (opts.fx.indexOf(",") > 0) { opts.multiFx = true; opts.fxs = opts.fx.replace(/\s*/g, "").split(","); for (i = 0; i < opts.fxs.length; i++) { var fx = opts.fxs[i]; tx = txs[fx]; if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { log("discarding unknown transition: ", fx); opts.fxs.splice(i, 1); i--; } } if (!opts.fxs.length) { log("No valid transitions named; slideshow terminating."); return false; } } else { if (opts.fx == "all") { opts.multiFx = true; opts.fxs = []; for (p in txs) { tx = txs[p]; if (txs.hasOwnProperty(p) && $.isFunction(tx)) { opts.fxs.push(p); } } } } if (opts.multiFx && opts.randomizeEffects) { var r1 = Math.floor(Math.random() * 20) + 30; for (i = 0; i < r1; i++) { var r2 = Math.floor(Math.random() * opts.fxs.length); opts.fxs.push(opts.fxs.splice(r2, 1)[0]); } debug("randomized fx sequence: ", opts.fxs); } return true; } function exposeAddSlide(opts, els) { opts.addSlide = function(newSlide, prepend) { var $s = $(newSlide), s = $s[0]; if (!opts.autostopCount) { opts.countdown++; } els[prepend ? "unshift" : "push"](s); if (opts.els) { opts.els[prepend ? "unshift" : "push"](s); } opts.slideCount = els.length; $s.css("position", "absolute"); $s[prepend ? "prependTo" : "appendTo"](opts.$cont); if (prepend) { opts.currSlide++; opts.nextSlide++; } if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) { clearTypeFix($s); } if (opts.fit && opts.width) { $s.width(opts.width); } if (opts.fit && opts.height && opts.height != "auto") { $slides.height(opts.height); } s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); $s.css(opts.cssBefore); if (opts.pager) { $.fn.cycle.createPagerAnchor(els.length - 1, s, $(opts.pager), els, opts); } if ($.isFunction(opts.onAddSlide)) { opts.onAddSlide($s); } else { $s.hide(); } }; } $.fn.cycle.resetState = function(opts, fx) { fx = fx || opts.fx; opts.before = []; opts.after = []; opts.cssBefore = $.extend({}, opts.original.cssBefore); opts.cssAfter = $.extend({}, opts.original.cssAfter); opts.animIn = $.extend({}, opts.original.animIn); opts.animOut = $.extend({}, opts.original.animOut); opts.fxFn = null; $.each(opts.original.before, function() { opts.before.push(this); }); $.each(opts.original.after, function() { opts.after.push(this); }); var init = $.fn.cycle.transitions[fx]; if ($.isFunction(init)) { init(opts.$cont, $(opts.elements), opts); } }; function go(els, opts, manual, fwd) { if (manual && opts.busy && opts.manualTrump) { $(els).stop(true, true); opts.busy = false; } if (opts.busy) { return; } var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) { return; } if (!manual && !p.cyclePause && ((opts.autostop && (--opts.countdown <= 0)) || (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { if (opts.end) { opts.end(opts); } return; } if (manual || !p.cyclePause) { var fx = opts.fx; curr.cycleH = curr.cycleH || $(curr).height(); curr.cycleW = curr.cycleW || $(curr).width(); next.cycleH = next.cycleH || $(next).height(); next.cycleW = next.cycleW || $(next).width(); if (opts.multiFx) { if (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length) { opts.lastFx = 0; } fx = opts.fxs[opts.lastFx]; opts.currFx = fx; } if (opts.oneTimeFx) { fx = opts.oneTimeFx; opts.oneTimeFx = null; } $.fn.cycle.resetState(opts, fx); if (opts.before.length) { $.each(opts.before, function(i, o) { if (p.cycleStop != opts.stopCount) { return; } o.apply(next, [curr, next, opts, fwd]); }); } var after = function() { $.each(opts.after, function(i, o) { if (p.cycleStop != opts.stopCount) { return; } o.apply(next, [curr, next, opts, fwd]); }); }; if (opts.nextSlide != opts.currSlide) { opts.busy = 1; if (opts.fxFn) { opts.fxFn(curr, next, opts, after, fwd); } else { if ($.isFunction($.fn.cycle[opts.fx])) { $.fn.cycle[opts.fx](curr, next, opts, after); } else { $.fn.cycle.custom(curr, next, opts, after, manual && opts.fastOnEvent); } } } opts.lastSlide = opts.currSlide; if (opts.random) { opts.currSlide = opts.nextSlide; if (++opts.randomIndex == els.length) { opts.randomIndex = 0; } opts.nextSlide = opts.randomMap[opts.randomIndex]; } else { var roll = (opts.nextSlide + 1) == els.length; opts.nextSlide = roll ? 0 : opts.nextSlide + 1; opts.currSlide = roll ? els.length - 1 : opts.nextSlide - 1; } if (opts.pager) { $.fn.cycle.updateActivePagerLink(opts.pager, opts.currSlide); } } var ms = 0; if (opts.timeout && !opts.continuous) { ms = getTimeout(curr, next, opts, fwd); } else { if (opts.continuous && p.cyclePause) { ms = 10; } } if (ms > 0) { p.cycleTimeout = setTimeout(function() { go(els, opts, 0, !opts.rev); }, ms); } } $.fn.cycle.updateActivePagerLink = function(pager, currSlide) { $(pager).find("a").removeClass("activeSlide").filter("a:eq(" + currSlide + ")").addClass("activeSlide"); }; function getTimeout(curr, next, opts, fwd) { if (opts.timeoutFn) { var t = opts.timeoutFn(curr, next, opts, fwd); while ((t - opts.speed) < 250) { t += opts.speed; } debug("calculated timeout: " + t + "; speed: " + opts.speed); if (t !== false) { return t; } } return opts.timeout; } $.fn.cycle.next = function(opts) { advance(opts, opts.rev ? -1 : 1); }; $.fn.cycle.prev = function(opts) { advance(opts, opts.rev ? 1 : -1); }; function advance(opts, val) { var els = opts.elements; var p = opts.$cont[0], timeout = p.cycleTimeout; if (timeout) { clearTimeout(timeout); p.cycleTimeout = 0; } if (opts.random && val < 0) { opts.randomIndex--; if (--opts.randomIndex == -2) { opts.randomIndex = els.length - 2; } else { if (opts.randomIndex == -1) { opts.randomIndex = els.length - 1; } } opts.nextSlide = opts.randomMap[opts.randomIndex]; } else { if (opts.random) { if (++opts.randomIndex == els.length) { opts.randomIndex = 0; } opts.nextSlide = opts.randomMap[opts.randomIndex]; } else { opts.nextSlide = opts.currSlide + val; if (opts.nextSlide < 0) { if (opts.nowrap) { return false; } opts.nextSlide = els.length - 1; } else { if (opts.nextSlide >= els.length) { if (opts.nowrap) { return false; } opts.nextSlide = 0; } } } } if ($.isFunction(opts.prevNextClick)) { opts.prevNextClick(val > 0, opts.nextSlide, els[opts.nextSlide]); } go(els, opts, 1, val >= 0); return false; } function buildPager(els, opts) { var $p = $(opts.pager); $.each(els, function(i, o) { $.fn.cycle.createPagerAnchor(i, o, $p, els, opts); }); $.fn.cycle.updateActivePagerLink(opts.pager, opts.startingSlide); } $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) { var a; if ($.isFunction(opts.pagerAnchorBuilder)) { a = opts.pagerAnchorBuilder(i, el); } else { a = '<a href="#">' + (i + 1) + "</a>"; } if (!a) { return; } var $a = $(a); if ($a.parents("body").length === 0) { var arr = []; if ($p.length > 1) { $p.each(function() { var $clone = $a.clone(true); $(this).append($clone); arr.push($clone); }); $a = $(arr); } else { $a.appendTo($p); } } $a.bind(opts.pagerEvent, function(e) { e.preventDefault(); opts.nextSlide = i; var p = opts.$cont[0], timeout = p.cycleTimeout; if (timeout) { clearTimeout(timeout); p.cycleTimeout = 0; } if ($.isFunction(opts.pagerClick)) { opts.pagerClick(opts.nextSlide, els[opts.nextSlide]); } go(els, opts, 1, opts.currSlide < i); return false; }); if (opts.pagerEvent != "click") { $a.click(function() { return false; }); } if (opts.pauseOnPagerHover) { $a.hover(function() { opts.$cont[0].cyclePause++; }, function() { opts.$cont[0].cyclePause--; }); } }; $.fn.cycle.hopsFromLast = function(opts, fwd) { var hops, l = opts.lastSlide, c = opts.currSlide; if (fwd) { hops = c > l ? c - l : opts.slideCount - l; } else { hops = c < l ? l - c : l + opts.slideCount - c; } return hops; }; function clearTypeFix($slides) { function hex(s) { s = parseInt(s).toString(16); return s.length < 2 ? "0" + s : s; } function getBg(e) { for (; e && e.nodeName.toLowerCase() != "html"; e = e.parentNode) { var v = $.css(e, "background-color"); if (v.indexOf("rgb") >= 0) { var rgb = v.match(/\d+/g); return "#" + hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]); } if (v && v != "transparent") { return v; } } return "#ffffff"; } $slides.each(function() { $(this).css("background-color", getBg(this)); }); } $.fn.cycle.commonReset = function(curr, next, opts, w, h, rev) { $(opts.elements).not(curr).hide(); opts.cssBefore.opacity = 1; opts.cssBefore.display = "block"; if (w !== false && next.cycleW > 0) { opts.cssBefore.width = next.cycleW; } if (h !== false && next.cycleH > 0) { opts.cssBefore.height = next.cycleH; } opts.cssAfter = opts.cssAfter || {}; opts.cssAfter.display = "none"; $(curr).css("zIndex", opts.slideCount + (rev === true ? 1 : 0)); $(next).css("zIndex", opts.slideCount + (rev === true ? 0 : 1)); }; $.fn.cycle.custom = function(curr, next, opts, cb, speedOverride) { var $l = $(curr), $n = $(next); var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut; $n.css(opts.cssBefore); if (speedOverride) { if (typeof speedOverride == "number") { speedIn = speedOut = speedOverride; } else { speedIn = speedOut = 1; } easeIn = easeOut = null; } var fn = function() { $n.animate(opts.animIn, speedIn, easeIn, cb); }; $l.animate(opts.animOut, speedOut, easeOut, function() { if (opts.cssAfter) { $l.css(opts.cssAfter); } if (!opts.sync) { fn(); } }); if (opts.sync) { fn(); } }; $.fn.cycle.transitions = { fade: function($cont, $slides, opts) { $slides.not(":eq(" + opts.currSlide + ")").css("opacity", 0); opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); opts.cssBefore.opacity = 0; }); opts.animIn = { opacity: 1 }; opts.animOut = { opacity: 0 }; opts.cssBefore = { top: 0, left: 0 }; } }; $.fn.cycle.ver = function() { return ver; }; $.fn.cycle.defaults = { fx: "fade", timeout: 4000, timeoutFn: null, continuous: 0, speed: 1000, speedIn: null, speedOut: null, next: null, prev: null, prevNextClick: null, prevNextEvent: "click", pager: null, pagerClick: null, pagerEvent: "click", pagerAnchorBuilder: null, before: null, after: null, end: null, easing: null, easeIn: null, easeOut: null, shuffle: null, animIn: null, animOut: null, cssBefore: null, cssAfter: null, fxFn: null, height: "auto", startingSlide: 0, sync: 1, random: 0, fit: 0, containerResize: 1, pause: 0, pauseOnPagerHover: 0, autostop: 0, autostopCount: 0, delay: 0, slideExpr: null, cleartype: !$.support.opacity, cleartypeNoBg: false, nowrap: 0, fastOnEvent: 0, randomizeEffects: 1, rev: 0, manualTrump: true, requeueOnImageNotLoaded: true, requeueTimeout: 250 }; })(jQuery);



/*
* jQuery Cycle Plugin Transition Definitions
* This script is a plugin for the jQuery Cycle Plugin
* Examples and documentation at: http://malsup.com/jquery/cycle/
* Copyright (c) 2007-2008 M. Alsup
* Version:	 2.72
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($) { $.fn.cycle.transitions.none = function($cont, $slides, opts) { opts.fxFn = function(curr, next, opts, after) { $(next).show(); $(curr).hide(); after(); }; }; $.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push($.fn.cycle.commonReset); var h = $cont.height(); opts.cssBefore = { top: h, left: 0 }; opts.cssFirst = { top: 0 }; opts.animIn = { top: 0 }; opts.animOut = { top: -h }; }; $.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push($.fn.cycle.commonReset); var h = $cont.height(); opts.cssFirst = { top: 0 }; opts.cssBefore = { top: -h, left: 0 }; opts.animIn = { top: 0 }; opts.animOut = { top: h }; }; $.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push($.fn.cycle.commonReset); var w = $cont.width(); opts.cssFirst = { left: 0 }; opts.cssBefore = { left: w, top: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: 0 - w }; }; $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push($.fn.cycle.commonReset); var w = $cont.width(); opts.cssFirst = { left: 0 }; opts.cssBefore = { left: -w, top: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: w }; }; $.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) { $cont.css("overflow", "hidden").width(); opts.before.push(function(curr, next, opts, fwd) { $.fn.cycle.commonReset(curr, next, opts); opts.cssBefore.left = fwd ? (next.cycleW - 1) : (1 - next.cycleW); opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW; }); opts.cssFirst = { left: 0 }; opts.cssBefore = { top: 0 }; opts.animIn = { left: 0 }; opts.animOut = { top: 0 }; }; $.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) { $cont.css("overflow", "hidden"); opts.before.push(function(curr, next, opts, fwd) { $.fn.cycle.commonReset(curr, next, opts); opts.cssBefore.top = fwd ? (1 - next.cycleH) : (next.cycleH - 1); opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH; }); opts.cssFirst = { top: 0 }; opts.cssBefore = { left: 0 }; opts.animIn = { top: 0 }; opts.animOut = { left: 0 }; }; $.fn.cycle.transitions.slideX = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $(opts.elements).not(curr).hide(); $.fn.cycle.commonReset(curr, next, opts, false, true); opts.animIn.width = next.cycleW; }); opts.cssBefore = { left: 0, top: 0, width: 0 }; opts.animIn = { width: "show" }; opts.animOut = { width: 0 }; }; $.fn.cycle.transitions.slideY = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $(opts.elements).not(curr).hide(); $.fn.cycle.commonReset(curr, next, opts, true, false); opts.animIn.height = next.cycleH; }); opts.cssBefore = { left: 0, top: 0, height: 0 }; opts.animIn = { height: "show" }; opts.animOut = { height: 0 }; }; $.fn.cycle.transitions.shuffle = function($cont, $slides, opts) { var i, w = $cont.css("overflow", "visible").width(); $slides.css({ left: 0, top: 0 }); opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, true, true); }); if (!opts.speedAdjusted) { opts.speed = opts.speed / 2; opts.speedAdjusted = true; } opts.random = 0; opts.shuffle = opts.shuffle || { left: -w, top: 15 }; opts.els = []; for (i = 0; i < $slides.length; i++) { opts.els.push($slides[i]); } for (i = 0; i < opts.currSlide; i++) { opts.els.push(opts.els.shift()); } opts.fxFn = function(curr, next, opts, cb, fwd) { var $el = fwd ? $(curr) : $(next); $(next).css(opts.cssBefore); var count = opts.slideCount; $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() { var hops = $.fn.cycle.hopsFromLast(opts, fwd); for (var k = 0; k < hops; k++) { fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop()); } if (fwd) { for (var i = 0, len = opts.els.length; i < len; i++) { $(opts.els[i]).css("z-index", len - i + count); } } else { var z = $(curr).css("z-index"); $el.css("z-index", parseInt(z) + 1 + count); } $el.animate({ left: 0, top: 0 }, opts.speedOut, opts.easeOut, function() { $(fwd ? this : curr).hide(); if (cb) { cb(); } }); }); }; opts.cssBefore = { display: "block", opacity: 1, top: 0, left: 0 }; }; $.fn.cycle.transitions.turnUp = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, false); opts.cssBefore.top = next.cycleH; opts.animIn.height = next.cycleH; }); opts.cssFirst = { top: 0 }; opts.cssBefore = { left: 0, height: 0 }; opts.animIn = { top: 0 }; opts.animOut = { height: 0 }; }; $.fn.cycle.transitions.turnDown = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, false); opts.animIn.height = next.cycleH; opts.animOut.top = curr.cycleH; }); opts.cssFirst = { top: 0 }; opts.cssBefore = { left: 0, top: 0, height: 0 }; opts.animOut = { height: 0 }; }; $.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, true); opts.cssBefore.left = next.cycleW; opts.animIn.width = next.cycleW; }); opts.cssBefore = { top: 0, width: 0 }; opts.animIn = { left: 0 }; opts.animOut = { width: 0 }; }; $.fn.cycle.transitions.turnRight = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, true); opts.animIn.width = next.cycleW; opts.animOut.left = curr.cycleW; }); opts.cssBefore = { top: 0, left: 0, width: 0 }; opts.animIn = { left: 0 }; opts.animOut = { width: 0 }; }; $.fn.cycle.transitions.zoom = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, false, true); opts.cssBefore.top = next.cycleH / 2; opts.cssBefore.left = next.cycleW / 2; opts.animIn = { top: 0, left: 0, width: next.cycleW, height: next.cycleH }; opts.animOut = { width: 0, height: 0, top: curr.cycleH / 2, left: curr.cycleW / 2 }; }); opts.cssFirst = { top: 0, left: 0 }; opts.cssBefore = { width: 0, height: 0 }; }; $.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, false); opts.cssBefore.left = next.cycleW / 2; opts.cssBefore.top = next.cycleH / 2; opts.animIn = { top: 0, left: 0, width: next.cycleW, height: next.cycleH }; }); opts.cssBefore = { width: 0, height: 0 }; opts.animOut = { opacity: 0 }; }; $.fn.cycle.transitions.blindX = function($cont, $slides, opts) { var w = $cont.css("overflow", "hidden").width(); opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); opts.animIn.width = next.cycleW; opts.animOut.left = curr.cycleW; }); opts.cssBefore = { left: w, top: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: w }; }; $.fn.cycle.transitions.blindY = function($cont, $slides, opts) { var h = $cont.css("overflow", "hidden").height(); opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); opts.animIn.height = next.cycleH; opts.animOut.top = curr.cycleH; }); opts.cssBefore = { top: h, left: 0 }; opts.animIn = { top: 0 }; opts.animOut = { top: h }; }; $.fn.cycle.transitions.blindZ = function($cont, $slides, opts) { var h = $cont.css("overflow", "hidden").height(); var w = $cont.width(); opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); opts.animIn.height = next.cycleH; opts.animOut.top = curr.cycleH; }); opts.cssBefore = { top: h, left: w }; opts.animIn = { top: 0, left: 0 }; opts.animOut = { top: h, left: w }; }; $.fn.cycle.transitions.growX = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, true); opts.cssBefore.left = this.cycleW / 2; opts.animIn = { left: 0, width: this.cycleW }; opts.animOut = { left: 0 }; }); opts.cssBefore = { width: 0, top: 0 }; }; $.fn.cycle.transitions.growY = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, false); opts.cssBefore.top = this.cycleH / 2; opts.animIn = { top: 0, height: this.cycleH }; opts.animOut = { top: 0 }; }); opts.cssBefore = { height: 0, left: 0 }; }; $.fn.cycle.transitions.curtainX = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, false, true, true); opts.cssBefore.left = next.cycleW / 2; opts.animIn = { left: 0, width: this.cycleW }; opts.animOut = { left: curr.cycleW / 2, width: 0 }; }); opts.cssBefore = { top: 0, width: 0 }; }; $.fn.cycle.transitions.curtainY = function($cont, $slides, opts) { opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, false, true); opts.cssBefore.top = next.cycleH / 2; opts.animIn = { top: 0, height: next.cycleH }; opts.animOut = { top: curr.cycleH / 2, height: 0 }; }); opts.cssBefore = { left: 0, height: 0 }; }; $.fn.cycle.transitions.cover = function($cont, $slides, opts) { var d = opts.direction || "left"; var w = $cont.css("overflow", "hidden").width(); var h = $cont.height(); opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts); if (d == "right") { opts.cssBefore.left = -w; } else { if (d == "up") { opts.cssBefore.top = h; } else { if (d == "down") { opts.cssBefore.top = -h; } else { opts.cssBefore.left = w; } } } }); opts.animIn = { left: 0, top: 0 }; opts.animOut = { opacity: 1 }; opts.cssBefore = { top: 0, left: 0 }; }; $.fn.cycle.transitions.uncover = function($cont, $slides, opts) { var d = opts.direction || "left"; var w = $cont.css("overflow", "hidden").width(); var h = $cont.height(); opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, true, true); if (d == "right") { opts.animOut.left = w; } else { if (d == "up") { opts.animOut.top = -h; } else { if (d == "down") { opts.animOut.top = h; } else { opts.animOut.left = -w; } } } }); opts.animIn = { left: 0, top: 0 }; opts.animOut = { opacity: 1 }; opts.cssBefore = { top: 0, left: 0 }; }; $.fn.cycle.transitions.toss = function($cont, $slides, opts) { var w = $cont.css("overflow", "visible").width(); var h = $cont.height(); opts.before.push(function(curr, next, opts) { $.fn.cycle.commonReset(curr, next, opts, true, true, true); if (!opts.animOut.left && !opts.animOut.top) { opts.animOut = { left: w * 2, top: -h / 2, opacity: 0 }; } else { opts.animOut.opacity = 0; } }); opts.cssBefore = { left: 0, top: 0 }; opts.animIn = { left: 0 }; }; $.fn.cycle.transitions.wipe = function($cont, $slides, opts) { var w = $cont.css("overflow", "hidden").width(); var h = $cont.height(); opts.cssBefore = opts.cssBefore || {}; var clip; if (opts.clip) { if (/l2r/.test(opts.clip)) { clip = "rect(0px 0px " + h + "px 0px)"; } else { if (/r2l/.test(opts.clip)) { clip = "rect(0px " + w + "px " + h + "px " + w + "px)"; } else { if (/t2b/.test(opts.clip)) { clip = "rect(0px " + w + "px 0px 0px)"; } else { if (/b2t/.test(opts.clip)) { clip = "rect(" + h + "px " + w + "px " + h + "px 0px)"; } else { if (/zoom/.test(opts.clip)) { var top = parseInt(h / 2); var left = parseInt(w / 2); clip = "rect(" + top + "px " + left + "px " + top + "px " + left + "px)"; } } } } } } opts.cssBefore.clip = opts.cssBefore.clip || clip || "rect(0px 0px 0px 0px)"; var d = opts.cssBefore.clip.match(/(\d+)/g); var t = parseInt(d[0]), r = parseInt(d[1]), b = parseInt(d[2]), l = parseInt(d[3]); opts.before.push(function(curr, next, opts) { if (curr == next) { return; } var $curr = $(curr), $next = $(next); $.fn.cycle.commonReset(curr, next, opts, true, true, false); opts.cssAfter.display = "block"; var step = 1, count = parseInt((opts.speedIn / 13)) - 1; (function f() { var tt = t ? t - parseInt(step * (t / count)) : 0; var ll = l ? l - parseInt(step * (l / count)) : 0; var bb = b < h ? b + parseInt(step * ((h - b) / count || 1)) : h; var rr = r < w ? r + parseInt(step * ((w - r) / count || 1)) : w; $next.css({ clip: "rect(" + tt + "px " + rr + "px " + bb + "px " + ll + "px)" }); (step++ <= count) ? setTimeout(f, 13) : $curr.css("display", "none"); })(); }); opts.cssBefore = { display: "block", opacity: 1, top: 0, left: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: 0 }; }; })(jQuery);




/**
* jQuery.ScrollTo - Easy element scrolling using jQuery.
* Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 9/11/2008
* @author Ariel Flesler
* @version 1.4
*
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
*/
; (function(h) { var m = h.scrollTo = function(b, c, g) { h(window).scrollTo(b, c, g) }; m.defaults = { axis: 'y', duration: 1 }; m.window = function(b) { return h(window).scrollable() }; h.fn.scrollable = function() { return this.map(function() { var b = this.parentWindow || this.defaultView, c = this.nodeName == '#document' ? b.frameElement || b : this, g = c.contentDocument || (c.contentWindow || c).document, i = c.setInterval; return c.nodeName == 'IFRAME' || i && h.browser.safari ? g.body : i ? g.documentElement : this }) }; h.fn.scrollTo = function(r, j, a) { if (typeof j == 'object') { a = j; j = 0 } if (typeof a == 'function') a = { onAfter: a }; a = h.extend({}, m.defaults, a); j = j || a.speed || a.duration; a.queue = a.queue && a.axis.length > 1; if (a.queue) j /= 2; a.offset = n(a.offset); a.over = n(a.over); return this.scrollable().each(function() { var k = this, o = h(k), d = r, l, e = {}, p = o.is('html,body'); switch (typeof d) { case 'number': case 'string': if (/^([+-]=)?\d+(px)?$/.test(d)) { d = n(d); break } d = h(d, this); case 'object': if (d.is || d.style) l = (d = h(d)).offset() } h.each(a.axis.split(''), function(b, c) { var g = c == 'x' ? 'Left' : 'Top', i = g.toLowerCase(), f = 'scroll' + g, s = k[f], t = c == 'x' ? 'Width' : 'Height', v = t.toLowerCase(); if (l) { e[f] = l[i] + (p ? 0 : s - o.offset()[i]); if (a.margin) { e[f] -= parseInt(d.css('margin' + g)) || 0; e[f] -= parseInt(d.css('border' + g + 'Width')) || 0 } e[f] += a.offset[i] || 0; if (a.over[i]) e[f] += d[v]() * a.over[i] } else e[f] = d[i]; if (/^\d+$/.test(e[f])) e[f] = e[f] <= 0 ? 0 : Math.min(e[f], u(t)); if (!b && a.queue) { if (s != e[f]) q(a.onAfterFirst); delete e[f] } }); q(a.onAfter); function q(b) { o.animate(e, j, a.easing, b && function() { b.call(this, r, a) }) }; function u(b) { var c = 'scroll' + b, g = k.ownerDocument; return p ? Math.max(g.documentElement[c], g.body[c]) : k[c] } }).end() }; function n(b) { return typeof b == 'object' ? b : { top: b, left: b} } })(jQuery);

/**
* jQuery.LocalScroll - Animated scrolling navigation, using anchors.
* Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 6/3/2008
* @author Ariel Flesler
* @version 1.2.6
**/
; (function($) { var g = location.href.replace(/#.*/, ''), h = $.localScroll = function(a) { $('body').localScroll(a) }; h.defaults = { duration: 1e3, axis: 'y', event: 'click', stop: 1 }; h.hash = function(a) { a = $.extend({}, h.defaults, a); a.hash = 0; if (location.hash) setTimeout(function() { i(0, location, a) }, 0) }; $.fn.localScroll = function(b) { b = $.extend({}, h.defaults, b); return (b.persistent || b.lazy) ? this.bind(b.event, function(e) { var a = $([e.target, e.target.parentNode]).filter(c)[0]; a && i(e, a, b) }) : this.find('a,area').filter(c).bind(b.event, function(e) { i(e, this, b) }).end().end(); function c() { var a = this; return !!a.href && !!a.hash && a.href.replace(a.hash, '') == g && (!b.filter || $(a).is(b.filter)) } }; function i(e, a, b) { var c = a.hash.slice(1), d = document.getElementById(c) || document.getElementsByName(c)[0], f; if (d) { e && e.preventDefault(); f = $(b.target || $.scrollTo.window()); if (b.lock && f.is(':animated') || b.onBefore && b.onBefore.call(a, e, d, f) === !1) return; if (b.stop) f.queue('fx', []).stop(); f.scrollTo(d, b).trigger('notify.serialScroll', [d]); if (b.hash) f.queue(function() { location = a.hash; $(this).dequeue() }) } } })(jQuery);


/**
* jQuery[a] - Animated scrolling of series
* Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 3/20/2008
* @author Ariel Flesler
* @version 1.2.1
*
* http://flesler.blogspot.com/2008/02/jqueryserialscroll.html
*/
; (function($) { var a = 'serialScroll', b = '.' + a, c = 'bind', C = $[a] = function(b) { $.scrollTo.window()[a](b) }; C.defaults = { duration: 1e3, axis: 'x', event: 'click', start: 0, step: 1, lock: 1, cycle: 1, constant: 1 }; $.fn[a] = function(y) { y = $.extend({}, C.defaults, y); var z = y.event, A = y.step, B = y.lazy; return this.each(function() { var j = y.target ? this : document, k = $(y.target || this, j), l = k[0], m = y.items, o = y.start, p = y.interval, q = y.navigation, r; if (!B) m = w(); if (y.force) t({}, o); $(y.prev || [], j)[c](z, -A, s); $(y.next || [], j)[c](z, A, s); if (!l.ssbound) k[c]('prev' + b, -A, s)[c]('next' + b, A, s)[c]('goto' + b, t); if (p) k[c]('start' + b, function(e) { if (!p) { v(); p = 1; u() } })[c]('stop' + b, function() { v(); p = 0 }); k[c]('notify' + b, function(e, a) { var i = x(a); if (i > -1) o = i }); l.ssbound = 1; if (y.jump) (B ? k : w())[c](z, function(e) { t(e, x(e.target)) }); if (q) q = $(q, j)[c](z, function(e) { e.data = Math.round(w().length / q.length) * q.index(this); t(e, this) }); function s(e) { e.data += o; t(e, this) }; function t(e, a) { if (!isNaN(a)) { e.data = a; a = l } var c = e.data, n, d = e.type, f = y.exclude ? w().slice(0, -y.exclude) : w(), g = f.length, h = f[c], i = y.duration; if (d) e.preventDefault(); if (p) { v(); r = setTimeout(u, y.interval) } if (!h) { n = c < 0 ? 0 : n = g - 1; if (o != n) c = n; else if (!y.cycle) return; else c = g - n - 1; h = f[c] } if (!h || d && o == c || y.lock && k.is(':animated') || d && y.onBefore && y.onBefore.call(a, e, h, k, w(), c) === !1) return; if (y.stop) k.queue('fx', []).stop(); if (y.constant) i = Math.abs(i / A * (o - c)); k.scrollTo(h, i, y).trigger('notify' + b, [c]) }; function u() { k.trigger('next' + b) }; function v() { clearTimeout(r) }; function w() { return $(m, l) }; function x(a) { if (!isNaN(a)) return a; var b = w(), i; while ((i = b.index(a)) == -1 && a != l) a = a.parentNode; return i } }) } })(jQuery);




(function() {
    $.fn.infiniteCarousel = function() {
        function repeat(str, n) {
            return new Array(n + 1).join(str);
        }

        return this.each(function() {
            // magic!
            var $wrapper = $('> div', this).css('overflow', 'hidden'),
                $slider = $wrapper.find('> ul').width(9999),
                $items = $slider.find('> li'),
                $single = $items.filter(':first')

            singleWidth = $single.outerWidth(),
                visible = Math.ceil($wrapper.innerWidth() / singleWidth),
                currentPage = 1,
                pages = Math.ceil($items.length / visible);

            /* TASKS */

            // 1. pad the pages with empty element if required
            if ($items.length % visible != 0) {
                // pad
                $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
                $items = $slider.find('> li');
            }

            // 2. create the carousel padding on left and right (cloned)
            $items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));
            $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
            $items = $slider.find('> li');

            // 3. reset scroll
            $wrapper.scrollLeft(singleWidth * visible);

            // 4. paging function
            function gotoPage(page) {
                var dir = page < currentPage ? -1 : 1,
                    n = Math.abs(currentPage - page),
                    left = singleWidth * dir * visible * n;

                $wrapper.filter(':not(:animated)').animate({
                    scrollLeft: '+=' + left
                }, 500, function() {
                    // if page == last page - then reset position
                    if (page > pages) {
                        $wrapper.scrollLeft(singleWidth * visible);
                        page = 1;
                    } else if (page == 0) {
                        page = pages;
                        $wrapper.scrollLeft(singleWidth * visible * pages);
                    }

                    currentPage = page;
                });
            }

            // 5. insert the back and forward link
            $wrapper.after('<a href="#" class="arrow back">&lt;</a><a href="#" class="arrow forward">&gt;</a>');

            // 6. bind the back and forward links
            $('a.back', this).click(function() {
                gotoPage(currentPage - 1);
                return false;
            });

            $('a.forward', this).click(function() {
                gotoPage(currentPage + 1);
                return false;
            });

            $(this).bind('goto', function(event, page) {
                gotoPage(page);
            });

            // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
            $(this).bind('next', function() {
                gotoPage(currentPage + 1);
            });
        });
    };
})(jQuery);









function log() {
	try {   
		var args = [];
		for(var i=0; i<arguments.length;i++)
			args.push("arguments["+i+"]");
			
		eval("console.log("+args.join(",")+")");
		   
	}catch(e){}
}


function DateDiff(date1, date2) {
    var dateDiffMsg = "";
    
    if (date1.getFullYear() - date2.getFullYear() != 0) {
        var years = date1.getFullYear() - date2.getFullYear();
        years = years < 0 ? years * -1 : years;
        if (!isNaN(years)) {
            dateDiffMsg = years + "yrs";
        }
    } else if (date1.getMonth() - date2.getMonth() != 0) {
        var months = date1.getMonth() - date2.getMonth();
        months = months < 0 ? months * -1 : months;
        if (!isNaN(months)) {
            dateDiffMsg = months + "mnts";
        }
    } else if (date1.getDay() - date2.getDay() != 0) {
        var diff = date1.getDay() - date2.getDay();
        diff = diff < 0 ? diff * -1 : diff;
        if (!isNaN(diff)) {
            dateDiffMsg = diff + "days";
        }
    } else if (date1.getHours() - date2.getHours() != 0) {
        var diff = date1.getHours() - date2.getHours();
        diff = diff < 0 ? diff * -1 : diff;
        if (!isNaN(diff)) {
            dateDiffMsg = diff + "hrs";
        }
    } else if (date1.getMinutes() - date2.getMinutes() != 0) {
        var diff = date1.getMinutes() - date2.getMinutes();
        diff = diff < 0 ? diff * -1 : diff;
        if (!isNaN(diff)) {
            dateDiffMsg = diff + "mins";
        }
    }

    return dateDiffMsg;
}



//start: abuse stuff from nanookie
function commentAbuse() {

    var $html = startMod("fieldset", "modv highlight noborder5 form abuseForm")
                  + "<div class='formrow' id='abuseform'>\
                        <input type='text' class='text bit w8 example' title='Add Interest' />\
                        <a href='#' class='u bit modh commentabuseButton' style='margin-top:3px;'>Report</a>\
                    </div>"
              + endMod("fieldset");

    $(".commentabuse").live("click", function(e) {
        e.preventDefault();

        if ($(this).findParent(".comment").find(".abuseForm").length == 0) {//insetad of findParent try closest()
            $(this).next().after($html);
        }
    });

    $("#abuseform input").live("keypress", function(e) {
        if (e.keyCode == 13) {
            e.preventDefault();
            $(this).findParent(".comment").find(".commentabuseButton").trigger("click");
        }
    });

    //look at raging bull version
    $(".commentabuseButton").live("click", function(e) {
        e.preventDefault();


        if ($(this).findParent(".comment").find(":disabled").length > 0) {
            return;
        }

        var $comment = $(this).findParent(".comment"), //insetad of findParent try closest()
            commentid = $comment.attr("id").replace("comment", ""),
            message = $.trim($comment.find("input").val());

        $(this).findParent(".comment")
                    .find("input")
                        .attr("disabled", "disabled")
                        .addClass("loading");

        $.ajax({
            dataType: 'json',

            data: {
                commentid: commentid,
                message: message
            },
            //            error: function(data) {
            //                alert("error");
            //                log(arguments)
            //            },
            //            success: function(data) {
            //                alert("success");
            //                $comment.find("success").val(data.msg);
            //                $comment.removeClass("loading");
            //            },

            complete: function(data) {

                //log("complete", data);
                var data = eval(data.responseText);
                //log(data);

                if (data.success) {
                    $comment.find("input").val(data.msg)
                                          .removeClass("loading");
                } else {
                    alert(data.msg);
                    $comment.find("input").attr('disabled', false)
                                           .removeClass("loading");
                }
            }
        });
    });
}

MGZ.OOCSS = { TOP_CORNERS: '<b class="top"><b class="tl"></b><b class="tr"></b></b>',
    BOTTOM_CORNERS: '<b class="bottom"><b class="bl"></b><b class="br"></b></b>'
};

$.fn.findParent = function(selector) {
    var parent = null;
    selector = $.trim(selector);

    $.each($(this).parents(), function() {
        if (selector.indexOf(".") != -1) {
            if ($(this).hasClass(selector.substr(1))) {
                parent = this;
                return;
            }

        } else {
            if (this.tagName.toLowerCase() == selector.toLowerCase()) {
                parent = this;
                return;
            }
        }
    });

    return $(parent); //should really splice it properly.....for proper chaining with end()?
};

function getValidationMessage(msg, title) {

    return '<div class="mod simple validation validationbg clear">' +
                 MGZ.OOCSS.TOP_CORNERS +
                '<div class="inner">' +
                    '<div class="hd">' +
                        '<h4>' + title.replace("<", "&lt;") + '</h4>' +
                    '</div>' +
                    '<div class="bd"><p>' + msg.replace("<", "&lt;") + '</p></div>' +
                '</div>' +
                 MGZ.OOCSS.BOTTOM_CORNERS +
           '</div>';
}





function format(str) {
    for (i = 1; i < arguments.length; i++) {
        str = str.replace("{" + (i - 1) + "}", arguments[i]);
    }
    return str;
}


function startMod(el, className, head, headClass) {
    className = typeof className == "undefined" ? "" : className;
    head = typeof head == "undefined" ? "" : head;
    headClass = typeof headClass == "undefined" ? "" : headClass;
    return format("<{0} class='mod {1}'>\
        {2} \
        <div class='inner'> \
        {3}\
       <div class='bd'>", el, className, MGZ.OOCSS.TOP_CORNERS,
                            !head.length ? "" : "<div class='hd " + headClass + "'>" + head + "</div>\n");
}

function endMod(el, foot, footClass) {
    foot = typeof foot == "undefined" ? "" : foot;
    footClass = typeof footClass == "undefined" ? "" : footClass;

    return format("</div>\
        {0}   \
    </div>\
    {1}\
   </{2}>",
       !foot.length ? "" : "<div class='ft " + footClass + "'>" + foot + "</div>\n",
       MGZ.OOCSS.BOTTOM_CORNERS, el);
}
//end: abuse stuff from nanookie