var slideDir = -30;
var featureBoxes = new Array();

<!------------------------------------------------------------------------------------------------------------------------>
<!------------------------------Edit this section to change the content of the feature boxes------------------------------>
<!------------------------------------------------------------------------------------------------------------------------>

function setFeatureBoxes()
{
/*
	var f1 = new featureBox();
	f1.img = '/graphics/healing/12.jpg';
	f1.heading = "2010 BRINGS AN AMAZING VARIETY OF WORKSHOPS AND RETREATS!";
	f1.content = "We invite you to join us on Koh Phangan in 2010, during which we offer our signature Tantra workshops, 4 new workshops, 2 new retreats, regular monthly retreats, and more! See the incredible schedule of events.";
	f1.lnk = "/calendar/pdf/courses_workshops_2010.pdf";
	featureBoxes.push(f1);	
*/


var f1 = new featureBox();
	f1.img = '/graphics/frontpage/ychc5.jpg';
	f1.heading = "THE AGAMA HEALING CENTER IS OPEN - STOP BY!";
	f1.content = "Our Healing Center is devoted to providing our students and community with Yogic and naturopathic therapies, from homeopathy to hypnotherapy, Tibetan healing massage to Taoist abdominal massage, sound therapy to acupuncture, and more. Please visit!";
	f1.lnk = "/healing/";
	featureBoxes.push(f1);
	
/*
var f1 = new featureBox();
	f1.img = '/graphics/audio/1.jpg';
	f1.heading = "YOGAPEDIA";
	f1.content = "Check out our new \"Yogapedia\" glossary! We will be continually updating and improving this resource and welcome your contributions.";
	f1.lnk = "/articles/yogapedia.htm";
	featureBoxes.push(f1);
*/

	var f2 = new featureBox();
	f2.img = '/graphics/frontpage/holiday3.jpg';
	f2.heading = "OUR ISLAND PARADISE WILL TAKE AWAY YOUR WINTER BLUES!";
	f2.content = "Join us on Koh Phangan for a Yoga holiday - you'll be glad you did! In addition to our First Level Intensive Course, you can snorkel, dive, play in waterfalls, sauna, and of course, relax in a hammock....";
	f2.lnk = "/courses/level1.htm";
	featureBoxes.push(f2);

/*
var f2 = new featureBox();
	f2.img = '/graphics/frontpage/story.jpg';
	f2.heading = "WHAT\'S YOUR AGAMA STORY?";
	f2.content = "Tell us how Agama introduced you to the spiritual path or otherwise changed your life and win great prizes!";
	f2.lnk = "/downloads/advertising/agama_story_poster.pdf";
	featureBoxes.push(f2);
*/	

/*
	var f2 = new featureBox();
	f2.img = '/graphics/frontpage/holiday3.jpg';
	f2.heading = "INTRODUCING THE WORLD\'S BEST YOGA HOLIDAYS PACKAGE!";
	f2.content = "Agama Yoga and Ananda Wellness Resort, our home, join hands to bring you a whole month of Yoga holidays for only €210! Almost everything's included - bring a friend or go solo....";
	f2.lnk = "/centers/thailand/koh_phangan/ananda/holidays.htm";
	featureBoxes.push(f2);	

*/
/*	var f3 = new featureBox();
	f3.img = '/graphics/frontpage/justine_for_ttc.jpg';
	f3.heading = "AGAMA KICKS OFF ITS SUMMER TTC";
	f3.content = "Apply now to reserve your place in our next three-month intensive teacher training program: 5 January - 28 March, 2009";
	f3.lnk = "/ttc/ttc.htm";
	featureBoxes.push(f3);	
	*/

	var f3 = new featureBox();
	f3.img = '/graphics/frontpage/justine_for_ttc.jpg';
	f3.heading = "OUR SUMMER TTC HAS ONLY A FEW SPACES LEFT - APPLY TODAY!";
	f3.content = "Our 12-week intensive teacher training is comprehensive and unparalleled. Join this remarkable and life-changing course!";
	f3.lnk = "/ttc/ttc.htm";
	featureBoxes.push(f3);

/*
var f2 = new featureBox();
	f2.img = '/graphics/frontpage/chiang_mai.jpg';
	f2.heading = "AGAMA - CHIANG MAI CENTER NOW OPEN!";
	f2.content = "We are pleased to introduce new and intensive teaching programs to visitors and residents of this ancient city in the beautiful hills of Northern Thailand. Please visit us if you are in this area!";
	f2.lnk = "/centers/thailand/chiang_mai/";
	featureBoxes.push(f2);
*/

	var f4 = new featureBox();
	f4.img = '/graphics/frontpage/meditation1.jpg';
	f4.heading = "AGAMA OFFERS MONTHLY MEDITATION RETREATS";
	f4.content = "The Hridaya Retreat for Revelation of the Spiritual Heart returns 5-14 March; Claudiu also brings this retreat to the Dhammapark Center, Chiang Mai, 19-24 March.";
	f4.lnk = "/retreats/hridaya.htm";
	featureBoxes.push(f4);	

/*
	var f4 = new featureBox();
	f4.img = '/graphics/frontpage/vancouver-night.jpg';
	f4.heading = "SWAMI VIVEKANANDA AND CLAUDIU TRANDAFIR BOTH NOW TEACHING IN NORTH AMERICA";
	f4.content = "Swami and Claudiu have both been invited to teach widely this year on both sides of the Pacific. They will bring teachings this autumn to Ontario, Ottawa, and BC (Canada), and Maui (Hawaii), before engagements in UK. Join us! See Tours for details";
	f4.lnk = "/tours/2009.htm";
	featureBoxes.push(f4);	
*/
/*
	var f4 = new featureBox();
	f4.img = '/graphics/frontpage/justine_ananda.jpg';
	f4.heading = "FIRST MONTH INTENSIVE";
	f4.content = "Our extensive First Month Intensive Course runs year-round at our Koh Phangan location and is an exceptional opportunity for Yoga immersion studies. No reservation is necessary, just drop in – your first day is free!";
	f4.lnk = "/courses/month1.htm";
	featureBoxes.push(f4);	
*/
/*	var f5 = new featureBox();
	f5.img = '/graphics/frontpage/switz.jpg';
	f5.heading = "AGAMA OPENS NEW CENTERS, PRESENTS MANY AUTUMN WORKSHOPS IN EUROPE";
	f5.content = "New Agama centers open in Berlin and Budapest this autumn, plus Agama-Amsterdam is open, Bristol (UK) classes are ongoing, and workshops are planned across the continent, from Spain to Switzerland....";
	f5.lnk = "/tours/europe2008.htm";
	featureBoxes.push(f5);	*/

	/*
var f2 = new featureBox();
	f2.img = '/graphics/frontpage/ychc5.jpg';
	f2.heading = "AGAMA APPRECIATES YOUR DONATIONS TO OUR HEALTH AND CONSULTATION CENTER";
	f2.content = "We are now open, offering individualized consultation, homeopathy, Yogic chiropractic, Reiki, cranio-sacral massage, and other therapies on a donation basis. Please support us in materializing the broad vision of this new center.";
	f2.lnk = "/healing/";
	featureBoxes.push(f2);	
*/

	/*
var f5 = new featureBox();
	f5.img = '/graphics/frontpage/damaru.jpg';
	f5.heading = "SWAMI’S FIRST BOOK ARRIVES!";
	f5.content = "The first of 9 books currently in production - a translation and commentary of the ancient Damaru Tantra, which details the benefits of urine therapy - is now available. Get yours here!";
	f5.lnk = "/register/";
	featureBoxes.push(f5);
*/	

	var f5 = new featureBox();
	f5.img = '/graphics/frontpage/budapest4.jpg';
	f5.heading = "AGAMA BRANCH TEACHINGS";
	f5.content = "<span style='background-color:black; color:white'><strong>SPOTLIGHT ON HUNGARY:</strong></span><br>Agama Yoga teachings are growing and expanding in beautiful Budapest! Please join enthusiastic teachers Kata, Eva, and Katalin for the First Level Intensive and other special programs and events!";
	f5.lnk = "/centers/hungary/budapest/";
	featureBoxes.push(f5);
}
<!------------------------------------------------------------------------------------------------------------------------>


function featureBox()
{
	this.img = null;
	this.heading = null;
	this.content = null;
	this.lnk = null;
}

function featureBox(img, heading, content, lnk )
{
	this.img = img;
	this.heading = heading;
	this.content = content;
	this.lnk = lnk;
}

function existsInArray(arr, num)
{	
	for(var n = 0; n < arr.length; n++)
	{
		if (arr[n] == num) { return 1;}
	}
}

function createRandomArray(size)
{
	var tempArr = new Array();
	for(var i = 0; i < size; i++)
	{
		tempNum = Math.floor(Math.random() * size);
		if (i > 0) 
		{
			
				while(existsInArray(tempArr, tempNum) == 1)
				{
					tempNum = Math.floor(Math.random() * size);
				}
				
			
		}
		tempArr[i] = tempNum;
	}
	return tempArr;
}

function loadFeatureBoxes()
{
	setFeatureBoxes();
	
	var randomIndex = createRandomArray(featureBoxes.length);
	
	r1 = randomIndex[0];
	r2 = randomIndex[1];
	r3 = randomIndex[2];
	r4 = randomIndex[3];
	r5 = randomIndex[4];
		
    	document.getElementById('newsImg1').src = featureBoxes[r1].img;
	document.getElementById('newsHeading1').innerHTML = featureBoxes[r1].heading;
	document.getElementById('newsContent1').innerHTML = featureBoxes[r1].content;
	document.getElementById('newsLink1').href = featureBoxes[r1].lnk;
	
	document.getElementById('newsImg2').src = featureBoxes[r2].img;
	document.getElementById('newsHeading2').innerHTML = featureBoxes[r2].heading;
	document.getElementById('newsContent2').innerHTML = featureBoxes[r2].content;
	document.getElementById('newsLink2').href = featureBoxes[r2].lnk;
	
	document.getElementById('newsImg3').src = featureBoxes[r3].img;
	document.getElementById('newsHeading3').innerHTML = featureBoxes[r3].heading;
	document.getElementById('newsContent3').innerHTML = featureBoxes[r3].content;
	document.getElementById('newsLink3').href = featureBoxes[r3].lnk;
	
	document.getElementById('newsImg4').src = featureBoxes[r4].img;
	document.getElementById('newsHeading4').innerHTML = featureBoxes[r4].heading;
	document.getElementById('newsContent4').innerHTML = featureBoxes[r4].content;
	document.getElementById('newsLink4').href = featureBoxes[r4].lnk;
	
	document.getElementById('newsImg5').src = featureBoxes[r5].img;
	document.getElementById('newsHeading5').innerHTML = featureBoxes[r5].heading;
	document.getElementById('newsContent5').innerHTML = featureBoxes[r5].content;
	document.getElementById('newsLink5').href = featureBoxes[r5].lnk;
	
	//matchColumns('newsHeading', 6);
	matchColumns('feature', 7);
	
}

function highlightLink(e)
{
	e.style.color = "orange";
}

function dehighlightLink(e)
{
	e.style.color = "white";
}

function matchColumns(id, num)
{  
	var maxHeight = 0;
	// find the maximum height of all the feature boxes
	for(i = 1; i < num; i++)
	{
		tempID = id + i;
		e = document.getElementById(tempID);
		h = getDivHeight(e);
		maxHeight = Math.max(h, maxHeight);
	}
	// set all the feature boxes to the max height
	for(i = 1; i < num; i++)
	{
		tempID = id + i;
		e = document.getElementById(tempID);
		e.style.height = maxHeight + 'px';
	}
}

function getDivHeight(d)
{
	var divHeight;
   	if(d.offsetHeight) { divHeight=d.offsetHeight; }
  	else if(d.style.pixelHeight){ divHeight=d.style.pixelHeight;}
  	return divHeight;
} 


function updateSlide()
{
	setTimeout('slide()', 1);
}

function slide()
{
	var e = document.getElementById('featureBoxContent');
	var left = parseInt(e.style.left);
	left += slideDir;
	e.style.left = left +"px";
	if(left <= -626) { e.style.left = -626; slideDir *= -1; }
	else if(left >= 0) { e.style.left = 0; slideDir *= -1; }
	else { updateSlide() }
	
}