swfobject.embedSWF("/flash/infoTabs.swf", "infoTabsFlash", "380", "320", "8.0.0", "", {}, { wmode: 'transparent' });
swfobject.embedSWF("/flash/player_flv_maxi.swf", "videoPlayer", "440", "276", "8.0.0", "", {
    flv:'/video/ALMAAndrewBinns.flv',
    autoplay: 1, 
    showplayer: 'always', 
    width: 440, 
    height: 276,
    showvolume: 1,
    showtime: 1
  });

/* inner fade */
$(function(){
	$('#partnersFlash').innerfade({ speed: 'slow', timeout: 5000, type: 'sequence', containerheight: '93px' });
});


jQuery(function($){
  
  // load in form validation and behaviors
  if($('#frmRegistration').is('*')) $.getScript("/js/forms/_registration_form.js");
  if($('#frmLogin').is('*')) $.getScript("/js/forms/_login_form.js");
  if($('#frmResetPassword').is('*')) $.getScript("/js/forms/_reset_password_form.js");
  if($('#frmProfile').is('*')) $.getScript("/js/forms/_profile_form.js");
  if($('#frmChangePassword').is('*')) $.getScript("/js/forms/_change_password.js");
  if($('#frmContact').is('*')) $.getScript("/js/forms/_contact_form.js");
  if($('#memberRegForm').is('*')) $.getScript("/js/forms/_member_reg_form.js");
  if($('#memberRenewForm').is('*')) $.getScript("/js/forms/_member_renew_form.js");
  if($('#eventRego').is('*')) $.getScript("/js/forms/_events_reg_form.js");
  
  // load all external links in a new window
  $('a[href*="http"]:not([href*="lifestylemedicine"])').attr('target', '_blank');
  
  // if there is an iframe on the page, customise the page specific to this user
  if($('iframe').is('*'))
  {
    $.ga.customisePage();
  }
  
  // Replace <audio> tags with flash players for browsers that don't support them (most browsers)
  $.each(document.getElementsByTagName('audio'), function(i){
    if(!this.canPlayType || (!this.canPlayType('audio/mp3') && !this.canPlayType('audio/mpeg')))
    {
      var generated_id = 'audio_player_' + i;
      $(this).attr('id', generated_id);
      swfobject.embedSWF('/flash/player_mp3.swf', generated_id, 300, 70, '8.0.0', "", { mp3: $(this).attr('src') });
    }
  });
  
});

//set default onmouseover event
//allows operation of banner menu code
//by default the menu hiding will occur while over a page element
document.onmouseover = f_NavMenuHide;

//load flash elements
//EventUtil.addEvent(window, 'load', fLoadFlashElements , false);

function fLoadFlashElements()
{
	//alert(document.location.hostname);
	
	//var FO = { movie:"flash/infoTabs.swf", width:"380", height:"320",majorversion:"8", build:"0", wmode:"opaque" };
    //UFO.create(FO, "infoTabsFlash");
	//swfobject.embedSWF("flash/infoTabs.swf", "infoTabsFlash", "380", "320", "8.0.0", "", {}, { wmode: 'transparent' });
	
	//var FO = { movie:"http://www.lifestylemedicine.net.au/flash/partnersLogoCycle.swf", width:"180", height:"100",majorversion:"8", build:"0", wmode:"opaque" };
    //UFO.create(FO, "partnersFlash");
	//swfobject.embedSWF("http://www.lifestylemedicine.net.au/flash/partnersLogoCycle.swf", "partnersFlash", "180", "100", "8.0.0", "");
};//end function

//handles automatically setting external links to open in a new window
//bypasses the depracation of the target attribute in A elements
//NOTE: More complex example at http://www.456bereastreet.com/archive/200610/opening_new_windows_with_javascript_version_12/
function fPageElementLinks() {
	//check if getElementsByTagName method is accesible
	if (document.getElementsByTagName) {
		a = document.getElementsByTagName("a");
		for(i=0; i<a.length; i++) {
			if(a[i].getAttribute("rel") && a[i].getAttribute("rel") == "external") {
				a[i].onclick = function() {
					window.open(this.getAttribute('href'));
					return false;
				}//end function
			}//end if
		}//end for
	}//end if
}//end function fPageElementLinks

EventUtil.addEvent(window, 'load', fPageElementLinks , false);



//*******************************************************************************************
//NAVIGATION
//*******************************************************************************************

//handles main nav menu operations
function f_navMenu(pm_key){
	//get key
	var my_key = pm_key;
	
	//find data procedures
	switch(my_key){
		case("about"):
			f_navMenuShow("navSubAbout");
			//f_styleBgPath("navAbout","url(images/navTabLeftRo.gif)");
			f_styleBgPosition("navAbout","left -50px");
			f_styleColor("navAbout","#ffffff");
			//f_styleBgPath("navAboutLi","url(images/navTabRightRo.gif)");
			f_styleBgPosition("navAboutLi","right -50px");
			//f_styleZindex("navSubAbout", '200');
			break;
		case("healthInfo"):
			f_navMenuShow("navSubHealthInfo");
			//f_styleBgPath("navHealthInfo","url(images/navTabLeftRo.gif)");
			f_styleBgPosition("navHealthInfo","left -50px");
			f_styleColor("navHealthInfo","#ffffff");
			//f_styleBgPath("navHealthInfoLi","url(images/navTabRightRo.gif)");
			f_styleBgPosition("navHealthInfoLi","right -50px");
			//f_styleZindex("navSubHealthInfo", '200');
			break;
		case("healthTools"):
			f_navMenuShow("navSubHealthTools");
			//f_styleBgPath("navHealthTools","url(images/navTabLeftRo.gif)");
			f_styleBgPosition("navHealthTools","left -50px");
			f_styleColor("navHealthTools","#ffffff");
			//f_styleBgPath("navHealthToolsLi","url(images/navTabRightRo.gif)");
			f_styleBgPosition("navHealthToolsLi","right -50px");
			//f_styleBgPosition("navDownloads","0px -35px");
			//f_styleZindex("navSubHealthTools", '200');
			break;
		case("healthProfessionals"):
			f_navMenuShow("navSubHealthProfessionals");
			//f_styleBgPath("navHealthTools","url(images/navTabLeftRo.gif)");
			f_styleBgPosition("navHealthProfessionals","left -50px");
			f_styleColor("navHealthProfessionals","#ffffff");
			//f_styleBgPath("navHealthToolsLi","url(images/navTabRightRo.gif)");
			f_styleBgPosition("navHealthProfessionalsLi","right -50px");
			//f_styleBgPosition("navDownloads","0px -35px");
			//f_styleZindex("navSubHealthTools", '200');
			break;
	}//end switch
}//end function f_navMenu

//handles hiding menus
function f_NavMenuHide(pm_array){
	//store list of menu div id's in global
	var g_menu_ids_list = ["navSubAbout","navSubHealthInfo","navSubHealthTools","navSubHealthProfessionals"];
	
	//hold list of sub menu refs for this page
	//retrieve from global
	var my_list = g_menu_ids_list;
	
	//iterate through id list
	for(i in my_list){
		//get menu object
		//menu object is a div containing menu elements
		var my_object_name = my_list[i];
		var my_object_menu = document.getElementById(my_object_name);
		
		//make menu divs invisible 
		if(my_object_menu!=null){my_object_menu.style.visibility='hidden'};
		
		//my_object_menu.style.zIndex = '100';
		//f_styleZindex(my_object_name, '100');
	}//end for
	
	//reset all buttons
	//f_styleBgPath("navAbout","url(images/navTabLeft.gif)");
	f_styleBgPosition("navAbout","top left");
	f_styleColor("navAbout","#747474");
	//f_styleBgPath("navAboutLi","url(images/navTabRight.gif)");
	f_styleBgPosition("navAboutLi","top right");
	
	//f_styleBgPath("navHealthInfo","url(images/navTabLeft.gif)");
	f_styleBgPosition("navHealthInfo","top left");
	f_styleColor("navHealthInfo","#747474");
	//f_styleBgPath("navHealthInfoLi","url(images/navTabRight.gif)");
	f_styleBgPosition("navHealthInfoLi","top right");
			
	
	//f_styleBgPath("navHealthTools","url(images/navTabLeft.gif)");
	f_styleBgPosition("navHealthTools","top left");
	f_styleColor("navHealthTools","#747474");
	//f_styleBgPath("navHealthToolsLi","url(images/navTabRight.gif)");
	f_styleBgPosition("navHealthToolsLi","top right");

	//f_styleBgPath("navHealthTools","url(images/navTabLeft.gif)");
	f_styleBgPosition("navHealthProfessionals","top left");
	f_styleColor("navHealthProfessionals","#747474");
	//f_styleBgPath("navHealthToolsLi","url(images/navTabRight.gif)");
	f_styleBgPosition("navHealthProfessionalsLi","top right");
	
	//f_styleBgPosition("navAbout","0px 0px");
	//f_styleBgPosition("navPortfolio","0px 0px");
	
}//end function f_NavMenuHide

//handles showing menus
function f_navMenuShow(pm_object){
	//shut all menus
	f_NavMenuHide();
	
	//get object to swap background image
	var my_object_name = pm_object;
	//var my_object = document.getElementById(my_object_name);
	//if(my_object==null){return(false)};
	
	//set visibility of object to true
	f_styleVisibility(my_object_name,true);
}//end function f_navMenuShow

//*******************************************************************************************
//END NAVIGATION
//*******************************************************************************************

//*******************************************************************************************
//STYLES
//*******************************************************************************************

//handles changing position of a background style
function f_styleBgPosition(pm_object,pm_pos){
	//get object to swap background image
	var my_object_name = pm_object;
	var my_object = document.getElementById(my_object_name);
	if(my_object==null){return(false)};
	
	//get path to new image
	var my_pos = pm_pos;
	
	//set background image
	//my_object.style.backgroundImage = my_path;
	my_object.style.backgroundPosition = my_pos;
}//end function f_styleBgPosition

//handles changing path of a background style
function f_styleBgPath(pm_object,pm_path){
	//get object to swap background image
	var my_object_name = pm_object;
	var my_object = document.getElementById(my_object_name);
	if(my_object==null){return(false)};
	
	//get path to new image
	var myPath = pm_path;
	
	//set background image
	//my_object.style.backgroundImage = my_path;
	my_object.style.backgroundImage = myPath;
}//end function f_styleBgPath

//handles changing color of a style
function f_styleColor(pm_object,pm_color){
	//get object to swap background image
	var my_object_name = pm_object;
	var my_object = document.getElementById(my_object_name);
	if(my_object==null){return(false)};
	
	//get path to new image
	var myColor = pm_color;
	
	//set background image
	//my_object.style.backgroundImage = my_path;
	my_object.style.color = myColor;
}//end function f_styleColor

//handles setting visibility of a style
function f_styleVisibility(pm_object,pm_visibility){
	//get div object to show
	var my_object = pm_object;
	my_object = document.getElementById(my_object);
	//check if object exists
	if(my_object==null){return(false)};
	
	//get visibility boolean
	if(pm_visibility){
		my_visibility = "visible";
	}else{
		my_visibility = "hidden";
	}//end if
	
	//show sub menu div object
	my_object.style.visibility = my_visibility;
}//end function f_styleVisibility

//handles setting visibility of a style
function f_styleZindex(pm_object,pm_zindex){
	//get div object to show
	var my_object = pm_object;
	
	my_object = document.getElementById(my_object);
	//check if object exists
	if(my_object==null){return(false)};
	
	//get visibility boolean
	var my_zindex = pm_zindex;
	
	//show sub menu div object
	my_object.style.zIndex = my_zindex;
}//end function f_styleVisibility

//handles setting class of an element
function f_styleClass(pm_object,pm_class){
	//get div object to show
	var my_object = pm_object;
	my_object = document.getElementById(my_object);
	
	//get class to apply
	var myClass = pm_class;
	
	//check if object exists
	if(my_object==null){return(false)};
	
	//get visibility boolean
	//if(pm_visibility){
		//my_visibility = "visible";
	//}else{
		//my_visibility = "hidden";
	//}//end if
	
	//show sub menu div object
	my_object.className = "poo";
}//end function f_styleVisibility

//*******************************************************************************************
//END STYLES
//*******************************************************************************************
