<!-- HIDE RIGHT COLUMN IF EMPTY -->
function stripHTML(str) {
    //    /<&#91;^>&#93;*>/g
    return str.replace(/<\S[^><]*>/g,'');
}

function isEmpty(str,checktag) {
    //EXEMPT IS OPTIONAL
    var checktag = (typeof checktag == "undefined") ? 'none' : checktag;
    var blnEmpty = true;
    var arrCheckTag = checktag.split(',');
    str = str.toLowerCase();
    
    //LOOK FOR EXEMPT TAGS, LIKE 'IMG'
    for (var i = 0; i < arrCheckTag.length; i++) {
        if (str.indexOf('<'+arrCheckTag[i]) != -1) {
            blnEmpty = false;
            break;
        }
    }
    
    //IF NO EXEMPT TAGS, RUN REGEX
    if (blnEmpty) {
        str = stripHTML(str);
        str = str.replace(/^\s+/g,''); //REMOVE SPACES
        if (str.length > 0) {
            blnEmpty = false;
        }
    }
    
    return blnEmpty;
}

//PROCEDURAL
if ($('#layout-right').length) {
	objRightCol = document.getElementById("layout-right");
	if (isEmpty(objRightCol.innerHTML,'img,meta,form,input,textarea,submit')) {
		objRightCol.style.display = 'none';
		document.getElementById("layout-article").style.marginRight = "0";
	}
}

// ++++++++++++++++++++++ SLIDESHOW ++++++++++++++++++++++
//CHECK FOR SLIDESHOW - PROCEDURAL
//http://www.kevinleary.net/jquery-fadein-fadeout-problems-in-internet-explorer/
(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeTo = function(speed,to,callback) {
		return this.animate({opacity: to}, speed, function() {
			if (to == 1 && jQuery.browser.msie)
				this.style.removeAttribute('filter');
			if (jQuery.isFunction(callback))
				callback();
		});
	};
})(jQuery);

//ADAPTED FROM http://jonraasch.com/blog/a-simple-jquery-slideshow
function slideSwitch() {
	//SET CURRENT
	var $slideclass = $('.slideshow .dfwp-item');
	var $active = $('.slideshow .active')
	$active.customFadeIn(750);
	$('.last').customFadeOut(750);
	
	//CHECK FOR CLASS TO LOOP OR JUST ONCE
	if ($active.find('img').attr('src')  == $slideclass.last().find('img').attr('src')) {
		if ($('.slideshow').hasClass('once')) {
			clearInterval(slideshowtimer);
		} else {
			//SET NEXT
			$slideclass.first().removeClass('last').addClass('active');
			$active.removeClass('active').addClass('last');
		}
	} else {
		//SET NEXT
		$active.next().removeClass('last').addClass('active');
		$active.removeClass('active').addClass('last');
	}

	//SET SLIDESHOW TO VISIBLE, REALLY ONLY THE FIRST TIME
	$slideclass.css('visibility','visible');
}

// PROCEDURAL :: CHECK FOR SLIDESHOW
if ($('.slideshow').length) {
	$('.slideshow .dfwp-item').customFadeOut(0);
	$('.slideshow .dfwp-item').first().addClass('active');
	$('.slideshow .dfwp-item').last().addClass('last');
	$('.slideshow .active').css('visibility','visible');
	$('.slideshow .active').customFadeIn(750);
	var slideshowtimer = setInterval("slideSwitch();",5000);
}
// ++++++++++++++++++++++ SLIDER ++++++++++++++++++++++
function showSlider() {
	$(this).children('.slider').animate({"top": "-=80px"},300);
	$(this).children('.slider').css('zIndex','7');
}

function hideSlider() {
	$(this).children('.slider').animate({"top": "+=80px"},300);
	$(this).children('.slider').css('zIndex','5');
}

if ($('.category').length) {
	$(".category").hoverIntent({    
	     sensitivity: 4, //7
	     interval: 50, //100
	     over: showSlider,
	     timeout: 300, //0
	     out: hideSlider
	});
}

