function addLoadEvent(func) {
	var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
		} 
	  else {
		window.onload = function() {
		  oldonload();
		  func();
		  }
		}
	}

function insertAfter(newElement,targetElement) {
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement) {
		parent.appendChild(newElement);
		}
	else {
		parent.insertBefore(newElement,targetElement.nextSibling);
		}
	}	
	
function setCopyright() {
	var element = document.getElementById("copyright");
	var date = element.childNodes[0].nodeValue;
	var year = new Date().getFullYear();
	if(year > date)
		element.childNodes[0].nodeValue = date + "-" + year;
	else
		element.childNodes[0].nodeValue = date;
	}
	
	
function codeMail() {
	var nospam_mail = document.getElementsByTagName("a");
	
	// eMail Obfuscator Script 2.1 by Tim Williams - freeware
	// modified to use class instead of id - m.schwartz 12/08

 	var coded = "BN8D@8JNKUNFBIFZAJ00.L2B ",
		cipher = "aZbYcXdWeVfUgThSiRjQkPlOmNnMoLpKqJrIsHtGuFvEwDxCyBzA1234567890";
		shift = coded.length,
		link = "";
	for (i=0; i<coded.length; i++) {
		if (cipher.indexOf(coded.charAt(i))==-1) {
			ltr = coded.charAt(i);
			link += (ltr);
			}
		else {     
			ltr = (cipher.indexOf(coded.charAt(i))-shift+cipher.length) % cipher.length;
			link += (cipher.charAt(ltr));
			}				
    	}
		
	for(i=0;i < nospam_mail.length;i++) {
		if (nospam_mail[i].className == "jsmailNoShow") { //do not show the email address on the page for this link
			nospam_mail[i].href="mailto:"+link+"?subject=Free Trial&body=Mark, I am interested in trying AiM to be Fit Boot Camp."; 
    		}
		else {
			if (nospam_mail[i].className == "jsmailShow") { // do show the email address on the page for this link
				nospam_mail[i].href = "mailto:"+link;
				nospam_mail[i].firstChild.nodeValue = link; 
				}
			}
		}
	}
	
	
/*  global variables used for starting coordinates of the div that will slide 
	into view. Inline styles are not used on the html page so cannot access the 
	values stored in css. Units are in pixels; do not put 'px' in with value.
*/
var moveDivCoordX = -800,
	moveDivCoordY = 100;
	
function slideDiv(movetoX, movetoY, movespeed) {
	var moveDiv = document.getElementById("signup");

	if (moveDiv == null) {
		return;  // if the layer does not exist, do nothing.
		}
	
	if (moveDiv.tmofn != null) {
		clearTimeout(moveDiv.tmofn);
		}
	
	var	xX = movetoX,
		yY = movetoY;
		
	if ((moveDivCoordX != movetoX) || (moveDivCoordY != movetoY)) {
		var moveX = ((movetoX - moveDivCoordX)/movespeed),
	   		moveY = ((movetoY - moveDivCoordY)/movespeed);
		moveX = (moveX > 0)?Math.ceil(moveX):Math.floor(moveX);
		movetoX = moveDivCoordX + moveX;
		moveY = (moveY > 0)?Math.ceil(moveY):Math.floor(moveY);
		movetoY = moveDivCoordY + moveY;
		if (moveX != 0) {
			moveDiv.style.left = movetoX + "px";
			moveDivCoordX = movetoX;
			}
		if (moveY != 0) {
			moveDiv.style.top = movetoY + "px";
			moveDivCoordY = movetoY;
			}
		var sFunction = "slideDiv(" + xX + "," + yY + "," + movespeed+ ")";
		moveDiv.tmofn = setTimeout(sFunction,movespeed);
		}
	}
	
function hideDiv(divId) {
	thisDiv = document.getElementById(divId);
	thisDiv.style.visibility="hidden";
	}

function setHide() {
	if (document.getElementById && document.getElementsByTagName) {
		var hideLink = document.getElementById('hide');
        hideLink.onclick = function() {
			return hideDiv('signup');
			}
		}
	}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
	return null;
	}
	
function callSlide() {
	var dispSignup = readCookie("aimDispSignup");
	if (dispSignup == "no") return;
	else {	
		slideDiv(-45,100,3); // final x position (in pixels), final y position (in pixels), move speed (lower number = faster)
		createCookie("aimDispSignup","no",1)  // cookie name, cookie value, expires (in days)
		}
	}
	
function get3Img() {
	// load all available image names in array. add to this array if more images added to site
	var aimImages = new Array();	
	// first value is image file name, second is alt text
	aimImages[0] = ["marlaPhoto", "Marla looking good on the golf course"];
	aimImages[1] = ["patPhoto", "Pat looking good in the garden"];
	aimImages[2] = ["saraPhoto", "Sara looking good and sassy"];
	aimImages[3] =["kristinPhoto", "Kristin looking good and happy"];
	var used = new Array();
	var img = new Array();
	
	for (i=0; i < 3; i++) { // loop three times to load three images 
		imgLoaded = "n";
		while (imgLoaded == "n") {
			randNo = Math.floor(Math.random()*(aimImages.length)); // select random number between 0 and number of photos (defined in aimImages array)
			imgLoaded = "y";
			for (x=0; x < used.length; x++) { // loop through 'used' array to make sure this random number hasn't already been used in loading the images
				if (used[x] == randNo) { // if the number is found, go back to beginning of while loop and get another random number
					imgLoaded = "n";
					}
				}			
			}
		img[i] = [aimImages[randNo][0], aimImages[randNo][1]]; // load image file name and alt text into img array for the selected random number
		used.push(randNo); // add this random number to the 'used' array so it won't be used again
		}
	
	for (i=0; i < 3;i++) { // loop through the three images on the index.html page
		testImg = document.getElementById("testImg"+(i+1));
		testImg.setAttribute("src","images/"+img[i][0]+".png"); // change the src value to the random image file name
		testImg.setAttribute("alt",img[i][1]); // change the alt value to the random image alt text
		testImg.style.visibility="visible";
		}
	}
	
	
addLoadEvent(get3Img);	
addLoadEvent(setCopyright);
addLoadEvent(codeMail);

/*

add this code on html page to activate slide in box:

	<script type="text/javascript">
		addLoadEvent(callSlide);
		addLoadEvent(setHide);
	</script> 
		
	<div id="signup">	
		<div class="topLeft">
	  		<div class="topRight">
				<div id="signupInfo">
					<h2>FREE Fitness Bonuses!<br />($64 Value)</h2>
					<p>Fill in your name and e-mail address to subscribe to the Aim Newsletter and receive:</p>
					<ul>
						<li>5-Part E-mail Series - "5 Fat Loss Myths You Must Not Fall Victim To" ($45)
							<ul>
								<li>Why cardio will keep you fat</li>
								<li>Why the food pyramid should NOT be followed for fat loss</li>
								<li>Why gym memberships are a waste of time and money</li>
								<li>... and more!</li>
							</ul>
						</li>
						<li>Free Circuit Training For Busy People guide ($19)</li>
						<li>Weekly newsletters that are short, sweet and to the point - only what you need to know to be fit and slim</li>
					</ul>					
					<form name="form1" method="post" action="http://www.1shoppingcart.com/app/contactsave.asp">
						<label>Name	<input name="name" type="text" id="name" size="26" /></label><br />
						<label>Email <input name="email1" type="text" id="email1" size="26" /></label><br />
						<input type="submit" name="Submit" value="Submit" /><br />
						<input type="hidden" name="defaultar" id="defaultar" value="279115" /> 
						<input type="hidden" name="merchantid" id="merchantid" value="118562" /> 
						<input type="hidden" name="copyarresponse" id="copyarresponse" value="0" /> 
						<input type="hidden" name="visiblefields" value="name,email1" />
						<input type="hidden" name="requiredfields" value="email1" /> 
						<!-- note email1 is always required.  Add 'Name' to RequiredFields value if you want it to be required. -->
						<input type="hidden" name="arthankyouurl" value="nlthankyou.htm" /> 
						<input type="hidden" name="allowmulti" value="1" /> 
						<input type="hidden" name="custom" value="0" />
						<br />
					</form>
					<a href="#" id="hide">x close</a>				
				</div> <!-- end signupInfo -->
			</div>   <!-- end top right -->
		</div>  <!-- end topLeft -->
		<div class="bottomLeft">
			<div class="bottomRight">			
			</div>   <!-- end bottomRight -->
		</div>  <!-- end bottomLeft -->
	</div> 
	<-- end signup -->
	
*/


