// SHARED
function init() {
	// preloaders
	MM_preloadImages('menu_about_2.gif, menu_books_2.gif, menu_resources_2.gif, menu_events_2.gif, menu_gallery_2.gif, menu_contact_2.gif');
	// Open off-site links in external window...
	if (document.getElementsByTagName) {
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i].getAttribute("href");
			if (anchor) {
				if (anchor.indexOf("wildfermentation") == -1) {
					if (anchor.substring(0,4) == "http") anchors[i].target = "_blank";
				}
			}
		}
	}
}

function rollover(target) {
	if (target.src.indexOf('_2') > 0) {
		parts = target.src.split('_2');
		target.src = parts[0] + parts[1];
	} else {
		path = target.src.slice(0,target.src.lastIndexOf('.'));
		xtension = target.src.slice(target.src.lastIndexOf('.')+1);
		target.src = path + '_2.' + xtension;
	}
}

function scroll_to(n){
	window.scrollTo(0,document.getElementById(n).offsetTop);
}

function toggle_div(n) {
	if (document.getElementById(n).style.display == "none") { 
		document.getElementById(n).style.display = "";
	} else {
		document.getElementById(n).style.display = "none";
	}
}

function swap_img(n,opt1,opt2) {
	if (document.getElementById(n).src.indexOf(opt1) > 1) document.getElementById(n).src = opt2;
	else document.getElementById(n).src = opt1;
}

function view_img(path,title,param) {
	window.open("view_img.php?src="+path,title,param);
}

// EMAIL
function no_spam(user,domain) {
	locationstring="mailto:"+user+"@"+domain;
	window.location=locationstring;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
