var id_holder = new Array(); //holds ids for all the rollovers in the nav sections
id_holder[0] = 'cyclo';
id_holder[1] = 'financial';
id_holder[2] = 'gift';
id_holder[3] = 'news';
id_holder[4] = 'store';
id_holder[5] = 'kids';
id_holder[6] = 'tudor';
id_holder[7] = 'natural';
id_holder[8] = 'myprofile';
id_holder[9] = 'spts';
id_holder[10] = 'attitude';
id_holder[11] = 'exercise';
id_holder[12] = 'nutrition';
id_holder[13] = 'sleep';
id_holder[14] = 'vitamins';
id_holder[15] = 'become';
id_holder[16] = 'weight';
id_holder[17] = 'goto';

var ending_array = new Array(); // holds end string for preloader assembly of img names
ending_array[0] = '_off';
ending_array[1] = '_on';
ending_array[2] = '_fade';
ending_array[3] = '_hilite';

var preloader = new Array(); // used to track rollover state options for rollover images
var img_status = new Array(); // initiates array to hold hilight/fade/normal status of preloaded images
preloader[0] = '/images/MembersIndex/cyclo_health';
img_status[0] = 0;
//preloader[1] = '/images/MembersIndex/spacer';
//preloader[1] = '/images/MembersIndex/financial_health_anim'; //commment out to take out img
//img_status[1] = 0; //commment out to take out img
preloader[2] = '/images/MembersIndex/gift_health';
img_status[2] = 0;
preloader[3] = '/images/MembersIndex/news_reel';
img_status[3] = 0;
preloader[4] = '/images/MembersIndex/online_store';
img_status[4] = 0;
preloader[5] = '/images/MembersIndex/truestar_kids1';
img_status[5] = 0;
preloader[6] = '/images/MembersIndex/tudor_bompa';
img_status[6] = 0;
preloader[7] = '/images/MembersIndex/natural_health';
img_status[7] = 0;
preloader[8] = '/images/MembersIndex/myprofile'; 
img_status[8] = 0;
preloader[9] = '/images/MembersIndex/spts_daily'; 
img_status[9] = 0;
preloader[10] = '/images/MembersIndex/attitude';
img_status[10] = 0;
preloader[11] = '/images/MembersIndex/exercise';
img_status[11] = 0;
preloader[12] = '/images/MembersIndex/nutrition';
img_status[12] = 0;
preloader[13] = '/images/MembersIndex/sleep';
img_status[13] = 0;
preloader[14] = '/images/MembersIndex/vitamin';
img_status[14] = 0;
/*preloader[15] = '/images/MembersIndex/attitude_feature';
preloader[16] = '/images/MembersIndex/exercise_feature'; 
preloader[17] = '/images/MembersIndex/nutrition_feature'; 
preloader[18] = '/images/MembersIndex/sleep_feature'; 
preloader[19] = '/images/MembersIndex/vitamin_feature'; 
preloader[20] = '/images/MembersIndex/attitude_sub'; 
preloader[21] = '/images/MembersIndex/exercise_sub'; 
preloader[22] = '/images/MembersIndex/nutrition_sub'; 
preloader[23] = '/images/MembersIndex/sleep_sub'; 
preloader[24] = '/images/MembersIndex/vitamin_sub'; 
*/
preloader[25] = '/images/MembersIndex/spacer'; 
img_status[25] = 0;
preloader[26] = '/images/MembersIndex/spacer'; 
img_status[26] = 0;
preloader[27] = '/images/MembersIndex/our_team';
img_status[27] = 0;
/*
preloader[27] = '/images/MembersIndex/latest_news'; 
preloader[28] = '/images/MembersIndex/nutrition_feature'; 
preloader[29] = '/images/MembersIndex/nutrition_recent'; 
preloader[30] = '/images/MembersIndex/nutrition_focus'; 
preloader[31] = '/images/MembersIndex/recent'; 
preloader[32] = '/images/MembersIndex/focus'; 
preloader[33] = '/images/MembersIndex/attitude_recent'; 
preloader[34] = '/images/MembersIndex/attitude_focus'; 
preloader[35] = '/images/MembersIndex/exercise_recent'; 
preloader[36] = '/images/MembersIndex/exercise_focus'; 
preloader[37] = '/images/MembersIndex/sleep_recent'; 
preloader[38] = '/images/MembersIndex/sleep_focus'; 
preloader[39] = '/images/MembersIndex/vitamin_recent'; 
preloader[40] = '/images/MembersIndex/vitamin_focus'; 
preloader[41] = '/images/MembersIndex/red_recent'; 
preloader[42] = '/images/MembersIndex/red_focus'; 
preloader[43] = '/images/MembersIndex/want_plan2'; 
preloader[44] = '/images/MembersIndex/want_sub'; 
preloader[45] = '/images/MembersIndex/yes_button'; 
preloader[46] = '/images/MembersIndex/enter_my_own'; 
preloader[47] = '/images/MembersIndex/substitute'; 
preloader[48] = '/images/MembersIndex/view_plan2'; 
preloader[49] = '/images/MembersIndex/remove_plan'; 
preloader[50] = '/images/MembersIndex/buy_vitamin'; 
preloader[51] = '/images/MembersIndex/next_day'; 
preloader[52] = '/images/MembersIndex/first_week'; 
preloader[53] = '/images/MembersIndex/second_week'; 
*/
preloader[54] = '/images/MembersIndex/spacer';
img_status[54] = 0;
preloader[55] = '/images/MembersIndex/spacer'; 
img_status[55] = 0;
/*preloader[56] = '/images/MembersIndex/vita_shoplist'; 
preloader[57] = '/images/MembersIndex/view_supp_plan_choices'; 
preloader[58] = '/images/MembersIndex/view_supp_choice_grey';
*/
preloader[59] = '/images/MembersIndex/weight_loss';
img_status[59] = 0;
/*preloader[60] = '/images/MembersIndex/profile_createprofile';
preloader[61] = '/images/MembersIndex/profile_viewprofile';
preloader[62] = '/images/MembersIndex/update_profile';
preloader[63] = '/images/MembersIndex/substitute_exercise';
preloader[64] = '/images/MembersIndex/print_today';
preloader[65] = '/images/MembersIndex/print_week';
preloader[66] = '/images/MembersIndex/advance_week';
preloader[67] = '/images/MembersIndex/choose_this';
preloader[68] = '/images/MembersIndex/food_journal';
preloader[69] = 'images/MembersIndex/stretches';
*/
//preloader[] = '';  // add new image to array if it has rollover ability


var this_color = new Array();
this_color[0] = '#804692'; //attitude
this_color[1] = '#f2114c'; //exercise
this_color[2] = '#67b65d'; //nutrition
this_color[3] = '#007fbf'; //sleep
this_color[4] = '#ffa92e'; //vitamin
this_color[5] = '#a01734'; //corp colours
this_color[6] = 'none'; // no right nav
this_color[7] = '#c7c7c7'; //colour of line if no nav; light grey.

var no_table = '&nbsp;'; //html to write if no table
var yes_table = '<a href="#" class="right_nav_link"><div>link 1</div> </a>'; //html to write if table exists, but has no links.
yes_table += '<a href="#" class="right_nav_link"><div>link 2 </div></a>';
yes_table += '<a href="#" class="right_nav_link"><div>link 3 </div></a>';
yes_table += '<a href="#" class="right_nav_link"><div>link 4 </div></a>';
yes_table += '<a href="#" class="right_nav_link"><div>link 5 </div></a>';
yes_table += '<a href="#" class="right_nav_link"><div>link 6 </div></a>';
yes_table += '<a href="#" class="right_nav_link"><div>link 7 </div></a>';


/*for(i=0; i<preloader.length; i++) // assembles preloaded images for rollovers
{img_status[i] = 0;} //set status for image to set rollover option in control box, made available by copying index number
//alert('img_status[27].status = ' + img_status[27]);
*/
function roller(id,source) //rollover function for images
{var elem = document.getElementById(id);
 elem.src = source;
}

function controlBox(id,preload_num,roll_status)//'natural',7,1,natural_health_on
{//alert(preload_num);
 var element = document.getElementById(id);
    
 var imgString = new String(element.src);
 var imgs = imgString.lastIndexOf("/");
 var imge = imgString.lastIndexOf("_");
  imgString = imgString.substr(imgs+1,imge-imgs-1)
 
 if((preload_num > 14) && ((preload_num != 25) && (preload_num !=  26) && (preload_num != 27) && (preload_num != 54) && (preload_num !=  55) && (preload_num !=  59)))
 {var ref_string = "/images/MembersIndex/" + imgString;
  var end_string = (roll_status == 1)? ending_array[1]: ending_array[0];
  ref_string += (end_string + ".gif");
  roller(id,ref_string);
  return true;
 }
 if((preload_num < 8) || (preload_num == 54) || (preload_num ==  55) || (preload_num ==  59))
 	{//alert('img ' + preloader[preload_num] + ' = ' + preload_num);
  	 img_status[preload_num] = (img_status[preload_num] == 0)? 7 : (img_status[preload_num] == 1)? 1 : (img_status[preload_num] > 1)? 7 : 0;
 	 //alert('img_status[preload] = ' + img_status[preload_num]);	
	}
 var src_obj; // make var recieve object reference
 switch (img_status[preload_num])// check status of image; 
	{case 0:
	 	src_obj = (roll_status == 0)?  preloader[preload_num] + ending_array[0] + '.gif': preloader[preload_num] + ending_array[1] + '.gif'; //normal state	
		break; //image flips from off to on
	 case 1:
	 	src_obj = (roll_status == 0)? preloader[preload_num] + ending_array[3] + '.gif': preloader[preload_num] + ending_array[3] + '.gif'; //been clicked: hilight both
	 	break; //image flips from hilite to hilite: contantly hilighted
	 case 2:
	 	src_obj = (roll_status == 0)? preloader[preload_num] + ending_array[2] + '.gif': preloader[preload_num] + ending_array[1] + '.gif'; //been faded: fade/on - out/over
	 	break; //image flips from fade to on
	 case 3:
	 	src_obj = (roll_status == 0)? preloader[preload_num] + ending_array[2] + '.gif': preloader[preload_num] + ending_array[0] + '.gif'; //been faded: fade/off - softer out/over
	 	break; //image flips from fade to off
	 case 4:
	 	src_obj = (roll_status == 0)? preloader[preload_num] + ending_array[1] + '.gif': preloader[preload_num] + ending_array[1] + '.gif'; //spts: both on state
	 	break; //image flips from on to on: constanly on
	 case 5:
	 	src_obj = (roll_status == 0)? preloader[preload_num] + ending_array[1] + '.gif': preloader[preload_num] + ending_array[0] + '.gif'; //been faded: fade/on - out/over
	 	break; //image flips from on to off
	 case 6:
	 	src_obj = (roll_status == 0)? preloader[preload_num] + ending_array[2] + '.gif': preloader[preload_num] + ending_array[0] + '.gif'; //been faded: fade/off - softer out/over
	 	break; //image flips from fade to off
	 case 7:
	 	src_obj = (roll_status == 0)? preloader[preload_num] + ending_array[0] + '.gif': preloader[preload_num] + ending_array[3] + '.gif'; //been faded: fade/off - softer out/over
	 	break; //image flips from off to hilite
	}
	//alert('id= ' + id + '; src_obj= ' + src_obj); 		
 roller(id,src_obj); //send to roller function 
}


function getDate2()
{	var mydate=new Date();
	var year=mydate.getYear();

	if (year<2000)
		year=1900+year;
	
	var day=mydate.getDay();
	var month=mydate.getMonth();
	var daym=mydate.getDate();

	if (daym<10)
		daym=""+daym;

	var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
    return ""+montharray[month]+" "+daym+", "+year+"";
}

var gif_array = new Array(); // holds src string for rounded corner gif in the right nav table.
gif_array[0] = '/images/MembersIndex/attitude_bottom.gif';
gif_array[1] = '/images/MembersIndex/exercise_bottom.gif';
gif_array[2] = '/images/MembersIndex/nutrition_bottom.gif';
gif_array[3] = '/images/MembersIndex/sleep_bottom.gif';
gif_array[4] = '/images/MembersIndex/vitamin_bottom.gif';
gif_array[5] = '/images/MembersIndex/right_nav_bottom.gif';
gif_array[6] = '/images/MembersIndex/spacer.gif';
//gif_array[] = '';


function gifSwitcher(id,which) //switches spacer gif for rounded corner gif in the right nav table.
{document.getElementById(id).src = gif_array[which];}

//array to set up rollover images for initial page display
var img_set_array = new Array(0,54,2,3,4,5,6,7,8,9,10,11,12,13,14,26,59); //for second position: 1 = no animation 54 = 2sec animation, 55 = 5 sec animation for financial health
var img_set_array1 = new Array(0,54,2,3,4,5,6,7,8,9,10,11,12,13,14,25,59); 

function setImages()//function to set up the images in inital state: add to id_holder if when adding to images
{

var which = 0;
var check_it = document.getElementById('become').src;

check_it = check_it.toString();

if(check_it.indexOf('goto')!= -1)
{img_status[25] = 0;}
else
{img_status[26] = 0;}//agent btn}

if(check_it.indexOf('goto')!= -1)
	{which = 1;}
	else
	{which = 0;}

 

 if(which == 1)
	{for(d=0; d<17; d++)
		{controlBox(id_holder[d],img_set_array1[d],0);}
	}
 else
	{for(d=0; d<17; d++)
		{controlBox(id_holder[d],img_set_array[d],0);}
	}
}

function fnStartInterval()
{
	oInterval = window.setInterval("fnRecycle()",1000);
}

function fnRecycle()
{// Code to display seconds.
   var the_para = document.getElementById('the_time');
   if (s < 10)
	{
		s = s + 1;
	}	
	else
	{
		s = 0;
	}

   if(s<10)
	{the_para.innerHTML = '&nbsp; ' + s;}
   else
	{the_para.innerHTML = s;}
}

function checkRadio(id) // checks if a radio button is checked
{document.getElementById(id).checked = true;
 frmVit.submit();
}

function newWin(the_url,win_name,the_width,bars) //used to popup new window
{var the_options = (arguments.length < 1)? "" : "width=" + the_width ;
 the_options += (bars == 1)? ",scrollbars" : ""; 
 var new_window = (arguments.length > 1)? eval("window.open(the_url,win_name,'" + the_options + "')") : window.open(the_url,'shopping_page','width=420,scrollbars');
 new_window.focus();
}

var the_window = null;
function newWindow(the_url,win_name,the_width,the_height,bars)
{var final_width = (the_width == 0)? (screen.width - 20) : the_width; //pass 0 as value for the_width to set width to available screen size
 var final_height = (the_height == 0)? (screen.height - 100) : the_height; //same for height
 var settings = 'width=' + final_width + ',height=' + final_height + ',scrollbars=' + bars + ',left=5,top=5,resizable';
 the_window = window.open(the_url,win_name,settings);
}


/*
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
win = window.open(mypage,myname,settings)
}
//<a href="#" onclick="NewWindow(this.href,'name','200','300','yes');return false">Website Abstraction</a>
*/

function newWindow22(the_url,win_name,the_width,the_height,bars)
{
	var the_window = null;
	var final_width = (the_width == 0)? (screen.width - 500) : the_width; //pass 0 as value for the_width to set width to available screen size
	var final_height = (the_height == 0)? (screen.height - 550) : the_height; //same for height
	var settings = 'width=' + final_width + ',height=' + final_height + ',scrollbars=' + bars + ',left=5,top=5,resizable,toolbar=yes';
	the_window = window.open(the_url,win_name,settings);
}