if(typeof(EVERYZING) == 'undefined') { EVERYZING = {}; }

EVERYZING.baseAdOrd = Math.floor(Math.random() * 1000000000);
EVERYZING.baseAdTile = 1;
EVERYZING.getAdTileNumber = function(){
	return EVERYZING.baseAdTile++;
}

EVERYZING.CreateBookmarkLink = function(title, url) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, "");
	} else if (window.external) { // IE Favorite
		window.external.AddFavorite(url, title);
	} else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}

EVERYZING.showEmailForm = function() {
	var obj = document.getElementById("ez-emailForm");
	obj.style.display = "block";
}

EVERYZING.updateEmailLink = function(email, subject, url) {
	var obj = document.getElementById("emailLink");
	url = url.replace("?", "%3F");
	url = url.replace("&", "%26");
	if (email.indexOf("@") != -1) {
		obj.setAttribute("href", "mailto:" + email + "?subject=" + subject + "&body=" + url);
	}
}

var ezc = 1;
EVERYZING.clearBox = function(obj) {
	if (ezc == 1) {
		obj.value = "";
		ezc++;
	}
}

EVERYZING.truncateMoreLess = function(len, obj) {
	jQuery(obj).truncate(len, {
	    chars: / /,
	    leave: false,
	    trail: [true, "... [ <a href='#' class='more-less' title='Click to show all of this text.'>+</a> ]", "&nbsp;[ <a href='#' class='more-less' title='Click to truncate this text.'>-</a> ]"]
	});
}
EVERYZING.imgError = function(el) {
	el.remove();
}

//blank out the searchbox value
EVERYZING.emptySearchBox = function() {
	var sObj = document.getElementById("ezsearch-string")
	sObj.value = "";
	sObj.className = "ezsearch-string ezsearch-string-active";
}

// validate search
EVERYZING.validateSearch = function(defaultText) {
	var bool = false;
	var str = document.getElementById("ezsearch-string");
	str.value = jQuery.trim(str.value);
	if (str.value.length > 0 && str.value != defaultText) {
		bool = true;
	}
	return bool;
}

// set target for links
EVERYZING.setLinkTarget = function(location, target) {
	jQuery(location + " a").each(function(){
		jQuery(this).attr("target", target);
	})
}
