// JavaScript Document
function startList(thisDiv) {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById(thisDiv);
		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", "");
				}
			}
		}
	}
}

///don't forget <body onload="startList('navRowOne'); startList('navRowTwo');">


function copyrightDate(){
	var d = new Date();
	var curr_year = d.getFullYear();
	var dateString = "&copy;" + " " + curr_year + " ";
	//return dateString
	document.write(dateString);
}



NumberOfImagesToRotate = 8;

FirstPart = '<img src="images/random/img';
LastPart = '.jpg" class="imgAlignRight">';

function printImage() {
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
document.write(FirstPart + r + LastPart);
}


//derived from http://newsourcemedia.com/art.117.flash_activex_workaround_.php
function embedFlash(swfName, swfHeight, swfWidth){
	var swfPath;
	swfPath = "swf/" + swfName + ".swf";
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + swfWidth + ' " height="' + swfHeight + '" id="' + swfName + '">');
	document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="opaque" />');
	document.write('<param name="movie" value="' + swfPath + '" /><param name="quality" value="high" />');
	document.write('<embed src="' + swfPath + '" allowScriptAccess="sameDomain" wmode="opaque" quality="high" width="' + swfWidth + '" height="' + swfHeight + '" wmode="opaque" name="' + swfName + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function imgRand(){
	
	var rand1 = Math.ceil(Math.random() * 12);
	var rand2 = Math.ceil(Math.random() * 12);
	var rand3 = Math.ceil(Math.random() * 12);
	
	if(rand1 == rand2){
		while (rand1 == rand2) {
			var rand2 = Math.ceil(Math.random() * 12);
			}
		}
		
	if(rand1 == rand3 || rand2 == rand3){
		while (rand1 == rand3 || rand2 == rand3) {
			var rand3 = Math.ceil(Math.random() * 12);
			}
		}	
	
	document.getElementById('randImg1').src = "images/random/img" + rand1 + ".jpg";
	document.getElementById('randImg2').src = "images/random/img" + rand2 + ".jpg";
	document.getElementById('randImg3').src = "images/random/img" + rand3 + ".jpg";

	
}

//load featured services randomly
function loadInteractives(){
	var randImg1 = Math.floor(Math.random() * 9);
	var randImg2 = Math.floor(Math.random() * 9);
	var randImg3 = Math.floor(Math.random() * 9);
	
	while (randImg1 == randImg2){
	  var randImg2 = Math.floor(Math.random() * 9);
	  }
	  
	while (randImg1 == randImg3 || randImg2 == randImg3){
	  var randImg3 = Math.floor(Math.random() * 9);
	  }	 
	  
	interactivesArray = new Array(2);
	interactivesArray[0] = new Array(2);
	interactivesArray[0][0] = "images/interactivesBackPain.jpg"; 
	interactivesArray[0][1] = "Back pain"; 
	interactivesArray[0][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=c7762266-297b-4999-9763-b169e3e3a809"; 

	interactivesArray[1] = new Array(2);
	interactivesArray[1][0] = "images/interactivesBMI.jpg";
	interactivesArray[1][1] = "Body mass index";
	interactivesArray[1][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=99c705ed-e15c-4c42-a291-41f8f1298c27"; 

	interactivesArray[2] = new Array(2);
	interactivesArray[2][0] = "images/interactivesCaloriesBurned.jpg";
	interactivesArray[2][1] = "Calories burned";
	interactivesArray[2][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=806ab1ee-629a-46e5-a5de-6ed5b594520f"; 
	
	interactivesArray[3] = new Array(2);
	interactivesArray[3][0] = "images/interactivesChildhoodIllnesses.jpg";
	interactivesArray[3][1] = "Childhood illnesses";
	interactivesArray[3][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=157fe35d-7422-4c11-b995-57ae9f9b0291"; 
	
	interactivesArray[4] = new Array(2);
	interactivesArray[4][0] = "images/interactivesDailyCalories.jpg";
	interactivesArray[4][1] = "Daily calories";
	interactivesArray[4][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=9bae9490-63dc-46c8-8d39-44a9a0c43986"; 

	interactivesArray[5] = new Array(2);
	interactivesArray[5][0] = "images/interactivesDepression.jpg";
	interactivesArray[5][1] = "Depression";
	interactivesArray[5][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=7bd10efb-40e0-4f17-ab43-587eaa512420"; 
	
	interactivesArray[6] = new Array(2);
	interactivesArray[6][0] = "images/interactivesExerciseBarriers.jpg";
	interactivesArray[6][1] = "Exercise barriers";
	interactivesArray[6][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=e0cb8b35-3d59-4a58-aa9d-ce9f5587c064"; 
	
	interactivesArray[7] = new Array(2);
	interactivesArray[7][0] = "images/interactivesPregnancyDueDate.jpg";
	interactivesArray[7][1] = "Pregnancy due date";
	interactivesArray[7][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=4be2b2ff-2d96-4fe5-ac3c-7ff802e9efe9"; 

	interactivesArray[8] = new Array(2);
	interactivesArray[8][0] = "images/interactivesProduce.jpg";
	interactivesArray[8][1] = "Buying and storing produce";
	interactivesArray[8][2] = "http://craiggeneralhospital.netreturns.biz/HealthInfo/Story.aspx?StoryID=b11531a7-7597-4b77-a4c5-e66ef43fedbb"; 
	
	
	document.getElementById('interactivesImg1').src = interactivesArray[randImg1][0];
	document.getElementById('interactivesImg2').src = interactivesArray[randImg2][0];
	document.getElementById('interactivesImg3').src = interactivesArray[randImg3][0];
	
	document.getElementById('interactivesLink1').href = interactivesArray[randImg1][2];
	document.getElementById('interactivesLink2').href = interactivesArray[randImg2][2];
	document.getElementById('interactivesLink3').href = interactivesArray[randImg3][2];
	
	document.getElementById('interactivesLink1').title = interactivesArray[randImg1][1];
	document.getElementById('interactivesLink2').title = interactivesArray[randImg2][1];
	document.getElementById('interactivesLink3').title = interactivesArray[randImg3][1];
		
	new Effect.Parallel([
		new Effect.Appear('interactivesImg1', { delay: 1.0 }),
		new Effect.Appear('interactivesImg2', { delay: 1.5 }), 
		new Effect.Appear('interactivesImg3', { delay: 2.0 })
	], { 
		sync: true
	});
}

function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	
	
	if(strValue.indexOf("px") != -1){ //stripping away ‘px’
		strValue = parseInt( strValue.slice(0, strValue.indexOf("px")) );
	}
	
	return strValue;
}

