// SHARED
function init() {
	// preloaders
	MM_preloadImages('images/menu_item_classes_b.gif','images/menu_item_instructor_b.gif','images/menu_item_application_b.gif','images/menu_item_consultation_b.gif','images/menu_item_gallery_b.gif','images/menu_item_contact_b.gif','images/menu_item_links_b.gif','images/menu_hdr_classes.jpg','images/menu_hdr_instructors.jpg','images/menu_hdr_application.jpg','images/menu_hdr_consultation.jpg','images/menu_hdr_gallery.jpg','images/menu_hdr_contact.jpg','images/menu_hdr_links.jpg');
	// 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("chestnutherbs") == -1) {
					if (anchor.substring(0,4) == "http") anchors[i].target = "_blank";
				}
			}
		}
	}
	// Add contact email...
	document.getElementById('contact_info').innerHTML = document.getElementById('contact_info').innerHTML + "<p>(828) 683-5233<br /> <a href=\"javascript:no_spam('juliet','chestnutherbs.com')\">juliet@chestnutherbs.com</a></p>";
}

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.replace("../","")) > 1) document.getElementById(n).src = opt2;
	else document.getElementById(n).src = opt1;
}

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

// MENU
function change_menu_hdr(n) {
	document.getElementById('menu_hdr').style.background = 'url(images/' + n + ') no-repeat';
}

// 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];}}
}

