﻿// map document as LoveMoney
var LoveMoney = $(document);

/* SITE SEARCH */
LoveMoney.Search = {
    siteSearch: function() {
        var searchboxValue = $('.SiteSearch input[type="text"]').attr('value');

        $('.SiteSearch input[type="text"]').focus(function () {
            if ($(this).attr('value') == searchboxValue) {
                $(this).attr('value', '');
            }
        });

        $('.SiteSearch input[type="text"]').blur(function () {
            if ($(this).attr('value') == '') {
                $(this).attr('value', searchboxValue);
            }
        });
    }
}

/* LOVEMONEY ADS FUNCTIONS */
LoveMoney.Ads = {
	drawLabels: function(target) {
		$(target).each(function() {
			var adHeight = $(this).height();
			if (adHeight > 240 && adHeight < 260) {
				// it's an MPU
				$(this).addClass('AdMpu');
			}
			else if (adHeight > 590 && adHeight < 610) {
				// it's a Skyscraper
				$(this).addClass('AdSkyscraper');
			}
			else if (adHeight > 80 && adHeight < 100) {
				// it's a Leaderboard
				$(this).addClass('AdLeaderboard');
			}
			else {
				$(this).removeClass('AdMpu');
				$(this).removeClass('AdSkyscraper');
				$(this).removeClass('AdLeaderboard');
				$(this).removeClass('Module');
			}
		});
	}
}

/* things that need to fire on page load */
$(document).ready(function() {
	LoveMoney.Search.siteSearch();
	LoveMoney.Ads.drawLabels('div.OpenXAd');
});
