$(document).ready(function() {
$(".level1activeitem").toggleClass("level1activeitem").toggleClass("level1");
//console.log($(".level1").get(0).innerHTML);
$($(".level1").get(0)).toggleClass("level1activeitem").toggleClass("level1");
$(".level1activeitem").prev().find("img").attr("src","/stellent/images/CorporateRefocus/minus_icon.gif");
$(".level2wrapperactiveitem").find("img").attr("src","/stellent/images/CorporateRefocus/minus_icon.gif");
$(".level1").prev().find("img").attr("src","/stellent/images/CorporateRefocus/plus_icon.gif");
$(".level2wrapperinactiveitems").find("img").attr("src","/stellent/images/CorporateRefocus/plus_icon.gif");
$(".level1activeitem, .level1").prev().find("img").attr("alt","Click to expand");
$(".level2wrapperactiveitem, .level2wrapperinactiveitems").find("img").attr("alt","Click to expand");
$(".level1").find("div.level2wrapperinactiveitems").hide();
$("div.level2wrapperinactiveitems").find("div.level3").hide();

// Actions
$("a.widgetlevel1").click(function() {
$(this).parent().next().find("div.level2wrapperinactiveitems,div.level2wrapperactiveitem").slideToggle('fast');
$(this).parent().next().find("level3wrapperactive").toggleClass("level3wrapperactive");
$(this).parent().next().toggleClass("level1activeitem").toggleClass("level1");
if($(this).find("img").attr("src").indexOf("plus_icon.gif") != -1)
$(this).find("img").attr("src","/stellent/images/CorporateRefocus/minus_icon.gif");
else
$(this).find("img").attr("src","/stellent/images/CorporateRefocus/plus_icon.gif");
return false;
})

$("a.widgetlevel2").click(function() {
$(this).parent().next().find("div.level3").slideToggle('fast');
$(this).parent().next().find("div.level3wrapper").find("h4").toggleClass("active");
$(this).parent().parent().toggleClass("level2wrapperactiveitem").toggleClass("level2wrapperinactiveitems");
if($(this).find("img").attr("src").indexOf("plus_icon.gif") != -1)
$(this).find("img").attr("src","/stellent/images/CorporateRefocus/minus_icon.gif");
else
$(this).find("img").attr("src","/stellent/images/CorporateRefocus/plus_icon.gif");
return false;
})

$("a#expandall").click(function() {
$("div.level1").addClass("level1activeitem");
$("div.level1").removeClass("level1");
$("div.level2wrapperinactiveitems").addClass("level2wrapperactiveitem");
$("div.level2wrapperinactiveitems").removeClass("level2wrapperinactiveitems");
$("div.level3wrapper").find("h4").addClass("active");
//update display
$("div.level1activeitem").show();
$("div.level1activeitem").find("div").show();
//change images to minus
$(".widgetwrapper a img").attr("src","/stellent/images/CorporateRefocus/minus_icon.gif");
})

$("a#collapseall").click(function() {
$("div.level2wrapperactiveitem").addClass("level2wrapperinactiveitems");
$("div.level2wrapperactiveitem").removeClass("level2wrapperactiveitem");
$("div.level2wrapperinactiveitems").hide();
$("div.level2wrapper").hide();
$("div.level1activeitem").addClass("level1");
$("div.level1activeitem").removeClass("level1activeitem");
$("div.level1activeitem").find("h2").removeClass("level1headingOn");
$("div.level3wrapper").find("h4").removeClass("active");
$("div.level3").hide();
//change images to plus
$(".widgetwrapper a img").attr("src","/stellent/images/CorporateRefocus/plus_icon.gif");
})
})

