﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />

var jsBaseUrl = "http://www.sassarinotizie.com/";
var jsPageTitle = "SassariNotizie.com";
var jsSiteName = "SN.com"
var jsNewWinMessage = " (apre collegamento in una nuova finestra)";
var jsLoadPrettyPhoto = false;
var jsPageType = "ContenutoHtml";
var jsMeteoTooltip = false;
var jsAddRefresh = false;

var addthis_config = { username: "sassarinotizie", data_ga_tracker: "pageTracker", ui_click: true, ui_language: "it", data_track_clickback: true, data_track_linkback: true };
var addthis_localize = { share_caption: "SassariNotizie.com" };

$(document).ready(
   function() {
      $("input:password").bind("cut copy paste", function(e) { e.preventDefault(); alert("Non è consentito il copia e incolla in un campo password."); });
      if (jsLoadPrettyPhoto == true) { $("a[rel^='lightbox']").prettyPhoto({ theme: 'facebook', social_tools: '' }) }; //inizializza prettyPhoto
      if (jsMeteoTooltip == true) { $(".meteobox *").tooltip(); };
      if (jsAddRefresh == true) {
         var evalString = 'location.href = "' + location.href
         if (evalString.indexOf('refresh=true') < 0) { evalString = evalString + "?refresh=true" + '"' }
         evalString = evalString + '"'
         setTimeout(evalString, 300000);
      }
      //inizializza HomePage
      if ((jsPageType == "HomePage") && (jsSiteName == "SN.com")) {
         $('#wtabs').tabs();
         //hover states on the static widgets
         $('#dialog_link, ul#icons li').hover(
            function() { $(this).addClass('ui-state-hover'); },
            function() { $(this).removeClass('ui-state-hover'); }
         );
         $("#ticker24ore").jCarouselLite({ vertical: true, hoverPause: true, visible: 3, auto: 3500, speed: 1000 });
         $("#CinemaSassariBox").jCarouselLite({ hoverPause: true, visible: 3, auto: 5000, speed: 1000, btnNext: "#CinemaBtnNext", btnPrev: "#CinemaBtnPrev" });
         $("#RubricheHome").jCarouselLite({ hoverPause: true, visible: 3, auto: 5000, speed: 1000 });
      }; //inizializza home
      //inizializza HomePage Animalando
      if (jsSiteName == "Animalando") { $('#mycarousel').jcarousel({ auto: 5, wrap: 'last', initCallback: mycarousel_initCallback }); }; //inizializza home Animalando
      //inizializza Notizia
      if (jsPageType == "Notizia" || jsPageType == "Articolo24Ore") {
         SetTextResizing();
         $("#testoArticolo").css("font-size", "14px");
         $("#testoArticolo p").css("font-size", "14px");
         $("#testoArticolo div").css("font-size", "14px");
         style = 'easeOutQuart';
         $('.image').hover(
            function() {
               //display heading and caption
               $(this).children('div:first').stop(false, true).animate({ top: 0 }, { duration: 200, easing: style });
               $(this).children('div:last').stop(false, true).animate({ bottom: 0 }, { duration: 200, easing: style });
            },
			   function() {
			      //hide heading and caption
			      $(this).children('div:first').stop(false, true).animate({ top: -50 }, { duration: 200, easing: style });
			      $(this).children('div:last').stop(false, true).animate({ bottom: -50 }, { duration: 200, easing: style });
			   }
		   );
      }; //inizializza Notizia
      //inizializza Evento
      if (jsPageType == "Evento") {
         SetTextResizing();
         $("#testoArticolo").css("font-size", "13px");
         $("#testoArticolo p").css("font-size", "13px");
         $("#testoArticolo div").css("font-size", "13px");
      }; //inizializza Evento
      //Inizializza ContenutiHtml
      if (jsPageType == "ContenutiHtml") {
         SetTextResizing();
         $("#testoArticolo").css("font-size", "13px");
         $("#testoArticolo p").css("font-size", "13px");
         $("#testoArticolo div").css("font-size", "13px");
      }; //inizializza ContenutiHtml
      //inizializza GalleriaFoto
      if (jsPageType == "GalleriaFoto") {
         style = 'easeOutQuart';
         $('.image').hover(
			   function() {
			      //display heading and caption
			      $(this).children('div:first').stop(false, true).animate({ top: 0 }, { duration: 200, easing: style });
			      $(this).children('div:last').stop(false, true).animate({ bottom: 0 }, { duration: 200, easing: style });
			   },
			   function() {
			      //hide heading and caption
			      $(this).children('div:first').stop(false, true).animate({ top: -50 }, { duration: 200, easing: style });
			      $(this).children('div:last').stop(false, true).animate({ bottom: -50 }, { duration: 200, easing: style });
			   }
		   );
      }; //inizializza FotoGallery
      jqTooltip(); //inizializza ToolTip
      SetTargetBlankJQ(); //inizializza class=targetBlank
      popupExternal(); //inizializza rel=external
      $("#lnk_ico_preferito").click(function() { AddToFavorites(); return false; });
      //funzionalità di base per i panel
      $('#mask').css({ 'height': $('#panel-1').height() });
      $('#panel').width(parseInt($('#mask').width() * $('#panel div').length));
      $('#panel div').width($('#mask').width());
      $('a[rel=panel]').click(function() {
         var panelheight = $($(this).attr('href')).height();
         $('a[rel=panel]').removeClass('selected');
         $(this).addClass('selected');
         $('#mask').animate({ 'height': panelheight }, { queue: false, duration: 500 });
         $('#mask').scrollTo($(this).attr('href'), 800);
         return false;
      });

      $('#PollAlertTitle').click(function() { switchViews('PollAlertText') });

      $('#tabs li').hover(function() { $('ul', this).slideDown(100); }, function() { $('ul', this).slideUp(100); });
   }
);            //document.ready

this.jqTooltip = function() {
   xOffset = 10; yOffset = 20; /* CONFIG */
   $("a.tooltip").hover(function(e) {
      this.t = this.title; this.title = ""; $("body").append("<p id='jqTooltip'>" + this.t + "</p>");
      $("#jqTooltip").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px").fadeIn("fast");
   },
	function() { this.title = this.t; $("#jqTooltip").remove(); }
	);
   $("a.tooltip").mousemove(function(e) { $("#jqTooltip").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px"); });
};

function switchViews(obj) { $('#' + obj).slideToggle(); }

function SetTargetBlankJQ() {
   $("a.targetBlank").each(function(e) {
   var newTitle = $(this).attr("title") + jsNewWinMessage; $(this).removeAttr("title"); $(this).attr("title", newTitle);
      $(this).click(function() { window.open(this.href); return false; })
   });
};

function SetTextResizing() {
   var FontSizeMin = 10; var FontSizeMax = 22;
   $("#NewsCharDn").click(function() {
      //testo articolo
      size = parseInt($("#testoArticolo").css("font-size")) - 1 + "px";
      if (parseInt(size) >= FontSizeMin) { $("#testoArticolo").css("font-size", size); }
      sizeP = parseInt($("#testoArticolo p").css("font-size")) - 1 + "px";
      if (parseInt(sizeP) >= FontSizeMin) { $("#testoArticolo p").css("font-size", size); }
      sizeD = parseInt($("#testoArticolo div").css("font-size")) - 1 + "px";
      if (parseInt(sizeD) >= FontSizeMin) { $("#testoArticolo div").css("font-size", size); }
      return false;
   });
   $("#NewsCharUp").click(function() {
      //testo articolo
      size = parseInt($("#testoArticolo").css("font-size")) + 1 + "px";
      if (parseInt(size) < FontSizeMax) { $("#testoArticolo").css("font-size", size); }
      sizeP = parseInt($("#testoArticolo p").css("font-size")) + 1 + "px";
      if (parseInt(sizeP) < FontSizeMax) { $("#testoArticolo p").css("font-size", size); }
      sizeD = parseInt($("#testoArticolo div").css("font-size")) + 1 + "px";
      if (parseInt(sizeD) < FontSizeMax) { $("#testoArticolo div").css("font-size", size); }
      return false;
   });
}

//utilizzo: <a href='url' rel='external' /> oppure <a href='url' rel='external[640,480]' />
function popupExternal() {
   var popupRE = /external\[(\d+),(\d+)\]/gi; var links = $('a[rel^="external"]'); var rel, width, height;
   links.click(function() {
      rel = $(this).attr('rel');
      if (rel == "external") { window.open($(this).attr('href')); return false; } 
      else if (rel.match(popupRE)) {
         width = RegExp.$1; height = RegExp.$2;
         window.open($(this).attr('href'), '', 'width=' + width + ',height=' + height + ',scrollbars=yes'); return false;
      }
   });
   links.each(function(e) {
      rel = $(this).attr('rel');
      if (rel == "external" || rel.match(popupRE)) {
         var newTitle = $(this).attr("title") + jsNewWinMessage; $(this).removeAttr("title"); $(this).attr("title", newTitle);
      }
   });
}

function centreWinPopUp(pageFile, popUpName, w, h, scroll, resize) {
   var winLeft = (screen.width - w) / 2;
   var winTop = (screen.height - h) / 2;
   winProperties = 'height=' + h + ',width=' + w + ',top=' + winTop + ',left=' + winLeft + ',scrollbars=' + scroll + ',toolbar=no,resizable=' + resize + ',status=no'
   if (!window.winPopUp)
   { winPopUp = window.open(pageFile, popUpName, winProperties) }
   else {
      if (!winPopUp.closed)
      { winPopUp.focus(); }
      else
      { winPopUp = window.open(pageFile, popUpName, winProperties) }
   }
}

function newwin(url, nome, larghezza, altezza) {
   finestra = window.open(url, nome, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=" + larghezza + ",height=" + altezza);
   return false;
}

function getParameterByName(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) { return ""; } else { return decodeURIComponent(results[1].replace(/\+/g, " ")); } }

function AddToFavorites() {
   if (window.sidebar) // firefox
      window.sidebar.addPanel(jsPageTitle, jsBaseUrl, "");
   else if (window.opera && window.print) { // opera
      var elem = document.createElement('a');
      elem.setAttribute('href', jsBaseUrl);
      elem.setAttribute('title', jsPageTitle);
      elem.setAttribute('rel', 'sidebar');
      elem.click();
   }
   else if (document.all) // ie
      window.external.AddFavorite(jsBaseUrl, jsPageTitle);
}

function setHome() {
   if (document.all) { //IE 
      document.body.style.behavior = 'url(#default#homepage)';
      document.body.setHomePage('http://www.sassarinotizie.com');
   }
   else if (window.sidebar) {
      if (window.netscape) {
         try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
         } catch (e) {
            alert("questa azione non è permessa dal tuo browser. Se vuoi abilitarla scrivi about:config nella tua barra degli indirizzi e cambia il valore di signed.applets.codebase_principal_support in true");
         }
      }
      var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
      prefs.setCharPref('browser.startup.homepage', 'http://www.sassarinotizie.com');
   }
} 

function getADVTDPool(pool,account) {
	var uri = 'http://impit.tradedoubler.com/imp?type(js)pool(' + pool + ')a(' + account + ')' + new String(Math.random()).substring(2, 11);
    document.write('<sc' + 'ript type="text/javascript" src="' + uri + '" charset="ISO-8859-1"></sc' + 'ript>');
}

function MoveAds(fromID, toID) {
	$("#" + fromID).appendTo("#" + toID)
}

function SendEncodedEmail(encodedEmail) {
   var email = "";
   for (i = 0; i < encodedEmail.length; ) {
      var letter = "";
      letter = encodedEmail.charAt(i) + encodedEmail.charAt(i + 1)
      email += String.fromCharCode(parseInt(letter, 16));
      i += 2;
   }
   location.href = email;
}

function getCookie(Name) {
   var re = new RegExp(Name + "=[^;]+", "i"); //construct RE to search for target name/value pair
   if (document.cookie.match(re)) //if cookie found
      return document.cookie.match(re)[0].split("=")[1] //return its value
   return ""
}

function setCookie(name, value) {
   var today = new Date();
   var expiry = new Date(today.getTime() + 60 * 24 * 60 * 60 * 1000);
   document.cookie = name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
}

function mycarousel_initCallback(carousel) {
   // Disable autoscrolling if the user clicks the prev or next button.
   carousel.buttonNext.bind('click', function() { carousel.startAuto(0); });
   carousel.buttonPrev.bind('click', function() { carousel.startAuto(0); });
   // Pause autoscrolling if the user moves with the cursor over the clip.
   carousel.clip.hover(function() { carousel.stopAuto(); }, function() { carousel.startAuto(); });
};

/*
* jQuery Tooltip plugin 1.3
* http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ http://docs.jquery.com/Plugins/Tooltip
* Copyright (c) 2006 - 2008 JÃ¶rn Zaefferer $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
* Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html
*/
; (function($) {
   var helper = {}, current, title, tID, IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent), track = false;
   $.tooltip = {
      blocked: false,
      defaults: { delay: 200, fade: false, showURL: false, extraClass: "", top: 15, left: 15, id: "tooltip" },
      block: function() { $.tooltip.blocked = !$.tooltip.blocked; }
   };
   $.fn.extend({
      tooltip: function(settings) {
         settings = $.extend({}, $.tooltip.defaults, settings);
         createHelper(settings);
         return this.each(function() {
            $.data(this, "tooltip", settings);
            this.tOpacity = helper.parent.css("opacity");
            this.tooltipText = this.title;
            $(this).removeAttr("title");
            this.alt = "";
         })
				.mouseover(save)
				.mouseout(hide)
				.click(hide);
      },
      fixPNG: IE ? function() {
         return this.each(function() {
            var image = $(this).css('backgroundImage');
            if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
               image = RegExp.$1;
               $(this).css({
                  'backgroundImage': 'none',
                  'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
               }).each(function() {
                  var position = $(this).css('position');
                  if (position != 'absolute' && position != 'relative')
                     $(this).css('position', 'relative');
               });
            }
         });
      } : function() { return this; },
      unfixPNG: IE ? function() {
         return this.each(function() {
            $(this).css({ 'filter': '', backgroundImage: '' });
         });
      } : function() { return this; },
      hideWhenEmpty: function() {
         return this.each(function() {
            $(this)[$(this).html() ? "show" : "hide"]();
         });
      },
      url: function() {
         return this.attr('href') || this.attr('src');
      }
   });
   function createHelper(settings) {
      if (helper.parent)
         return;
      helper.parent = $('<div id="' + settings.id + '"><h3></h3><div class="body"></div><div class="url"></div></div>')
			.appendTo(document.body)
			.hide();
      if ($.fn.bgiframe)
         helper.parent.bgiframe();
      helper.title = $('h3', helper.parent);
      helper.body = $('div.body', helper.parent);
      helper.url = $('div.url', helper.parent);
   }
   function settings(element) { return $.data(element, "tooltip"); }
   function handle(event) {
      if (settings(this).delay)
         tID = setTimeout(show, settings(this).delay);
      else
         show();
      track = !!settings(this).track;
      $(document.body).bind('mousemove', update);
      update(event);
   }
   function save() {
      if ($.tooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler))
         return;
      current = this;
      title = this.tooltipText;
      if (settings(this).bodyHandler) {
         helper.title.hide();
         var bodyContent = settings(this).bodyHandler.call(this);
         if (bodyContent.nodeType || bodyContent.jquery) {
            helper.body.empty().append(bodyContent)
         } else {
            helper.body.html(bodyContent);
         }
         helper.body.show();
      } else if (settings(this).showBody) {
         var parts = title.split(settings(this).showBody);
         helper.title.html(parts.shift()).show();
         helper.body.empty();
         for (var i = 0, part; (part = parts[i]); i++) {
            if (i > 0)
               helper.body.append("<br/>");
            helper.body.append(part);
         }
         helper.body.hideWhenEmpty();
      } else {
         helper.title.html(title).show();
         helper.body.hide();
      }
      if (settings(this).showURL && $(this).url())
         helper.url.html($(this).url().replace('http://', '')).show();
      else
         helper.url.hide();
      helper.parent.addClass(settings(this).extraClass);
      if (settings(this).fixPNG)
         helper.parent.fixPNG();
      handle.apply(this, arguments);
   }
   function show() {
      tID = null;
      if ((!IE || !$.fn.bgiframe) && settings(current).fade) {
         if (helper.parent.is(":animated"))
            helper.parent.stop().show().fadeTo(settings(current).fade, current.tOpacity);
         else
            helper.parent.is(':visible') ? helper.parent.fadeTo(settings(current).fade, current.tOpacity) : helper.parent.fadeIn(settings(current).fade);
      } else {
         helper.parent.show();
      }
      update();
   }
   function update(event) {
      if ($.tooltip.blocked)
         return;
      if (event && event.target.tagName == "OPTION") { return; }
      if (!track && helper.parent.is(":visible")) { $(document.body).unbind('mousemove', update) }
      if (current == null) { $(document.body).unbind('mousemove', update); return; }
      helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");
      var left = helper.parent[0].offsetLeft;
      var top = helper.parent[0].offsetTop;
      if (event) {
         left = event.pageX + settings(current).left;
         top = event.pageY + settings(current).top;
         var right = 'auto';
         if (settings(current).positionLeft) { right = $(window).width() - left; left = 'auto'; }
         helper.parent.css({ left: left, right: right, top: top });
      }
      var v = viewport(), h = helper.parent[0];
      if (v.x + v.cx < h.offsetLeft + h.offsetWidth) {
         left -= h.offsetWidth + 20 + settings(current).left;
         helper.parent.css({ left: left + 'px' }).addClass("viewport-right");
      }
      if (v.y + v.cy < h.offsetTop + h.offsetHeight) {
         top -= h.offsetHeight + 20 + settings(current).top;
         helper.parent.css({ top: top + 'px' }).addClass("viewport-bottom");
      }
   }
   function viewport() { return { x: $(window).scrollLeft(), y: $(window).scrollTop(), cx: $(window).width(), cy: $(window).height() }; }
   function hide(event) {
      if ($.tooltip.blocked) return;
      if (tID) clearTimeout(tID);
      current = null;
      var tsettings = settings(this);
      function complete() { helper.parent.removeClass(tsettings.extraClass).hide().css("opacity", ""); }
      if ((!IE || !$.fn.bgiframe) && tsettings.fade) {
         if (helper.parent.is(':animated'))
            helper.parent.stop().fadeTo(tsettings.fade, 0, complete);
         else
            helper.parent.stop().fadeOut(tsettings.fade, complete);
      } else
         complete();
      if (settings(this).fixPNG) helper.parent.unfixPNG();
   }
})(jQuery);

/*
* jQuery Maxlength plugin
* @version		$Id: jquery.maxlength.js 18 2009-05-16 15:37:08Z emil@anon-design.se $
* @package		jQuery maxlength 1.0.5
* @copyright	Copyright (C) 2009 Emil Stjerneman / http://www.anon-design.se
* @license		GNU/GPL, see LICENSE.txt
*/
(function($) {
	$.fn.maxlength = function(options) {
		var settings = jQuery.extend(
		{
			events: [], // Array of events to be triggerd
			maxCharacters: 10, // Characters limit
			status: true, // True to show status indicator bewlow the element
			statusClass: "status", // The class on the status div
			statusText: "caratteri rimanenti", // The status text
			notificationClass: "notification", // Will be added to the emement when maxlength is reached
			showAlert: false, // True to show a regular alert message
			alertText: "Hai digitato troppi caratteri.", // Text in the alert message
			slider: false // Use counter slider
		}, options);
		$.merge(settings.events, ['keyup']); // Add the default event
		return this.each(function() {
			var item = $(this);
			var charactersLength = $(this).val().length;
			// Update the status text
			function updateStatus() {
				var charactersLeft = settings.maxCharacters - charactersLength;
				if (charactersLeft < 0) { charactersLeft = 0; }
				item.next("div").html(charactersLeft + " " + settings.statusText);
			}
			function checkChars() {
				var valid = true;
				// Too many chars?
				if (charactersLength >= settings.maxCharacters) {
					valid = false; // Too may chars, set the valid boolean to false
					item.addClass(settings.notificationClass); // Add the notifycation class when we have too many chars
					item.val(item.val().substr(0, settings.maxCharacters)); // Cut down the string
					showAlert(); // Show the alert dialog box, if its set to true
				}
				else {
					if (item.hasClass(settings.notificationClass)) { item.removeClass(settings.notificationClass); }  // Remove the notification class
				}
				if (settings.status) { updateStatus(); }
			}
			// Shows an alert msg
			function showAlert() {
				if (settings.showAlert) { alert(settings.alertText); }
			}
			// Check if the element is valid.
			function validateElement() {
				var ret = false;
				if (item.is('textarea')) { ret = true; } else if (item.filter("input[type=text]")) { ret = true; } else if (item.filter("input[type=password]")) { ret = true; }
				return ret;
			}
			// Validate
			if (!validateElement()) { return false; }
			// Loop through the events and bind them to the element
			$.each(settings.events, function(i, n) {
				item.bind(n, function(e) { charactersLength = item.val().length; checkChars(); });
			});
			// Insert the status div
			if (settings.status) { item.after($("<div/>").addClass(settings.statusClass).html('-')); updateStatus(); }
			// Remove the status div
			if (!settings.status) {
				var removeThisDiv = item.next("div." + settings.statusClass);
				if (removeThisDiv) { removeThisDiv.remove(); }
			}
			// Slide counter
			if (settings.slider) {
				item.next().hide();
				item.focus(function() { item.next().slideDown('fast'); });
				item.blur(function() { item.next().slideUp('fast'); });
			}
		});
	};
})(jQuery);

/*
*  @license You can use it free of charge for private and commercial websites. You can't sell this code. You have to leave the @license and the @author name and website even in minified (or similar) js files Thanks.
*  @name fixBoxModel @type jQuery @cat Plugins/Fixes @author Alessandro Coscia (php_staff [/\] ya hoo [-] it || http://www.programmatorephp.it/jquery)
*/
(function($) {
	$.fn.fixBoxModel = function(options) {
		settings = jQuery.extend({
			force: false // Force fix even if IE7 fix js is detected
		}, options);
		// this browser not implements W3C implementation and (forced by setting or IE7 fix js detected)
		if (!jQuery.support.boxModel && (settings.force || typeof (IE7) != 'object')) {
			return this.each(function() {
				widthDiff = $(this).outerWidth() - $(this).width();
				heightDiff = $(this).outerHeight() - $(this).height();
				$(this).width($(this).outerWidth() + widthDiff);
				$(this).height($(this).outerHeight() + heightDiff);
			});
		}
		return this;
	}
})(jQuery);

/**
 * jQuery.ScrollTo
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 *
 * @projectDescription Easy element scrolling using jQuery.
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 * Works with jQuery +1.2.6. Tested on FF 2/3, IE 6/7/8, Opera 9.5/6, Safari 3, Chrome 1 on WinXP.
 *
 * @author Ariel Flesler
 * @version 1.4.2
 */
(function($) {
   var $scrollTo = $.scrollTo = function(target, duration, settings) {
      $(window).scrollTo(target, duration, settings);
   };
   $scrollTo.defaults = { axis: 'xy', duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1 };
   $scrollTo.window = function(scope) { return $(window)._scrollable(); };
   $.fn._scrollable = function() {
      return this.map(function() {
         var elem = this,
				isWin = !elem.nodeName || $.inArray(elem.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1;
         if (!isWin)
            return elem;
         var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
         return $.browser.safari || doc.compatMode == 'BackCompat' ?
				doc.body :
				doc.documentElement;
      });
   };
   $.fn.scrollTo = function(target, duration, settings) {
      if (typeof duration == 'object') { settings = duration; duration = 0; }
      if (typeof settings == 'function') settings = { onAfter: settings };
      if (target == 'max') target = 9e9;
      settings = $.extend({}, $scrollTo.defaults, settings);
      duration = duration || settings.speed || settings.duration;
      settings.queue = settings.queue && settings.axis.length > 1;
      if (settings.queue) duration /= 2;
      settings.offset = both(settings.offset);
      settings.over = both(settings.over);
      return this._scrollable().each(function() {
         var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');
         switch (typeof targ) {
            case 'number':
            case 'string':
               if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
                  targ = both(targ);
                  break;
               }
               targ = $(targ, this);
            case 'object':
               if (targ.is || targ.style)
                  toff = (targ = $(targ)).offset();
         }
         $.each(settings.axis.split(''), function(i, axis) {
            var Pos = axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					max = $scrollTo.max(elem, axis);
            if (toff) {// jQuery / DOMElement
               attr[key] = toff[pos] + (win ? 0 : old - $elem.offset()[pos]);
               if (settings.margin) {
                  attr[key] -= parseInt(targ.css('margin' + Pos)) || 0;
                  attr[key] -= parseInt(targ.css('border' + Pos + 'Width')) || 0;
               }
               attr[key] += settings.offset[pos] || 0;
               if (settings.over[pos])
                  attr[key] += targ[axis == 'x' ? 'width' : 'height']() * settings.over[pos];
            } else {
               var val = targ[pos];
               attr[key] = val.slice && val.slice(-1) == '%' ?
						parseFloat(val) / 100 * max
						: val;
            }
            if (/^\d+$/.test(attr[key]))
               attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
            if (!i && settings.queue) {
               if (old != attr[key])
                  animate(settings.onAfterFirst);
               delete attr[key];
            }
         });
         animate(settings.onAfter);
         function animate(callback) {
            $elem.animate(attr, duration, settings.easing, callback && function() {
               callback.call(this, target, settings);
            });
         };
      }).end();
   };
   $scrollTo.max = function(elem, axis) {
      var Dim = axis == 'x' ? 'Width' : 'Height',
			scroll = 'scroll' + Dim;
      if (!$(elem).is('html,body'))
         return elem[scroll] - $(elem)[Dim.toLowerCase()]();
      var size = 'client' + Dim,
			html = elem.ownerDocument.documentElement,
			body = elem.ownerDocument.body;
      return Math.max(html[scroll], body[scroll])
			 - Math.min(html[size], body[size]);
   };
   function both(val) {
      return typeof val == 'object' ? val : { top: val, left: val };
   };
})(jQuery);

/* (function($) { $.fn.jCarouselLite = function(o) { o = $.extend({ btnPrev: null, btnNext: null, btnGo: null, mouseWheel: false, auto: null, speed: 200, easing: null, vertical: false, circular: true, visible: 3, start: 0, scroll: 1, beforeStart: null, afterEnd: null }, o || {}); return this.each(function() { var b = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width"; var c = $(this), ul = $("ul", c), tLi = $("li", ul), tl = tLi.size(), v = o.visible; if (o.circular) { ul.prepend(tLi.slice(tl - v - 1 + 1).clone()).append(tLi.slice(0, v).clone()); o.start += v } var f = $("li", ul), itemLength = f.size(), curr = o.start; c.css("visibility", "visible"); f.css({ overflow: "hidden", float: o.vertical ? "none" : "left" }); ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" }); c.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" }); var g = o.vertical ? height(f) : width(f); var h = g * itemLength; var j = g * v; f.css({ width: f.width(), height: f.height() }); ul.css(sizeCss, h + "px").css(animCss, -(curr * g)); c.css(sizeCss, j + "px"); if (o.btnPrev) $(o.btnPrev).click(function() { return go(curr - o.scroll) }); if (o.btnNext) $(o.btnNext).click(function() { return go(curr + o.scroll) }); if (o.btnGo) $.each(o.btnGo, function(i, a) { $(a).click(function() { return go(o.circular ? o.visible + i : i) }) }); if (o.mouseWheel && c.mousewheel) c.mousewheel(function(e, d) { return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll) }); if (o.auto) setInterval(function() { go(curr + o.scroll) }, o.auto + o.speed); function vis() { return f.slice(curr).slice(0, v) }; function go(a) { if (!b) { if (o.beforeStart) o.beforeStart.call(this, vis()); if (o.circular) { if (a <= o.start - v - 1) { ul.css(animCss, -((itemLength - (v * 2)) * g) + "px"); curr = a == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll } else if (a >= itemLength - v + 1) { ul.css(animCss, -((v) * g) + "px"); curr = a == itemLength - v + 1 ? v + 1 : v + o.scroll } else curr = a } else { if (a < 0 || a > itemLength - v) return; else curr = a } b = true; ul.animate(animCss == "left" ? { left: -(curr * g)} : { top: -(curr * g) }, o.speed, o.easing, function() { if (o.afterEnd) o.afterEnd.call(this, vis()); b = false }); if (!o.circular) { $(o.btnPrev + "," + o.btnNext).removeClass("disabled"); $((curr - o.scroll < 0 && o.btnPrev) || (curr + o.scroll > itemLength - v && o.btnNext) || []).addClass("disabled") } } return false } }) }; function css(a, b) { return parseInt($.css(a[0], b)) || 0 }; function width(a) { return a[0].offsetWidth + css(a, 'marginLeft') + css(a, 'marginRight') }; function height(a) { return a[0].offsetHeight + css(a, 'marginTop') + css(a, 'marginBottom') } })(jQuery); */

(function($) {                                          // Compliant with jquery.noConflict()
   $.fn.jCarouselLite = function(o) {
      o = $.extend({
         btnPrev: null,
         btnNext: null,
         btnGo: null,
         mouseWheel: false,
         auto: null,
         hoverPause: false,
         
         speed: 200,
         easing: null,

         vertical: false,
         circular: true,
         visible: 3,
         start: 0,
         scroll: 1,

         beforeStart: null,
         afterEnd: null
      }, o || {});

      return this.each(function() {                           // Returns the element collection. Chainable.

         var running = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width";
         var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;

         if (o.circular) {
            ul.prepend(tLi.slice(tl - v - 1 + 1).clone())
              .append(tLi.slice(0, v).clone());
            o.start += v;
         }

         var li = $("li", ul), itemLength = li.size(), curr = o.start;
         div.css("visibility", "visible");

         li.css({ overflow: "hidden", float: o.vertical ? "none" : "left" });
         ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" });
         div.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" });

         var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
         var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
         var divSize = liSize * v;                           // size of entire div(total length for just the visible items)

         li.css({ width: li.width(), height: li.height() });
         ul.css(sizeCss, ulSize + "px").css(animCss, -(curr * liSize));

         div.css(sizeCss, divSize + "px");                     // Width of the DIV. length of visible images

         if(o.btnPrev) {
            $(o.btnPrev).click(function() {
               return go(curr-o.scroll);
            });
            if(o.hoverPause) {
               $(o.btnPrev).hover(function(){stopAuto();}, function(){startAuto();});
            }
         }
         if(o.btnNext) {
            $(o.btnNext).click(function() {
               return go(curr+o.scroll);
            });
            if(o.hoverPause) {
               $(o.btnNext).hover(function(){stopAuto();}, function(){startAuto();});
            }
         }

         if (o.btnGo)
            $.each(o.btnGo, function(i, val) {
               return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll);
            });

         if (o.mouseWheel && div.mousewheel)
            div.mousewheel(function(e, d) {
               return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll);
            });

         var autoInterval;
         function startAuto() {
            autoInterval = setInterval(function() {
               go(curr+o.scroll);
            }, o.auto+o.speed);
         };

         function stopAuto() { clearInterval(autoInterval); };
         if(o.auto) { if(o.hoverPause) { div.hover(function(){stopAuto();}, function(){startAuto();}); }
            startAuto();
         };

         function vis() {
            return li.slice(curr).slice(0, v);
         };

         function go(to) {
            if (!running) {

               if (o.beforeStart)
                  o.beforeStart.call(this, vis());

               if (o.circular) {            // If circular we are in first or last, then goto the other end
                  if (to <= o.start - v - 1) {           // If first, then goto last
                     ul.css(animCss, -((itemLength - (v * 2)) * liSize) + "px");
                     // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
                     curr = to == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll;
                  } else if (to >= itemLength - v + 1) { // If last, then goto first
                     ul.css(animCss, -((v) * liSize) + "px");
                     // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements.
                     curr = to == itemLength - v + 1 ? v + 1 : v + o.scroll;
                  } else curr = to;
               } else {                    // If non-circular and to points to first or last, we just return.
                  if (to < 0 || to > itemLength - v) return;
                  else curr = to;
               }                           // If neither overrides it, the curr will still be "to" and we can proceed.

               running = true;

               ul.animate(
                    animCss == "left" ? { left: -(curr * liSize)} : { top: -(curr * liSize) }, o.speed, o.easing,
                    function() {
                       if (o.afterEnd)
                          o.afterEnd.call(this, vis());
                       running = false;
                    }
                );
               // Disable buttons when the carousel reaches the last/first, and enable when not
               if (!o.circular) {
                  $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                  $((curr - o.scroll < 0 && o.btnPrev)
                        ||
                       (curr + o.scroll > itemLength - v && o.btnNext)
                        ||
                       []
                     ).addClass("disabled");
               }

            }
            return false;
         };
      });
   };

   function css(el, prop) {
      return parseInt($.css(el[0], prop)) || 0;
   };
   function width(el) {
      return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
   };
   function height(el) {
      return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
   };

})(jQuery);
