<!--//
// ----------------------------------- //
// General JavaScript for Bear Archery //
// ----------------------------------- //

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.2");


//on page load
google.setOnLoadCallback(function() {
	//set rollovers for images and input images
	setImageRollovers();
	
	//load jQuery Plugins dynamically
	loadJavaScriptFile('/scripts/jquery/jquery-pngfix.js');
	loadJavaScriptFile('/scripts/jquery/jquery.bgiframe.min.js');
	
	//run jQuery Plugins
	fixPagePngs();
});

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>
}



/* **************************************
			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 });
}

function fixPagePngs(){
	//fix for IE 5.5 and 6 PNG transparency issues
	//may cause problems with overlayed links or form items, doesn't work for tiled CSS backgrounds
	$("img[src$=.png]").pngfix();
}


/* **************************************
			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);
}

// ------------------------------- //
//       Window Popup Function     //
// ------------------------------- //

var w;
function popup(target, width, height, scrollbars, hidemenus){
 	var settings;
 	var menus;
 	var scrolls;
	
 	if (hidemenus) { menus = ",status=yes,toolbar=no,menubar=no,location=no"; }else{ menus = ",status=yes,toolbar=yes,menubar=yes,location=yes"; }
	
 	if (scrollbars) { scrolls = ",scrollbars=yes"; }else{ scrolls = ""; }
	
 	settings = 'width=' + width + ',height=' + height + ',resizable=yes' + scrolls + menus;
	
 	w = window.open(target,'bearpop',settings);
 	w.focus();
}

// ----------------------------------- //
//   Display and Visibility Functions  //
// ----------------------------------- //
function toggleDisplay(divID)
{
	if (document.layers)
		{
		var thisDiv = document.layers[divID];
		var newValue = (thisDiv.display != 'block') ? 'block' : 'none';
		thisDiv.display = newValue;
		}
	else if (document.all)
		{
		var thisDiv = document.all[divID];
		var newValue = (thisDiv.style.display != 'block') ? 'block' : 'none';
		thisDiv.style.display = newValue;
		}
	else if (document.getElementById)
		{
		var thisDiv = document.getElementById(divID);
		var newValue = (thisDiv.style.display != 'block') ? 'block' : 'none';
		thisDiv.style.display = newValue;
		}
}

function toggleVisible(divID)
{
	if (document.layers)
		{
		var thisDiv = document.layers[divID];
		var newValue = (thisDiv.visibility != 'show') ? 'show' : 'hide'
		thisDiv.visibility = newValue;
		}
	else if (document.all)
		{
		var thisDiv = document.all[divID];
		var newValue = (thisDiv.style.visibility != 'visible') ? 'visible'	: 'hidden';
		thisDiv.style.visibility = newValue;
		}
	else if (document.getElementById)
		{
		var thisDiv = document.getElementById(divID);
		var newValue = (thisDiv.style.visibility != 'visible') ? 'visible' : 'hidden';
		thisDiv.style.visibility = newValue;
		}
}

function setDisplay(divID,setType){
	if (document.layers){
		document.layers[divID].display = setType;
		}
	else if (document.all){
		document.all[divID].style.display = setType;
		}
	else if (document.getElementById){
		document.getElementById(divID).style.display = setType;
		}
}

// ------------------------------- //
//   Email Addy Hiding Functions   //
// ------------------------------- //
at = '@';
mailer = 'mailto:';

function getmail(name, domain, suffix, text, cssclass, titletext){ //user supplied email parts and alt text
	hiddenMail=(name + at + domain + '.' + suffix);
	if (! text || text == ''){ //if no text then use full email address
		text = hiddenMail;
	}
	if (! titletext || titletext == ''){
		email = '<a href="' + mailer + hiddenMail + '" class="' + cssclass + '" onclick="urchinTracker(\'/mailto/' + hiddenMail + '\');">' + text + '</a>';
	}else{
		email = '<a href="' + mailer + hiddenMail + '" class="' + cssclass + '" onclick="urchinTracker(\'/mailto/' + hiddenMail + '\');" title="' + titletext + '">' + text + '</a>';
	}
	document.write(email);
}



function hideAllSelectBoxes(){
	// Hide select boxes as they will 'peek' through the image in IE
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "hidden";}
}

function showAllSelectBoxes(){
	// reveal select boxes that were hidden from IE	
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "visible";}	
}

//-->