﻿/**
 * jQuery liftTools plugin
 * @version 0.2
 * @date Nov 11, 2009
 * @author Eli Dupuis
 * @copyright (c) 2009 Lift Interactive (http://liftinteractive.com)
 * @license Creative Commons Attribution 3.0 Unported License (http://creativecommons.org/licenses/by/3.0)
 * @requires jQuery 1.3.2 or later (will likely work with previous verions as well)
 *
 * [liftTools.divide-0.2], [liftTools.defaultText-0.3], [liftTools.dropdown-0.2], [liftTools.qCycle-0.2], [liftTools.blockify-0.1]
 *
*/
(function(a){var i="0.2";jQuery.fn.divide=function(h){return this.each(function(){var c=a(this),e=a.extend({},a.fn.divide.defaults,h);c=e.target?c.find(e.target):c;var f=c.children(),b=f.length;if(b>e.threshold){var d=c[0].tagName,g=Math.floor(b/e.cols);b=b%e.cols;var j;j=e.target?c.parent():a("<"+e.wrapper+">");c.attr("class")&&j.attr("class",c.attr("class"));c.attr("id")&&j.attr("id",c.attr("id"));for(var k=0;k<e.cols;k++){var l=g;if(k<b)l=g+1;var m=a("<"+d+' class="column-'+(k+1)+'">');m.append(f.slice(0,l));j.append(m);f=f.filter(":gt("+(l-1)+")")}e.target?c.remove():c.replaceWith(j)}})};a.fn.divide.defaults={threshold:0,cols:2,wrapper:"div",target:null};a.fn.divide.ver=function(){return"jquery.divide ver. "+i}})(jQuery);
(function(a){var i="0.3";jQuery.fn.defaultText=function(h){return this.each(function(){var c=a(this),e=a.extend({},a.fn.defaultText.defaults,h);if(e.force){c.data("orig",e.text);c.val(e.text)}else c.data("orig",c.val()!=""?c.val():e.text);c.focus(function(){window.console&&window.console.log("focus");a(this).val()==c.data("orig")||e.clearOnFocus?a(this).val(""):a(this).select()});c.blur(function(){a(this).val()==""&&a(this).val(c.data("orig"))});c.blur()})};a.fn.defaultText.defaults={text:"Search",force:false,clearOnFocus:false};a.fn.defaultText.ver=function(){return"jquery.defaultText ver. "+i}})(jQuery);
(function(a){var f="0.2";a.fn.dropdown=function(g){var e=a.extend({},a.fn.dropdown.defaults,g),d=[];return this.each(function(){$this=a(this);var b=a.meta?a.extend({},e,$this.data()):e;if(a.browser.mozilla){$this.removeAttr("title");$this.find("*[title]").each(function(){a(this).removeAttr("title")})}a(this).hover(function(){var c=a.data(this),h=a(this);d[c]=setTimeout(function(){h.find(b.child).fadeIn(b.speedIn);d[c]=""},b.delay)},function(){var c=a.data(this);d[c]!=""?clearTimeout(d[c]):a(this).find(b.child).fadeOut(b.speedOut)})})};a.fn.dropdown.defaults={delay:100,speedIn:300,speedOut:200,child:"ul"};a.fn.dropdown.ver=function(){return"jquery.dropdown version "+f}})(jQuery);
(function(a){var e="0.1";jQuery.fn.blockify=function(f){return this.each(function(){var c=a(this),b=a.extend({},a.fn.blockify.defaults,f),d=c.find(b.selector);b.pointer&&a(this).css({cursor:"pointer"});b.hoverClass&&c.hover(function(){a(this).addClass(b.hoverClass)},function(){a(this).removeClass(b.hoverClass)});c.click(function(g){if(g.target.nodeName.toLowerCase()!="a")if(h()=="")if(d.hasClass(b.externalClass))window.open(d.attr("href"));else window.location=d.attr("href")})})};a.fn.blockify.defaults={selector:"a:last",pointer:true,hoverClass:"hover",externalClass:"ext"};a.fn.blockify.ver=function(){return"jquery.blockify ver. "+e};function h(){if(window.getSelection)return window.getSelection().toString();else if(document.getSelection)return document.getSelection();else if(document.selection)return document.selection.createRange().text}})(jQuery);
/* jquery.qCycle */
(function($) {
var ver = '0.2';
$.fn.qCycle = function(options) {
    // build main options before element iteration:
    var opts = $.extend({}, $.fn.qCycle.defaults, options);
    return this.each(function() {
        $this = $(this);
        // build element specific options:
        var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
        $this.data('qCycle.opts',o);
        $(window).load(function(){
            initSlideshow($this);
        });
    });
};
function initSlideshow(obj){
    var o = obj.data('qCycle.opts');
    obj.data( 'qCycle.slidesLoaded', 0 );
    
    var loaded = obj.data( 'qCycle.slidesLoaded' );
    if (o.toLoad != null) $('<img/>').load(function(){ 
            addSlide($(this),obj,true);
        }).data(
            'slideData',o.toLoad[loaded]
        ).attr(
            'src',o.toLoad[loaded].img
        );
    
    obj.data( 'qCycle.slidesLoaded', obj.data( 'qCycle.slidesLoaded' )+1 );
    
};
function startSlideshow(obj){
    var o = obj.data('qCycle.opts');
    var loaded = obj.data( 'qCycle.slidesLoaded' );
    //    homepage feature cycle
    var slideshow = obj.cycle(o.cycleOpts);        //    start cycle
    obj.data('qCycle.cycleOpts', $(slideshow).data('cycle.opts'));    //    grab reference to cycle so we can use cycle.addSlide() later
    if (loaded < obj.data('qCycle.opts').toLoad.length) loadSlide(obj);
    obj.data( 'qCycle.slidesLoaded', obj.data( 'qCycle.slidesLoaded' )+1 );        //    increment loaded counter
};
function loadSlide(obj){
    var loaded = obj.data( 'qCycle.slidesLoaded' );
    
    $('<img/>').load(function(){ 
            addSlide($(this),obj);
        }).data(
            'slideData',obj.data('qCycle.opts').toLoad[loaded]
        ).attr(
            'src',obj.data('qCycle.opts').toLoad[loaded].img
        );
};
function addSlide(img,obj,init){
    
    var cycleOpts = obj.data('qCycle.cycleOpts');
    var slide = obj.data('qCycle.opts').createSlide.call(this,img);
    //    add newly loaded slide:
    if (init == true) {
        //    first pass. use standard jquery.append because cycle is not initialized yet.
        obj.append(slide);
        startSlideshow(obj);
    }else{
        //    not first pass. add slide via cycle.addSlide() function:
        cycleOpts.addSlide(slide);
    };
    
    //    update counters and initiate loading of next image (if there's more tho load!):
    var loaded = obj.data( 'qCycle.slidesLoaded' );
    if (loaded < obj.data('qCycle.opts').toLoad.length ) loadSlide(obj);
    obj.data( 'qCycle.slidesLoaded', obj.data( 'qCycle.slidesLoaded' )+1 );
    
};

//
// plugin defaults
//
$.fn.qCycle.defaults = {
    toLoad: null,                                    //    array of objects. each object must have attribute 'img' that contains the url of an image to load.
    cycleOpts:{},                                    //    passed directly into jQuery.cycle on init. see http://www.malsup.com/jquery/cycle/options.html for options.
    createSlide: function(img){    return img;    }        //    function where slides are created. default just returns the loaded image.
};
//    public function/method
$.fn.qCycle.ver = function() { return "jquery.qCycle version " + ver; };

})(jQuery);

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(d,c,a){if(typeof c!="undefined"){a=a||{};if(c===null){c="";a.expires=-1}var b="";if(a.expires&&(typeof a.expires=="number"||a.expires.toUTCString)){if(typeof a.expires=="number"){b=new Date;b.setTime(b.getTime()+a.expires*24*60*60*1E3)}else b=a.expires;b="; expires="+b.toUTCString()}var e=a.path?"; path="+a.path:"",f=a.domain?"; domain="+a.domain:"";a=a.secure?"; secure":"";document.cookie=[d,"=",encodeURIComponent(c),b,e,f,a].join("")}else{c=null;if(document.cookie&&document.cookie!= ""){a=document.cookie.split(";");for(b=0;b<a.length;b++){e=jQuery.trim(a[b]);if(e.substring(0,d.length+1)==d+"="){c=decodeURIComponent(e.substring(d.length+1));break}}}return c}};
