function emailCheck(str) {

	var at = "@";
	var dot = ".";
	var lat = str.indexOf(at);
	var lstr = str.length;
	var ldot = str.indexOf(dot);
	
	if (str.indexOf(at) == -1)
	   return false;
	if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr)
	   return false;
	if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr)
		return false;
	 if (str.indexOf(at, (lat + 1)) != -1)
		return false;
	 if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot)
		return false;
	 if (str.indexOf(dot,(lat + 2)) == -1)
		return false;
	 if (str.indexOf(" ") != -1)
		return false;
		
	 return true
	 
}




//dropdown menu fixer...for IE, of course
function IEdropdownFix() {
	if(document.all && document.getElementById) {
		navRoot = document.getElementById("nav").firstChild;
		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 debuggerStuff() {

	try {
		loadFirebugConsole();
	}
	catch(e) {
		//make IE behave
		console = new Object;
		console.log = function() {} ;
	}
	
}



function linkOpener(testingServer) {
	return;

	var allAnchors = $(document.body).getElements("a");
	allAnchors.each(function(item) {
		
		if(item.href == "") //some non-href link...maybe javascript
			return;
		
		var localLink = item.href.contains("baynote.com"); //production box
		var kentonLink = item.href.contains(testingServer); //testing box
		
		if(localLink || kentonLink) {
			//console.log("leave me alone");
		}
		else {
			//console.log("open new window");
			//item.target = "_blank";
		}

	});
	
}




var currentPanelPos = 0;

function movePanel(target) {

	var panels = $("panels");
	var viewportWidth = 650;
	var fullWidth = panels.getSize().x;
	
	if(target == "forward") {
		var newPanelPos = currentPanelPos - viewportWidth;
		if(currentPanelPos == -(fullWidth - viewportWidth)) {
			newPanelPos = 0;
		}	
	}
	
	else if(target == "back") {
		var newPanelPos = currentPanelPos + viewportWidth;
		if(currentPanelPos == 0) {
			newPanelPos = -(fullWidth - viewportWidth);
		}	
	}
	
	else {
		var targetPos = $(target).getPosition(panels).x;
		var newPanelPos = -(targetPos);
	}
	
	//the pretty
	var myMorph = new Fx.Morph(panels,
		{
			duration:300,
			transition: Fx.Transitions.Sine.easeOut
		}
	);
	myMorph.start(
		{
			"margin-left":newPanelPos
		}
	);
	
	currentPanelPos = newPanelPos;
}





function printerFriendly() {

	//<a href="javascript:news_editor=void(window.open('/news/editor.php?newsID=280','news_editor','resizable=1,scrollbars=1,status=,width=800,height=600,top=60,left=60'))"><img src="/admin/images/edit.png" width="16" height="16" border="0" alt="Edit" /></a> <a href="/programs/c/" >

	var currentURL = window.location.href;
	var connector;
	
	if(currentURL.contains("?")) {
		connector = "&";
		
	}
	else {
		connector = "?";
	}
	
	var newURL = currentURL + connector + "print=1";
	
	var newWindow = window.open(newURL,"printFriendly","resizable=1,scrollbars=1,status=,width=1000,height=600");
	//newWindow.print();
	//console.log(printFriendly);
	return;
	
	//window.open('/news/editor.php?newsID=280','news_editor','resizable=1,scrollbars=1,status=,width=800,height=600,top=60,left=60'))
	
	if($("printCSS")) {
		console.log("it's there!");
		$("printCSS").dispose();
		var mainCSS = new Asset.css("/includes/css/main.css",
			{
				id:"mainCSS"
			}	
		);
		return;
	}

	var printCSS = new Asset.css("/includes/css/print.css",
		{
			id:"printCSS"
		}	
	);
	
	
	//alert(getObject("theStylesheet").href);
	
//	if($("theStylesheet").getAttribute("href") == "/includes/css/main.css") {
//		$("theStylesheet").href = "/includes/css/print.css";
//		window.print();
//	}
//	else {
//		$("theStylesheet").href = "<?=$bnStylesheet?>";
//	}
	
		
}

function mediaplayer(myObj) {

/*
window.addEvent("domready", function() {

	var myFileSettings = 
		{
			file:"/resources/webinars/mob-marketing/trailer-280x210.flv",
			poster:"/resources/webinars/mob-marketing/poster-280x210.png",
			width:280,
			height:230,
			replaceElement:"trailer"
		}
		
	var myPlayer = new mediaplayer(myFileSettings);
	myPlayer.setAutostart(true);
	myPlayer.render();

});
*/

	this.playerSpecs = 
		{
			//pathToPlayer:"/includes/js/mediaplayer/player.swf",
			pathToPlayer:"/includes/js/NonverBlaster-hover/examples/NonverBlaster.swf",
			version:"9.0.115",
			//controllerHeight:20
			controllerHeight:0
		}

	this.flashvars = 
		{
			//file:myObj.file, 
			//image:myObj.poster, 
			//fullscreen:true,
			//autostart:false
			mediaURL:myObj.file,
			//videoURL:myObj.file,
			teaserURL:myObj.poster,
			autoPlay:false,
			controlColour:0x777777
		}
		
	this.params = 
		{
			wmode:"transparent", 
			//allowfullscreen:true,
			allowfullscreen:false,
			allowscriptaccess:"always"
		}
		
	this.attributes =
		{
			name:myObj.replaceElement
			//id:myObj.replaceElement
		}
		
	this.setFullscreen = function(trueFalse) {
			this.flashvars.fullscreen = trueFalse;
			this.params.allowfullscreen = trueFalse;
		}
	
	this.setAutostart = function(trueFalse) {
			//this.flashvars.autostart = trueFalse;
			this.flashvars.autoPlay = trueFalse;
		}
	
	this.render = function() {
			
			var height = myObj.height + this.playerSpecs.controllerHeight;
	
			if($(myObj.replaceElement)) {
				//console.log("here");
				//$(myObj.replaceElement).set("html", "hey!");
				//return;
				
				//get major flash version
				var thisMajorVersion = this.playerSpecs.version.split(".", 1);
				if(thisMajorVersion[0] > Browser.Plugins.Flash.version) {
					$(myObj.replaceElement).set("html", "Adobe Flash Player version " + this.playerSpecs.version + " or greater is required to load this asset. (You have version " + Browser.Plugins.Flash.version + ".) Please download the latest player at <a href=\"http://get.adobe.com/flashplayer/\">http://get.adobe.com/flashplayer/</a>");
				}
				else { //make it so
					swfobject.embedSWF(this.playerSpecs.pathToPlayer, myObj.replaceElement, myObj.width, height, this.playerSpecs.version, false, this.flashvars, this.params, this.attributes);
					console.log(this);
				
				}
				
			}
		}
}

function playerReady(obj) {
	//console.log(obj);
	player = $(obj["id"]);
	//console.log(player.getConfig());
};

