// Tell a Friend Popup
var s5_taf_parent = window.location;
function s5_open_taf_popup() {
window.open('/modules/mod_S5tellafriend/tellafriend.htm','page','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=570,left=50,top=50,titlebar=yes')
}
// Blog Email Popup
function s5_blogemail() {
window.open('/modules/mod_S5tellafriend/email_blog.html','page','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=570,left=50,top=50,titlebar=yes')
}


var $j = jQuery.noConflict();


$j(document).ready(function(){

	// Temporary fix to hide intro copy on article view by makig first paragraph invisible.
	$j("div.resourcearticle div.article-content p:first").css({"display":"none"});


	// Submenu styles
	$j("ul.sf-menu li li:first-child span").css({"border-top":"2px solid #5b70bd"});
	$j("ul.sf-menu li li:last-child").css({"border-bottom":"2px solid #5b70bd"});
	$j("ul.sf-menu li li#current").parent("ul").parent("li").addClass("currentParent");
	/*$j("ul.sf-menu li li").removeClass("parent");
	$j("ul.sf-menu li li ul").replaceWith("");*/
	
	
	// Star ratings style changes
	$j("div.rating span:first").css({"float":"left"});
	$j("div.rating span:last").css({"width":"auto"}).css({"clear":"none"}).css({"line-height":"25px"}).css({"margin-left":"10px"}).css({"font-weight":"normal"});
	
	// Checklist styles
	$j("div.checklist ul li:first-child").addClass("checklist_first");
	$j("div.checklist ul li ul li:first-child").removeClass("checklist_first");
	$j("div.checklist ul li:odd").addClass("checklist_odd");
	$j("div.checklist ul li:last-child").addClass("checklist_last");
	$j("div.checklist ul li ul li:last-child").removeClass("checklist_last");
	$j("#checklistmods_printtop img").attr({src: "/templates/images/but_printchecklist.gif"}); // printable buttons
	$j("#checklistmods_printmain img").attr({src: "/templates/images/but_printchecklist_lrg.gif"}); // printable buttons
	
	
	// Bottom Nav styles
	$j("#nav_bot ul li:last-child").css({"border":"none"});
	
	// Set bottom padding of page to match the footer height
	var footerheight =  $j("#footer").height();
	var extraPad = footerheight+20;
	$j("#container").css({"padding-bottom":extraPad});
	
	
	// Copy checklist module from hidden DIV to inside article
	$j("#checklistmods *").prependTo("#checklistmods_dupe");
	
	$j("span.pagenavcounter").prependTo("#pageofpage");
	
	// Category listing styles
	$j("div.category_item:first").css({"border-top":"1px solid #c0c1c5"});
	// Cloning & styling pagination
	//$j("span.pagination").wrap('<div id="pagenav_toclone"></div>');
	$j("#pagenav_toclone span.pageitem:first").removeClass("pageitem");
	$j("#pagenav_toclone").prependTo("div.blog div.pagination_dupe");
	//$j("div.pagination_dupe br").replaceWith("<span></span>");
	
	
	// Format Signature Article Module
	$j("div.jstcltblcol2_signature").prependTo("div.jstcltbl_signature");
	$j("div.jstcltblrow_signature0 a:first").prependTo("div.jstcltbl_signature").css({"float":"left"});
	$j("div.jstcltbl_signature a.readmore_sig").appendTo('div.jstcltblrow_signature0');
	$j("div.jstcltbl_signature").append('<div class="cleared">&nbsp;</div>');
	
	// Format Featured Article Module
	$j("#jstcltblrow0 div.jstcltblcol2_featured *").prependTo('#jstcltblrow0 div.jstcltblcol1_featured a');
	$j("#jstcltblrow1 div.jstcltblcol2_featured *").prependTo('#jstcltblrow1 div.jstcltblcol1_featured a');
	$j("#jstcltblrow2 div.jstcltblcol2_featured *").prependTo('#jstcltblrow2 div.jstcltblcol1_featured a');
	$j("div.jstcltbl_featured div div").parent("div").css({"float":"left"});	
	$j("div.jstcltbl_featured").append('<div class="cleared">&nbsp;</div>');
	
	// Poll
	$j("div.pollwrapper table").replaceWith("");
	
	$j("div.category_item tr").replaceWith("");
	$j("div.category_item td").replaceWith("");
	$j("div.category_item").append('<div class="cleared">&nbsp;</div>');
	
	// Section Page Styles
	$j("div.sectionIntro").parent("div.contentpaneopen").addClass("sectionLanding");
	
	// Homepage Styles
	$j("#home_tools li:last").css({"margin-right":"0px"});
	//$j("#home_left div.js_cc_toprated").prepend("<h2>Top Rated Articles</h2>");	
	
	// Tools Slider Styles & Behavior
	$j("div.jwts_slider").prepend("<h2>Toolbox</h2>").wrap('<div class="sliderborder"></div>');	

	// Search Results 
	$j("#searchresults_form").parent("#col_left").css({"padding":"0px 0px 0px 0px"});
	$j("#pagenav_pageofnum div").prependTo("div.pagination_pageofpage");
	
	$j("span.breadcrumbs").append('&nbsp;');
	
	// Registration Page Rules
	//$j("#regSubmit *").clone().prependTo("#reg_buttonclone");
	$j("#regSubmit").parent("#jomsForm").parent("#community-wrap").addClass("reg_pg2");
	$j("div.reg_pg2 #regIntro").prepend('<p>The stuff below is optional. If you have it, great; it\'ll help us give you better, more personalized content. If not, no sweat. But make sure you hit "Submit" below.</p>');
		/* The following lines remove/change the "required" text on page 2 of the form */
	$j("div.reg_pg2 div.form_outer:nth-child(1) td.listvalue:last").css({"display":"none"});
	$j("div.reg_pg2 div.form_outer:nth-child(4) td.listvalue:last").css({"display":"none"});
	$j("div.reg_pg2 div.form_outer:nth-child(5) td.listvalue:last").css({"display":"none"});
	$j("div.reg_pg2 div.form_outer:nth-child(2) td.listvalue:last").replaceWith("<td class='listvalue'>If you are not sure enter as much as you know.</td>");
	$j("div.reg_pg2 div.form_outer:nth-child(3) td.listvalue:last").replaceWith("<td class='listvalue'>If you are not sure enter as much as you know.</td>");
		/* Stretch the first cell on the Radio Button table so it isn't squished */
	$j("div.reg_pg2 div.form_outer:nth-child(4) td.listkey").removeClass("listkey").addClass("listkey_wide");

	
	// Blog Rules
	$j("div.jctools").prependTo("div.buttons_container");
	$j("div.buttons_container").prependTo("#blogshare");
	$j("#blogshare div.buttons_container div").css({"float":"right"}).css({"margin":"0px 0px 0px 25px"}).css({"padding":"0px"});
	
	
	
	// Tabbed Module Tweaks
	//$j("div.jwts_tabbertab #homethumbs ul li").append('<div class="cleared">&nbsp;</div>');
	//$j("div.jwts_tabbertab #homethumbs ul li:last-child").css({"border":"none"});
	$j("div.jwts_tabbertab div.js_cc_toprated ul li").append('<div class="cleared">&nbsp;</div>');
	$j("div.jwts_tabbertab div.js_cc_toprated ul li:last-child").css({"border":"none"});
	
	
	// Rollovers
	$j("#joinlogin_join").mouseover(function(){
		$j(this).css({"background":"url(/templates/images/nav_join.gif) no-repeat left -8px"});
    }).mouseout(function(){
		$j(this).css({"background":"url(/templates/images/nav_join.gif) no-repeat left -38px"});
    });
    $j("#joinlogin_login").mouseover(function(){
		$j(this).css({"background":"url(/templates/images/nav_login.gif) no-repeat left -8px"});
    }).mouseout(function(){
		$j(this).css({"background":"url(/templates/images/nav_login.gif) no-repeat left -38px"});
    });
    $j("div.seeanswer div").mouseover(function(){
		$j(this).css({"background":"url(/templates/images/modules/but_seeanswer.gif) no-repeat left top"});
    }).mouseout(function(){
		$j(this).css({"background":"url(/templates/images/modules/but_seeanswer.gif) no-repeat left bottom"});
    });
    $j("div.benny").mouseover(function(){
		$j(this).css({"background":"url(/templates/images/modules/but_join.gif) no-repeat left top"});
    }).mouseout(function(){
		$j(this).css({"background":"url(/templates/images/modules/but_join.gif) no-repeat left bottom"});
    });
    $j("div.but_tellafriend").mouseover(function(){
		$j(this).css({"background":"url(/templates/images/modules/but_tellafriend.gif) no-repeat left top"});
    }).mouseout(function(){
		$j(this).css({"background":"url(/templates/images/modules/but_tellafriend.gif) no-repeat left bottom"});
    });
	
});
