var themeRoot = themeDisplay.getPathThemeImages();
function rollover_jpg(whichImage, status) {
	if (status)
		document.getElementById(whichImage).setAttribute("src",themeRoot+"/jkm/" + whichImage + "_on.jpg");
	else
		document.getElementById(whichImage).setAttribute("src",themeRoot+"/jkm/" + whichImage + "_off.jpg");
}

function rollover(whichImage, status) {
	if (status)
		document.getElementById(whichImage).setAttribute("src",themeRoot+"/jkm/" + whichImage + "_on.gif");
	else
		document.getElementById(whichImage).setAttribute("src",themeRoot+"/jkm/" + whichImage + "_off.gif");
}

function rollover_nav_ty(whichImage, status) {
	if (status)
		document.getElementById('nav_ty_bottom').setAttribute("src",themeRoot+"/jkm/" + whichImage + "_on.gif");
	else
		document.getElementById('nav_ty_bottom').setAttribute("src",themeRoot+"/jkm/" + whichImage + "_off.gif");
}

function newWindow(url,name,w,h,t,m,s,r,st,l,d,c) {
	var windowOptions = "width=" + w + "," +
	"height=" + h + "," +
	"toolbar=" + t + "," +
	"menubar=" + m +"," +
	"scrollbars=" + s + "," +
	"resizable=" + r + "," +
	"status=" + st + "," +
	"location=" + l + "," +
	"directories=" + d + "," +
	"copyhistory=" + c;
	window.open(url, name, windowOptions);
}

//function printPage(whichPage) {
//	newWindow('print.html','print',986,470,1,1,1,0,0,0,0,0);
//}

function printPage(whichPage) {
	window.print();
}

function printDialog() {
	var agt = navigator.userAgent.toLowerCase(); 
    var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    var is_mac    = (agt.indexOf("mac")!=-1);
    var macos  = (is_mac && ((agt.indexOf("mac os") != -1) || (agt.indexOf("macos") != -1) || this.ie));
    var macosx = (macos && ((agt.indexOf("os x") != -1) || (agt.indexOf("osx") != -1)));

	if(macosx || is_win ){
		window.print();
	} else {
		alert("To print this page, press 'command+P'.")
	}
}

function rolloverModule(whichModule, fromNav, status) {
	if (status) {
		if (fromNav) {
			document.getElementById('mod_ds_right_' + whichModule).setAttribute("src",themeRoot+"/jkm/blank.gif");
			document.getElementById('mod_ds_bottom_' + whichModule).setAttribute("src",themeRoot+"/jkm/blank.gif");
		}
		document.getElementById('mod_top_' + whichModule).setAttribute("src",themeRoot+"/jkm/mod_" + whichModule + "_top_ro.gif");
	} else {
		if (fromNav) {
			document.getElementById('mod_ds_right_' + whichModule).setAttribute("src",themeRoot+"/jkm/mod_ds_right.gif");
			document.getElementById('mod_ds_bottom_' + whichModule).setAttribute("src",themeRoot+"/jkm/mod_ds_bottom.gif");
		}
		document.getElementById('mod_top_' + whichModule).setAttribute("src",themeRoot+"/jkm/mod_" + whichModule + "_top_on.gif");
	}
}

prevProductModule = 1;
prevProductModuleTab = 1;
function showProdModuleTab(whichTab) {
	if (prevProductModuleTab != whichTab) {
		document.getElementById('nav_5_x_0' + prevProductModuleTab).setAttribute("src",themeRoot+"/jkm/nav_5_x_0" + prevProductModuleTab + "_off.gif");
		document.getElementById('nav_tyl_prod' + prevProductModule + '_tab' + prevProductModuleTab).style.display = 'none';
		if (prevProductModuleTab == "1") {
			document.getElementById('nav_5_x_01').onmouseout = function(){this.src=themeRoot+'/jkm/nav_5_x_01_off.gif';};
			document.getElementById('nav_5_x_01').onmouseover = function(){this.src=themeRoot+'/jkm/nav_5_x_01_ro.gif';};
		}

		if (prevProductModuleTab == "2") {
			document.getElementById('nav_5_x_02').onmouseout = function(){this.src=themeRoot+'/jkm/nav_5_x_02_off.gif';};
			document.getElementById('nav_5_x_02').onmouseover = function(){this.src=themeRoot+'/jkm/nav_5_x_02_ro.gif';};
		}

		if (prevProductModuleTab == "3") {
			document.getElementById('nav_5_x_03').onmouseout = function(){this.src=themeRoot+'/jkm/nav_5_x_03_off.gif';};
			document.getElementById('nav_5_x_03').onmouseover = function(){this.src=themeRoot+'/jkm/nav_5_x_03_ro.gif';};
		}
		
		document.getElementById('nav_5_x_0' + whichTab).setAttribute("src",themeRoot+"/jkm/nav_5_x_0" + whichTab + "_on.gif");
		document.getElementById('nav_tyl_prod' + prevProductModule + '_tab' + whichTab).style.display = 'block';

		if (whichTab == "1") {
			document.getElementById('nav_5_x_01').onmouseout = function(){this.src=themeRoot+'/jkm/nav_5_x_01_on.gif';};
			document.getElementById('nav_5_x_01').onmouseover = function(){this.src=themeRoot+'/jkm/nav_5_x_01_on.gif';};
		}

		if (whichTab == "2") {
			document.getElementById('nav_5_x_02').onmouseout = function(){this.src=themeRoot+'/jkm/nav_5_x_02_on.gif';};
			document.getElementById('nav_5_x_02').onmouseover = function(){this.src=themeRoot+'/jkm/nav_5_x_02_on.gif';};
		}

		if (whichTab == "3") {
			document.getElementById('nav_5_x_03').onmouseout = function(){this.src=themeRoot+'/jkm/nav_5_x_03_on.gif';};
			document.getElementById('nav_5_x_03').onmouseover = function(){this.src=themeRoot+'/jkm/nav_5_x_03_on.gif';};
		}
	
		prevProductModuleTab = whichTab;
	}
}

function showProdModule(whichTab) {
	document.getElementById('nav_tyl_prod' + prevProductModule).style.display = 'none';
	document.getElementById('nav_tyl_prod' + prevProductModule + '_tab' + prevProductModuleTab).style.display = 'none';
	
	document.getElementById('nav_tyl_prod' + whichTab).style.display = 'block';
	document.getElementById('nav_tyl_prod' + whichTab + '_tab' + prevProductModuleTab).style.display = 'block';
	
	prevProductModule = whichTab;
}

function createBookmark() {
	title = "KEEP MOVING(TM) Program";
	url = "http://www.justkeepmoving.com";
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,"");	
	} else if (window.external) { 
		window.external.AddFavorite(url, title);
	} else { 
		alert("Bookmark this page by pressing Command-D");
	}
}

function displayChangeLocation(whichState, whichPage) {
	var portletXPosition = document.getElementById('portlet_weather').offsetLeft;
	var portletYPosition = document.getElementById('portlet_weather').offsetTop;
	
	var offsetX = whichPage == "homepage" ? 140 : 187;
	document.getElementById('changeLocation').style.top = portletYPosition + offsetX + "px";
	document.getElementById('changeLocation').style.left = portletXPosition + 6 + "px";

	if (whichState) {
		document.getElementById('changeLocation').style.display = 'block';
	} else {
		document.getElementById('changeLocation').style.display = 'none';
	}
}

function displayWeatherDisclaimer(whichState, whichPage) {
	if (whichPage == "homepage") {
		var portletXPosition = document.getElementById('portlet_weather').offsetLeft;
		var portletYPosition = document.getElementById('portlet_weather').offsetTop;
	} else {
		var portletXPosition = document.getElementById('portlet_weather_form').offsetLeft;
		var portletYPosition = document.getElementById('portlet_weather_form').offsetTop;
	}
	
	var offsetX = whichPage == "homepage" ? 182 : 229;
	document.getElementById('weatherDisclaimer').style.top = portletYPosition + offsetX + "px";
	document.getElementById('weatherDisclaimer').style.left = portletXPosition + 6 + "px";

	if (whichState) {
		document.getElementById('weatherDisclaimer').style.display = 'block';
	} else {
		document.getElementById('weatherDisclaimer').style.display = 'none';
	}
}

function displayLogin(whichState) {
	document.getElementById('rssModuleTop').style.display = 'none';
	document.getElementById('rssModule').style.display = 'none';
	document.getElementById('loginForm').style.display = 'block';
	document.getElementById('forgotpwdForm').style.display = 'none';
	
	if (whichState) {
		document.getElementById('loginModuleTop').style.display = 'inline';
		document.getElementById('loginModule').style.display = 'inline';
	} else {
		document.getElementById('loginModuleTop').style.display = 'none';
		document.getElementById('loginModule').style.display = 'none';
	}
}

function showLoginState(whichState) {
	if (whichState) {
		document.getElementById('loginForm').style.display = 'none';
		document.getElementById('forgotpwdForm').style.display = 'block';
	} else {
		document.getElementById('forgotpwdForm').style.display = 'none';
		document.getElementById('loginForm').style.display = 'block';
	}
}

function displayRSS(whichState) {
	if (document.getElementById('loginModuleTop') != null) {
		document.getElementById('loginModuleTop').style.display = 'none';
		document.getElementById('loginModule').style.display = 'none';
	}
		
	if (whichState) {
		document.getElementById('rssModuleTop').style.display = 'inline';
		document.getElementById('rssModule').style.display = 'inline';
	} else {
		document.getElementById('rssModuleTop').style.display = 'none';
		document.getElementById('rssModule').style.display = 'none';
	}
}

function editEmail() {
	document.getElementById('changeEmailLink').style.display = 'none';
	document.getElementById('userEmail').style.display = 'none';
	document.getElementById('userConfirmEmail').style.display = 'inline';
	document.getElementById('editUserEmail').style.display = 'inline';
	document.getElementById('confirmEmail').style.display = 'inline';
}

function editPwd() {
	document.getElementById('changePwdLink').style.display = 'none';
	document.getElementById('userPwd').style.display = 'none';
	document.getElementById('userConfirmPwd').style.display = 'inline';
	document.getElementById('editUserPwd').style.display = 'block';
	document.getElementById('confirmPwd').style.display = 'inline';
}

function pauseFlashMovie() {
	var movie=thisMovie("flashMovie");
	if(movie)
		movie.pauseMovie();
}
function unPauseFlashMovie() {
	var movie=thisMovie("flashMovie");
	if(movie)
		movie.unPauseMovie();
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	}
	else {
		return document[movieName];
	}
}

var baseFontSize10 = 10;
var baseFontSize12 = 12;
function adjustFontSize(whichDirection) {
	copyblocks10 = new Array();
	copyblocks12 = new Array();

	arr = document.getElementById("content").getElementsByTagName("td");
	for (var i = 0; i < arr.length; i++) {
		if (arr[i].className == "gray fontsize10") {
			copyblocks10.push(arr[i]);
		}
		
		if (arr[i].className == "fontsize12") {
			copyblocks12.push(arr[i]);
		}
	}
	
	arr = document.getElementById("copyContainer").getElementsByTagName("a");
	for (var i = 0; i < arr.length; i++) {
		if (arr[i].className.indexOf("fontsize12") >= 0) {
			copyblocks12.push(arr[i]);
		} else {
			copyblocks10.push(arr[i]);
		}
	}
	
	arr = document.getElementById("copyContainer").getElementsByTagName("p");
	for (var i = 0; i < arr.length; i++) {
		copyblocks12.push(arr[i]);
	}
	
	arr = document.getElementById("copyContainer").getElementsByTagName("span");
	for (var i = 0; i < arr.length; i++) {
		if (arr[i].className.indexOf("fontsize12") >= 0) {
			copyblocks12.push(arr[i]);
		}
		
		if (arr[i].className.indexOf("fontsize10") >= 0) {
			copyblocks10.push(arr[i]);
		}
	}

	arr = document.getElementById("content").getElementsByTagName("li");
	for (var i = 0; i < arr.length; i++) {
		if (arr[i].className == "pad15") {
			copyblocks12.push(arr[i]);
		}
	}
	
	if (whichDirection == "+") {
		if (parseInt(baseFontSize12) <= 15) {
			baseFontSize10 = (parseInt(baseFontSize10)+1) +'px';
			baseFontSize12 = (parseInt(baseFontSize12)+1) +'px';
		} else {
			return;
		}
	} else {
		if (parseInt(baseFontSize12) >= 12) {
			baseFontSize10 = (parseInt(baseFontSize10)-1) +'px';
			baseFontSize12 = (parseInt(baseFontSize12)-1) +'px';
		} else {
			return;
		}
	}
	
	for (var i = 0; i < copyblocks10.length; i++) {
		copyblocks10[i].style.fontSize = baseFontSize10;
	}
	
	for (var i = 0; i < copyblocks12.length; i++) {
		copyblocks12[i].style.fontSize = baseFontSize12;
	}
}

function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}

function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

function displayFont(key){
	if(queryString(key)=='false') {
		whichFont = "0";
	} else {
		whichFont = queryString(key);
	}

	if (whichFont == "1") {
		baseFontSize10 = 10;
		baseFontSize12 = 12;
		increaseURL = "2";
		decreaseURL = "0";
	}
	
	if (whichFont == "2") {
		baseFontSize10 = 11;
		baseFontSize12 = 13;
		increaseURL = "3";
		decreaseURL = "1";
	}

	if (whichFont == "3") {
		baseFontSize10 = 12;
		baseFontSize12 = 14;
		increaseURL = "4";
		decreaseURL = "2";
	}

	if (whichFont >= "4") {
		baseFontSize10 = 13;
		baseFontSize12 = 15;
		increaseURL = "4";
		decreaseURL = "3";
	}
}

function opacity(id, opacStart, opacEnd, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
}

function leavingsiteAlert(whichSite) {
	currentOpac('container', 20, 300);
	document.getElementById('leavingsiteURL').setAttribute("href", whichSite);
	document.getElementById('leavingsitealertContainer').style.visibility = 'visible';
}

function leavingsiteCancel() {
	document.getElementById('leavingsitealertContainer').style.visibility = 'hidden';
	currentOpac('container', 100, 300);
}
function deletedmodulesAlert() {
	currentOpac('container', 20, 300);
	document.getElementById('deletedmodulesalertContainer').style.visibility = 'visible';
}
function deletedmodulesCancel() {
	document.getElementById('deletedmodulesalertContainer').style.visibility = 'hidden';
	currentOpac('container', 100, 300);
}
function nomodulesAlert() {
	currentOpac('container', 20, 300);
	document.getElementById('missingmodulesalertContainer').style.visibility = 'visible';
}

function nomodulesCancel() {
	document.getElementById('missingmodulesalertContainer').style.visibility = 'hidden';
	currentOpac('container', 100, 300);
}

function notSavedAlert() {
	currentOpac('container', 20, 300);
	document.getElementById('savealertContainer').style.visibility = 'visible';
}

function sendEmail() {
	currentOpac('container', 20, 300);
	document.getElementById('emailThanks').style.display = 'none';
	document.getElementById('emailForm').style.display = 'block';
	document.getElementById('emailContainer').style.visibility = 'visible';
}

function cancelEmail() {
	document.getElementById('emailContainer').style.visibility = 'hidden';
	currentOpac('container', 100, 300);
}

function openCreateHomepage() {
	currentOpac('container', 20, 300);
	document.getElementById('createhpContainer').style.visibility = 'visible';
	//pauseFlashMovie();
}

function cancelCreateHomepage() {
	document.getElementById('createhpContainer').style.visibility = 'hidden';
	currentOpac('container', 100, 300);
}

function submitEmail() {
	document.getElementById('emailForm').style.display = 'none';
	document.getElementById('emailThanks').style.display = 'block';
}

function currentOpac(id, opacEnd, millisec) { 
    var currentOpac = 100; 
     
    if(document.getElementById(id).style.opacity < 100) { 
        currentOpac = document.getElementById(id).style.opacity * 100; 
    } 

    opacity(id, currentOpac, opacEnd, millisec) 
} 

function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
    if (opacity == 20 ) {
    	object.cursor='default';
    }else {
    	object.cursor='pointer';
    }
}
function jkm_page_flow_tracking(params){
	var pageTracker = _gat._getTracker('UA-2315409-3');
//	alert(params);
	pageTracker._trackPageview(params);
}
//var leaving = true;
//function checkUrl(href) {
//leaving = ((href.indexOf("://") > -1) || (href.indexOf("www.") > -1));
//}
//function pop() {
//if(leaving) notSavedAlert();
//}
//window.onunload = pop;
//var e = document.getElementsByTagName("a");
//for(var i=0;i<e.length;i++) e[i].onclick = "checkUrl(this.href)";