var wn_userblocks = {};
var wn_userblocks_ix = 0;
function weatherbynation_ready()
{
	// Miscellaneous classes, etc
	$('form.confirmation div.container-inline a:contains("Cancel")').addClass('button').addClass('cancel');
	$('#node-filter-form #node-admin-buttons #edit-submit').addClass('filter');
	$('#rightCol h2.pageTitle').contains("Edit comment").addClass('editComment');
	$('#rightCol h2.pageTitle').contains("Preview comment").addClass('editComment');
	$('#rightCol.editComment div.content > img').hide();
	//$('div.eventWrapper div.ical-link a').addClass('button').addClass('addToIcal').children('img').hide();
	$('#og-user-roles-page-form #og-roles-table td br').remove();
	$('div.manageSubscribers table').prepend('<thead><tr><th colspan="3">Subscribers</th></tr></thead>');
	//$('td.adminMain input[type=submit]').addClass('submit');
	$('input').hover(function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});
	$('input.edit-search').unbind('hover').hover(function(){
		$(this).addClass('edit-search-hover');
	},function(){
		$(this).removeClass('edit-search-hover');
	});
	
	/*
	if( !$.browser.msie ) {
		if($('#user-login-form .username input').length > 0) {
			document.getElementById('edit-pass').type = "text";
		}
	}*/
	// Change Background if Browser Remembers Value
	/*if($('#user-login-form .username input').val() != '') {
		$('#user-login-form .username input').css('background-position', '0 -24px');
	} 
	if($('#user-login-form .password input').val() != '') {
		$('#user-login-form .password input').css('background-position', '0 -24px');
	} */
	

	// Add "Beta" tag
    /*
	var currentUrl = document.location.href;
	var currentUrl = currentUrl.split("?",1);
	$('body').append('<a id="betatag" href="/feedback?url='+currentUrl+'"></a>');
	$('#betaFormWrapper form.beta #fromPage').val(document.location.search.substring(5));
	*/

	// Add extra classes to private messaging
	$('#privatemsg-list-form input').addClass('button');
	$('#privatemsg-new input#edit-2').addClass('button');
	$('#privatemsg-list-form input ~ br').remove();
	$('#privatemsg-new').before('<h3>Send a Personal Message</h3>');
	$('#privatemsg-new input#edit-1').addClass('button');

	// Tooltips
	if( $.browser.msie && parseInt($.browser.version) < 7 ) {
		// don't display tooltips for IE6 and lower
	}
	else {
		$('a[@title]').Tooltip({
			track: false,
			delay: 0,
			showURL: false,
			extraClass: "weatherby",
			opacity: 0.85
		});
		$('div.option[@title]').Tooltip({
			track: false,
			delay: 0,
			showURL: false,
			extraClass: "geolocator",
			opacity: 0.85
		}).hover(function(){
			$(this).css("cursor","help");
		},function(){
			$(this).css("cursor","normal");
		});
	}

	// Load user blocks for the forum.
	$('.load-userblock').each(function() {
		var uname = $(this).html();
		var ix = wn_userblocks_ix;
		
		$(this).addClass('loading').removeClass('load-userblock');
		if (typeof wn_userblocks[uname] == 'undefined') {
//			alert(uname);
			wn_userblocks[uname] = ix;
			wn_userblocks_ix++;
			$(this).load('/sites/all/modules/jsforum/cache.php?i=userblock&k=' + encodeURI(uname), {}, function(m){ $(this).removeClass('loading'); $('.userblock-'+ix).removeClass('loading').html(m) });
		} else {
			ix = wn_userblocks[uname];
			$(this).addClass('userblock-' + ix)
		}
	});

	// Limit size of images/objects
	function com_weatherby_image_resize(obj) {
		try {
			var x = $(obj)[0].src.indexOf(document.location.hostname);
			if ((x > 5 && x < 10) || $(obj)[0].src.substring(0,1) == '/') {
				return;
			}
		} catch(err) {}

		if( $(obj).parent().parent('div.imageNode').eq(0).length > 0 ) {
			var mw = 600;
		}
		else {
			if($('body').hasClass('articles')) {
				var mw = 520;
			} else {
				var mw = 400;
			}
		}

		if ($(obj).is('img')) {
			$(obj).css('max-width', mw + 'px');
		}

		var w = $(obj).width();
		if (w > mw) {
			$(obj).height(Math.ceil($(obj).height()/w*mw)+"px").width(mw+"px");
		}
	}
	if($('.content img , .content object , .content embed').length) {
		$('.content img , .content object , .content embed').each(function() {
		    if( document.location.href.indexOf('videocontest')==-1 ) {
			    com_weatherby_image_resize($(this));
		    }
		}).load(function() {
			if($.browser.safari) {
				com_weatherby_image_resize($(this));
			}
		});
	}

	// Trophy Room
	$('#rightCol.trophyRoom div.messages').insertAfter('#trophyRoomHeader');
	$('#rightCol.trophyRoom div.trophyRoomImages ul.images li:last').addClass('last');
	if( $('#rightCol #node-form select#edit-gallery option:selected').val() == "0" ) {
		$('#rightCol #node-form fieldset.new-gallery-settings').show();
	}
	$('#rightCol #node-form #edit-gallery').change(function() {
		if( $(this).val() == "0" ) {
			$('#rightCol #node-form fieldset.new-gallery-settings').show();
		}
		else {
			$('#rightCol #node-form fieldset.new-gallery-settings').hide();
		}
	});
	$('#rightCol #node-form[label:contains("Photo Title")]').addClass('addEditPhoto');
	$('#rightCol #node-form.addEditPhoto #edit-submit')
	   .after('<div class="form-submit-loading">Loading...</div>')
	   .click(function() {
	       $('.form-submit-loading').show();
	   });
	$('#rightCol div.imageNode #node-form div.form-item[label:contains("Upload Certification")]').hide();

	// Shutterfly form
	$('#rightCol.trophyRoom div.imageDetails span.printShutterfly a').click(function() {
		$(this).hide();
		$('#extPrintWrapper').show();
		return false;
	});
	$('#rightCol.trophyRoom div.imagePrint a.print').click(function() {
		if( $('#shutterflyPrintForm select option:selected').val() == "null" ) {
			window.alert('Please select a service.');
		}
		else {
			$('#shutterflyPrintForm').eq(0).submit();
		}
		return false;
	});

	// Fixing groups filter form
	$('#rightCol.groups #views-filters td[#edit-filter0]').addClass('form-item');
	$('#rightCol.groups #views-filters td[#edit-submit]').addClass('edit-submit');

	// Move pager, if present
	$('#oneCol.spikeCamp div.pager').before('<span class="label">Page Index:</span>');
	$('.trophyroom.search .pgPagination').before('<span class="label">Page Index:</span>');
	$('.search #rightCol div.pager .pager-list').before('<span class="label">Page Index:</span>');
	$('.search #rightCol div.pager').prependTo('.search #rightCol .content.search');
	//$('#oneCol.spikeCamp #spikeCampPagerTop').appendTo('#spikeCampSearchTop div.right');
	$('#oneCol.spikeCamp #spikeCampPagerBottom').insertBefore('#oneCol.spikeCamp div.forumFooter');
	$("#main div.pager a:contains('next')").addClass('buttonNext');
	$("#main div.pager a:contains('previous')").addClass('buttonPrevious');
	$("#main div.pager a:contains('first')").hide();
	$("#main div.pager a:contains('last')").hide();

	// Move Moderator Links
	$('.spikeCamp #oneCol .forumFooter').before($('.spikeCampBody .linkWrap #adminModOptionsWrapper'));

	// intialize profile what you hunt
	if (typeof $.fn.com_gorad_ui_multiselect == "function") {
		$("#edit-profile-hunt").com_gorad_ui_multiselect();
	}
	
	// Hover for jsforum threads
	/*$('#oneCol.spikeCamp div.thread div.postWrapper').hover(function() {
		$(this).css("background-color","#f9f8f1").css("cursor","hand");
	},function() {
		$(this).css("background-color","").css("cursor","normal");
	});
	$('#oneCol.spikeCamp div.thread div.postWrapper a.hoverClick').click(function() {
		window.location.href=this.href;
		return false;
	});
	$('#oneCol.spikeCamp div.thread div.postWrapper').click(function() {
		$(this).children().children('a.hoverClick').click();
		return false;
	});*/

	$('#oneCol.spikeCamp div.thread div.profile .right a').click(function() {
		return false;
	});

	// Remove certain tags.
	$('marquee , blink').each(function() {
		$(this).after('<div class="badtag">' + $(this).html() + '</div>');
		$(this).remove();
	});

	// Fix event sign-up form/table
	$('#rightCol div.eventWrapper #signup-form fieldset').removeClass('collapsed');
	$("#rightCol table[th:contains('individuals signed up')]").addClass('registeredUsers');
	$("table.registeredUsers td[input[value='Cancel Signup']]").children('form').addClass('formCancelSignup');
	if( $('table.registeredUsers th').text() == "0 individuals signed up" ) {
		$('table.registeredUsers').hide();
	}

	// Adjust font sizes, where appropriate
	$('body span.fontSize a.decrease').addClass('inactive');
	$('body.largeFont span.fontSize a.increase').addClass('inactive');
	$.each(document.cookie.split(';'), function(i, n) {
		var cookieParts = n.split('=');
		cookieParts[0] = cookieParts[0].replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
		if (cookieParts[0] == "fontSize") {
			switch (cookieParts[1]) {
				case "large":
					weatherby_increase_font();
					break;
				case "normal":
					weatherby_decrease_font();
					break;
			}
		}
	});

	// Articles DOM mods
	$('.articles #rightCol .view-articles .item-list ul li, .articles #rightCol .view-insider .item-list ul li, .articles #rightCol .view-history .item-list ul li, .articles #rightCol .view-allarticles .item-list ul li, .frontSection .view-allarticles ul li').each(function(index) {
		var commentcount = $(this).find('.view-data-node-comment-statistics-comment-count').html(); 
		var commentpath = $(this).find('.view-data-node-link a').attr('href');
		$(this).find('.view-label-node-comment-statistics-comment-count').hide();
		$(this).find('.view-data-node-comment-statistics-comment-count').html('<a href="' + commentpath + '">Comments (' + commentcount + ')</a>');
		var newshare = $(this).find('.view-item');
		$('.articles #adjustFontSize .buttons .share').clone().appendTo(newshare);
		if($('.view-data-node-link a').href() != null || $('.view-data-node-link a').href() != undefined) {
			$(this).find('a.button.share').attr('onmouseover','return addthis_open(this, "", "' + $(this).find('.view-data-node-link a').href() + '", "[TITLE]")');
		}
		$(this).find('.view-data-node-data-field-teaser-field-teaser-value').after('<div class="view-item-footer"></div>');
		$(this).find('.view-data-node-link').appendTo($(this).find('.view-item-footer'));
		$(this).find('.view-data-node-comment-statistics-comment-count').appendTo($(this).find('.view-item-footer'));
		$(this).find('a.share').appendTo($(this).find('.view-item-footer'));
		if($(this).find('.view-data-node-data-field-author-field-author-value').html() == "") {
			$(this).find('.view-label-node-data-field-author-field-author-value').css('display', 'none');
		}
	});

	$('.articles #adjustFontSize .buttons .share').clone().appendTo('.articles #rightCol .node .content', function() {
		$('.articles #rightCol .node .content .share').before('<div class="clear"></div>');
	});

	$('#main #block-views-short_article_list li:first-child').remove();
	$('#main #block-views-short_article_list li').each(function() {
		var commentcount = $(this).find('.view-data-node-comment-statistics-comment-count').html(); 
		var commentpath = $(this).find('.view-data-node-link a').attr('href');
		$(this).find('.view-label-node-comment-statistics-comment-count').hide();
		$(this).find('.view-data-node-comment-statistics-comment-count').html('<a href="' + commentpath + '#comments">Comments (' + commentcount + ')</a>');
		var title = $(this).find('.view-data-node-title a').html();
		if(title.length > 45) {
			$(this).find('.view-data-node-title a').html(title.substr(0,40) + "...");
		}
	});
	$('#main #block-views-short_article_list .item-list').after('<a class="more-articles" href="/articles">View more articles</a>');
    
    // Random banner ads
    var random_banner_total = $('#side_banner_ad img').length;
    var random_banner_id = Math.floor(Math.random() * (random_banner_total));
    
    $('#side_banner_ad > a').hide().eq(random_banner_id).show();

	// External links
	$('#main a[@href^=http]').not('[@href*=weatherbynation]').not('[@href*=uppercasedev.com]').not('[@href*=addthis.com]').addClass('extLink').attr('target','_blank');
	$('#main a[@href^=http][img]').removeClass('extLink');
	$('#main a[@href*=weatherbydreamhunt.com]').removeClass('extLink');
	$('#main a[@href*=weatherby.com]').addClass('extWeatherby').attr('target','_blank');
	$('#main a[@href*=weatherby.com][img]').removeClass('extWeatherby');
	$('#main a[@href^=http]:has(img)').removeClass('extLink');
}
//theme_onMarkupChange = weatherbynation_ready;

function weatherbynation_swfobject() {
    // Front page
    if( $('div.frontWrapper #videoContest').length > 0 ) {
        var flashvars = {};
        var params = {
            quality: "high",
            scale: "noscale",
            wmode: "transparent"
        };
        swfobject.embedSWF("/_ui/srawn/swf/wiwaw_home.swf", "home-flash-banner", "600", "150", "8.0.23", "/_ui/srawn/swf/expressintall.swf", flashvars, params);
    }

    // Banner Block
    if( $('#side-flash-banner').length > 0 ) {
        var flashvars = {};
        var params = {
            quality: "high",
            scale: "noscale",
            wmode: "transparent"
        };
        swfobject.embedSWF("/_ui/srawn/swf/wiwaw_block.swf", "side-flash-banner", "200", "135", "8.0.23", "/_ui/srawn/swf/expressintall.swf", flashvars, params);
    }

	// Universal header
	/*
        if (wn_profile.uid > 0) {
		var flashvars = {
			loggedIn: true,
			userName: wn_profile.name
		};
	}
	else {
		var flashvars = {
			loggedIn: false
		}
	}
	var params = {
		quality: "high",
		scale: "noscale",
		wmode: "transparent"
	}
	swfobject.embedSWF("/_ui/srawn/swf/header.swf", "heroFlash", "920", "207", "8.0.23", "/_ui/srawn/swf/expressinstall.swf", flashvars, params);
        */

	// Universal footer
	var flashvars = {
	    avatar: wn_footer_avatar_url
	};
	var params = {
	    quality: "high",
	    scale: "noscale",
	    wmode: "transparent"
	};
	swfobject.embedSWF("/_ui/srawn/swf/foot.swf", "footFlash", "920", "293", "8.0.23", "/_ui/srawn/swf/expressinstall.swf", flashvars, params);
}

function weatherbynation_change_userstar_filter() {
	$.get("/userstar/ajaxupdate", {
		bias: $('#userstar_filter option:selected').val()
	},
    function(data){
		if(data == 1) window.location.reload();
	});
}

function weatherbynation_send_ajax_form_bottom(page) {
	noErrors = false;
	if( $('#sendAjaxForm #bottom_from_name').length > 0 && $('#sendAjaxForm #bottom_recipient').val().length > 0 ) {
		noErrors = true;
	}
	if( $('#sendAjaxForm #bottom_recipient').val().length > 0 ) {
		noErrors = true;
	}
	if( noErrors == true ) {
		$('#sendAjaxForm').addClass('loading');
		$.post('/send/ajax', {
			'from_name': $('#sendAjaxForm #bottom_from_name').val(),
			'url': page,
			'to': $('#sendAjaxForm #bottom_recipient').val()
		},
		function() {
			$('#sendAjaxForm').removeClass('loading');
			$('#sendAjaxForm input.text').val('');
			$('#sendAjaxForm').hide();
			$('div.printSendLinks .buttons a.send').removeClass('active');
			$('div.printSendLinks').append('<div class="messages status ajaxSentMessage">Thank you. Your email has been sent.</div>');
		});
	}
	else {
		window.alert("Error: please fill out the entire form.");
	}
}

function weatherbynation_send_ajax_form_top(page) {
	noErrors = false;
	if( $('#sendAjaxFormTop #top_from_name').length > 0 && $('#sendAjaxFormTop #top_recipient').val().length > 0 ) {
		noErrors = true;
	}
	if( $('#sendAjaxFormTop #top_recipient').val().length > 0 ) {
		noErrors = true;
	}
	if( noErrors == true ) {
		$('#sendAjaxFormTop').addClass('loading');
		$.post('/send/ajax', {
			'from_name': $('#sendAjaxFormTop #top_from_name').val(),
			'url': page,
			'to': $('#sendAjaxFormTop #top_recipient').val()
		},
		function() {
			$('#sendAjaxFormTop').removeClass('loading');
			$('#sendAjaxFormTop input.text').val('');
			$('#sendAjaxFormTop').removeClass('form');
			$('#sendAjaxFormTop a.toggleLink').hide();
			$('#sendAjaxFormTop').append('<div class="messages status ajaxSentMessage">Thank you. Your email has been sent.</div>');
		});
	}
	else {
		window.alert("Error: please fill out the entire form.");
	}
}

function weatherby_post_ajax_comment(location,imageId) {
	$('#comments-add textarea').addClass('loading');
	$.post(location, {
		'comment':$('#comments-add textarea').val()
	}, function(m){
		if(m.length > 100) {
			// Require login if reponse if html for login page
			$('#comments-add h3').after('<strong>You must <a href="/user/login">login</a> to post comments.</strong>');
			$('#comments-add textarea').val('').removeClass('loading');
		}
		else {
			$('#comments-add textarea').val('').removeClass('loading');
			if(imageId) {
				url = document.location.href;
				if(url.indexOf("&startId") != "-1") {
					url = url.split("&startId");
				}

				else {
					url = url.split("?startId");
				}
				url = url[0];
				if(url.indexOf("page") != "-1") {
					document.location.href = url+'&startId='+imageId;
				}
				else {
					document.location.href = url+'?startId='+imageId;
				}
			}
			else {
				window.location.reload();
			}
		}
	});
}


function weatherby_pfc(uname)
{
	if (typeof weatherby_chat_window.pfc == 'object') {
		try {
			weatherby_chat_window.initPv(uname);
			return;
		} catch (e) {
			//alert('Unable to request private chat.');
		}
	}
	if (!weatherby_chat_window.closed) {
		setTimeout("weatherby_pfc('" + uname + "')", 500);
	}
}

var weatherby_chat_window = null;
function weatherby_chat(uname, pm)
{
	// Open the chat in frames.
	weatherby_chat_window = window.open('/chat/index.php', 'weatherbynation_chat', 'height=605,width=482,status=no,toolbar=no,menubar=no,location=no,resizable=no');

	// try to go straight to the chat.
	if (uname != '')
		weatherby_pfc(uname);

	// Send the PM if necessary.
	if (pm === 1) {
		$.get('/privatemsg/request/chat/' + uname);
	}
}

function weatherby_pm()
{
	if ($('#privatemsgAjaxView').length == 0) {
		$('#pmAlerts').hide().load('/sites/all/modules/privatemsg_ajax/privatemsg_ajax.php?' + wn_profile.uid, {}, function(){setTimeout('weatherby_pm()', 15000)} );
	} else {
		$('#pmAlerts').show();
		setTimeout('weatherby_pm()', 15000);
	}
}

function weatherby_increase_font() {
	$('body').addClass('largeFont');
	$('body span.fontSize a.decrease').removeClass('inactive');
	$('body span.fontSize a.increase').addClass('inactive');
	document.cookie = "fontSize=large;Path=/";
}
function weatherby_decrease_font() {
	$('body').removeClass('largeFont');
	$('body span.fontSize a.decrease').addClass('inactive');
	$('body span.fontSize a.increase').removeClass('inactive');
	document.cookie = "fontSize=normal;Path=/";
}

function weatherby_albumswf(ad)
{
    var flashvars = {
        galleries: ad
    };
    var params = {
        quality: "high",
        scale: "noscale",
        wmode: "transparent"
    };
    swfobject.embedSWF("/_ui/srawn/swf/thumb_viewer.swf", "profileTrophyRoomFlash", "590", "210", "8.0.23", "/_ui/srawn/swf/expressinstall.swf", flashvars, params);
}

function weatherby_checkCalendar() {
	var isApplied = false;
	if( $('#block-event-0').is('.js-applied') ) {
		isApplied = true;
	}
	if(!isApplied) {
		$('#block-event-0').addClass('js-applied');
		$('table.event-block thead th:first-child').addClass('first-cell');
		$('table.event-block thead th:last-child').addClass('last-cell');
		$('table.event-block tbody tr:first-child').addClass('first-row');
		$('table.event-block tbody tr:last-child').addClass('last-row');
		$('table.event-block tbody td:first-child').addClass('first-cell');
		$('table.event-block tbody td:last-child').addClass('last-cell');
		$('table.event-block tbody td > a').parent().addClass('hasEvent');
		setTimeout('weatherby_checkCalendar()', 1000);
	}
}

function weatherbynation_profile(){
	//WHAT I HUNT
	$('#leftCol.profile #block-user-hunts ul.cloud li').not(':last').each(function(i){
		$(this).append(',');
	});
	
	
	//CAROUSEL
	var totalBuddies = $('ul#user-buddies li').size();
	if(totalBuddies > 4){
		$('#boxBuddyList #user-buddies').jcarousel();
	}
	
	var totalTrophies = $('ul#user-trophies li').size();
	if(totalTrophies > 4){
		$('#boxTrophyRoom #user-trophies').jcarousel();
	}
}

function weatherbynation_home(){
	//CAROUSEL
	$('#main #frontTrophyRoom').css('display', 'block');
	$('#main #frontTrophyRoom ul#trophy-room').jcarousel();
	
	//UL LI for recent articles and messages
	$('#articles .item-list ul').addClass('menu');
	$('#articles .item-list ul li').addClass('leaf');
	$('#articles .item-list ul li:first').addClass('first');
	
	
	//INSIDER and MESSAGES
	$('#block-views-frontpage_insider h2').addClass('pageTitle');
	var tmpHref = $('#block-views-frontpage_insider .view-data-node-link a').attr('href');
	$('#block-views-frontpage_insider h2 a').removeAttr('href');
	$('#rightCol .frontWrapper a.continue-reading').attr('href', tmpHref);
	$('#block-views-frontpage_messages .view-data-users-name a').removeAttr('href');

	//ARTICLES LISTING
	$('#block-views-allarticles .view-content').before('<h2 class="pageTitle">Recent Articles</h2>');
}


//DOCUMENT READY
$(document).ready(function() {
	weatherbynation_ready();

	weatherbynation_home();
	weatherbynation_profile();
   
	if( $.browser.msie && parseInt($.browser.version) < 7 ) {
		// don't add fancy fading hover in IE6
	} else {
		$('#head #topnav > li').each(function() {
			if($(this).css('background-position')){
				var bgpos = $(this).css('background-position').split(' ');
			} else {
				var bgpos = 0;
			}
			var anc = $(this).find('a.first');
			$(this).hover( function() {
				$(this).css('background-position', bgpos[0] + ' ' + bgpos[1]);
			},function() {});
			anc.css('background', 'url(/_ui/srawn/img/topnav/nav-primary.png) ' + bgpos[0] + " -34px");
			anc.css('opacity','0');
			$(this).bind('mouseenter', function() {
				anc.animate({
					opacity: 1
				}, 150);
			});
			$(this).bind('mouseleave', function() {
				anc.animate({
					opacity: 0
				}, 150);
			});
		});
		$('#head #topnav li.topnavItem01').bind('mouseenter', function() {
			$(this).find('ul').animate({display: block},150);	
		});
	}
	
	// Where To Buy Button
	var origMargin = $('#whereToBuy .top').css('marginTop');
	$('#whereToBuy .bottom a').attr('href', '#');
	$('#whereToBuy .bottom a').removeAttr('target');
	$('#whereToBuy .bottom').click(function(){
		if ($('#whereToBuy').hasClass('active')) {
			$('#whereToBuy .top').animate({'marginTop':origMargin},null, null, function() {
				$('#whereToBuy').css("z-index","3");
				$('#whereToBuy').removeClass('active');
			});
		} else {
			$('#whereToBuy').css("z-index","5");
			$('#whereToBuy .top').animate({'marginTop':0});
			$('#whereToBuy').addClass('active');
		}
	});

	// New Topic AJAX Menu
	if ($('#newTopicListTop').length != 0) {
		$('#newTopicListTop').load('/jsforum/ajax/boards/open');
	}
	if ($('#newTopicListBottom').length != 0) {
		$('#newTopicListBottom').load('/jsforum/ajax/boards/open');
	}

	// Add extra classes to calendar block
	if( $('#block-event-0 .month-view').length > 0 ) {
		weatherby_checkCalendar();
	}

	// Look for incomplete items
	if ($('.incomplete').length > 0) {
		$('body').prepend('<div id="incomplete">' + $('.incomplete').length + ' incomplete items on this page.');
		$('#incomplete').append($('<span>Highlight</span>').click(function(){$('.incomplete').addClass('incomplete-highlight')}));
		$('#incomplete').append($('<span>Unhighlight</span>').click(function(){$('.incomplete-highlight').removeClass('incomplete-highlight')}));
		$('#incomplete').append($('<span>Close</span>').click(function(){$('#incomplete').remove()}));
	}

	// Add the pmAlerts div
    if (typeof(wn_profile) != 'undefined') {
        if (parseInt(wn_profile.uid) > 0) {
            $('body').append('<div id="pmAlerts"></div>');
            weatherby_pm();
        }
    }
	
	//commet odd and even
	$('#rightCol #comments .comment:even').addClass('even');
	$('#rightCol #comments .comment:odd').addClass('odd');
	
	// Load swfobject(s)
	//weatherbynation_swfobject();
	
	// set min-height to account for banners
	var banner_height = $('#banner_sidebar').height();
	var body_minheight = parseInt($('#main #rightCol').css('min-height'));
	if(!body_minheight) {
		var body_minheight = parseInt($('#main #oneCol').css('min-height'));
	}
	if(!body_minheight) {
		var body_minheight = 570;
	}
	if( body_minheight < banner_height )
	{
		$('#main').css('min-height',banner_height);
		$('#main #oneCol, #main #rightCol').css('min-height',banner_height);
	}
	
	// Call entersubmit when enter key is pressed in login form
	$('#hero #user-login-form #edit-pass').attr('onkeypress','return entersubmit(event,this.form)');

	// Open external links in new window
	$("a[href^=http]").not("[href*="+ location.hostname +"]").attr("target","_blank");

	$('input[placeholder], textarea[placeholder]').placeholder();
});

function event_notify_on_time_discrepancy(drupalUtc, drupalTzOffset, localUtc, localTzOffset, utcTolerance, tzTolerance) {
    $('#rightCol div.contentMessages').append('<div class="error messages">There is a possible discrepancy between the local timezone as set on your computer and the one specified in your profile. <a href="/user/' + wn_profile.uid + '/edit?page=settings">Edit your locale settings</a> to correct this problem.</div>');
}

function entersubmit(event, theform) {
	if (event && event.which == 13) {
		theform.submit();
	} else {
		return true;
	}
}

