/*** hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+* <http://cherne.net/brian/resources/jquery.hoverIntent.html>** @param  f  onMouseOver function || An object with configuration options* @param  g  onMouseOut function  || Nothing (use configuration options object)* @author    Brian Cherne <brian@cherne.net>*///(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);function setEqualHeight(columns) {    var tallestColumn = 0;    $(columns).each(function() {        currentHeight = $(this).height();        if (currentHeight > tallestColumn) {            tallestColumn = currentHeight;        }    });    $(columns).height(tallestColumn);}function carousel(tabWrapper, slideshowItems) {    if($('body#homepage').length){        var tabCount;        var i;        tabCount = slideshowItems.length;        //console.log(tabCount);        i = 1;        $(slideshowItems).each(function() {           $(tabWrapper).append('<a href="#">' + i + '</a>');           i++;        });        $(tabWrapper).tabs(slideshowItems, {                // enable "cross-fading" effect                effect: 'fade',                fadeInSpeed: 400,                fadeOutSpeed: 400,                // start from the beginning after the last tab                rotate: true        // use the slideshow plugin. It accepts its own configuration        }).slideshow({            autoplay: true,            autopause: true,            //pause: 2000,            clickable: true,            interval: 8000        });        var slideshowApi = $(tabWrapper).data('slideshow');        console.log('API:');        console.log(slideshowApi);        // setTimeout(function() {        //      slideshowApi.play(function() {        //          setTimeout(function() {        //              slideshowApi.stop();        //          }, 1600);        //      });        // }, 800);        //alert(api.slideshow.pause(1));    }}// Remove semantic editor plugin wrappersfunction removeSEElement(replacedElement) {    //var thePlugin = $(replacedElement).html();    if(replacedElement) {        //console.log(thePlugin);        $(replacedElement + ' > *').unwrap();    }}function pToSmall(p) {    var text = $(p).text();    var pClass = $(p).attr('class');    $(p).replaceWith('<small class="' + pClass +'">' + text + '</small>');}function convertToTabs(el) {    // get the headings    var tabHeaderElements = $(el).find('.column div h3');    // create an array from the header elements    var tabHeaders = [];    //tabHeaders.reverse();    $(tabHeaderElements).each(function(i, elem) {        tabHeaders.push($(elem).text());    });    //var tabText = tabHeaderElements.text();    var tabList = '<ul class="tabs">';    //console.log(tabText);    console.log(tabHeaders);    for(i=0; i < tabHeaders.length; i++) {        tabList += '<li><a href="#">' + tabHeaders[i] + '</a></li>';    }    tabList += '</ul>';    //console.log(tabList);    $(el).addClass('infotabs');    $(el).prepend(tabList);    //$(el).find('div.div').removeClass('div inner');    $(el).find('div.column').wrapAll('<div class="panes" />');    $(el).find('.panes div div').addClass('inner');    $(el).find('.panes div div').children().removeClass('inner');    $(el).find(' .inner h3').remove();    $(el).find('.inner figure').unwrap();    $(el).find('.inner figure img').unwrap();}function convertToBoxout(boxout) {    // find the columns    var colCount = $(boxout).find('.column').length;    //var heading = $(el).find('h3');    //alert(containerCols[]);    var image = $(boxout).find('figure img');    var boxoutHtml = $(boxout).html();    //console.log(boxoutHtml);    // seek out the image so we can wrap it in a figure element    //var imgClean = $(boxout + ' div.column img').unwrap();    //console.log(imgClean);    var figure = $(boxout).find(' figure').unwrap();    var hasFigure = $(boxout).find(' figure').length;    if(hasFigure > 0) {        hasFigure = true;    }    var inner = $(boxout).find('div.column').wrapAll('<div class="inner clearfix" />');    // unwrap the 2nd divs content and give us it's elements    if($(boxout).find(' .inner div.lastcolumn')) {        $(boxout).find(' .inner div.lastcolumn div').addClass('content');    } else {        $(boxout).find('div.column div').addClass('content');    }    var content = $(boxout).find('div.column > *').unwrap();    figure += $(figure).unwrap();    $(boxout).find('div.lastcolumn div > *').unwrap();    //console.log(content);    if(hasFigure > 0) {        $(boxout).addClass('with-media');    }    boxout += inner;    if(hasFigure > 0) {        boxout += figure;    }    boxout += content;}function convertToPullquote(pullquote) {    // find the columns    var pcolCount = $(pullquote).find('.column').length;    //var heading = $(el).find('h3');    //alert(containerCols[]);    var pimage = $(pullquote).find('figure img');    var pullquoteHtml = $(pullquote).html();    //console.log(pullquoteHtml);    // seek out the image so we can wrap it in a figure element    //var imgClean = $(boxout + ' div.column img').unwrap();    //console.log(imgClean);    var pfigure = $(pullquote).find('figure').unwrap();    var phasFigure = $(pullquote).find('figure').length;    if(phasFigure > 0) {        var pinner = $(pullquote).find('div.column').wrapAll('<div class="inner clearfix" />');    } else {       // $(pullquote).find('div div').replace(pullquoteHtml);        var pinner = $(pullquote).find('div').wrapAll('<div class="inner clearfix" />');    }    // unwrap the 2nd divs content and give us it's elements    if($(pullquote).find(' .inner div.lastcolumn')) {        $(pullquote).find(' .inner div.lastcolumn div').addClass('content');        var pheading = $(pullquote).find('.content h3').text();        $(pullquote).find('figure').append('<figcaption>' + pheading + '<figcaption>');        $(pullquote).find('.content h3, figcaption figcaption').remove();    } else {        $(pullquote).find('div.column div').addClass('content');    }    var pcontent = $(pullquote).find('div.column > *').unwrap();    if(phasFigure > 0) {        pfigure += $(pfigure).unwrap();    }    $(pullquote).find('div.lastcolumn div > *').unwrap();    //console.log(content);    if(phasFigure > 0) {        $(pullquote).addClass('with-media');    }    pullquote += pinner;    if(phasFigure > 0) {        pullquote += pfigure;    }    pullquote += pcontent;}// tooltip function/*function extraInfo(infoTrigger) {    $("#primary-content .related-items .extra-info").appendTo("primary-content");    var ua = $.browser;    var target = $(infoTrigger).attr('href');    if (ua.msie){        $(infoTrigger).wijtooltip();    } else {        $(infoTrigger).wijtooltip(            {"options": {                "content": "This is the target: " + target + ".",                "animation": {animated: "fade", duration: 100, easing: null}            },        });    }    $(infoTrigger).wijtooltip({ showCallOut: false, calloutFilled: false,        position: { my: 'center top', at: 'left top' },        height: 355, width: 405, offset: '0, 0',        triggers: 'hover',        hideDelay: 900,        ajaxCallback: function () {            var ele = $('div' + this.attr('href'));            console.log(ele);            this.wijtooltip("option", "content", ele.html());        }        });    $('.wijmo-wijtooltip-container').addClass('extra-info');}*/$(document).ready(function() {    setEqualHeight('.key-page');   var alertFallback = true;   if (typeof console === "undefined" || typeof console.log === "undefined") {     console = {};     if (alertFallback) {         console.log = function(msg) {              //alert(msg);         };     } else {         console.log = function() {};     }   }    pToSmall('.boxout p.copyright, .pullquote p.copyright');    convertToTabs('#primary-content .columns4, #primary-content .infotabs');    $('ul.tabs').tabs('div.panes > div', {        effect: 'fade'    });    removeSEElement('p + div.div');    $('p + figure.clearfix').removeClass('clearfix');    $('.related-items .more-info').tooltip({        effect: "fade",        relative: true,        position: "top left",        offset: [0, 200],        fadeInSpeed: 300,        fadeOutSpeed: 200    });    //extraInfo('.more-info');    carousel('.feature-tabs', '#featured .images > section');    convertToBoxout('#primary-content .boxout');    convertToPullquote('#primary-content .pullquote');    //$('#secondary-content *').show();});
