(function($) { 

// random background images
var randomImages = ['bg0','bg1','bg2'];
var rndNum = Math.floor(Math.random() * randomImages.length); 
$("html, body#Body").css("background","#ebe9e8 url(/Portals/74282/images/blog/bg" + rndNum + "-new.jpg) no-repeat fixed center top");

var valueArray = new Array();
arrayIndex = 0;
var minValue;

$(document).ready(function() {

    //Non-IE browsers wrap post content in div.postContent
    if (! $.browser.msie) {
	$(".post").each(function(){
		var title = $(this).find(".title");
		var byline = $(this).find(".byline");
		var submissions = $(this).find(".submissions");
		$(this).find(".submissions,.title,.byline,.comments,.tags").remove();
		var postContent = $(this).html();
		$(this).empty();
		$(this).append('<div class="postContent">' + postContent + '</div>');
		$(submissions).prependTo($($(this)));
		$(byline).prependTo($($(this)));
		$(title).prependTo($($(this)));
	});
        $('#bb-container div.listing div.postContent').truncate({max_length:100,more:"More",less:"Less"});
    }

// hide h1 tag
$("#brighton_col2 h1:contains('Welcome to the IdeaBlog')").remove();

// hide blog navigation
if(! $("#hsnavigation").length) {
	$("p.Normal:has(a.MenuTopSelected)").css("display","none");
	$("#bb-container a.CommandButton").css("display","none");
	$("#bb-container div.blognav").css("display","none");
}


// removing objects from blog home
$("#bb-container div.listing div.comments").css("display","none");
$("#bb-container div.listing div.tags").css("display","none");

// move search to column 3
//$("#googlesearchbox").prependTo("#brighton_col3");

// class for blog blocks
$("div.block div.pad:has(.BloggerBrowseByTags)").addClass("tagcloud");
$("div.block div.pad:has(.IngeniMailSubscribeContainer)").addClass("subscribe");
$("div.block div.pad:has(#samplejoin)").addClass("samplejoin");
$("div.block div.pad:has(h3:contains('Archive'))").addClass("archive");

//subscribe module
$("div.subscribe .subhead").html("<h4>Subscribe By Email</h4>");
$("div.subscribe .IngeniMailSubscribeContainer div:has(.IngeniMailSubscribeEmailInput)").addClass("subscribe-container");
$("div.subscribe .IngeniMailSubscribeButton").appendTo("div.subscribe-container");
$("div.subscribe .IngeniMailSubscribeButton").val("");

//social icons
$("div.block:has(#social-icons)").addClass("social-icons");

//combine social icons and subscribe module
$("div.social-icons").prependTo("div.subscribe .IngeniMailSubscribeContainer");

});

$(window).load(function() {

// tag cloud
// move tag number to value
$("ul#_TagList li a").each(function (i) {
	//Get the inner html from the a:link
	var itemHtml = $(this).html();

	//Find index of first parenthesis
	var valIndex = itemHtml.indexOf("(");

	var value = itemHtml.substring(valIndex,itemHtml.length);

	//Remove value from the link
	itemHtml = itemHtml.replace(value,"");

	//Get the Numerical value
	var value = value.replace("(","");
	var value = value.replace(")","");

	$(this).parent().attr("value",value);
	$(this).html(itemHtml);

	valueArray[arrayIndex] = value;				
        arrayIndex ++;

});

//set minValue which is called in the tag cloud function
minValue = Math.min.apply(0,valueArray);

// initiate tag cloud
$("#_TagList").tagcloud({type:"list",sizemin:10,sizemax:20,colormax:"333333",colormin:"888888",}).find("li");

});

})(jQuery);
