// JavaScript Document
function insertFlash(swf, width, height, area, bgcolor){
	var flash = '<object ';
	flash += '	classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
	flash += '	codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	flash += '	width="'+width+'" ';
	flash += '	height="'+height+'" ';
	flash += '	align="middle">';
	flash += '	<param name="allowScriptAccess" value="sameDomain" />';
	flash += '	<param name="movie" value="'+swf+'" />';
	flash += '	<param name="quality" value="high" />';
	if(bgcolor) flash += '	<param name="bgcolor" value="'+bgcolor+'" />';
	else 		 flash += '	<param name="wmode" value="transparent" />';
	flash += '	<embed ';
	flash += '		src="'+swf+'" ';
	flash += '		quality="high" ';
	if(bgcolor) flash += '		bgcolor="'+bgcolor+'" ';
	else 		 flash += '		wmode="transparent" ';
	flash += '		width="'+width+'" ';
	flash += '		height="'+height+'" ';
	flash += '		align="middle" ';
	flash += '		allowScriptAccess="sameDomain" ';
	flash += '		type="application/x-shockwave-flash" ';
	flash += '		pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flash += '</object>';	
	if(area) getObj(area).innerHTML = flash;
	else document.write(flash);
}

function popUp(url, title, width, height, scrollbars){
	var x = (self.screen.width-width)/2;
	var y = (self.screen.height-height)/2;
	if(scrollbars) var myScroll = scrollbars;
	else var myScroll = "no";
	window.open(url,title,'left='+x+',top='+y+',screenx='+x+',resizable=0, status=0,toolbar=0, screeny='+y+',scrollbars='+myScroll+',width='+width+',height='+height);
}

function getObj(obj){
	return document.getElementById(obj);
}

function swapClass(myID, myClass){
	document.getElementById(myID).className = myClass;	
}

function changePage(url){
	location.href = url;
}

function changeImg(myImg,mySRC){
	getObj(myImg).src=mySRC;
}

// Drop Down Menu Navigation Code
processList = function(myList){
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById(myList);
		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", "");
				}
			}
		}
	}
}

function getFormValues(formName){
	var myForm = getObj(formName);
	var formLength = myForm.length;
	var passVars = "";
	for (i=0; i<formLength;i++){
		passVars += "&"+myForm[i].name+"="+myForm[i].value;
	}
	return(passVars);
}

startList = function() {
	processList("navSmallUL");
	processList("navLargeUL");
}
window.onload=startList;

// Unused //
function ajaxNLsignup(respondDiv){
	ajaxRequest("/inc/ajaxNLsignup.php?"+getFormValues("formContact"), "changeContent", respondDiv);
	return false;
}
function ajaxSubmitForm(formName,respondDiv){
	ajaxRequest("/inc/ajaxFormMail.php?"+getFormValues(formName), "changeContent", respondDiv);
	return false;
}

function validateAndSubmit(formName,respondDiv){
	if(validateForm(formName)) ajaxSubmitForm(formName,respondDiv);
	return false;
}

function validateForm(formName,respondDiv){
	// This function will cause all form fields of formName that have a title attributes to be required
	var myForm = getObj(formName);
	for(i=0;i<myForm.length;i++){
		//alert(myForm[i].name+" = "+myForm[i].value+" | "+myForm[i].alt);
		if(myForm[i].value == "" && myForm[i].title){ 
			alert("Please provide your "+myForm[i].title);
			return false;
		}
	}
	//alert("end loop");
	return true;
	//return ajaxSubmitForm(formName,respondDiv);
}