// JavaScript Document
function openwindow(theurl){
		planpreview=window.open(theurl,'tp_plan','height=450,width=850,screenX=50,left=50,screenY=50,top=50,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0')
}
//used on plans page
function dohide(theelement){
    message   = document.getElementById(theelement);
    message2   = document.getElementById(theelement) + '2';
	if (message.className == 'error2'){ 
		message.className = 'hidden2';
		message2.className = 'hidden2';
	} else{
		message.className = 'error2';
		message2.className = 'error2';
	}
}
bool = true;
function openLogin() {	
	getE('tp_login').style.display = bool ? 'block' : 'none';
	if(bool) getE('username').focus();
	bool = bool ? false : true;
}
function getMRsEmail(text) {
	if(!text) text = 'Coach Mike';
	var arrEm=[109,105,107,101,64,100,51,109,117,108,116,105,115,112,111,114,116,46,99,111,109];
	var sEncrypt=''; //variable to contain encrypted email 
	for (var i=0; i<arrEm.length; i++) sEncrypt+=String.fromCharCode(arrEm[i]);
	document.write('<a href="mailto:'+sEncrypt+'">' + text + '</a>');
}
function outPage() {
	if (self.parent.frames.length != 0) self.parent.location="http://d3multisport.com/";
}
function getE(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}
function addEvent(e,evType,fn,useCapture) {
	if(e.addEventListener) {
		e.addEventListener(evType,fn,useCapture);
		return true;
	} else if (e.attachEvent) {
		var r = e.attachEvent('on'+evType, fn);
		return r;
	} else e['on'+evType]=fn;
}
addEvent(window, "load", function(){aX = document.getElementsByTagName('body');bgcolor = aX[0].style.backgroundColor;});
function centerLayerOnPage(dialogId, layerId) {
	//the element must have height and width set in-line, not by className
	var layer = getE(dialogId);
	if(layer) {
		/*aX = document.getElementsByTagName('body');
		aX[0].style.backgroundColor = '#000';
		aX[0].className = 'alpha';
		layer.className = 'alphaNormal';
		layer.style.backgroundColor = '#fff';*/
		layer.style.display = 'block';
		layer.style.zIndex = 99;
		layer.style.position = 'absolute';
		//alert(document.body.clientHeight +'-'+document.body.scrollTop +'-'+ layer.style.height);
		layer.style.top = ((document.body.clientHeight/2)-(layer.style.height.replace(/[^\d]/g,"")/2))+'px';
		layer.style.left = ((document.body.clientWidth/2)-(layer.style.width.replace(/[^\d]/g,"")/2))+'px';
	}
}
function closeDialog(layerId) {
	getE(layerId).style.display='none';
		aX = document.getElementsByTagName('body');
		aX[0].style.backgroundColor = bgcolor;
		aX[0].className = 'alphaNormal';/**/
}
function swapContent(eId) {
	$("div.coachbox").hide();
	$(eId).fadeIn(1200);
}
function q(eId) {
	$("div.answer").hide();
	$("#q"+eId).fadeIn(600);
}
function loadVideo(vid){
	if(location.search != vid)
		location.href = location.pathname + '?video=' + vid;
}
/*function showSub(bShow) {
	if(bShow) {
		$('#sub_links').slideDown("slow");
	} 
}*/
