
// General JavaScript Functions for DBDnet.com //

//calls current year in footer
var date = new Date();
var year = date.getYear();
if (year < 1000) year += 1900;

//see if this is a Microsoft browser
var isIE = navigator.appName.indexOf("Microsoft")!=-1;

// Load jQuery & jQuery UI, from Google APIs
google.load("jquery", "1.3.2");
google.load("jqueryui", "1.7.1");

//on page load
google.setOnLoadCallback(function() {
	//set rollovers for images and input images
	setImageRollovers();
	
	removeBannerLinks();
	
});

function jsnull(){
	//do nothing
	//this function allows entry of href attribute without causing a page jump
	//<a href="javascript:jsnull();" onclick="jsDoSomething();">do something</a>
}

function removeBannerLinks(){
	//we don't want the SquareSpace banners to be linked
	//this is globally applied to all pages that load this JS file
	$("#bannerWrapper a").each(function(){
		$(this).removeAttr('href');
		$(this).removeAttr('onclick');
	})
}

/* **************************************
			jQuery Items
   ************************************** */
function loadJavaScriptFile(scriptName){
	// Change requests to be sent synchronous
	$.ajaxSetup({ async: false });

	// Loads and executes a local JavaScript file
	$.getScript(scriptName);


	// Restore requests to be sent asynchronous
	$.ajaxSetup({ async: true });
}



/* **************************************
			Image Rollovers
   ************************************** */
function setImageRollovers(){
	$("img[src*=_nm.]").each(function(index, domElement) { 
		setRolloverEvents($(domElement));
		setRolloverPreloads($(domElement))
	});	
	$("input[type=image][src*=_nm.]").each(function(index, domElement) {	
		setRolloverEvents($(domElement));
		setRolloverPreloads($(domElement));
	});
}

function setRolloverEvents(jqueryobj){
	var imgsrc = jqueryobj.attr("src");
	var imgsrcON = imgsrc.replace(/_nm/ig,"_hv");
	
	jqueryobj.mouseover(function(){
		if(jqueryobj.attr("src").indexOf("-av.") < 0) {jqueryobj.attr("src", imgsrcON)};
	});
	jqueryobj.mouseout(function(){
		if(jqueryobj.attr("src").indexOf("-av.") < 0) {jqueryobj.attr("src", imgsrc)};
	});
}

function setRolloverPreloads(jqueryobj){
	rollsrc = jqueryobj.attr("src");
	rollON = rollsrc.replace(/_nm/ig,"_hv");
	$("<img>").attr("src", rollON);
}


/* **************************************
			email protection
   ************************************** */

at = '@';
mailer = 'mailto:';

function getmail(name, domain, suffix, text){ //user supplied email parts and alt text
		hiddenMail=(name + at + domain + '.' + suffix);
		if (! text){ //if no alt text then use full email address
			text = hiddenMail;
		}
		email = '<a style="padding-right:0px;" href="' + mailer + hiddenMail + '" onClick="javascript:pageTracker._trackPageview(\'/mailto/' + hiddenMail + '\');">' + text + '</a>';
		return email;
}


