// --------------- XMLHTTP OBJECT DETECTION ------------------------------ //
//Detect appropriate xmlhttp objects
var xmlhttp = null;
if (window.XMLHttpRequest) {
	//assign native object for modern browsers (Mozilla, Safari, IE7, etc.)
	xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
	//assign the ActiveX object for IE5 and IE6
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

// --------------- XMLHTTP DATA SUBMISSION ------------------------------- //
function submit(category) {
	var type = document.getElementById('type').value;
	var target = document.getElementById('target_id');
	target.innerHTML = '<span class="load_msg">Loading data...</span>';
	xmlhttp.open("GET", 'includes/process.php?cat='+category);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		target.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}
// --------------- XMLHTTP AUDIO REQUEST --------------------------------- //
function audioreq(item,id) {
	var target = document.getElementById(id);
	target.innerHTML = '<span class="load_msg">Requesting data from server...</span>';
	xmlhttp.open("GET", 'includes/process_audioreq.php?req='+item);
	xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		target.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}
// --------------- DISPLAY/HIDE ELEMENTS --------------------------------- //
function toggle_audio(id) {
	body=document.getElementById(id);
	if (body) {
		if (body.style.display == 'none') {
			//display id block
    		try {
    			body.style.display='table-row'; //for modern browsers
     		} catch(e) {
     		body.style.display = 'block'; //for IE
      		}
       	}
		else {
 			body.style.display = 'none';
		}
 	}
}
function toggle_info(id) {
	body=document.getElementById(id);
	if (body) {
		if (body.style.display == 'none') {
			//display id block
    		try {
    			body.style.display='table-row'; //for modern browsers
     		} catch(e) {
     		body.style.display = 'block'; //for IE
      		}
       	}
		else {
 			body.style.display = 'none';
		}
 	}
}
function toggle_notes(id) {
	body=document.getElementById(id);
	if (body) {
		if (body.style.display == 'none') {
			//display id block
    		try {
    			body.style.display='table-row'; //for modern browsers
     		} catch(e) {
     		body.style.display = 'block'; //for IE
      		}
       	}
		else {
 			body.style.display = 'none';
		}
 	}
}
// --------------- EXTERNAL LINKING -------------------------------------- //
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName('a');
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'external')
     anchor.target = '_blank';
 }
}
window.onload = externalLinks;
// --------------- EMAIL MASKING ----------------------------------------- //
function email() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName('a');
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'email') {
			anchor.href = 'mail' + 'to:' + 'alan' + 'scott' + '@' + 'ala' + 'nsc' + 'ott.us';
		}
	}
}
window.onload = email;
// --------------- HTML REPLACEMENT -------------------------------------- //
function unused() {
	body=document.getElementById(variable);
	if (body) {
		if (body.style.visibility == 'hidden') {
			//display duration
	     	body.style.visibility = 'visible';
	       }
		else {
			//hide duration
	 		body.style.visibility = 'hidden';
		}
	}
}

