// typical website functions, with jquery goodness

/* SET UP NAV FOR IE6 AND OLDER */
startNav = function() {
/*if (document.all&&document.getElementById) {
navRoot = $("nav");
	for (i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
	if (node.nodeName=="LI") {
		node.onmouseover=function() {
			this.className+=" over";
		}
		node.onmouseout=function() {
			this.className=this.className.replace(" over", "");
		}
	}
	}
}*/
}

// SPAM EMAIL FILTER
showEml = function() {
	email_adds = $(".elink");
	for (i = 0; i < email_adds.length; i++) {
		eaddr = email_adds[i];
		addr = $(eaddr).attr("id");
		// underscored values enable multiple uses of the same email on the page, but with a slightly different id.
		altext = addr.lastIndexOf("_");
		// if there are others, we strip the leading underscores and return the actual email addressee
		if(altext == 0) {addr_temp = addr.substring(altext+1,addr.length); } else { addr_temp = addr;}
		showeml = addr_temp + '@onereel.org';
		$(eaddr).replaceWith('<a href="mailto:' + showeml + '">' + showeml + '</a>');
	}
}

// INFO PAGES; though these could be used elsewhere
showInfo = function() {
	$(".anchors").click(function(event){
		unhide = $(this).attr('href');
		showQs();
		return false;
	});
}
	
hideQs = function() {
	shortcuts = $(".shortcuts");
	for (i = 0; i < shortcuts.length; i++) {
		$(shortcuts[i]).css("display","none");
	}
}

// to work, needs to be preceded by: unhide = $(this).attr('href');
showQs = function() {
	hideQs();
	$(unhide).css("display","block");
}

// ANCHOR URL enabling
dropAnchor = function() {
	var lb = window.location.href;
	if(lb.indexOf('#') > -1) {
		temp = lb.split('#');
		divReplace("#dr_"+temp[1]);
	}
}

startShortcuts = function() {
	$("#shortcuts a").click(function(event){
		temp = $(this).attr('href').split("#");
		divReplace("#dr_"+temp[1]);
		return false;
	});
}

divReplace = function(insertdata) {
	$("#replace").html($(insertdata).html());
}

switchSelect = function() {
	// find out the selection of the form
	temp = $("option:selected");
	divReplace("#"+temp.text());
}

insertFlash = function(filename, title, width, height, bgcolor, where) {
	var fc = new FlashObject(filename, title, width, height, "7", bgcolor);
	fc.addParam("wmode", "opaque");
	fc.write(where);
	return false;
}

insertSWFObject = function(filename, where, width, height, bghex) {
	var flashvars = {};
	var params = {};
	params.bgcolor = bghex;
	params.wmode = "opaque";
	var attributes = {};
	swfobject.embedSWF(filename, where, width, height, "8", false, flashvars, params, attributes);
}