function imagechange(id,file) {

   document.getElementById(id).src = file;

}

function hidediv(id) {

    if(document.getElementById(id) != null) {

    	document.getElementById(id).style.display = 'none';

    }

}


function showdiv(id) {

    if(document.getElementById(id) != null) {

    	document.getElementById(id).style.display = 'block';

    }

}

function togglediv(id) {

    if(document.getElementById(id).style.display == 'none') {

        document.getElementById(id).style.display = 'block';

    } else {

        document.getElementById(id).style.display = 'none';

    }

}

function goto(url){
       if(url != null) {
           document.location=url;
       }
   }


function validate_email(field,alerttxt){

with (field)

{

apos=value.indexOf("@")

dotpos=value.lastIndexOf(".")

if (apos<1||dotpos-apos<2) 

  {alert(alerttxt);return false}

else {return true}

}

}

  

 function FormSubscribe_Validator(Form)

{

// check to see if the field is blank

	

with (Form)

{

if ((Form.email.value==null)||(Form.email.value=="") || (Form.email.value=="E-mail Address")){

		alert("Please Enter Your Email Address")

		Form.txtemail.focus()

		return false

	}

if (validate_email(Form.email,"Your Email Address is Not Valid!")==false)

  {Form.email.focus();return false}

}



}

  

function FormSearch_Validator(Form)

{

// check to see if the field is blank

	

if (Form.search.value == "")

	{

	alert("Please enter your keyword");

	Form.search.focus();

	return (false);

	}



}

function FormComment_Validator(Form)

{

// check to see if the field is blank

	

if (Form.comment.value == "")

	{

	alert("Please enter your comment");

	Form.comment.focus();

	return (false);

	}



}

function FormForgot_Validator(Form){

if (Form.user.value == "")
	{

	alert("Please enter your username");

	Form.user.focus();
	return (false);

	}
}

function FormCard_Validator(Form)

{

// check to see if the field is blank

	

if (Form.From_Name.value == "")

	{

	alert("Please enter your name");

	Form.From_Name.focus();

	return (false);

	}



with (Form)

{

if ((From_Email.value==null)||(From_Email.value=="")){

		alert("Please Enter Your Email Address")

		From_Email.focus()

		return false

	}

if (validate_email(From_Email,"Your Email Address is Not Valid!")==false)

  {From_Email.focus();return false}

}





if (Form.To_Name.value == "")

	{

	alert("Please enter your friend's name.");

	Form.To_Name.focus();

	return (false);

	}

	

with (Form)

{

if ((To_Email.value==null)||(To_Email.value=="")){

		alert("Please Enter Your Friend's Email Address")

		To_Email.focus()

		return false

	}

if (validate_email(To_Email,"Your Friend's Email Address is Not Valid!")==false)

  {To_Email.focus();return false}

}



if (Form.Message.value == "")

	{

	alert("Please enter your message.");

	Form.Message.focus();

	return (false);

	}





}



function FormFriend_Validator(Form)

{

// check to see if the field is blank

	

if (Form.From_Name.value == "")

	{

	alert("Please enter your name");

	Form.From_Name.focus();

	return (false);

	}



with (Form)

{

if ((From_Email.value==null)||(From_Email.value=="")){

		alert("Please Enter Your Email Address")

		From_Email.focus()

		return false

	}

if (validate_email(From_Email,"Your Email Address is Not Valid!")==false)

  {From_Email.focus();return false}

}





if (Form.To_Name.value == "")

	{

	alert("Please enter your friend's name.");

	Form.To_Name.focus();

	return (false);

	}

	

with (Form)

{

if ((To_Email.value==null)||(To_Email.value=="")){

		alert("Please Enter Your Friend's Email Address")

		To_Email.focus()

		return false

	}

if (validate_email(To_Email,"Your Friend's Email Address is Not Valid!")==false)

  {To_Email.focus();return false}

}



}



function FormCompetition_Validator(Form)

{

var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections

for (counter = 0; counter < Form.answer1.length; counter++)

{

// If a radio button has been selected it will return true

// (If not it will return false)

if (Form.answer1[counter].checked)

radio_choice = true; 

}



if (!radio_choice)

{

// If there were no selections made display an alert box 

alert("Please select your first answer.");

return (false);

}


/*
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections

for (counter = 0; counter < Form.answer2.length; counter++)

{

// If a radio button has been selected it will return true

// (If not it will return false)

if (Form.answer2[counter].checked)

radio_choice = true; 

}



if (!radio_choice)

{

// If there were no selections made display an alert box 

alert("Please select your second answer.");

return (false);

}



var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections

for (counter = 0; counter < Form.answer3.length; counter++)

{

// If a radio button has been selected it will return true

// (If not it will return false)

if (Form.answer3[counter].checked)

radio_choice = true; 

}



if (!radio_choice)

{

// If there were no selections made display an alert box 

alert("Please select your third answer.");

return (false);

}
*/
	

if (Form.Name.value == "")

	{

	alert("Please enter your name");

	Form.Name.focus();

	return (false);

	}



with (Form)

{

if ((Email.value==null)||(Email.value=="")){

		alert("Please Enter Your Email Address")

		Email.focus()

		return false

	}

if (validate_email(Email,"Your Email Address is Not Valid!")==false)

  {Email.focus();return false;
  }
  

if ((Remail.value==null)||(Remail.value=="")){

		alert("Please Retype Your Email Address")

		Remail.focus()

		return false

	}

if (validate_email(Remail,"Email Address You Retyped is Not Valid!")==false)

  {Remail.focus();return false;
  }
  
  if (Remail.value!=Email.value)

  {
	  alert("Email Addresses Do Not Match. Please Retype Carfully");
	  Remail.focus();return false;
  }

}





var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections

for (counter = 0; counter < Form.gender.length; counter++)

{

// If a radio button has been selected it will return true

// (If not it will return false)

if (Form.gender[counter].checked)

radio_choice = true; 

}



if (!radio_choice)

{

// If there were no selections made display an alert box 

alert("Please select your gender.");

return (false);

}


if (Form.city_id.value == "")

	{

	alert("Please select your city");

	Form.city_id.focus();

	return (false);

	}
	
if (Form.age.value == "")

	{

	alert("Please select your age group");

	Form.age.focus();

	return (false);

	}



}





function FormEvent_Validator(Form)

{

// check to see if the field is blank

	

if (Form.type.value == "")

	{

	alert("Please select your Event type.");

	Form.type.focus();

	return (false);

	}



if (Form.name.value == "")

	{

	alert("Please enter your Event name");

	Form.name.focus();

	return (false);

	}

	

if (Form.venue.value == "")

	{

	alert("Please enter your Event venue.");

	Form.venue.focus();

	return (false);

	}

if (Form.content.value == "")

	{

	alert("Please provide Event details.");

	Form.content.focus();

	return (false);

	}



with (Form)

{

if ((email.value==null)||(email.value=="")){

		alert("Please Enter Event organizer's Email Address")

		email.focus()

		return false

	}

if (validate_email(email,"Email Address is Not Valid!")==false)

  {email.focus();return false}

}

}

function FormRegister_Validator(Form)
{
// check to see if the field is blank
	
if ( Form.user.value == "")
	{
	alert("Please Enter Your Username");
	Form.user.focus();
	return (false);
	}

with (Form)
{
if ((Form.email.value==null)||(Form.email.value=="") ){
		alert("Please Enter Your Email Address")
		Form.email.focus()
		return false
	}
if (validate_email(email,"Your Email Address is Not Valid!")==false)
  {Form.email.focus();return false}
}

if (Form.email2.value == "")
	{
	alert("Please Re-enter Your Email Address.");
	Form.email2.focus();
	return (false);
	}
	
if (Form.email.value != Form.email2.value)
	{
	alert("Your Email Addresses do not match!");
	Form.email2.focus();
	return (false);
	}

if (Form.first_name.value == "")
	{
	alert("Please Enter Your First Name.");
	Form.first_name.focus();
	return (false);
	}

if (Form.last_name.value == "")
	{
	alert("Please Enter Your Last Name.");
	Form.last_name.focus();
	return (false);
	}
	
	
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections

for (counter = 0; counter < Form.gender.length; counter++)

{

// If a radio button has been selected it will return true

// (If not it will return false)

if (Form.gender[counter].checked)

radio_choice = true; 

}



if (!radio_choice)

{

// If there were no selections made display an alert box 

alert("Please select your gender.");

return (false);

}


if (Form.city_id.value == "")

	{

	alert("Please select your city");

	Form.city_id.focus();

	return (false);

	}
	
if (Form.age_group.value == "")

	{

	alert("Please select your age group");

	Form.age_group.focus();

	return (false);

	}
	
}

function FormProfile_Validator(Form)
{
// check to see if the field is blank
	
if (Form.first_name.value == "")
	{
	alert("Please Enter Your First Name.");
	Form.first_name.focus();
	return (false);
	}

if (Form.last_name.value == "")
	{
	alert("Please Enter Your Last Name.");
	Form.last_name.focus();
	return (false);
	}
	
	
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections

for (counter = 0; counter < Form.gender.length; counter++)

{

// If a radio button has been selected it will return true

// (If not it will return false)

if (Form.gender[counter].checked)

radio_choice = true; 

}



if (!radio_choice)

{

// If there were no selections made display an alert box 

alert("Please select your gender.");

return (false);

}


if (Form.city_id.value == "")

	{

	alert("Please select your city");

	Form.city_id.focus();

	return (false);

	}
	
if (Form.age_group.value == "")

	{

	alert("Please select your age group");

	Form.age_group.focus();

	return (false);

	}
	
}

function FormPassword_Validator(Form)
{
// check to see if the field is blank
	
if ( Form.curpass.value == "")
	{
	alert("Please Enter Your Current Password.");
	Form.curpass.focus();
	return (false);
	}

if (Form.newpass.value == "")
	{
	alert("Please Enter Your New Password.");
	Form.newpass.focus();
	return (false);
	}
	
else if (Form.newpass.value.length <= 3)
	{
	alert("Your New Password is too short. Please select a longer password");
	Form.newpass.focus();
	return (false);
	}
	
if (Form.newpass2.value != Form.newpass.value)
	{
	alert("Your Password does not match with the selected new Password. Please re-enter it.");
	Form.newpass2.focus();
	return (false);
	}
}

function FormLogin_Validator(Form)
{
// check to see if the field is blank
	
if ( Form.user.value == "")
	{
	alert("Please Enter Your Username");
	Form.user.focus();
	return (false);
	}

if (Form.pass.value == "")
	{
	alert("Please Enter Your Password.");
	Form.pass.focus();
	return (false);
	}
	
}

function CheckMultiple1(frm, name) {
				for (var i=0; i < frm.length; i++)
				{
					fldObj = frm.elements[i];
					fldId = fldObj.id;
					if (fldId) {
						var fieldnamecheck=fldObj.id.indexOf(name);
						if (fieldnamecheck != -1) {
							if (fldObj.checked) {
								return true;
							}
						}
					}
				}
				return false;
			}

function CheckSubscribe(f) {
			var email_re = /[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i;
			if (!email_re.test(f.email.value)) {
				alert("Please enter your email address.");
				f.email.focus();
				return false;
			}
		
				return true;
			}

//** Tab Content script v2.0- ) Dynamic Drive DHTML code library (http://www.dynamicdrive.com)

//** Updated Oct 7th, 07 to version 2.0. Contains numerous improvements:

//   -Added Auto Mode: Script auto rotates the tabs based on an interval, until a tab is explicitly selected

//   -Ability to expand/contract arbitrary DIVs on the page as the tabbed content is expanded/ contracted

//   -Ability to dynamically select a tab either based on its position within its peers, or its ID attribute (give the target tab one 1st)

//   -Ability to set where the CSS classname "selected" get assigned- either to the target tab's link ("A"), or its parent container 



////NO NEED TO EDIT BELOW////////////////////////



function ddtabcontent(tabinterfaceid){

	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container

	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container

	this.enabletabpersistence=true

	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container

	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)

	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)

	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")

}



ddtabcontent.getCookie=function(Name){ 

	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair

	if (document.cookie.match(re)) //if cookie found

		return document.cookie.match(re)[0].split("=")[1] //return its value

	return ""

}



ddtabcontent.setCookie=function(name, value){

	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)

}



ddtabcontent.prototype={



	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers

		this.cancelautorun() //stop auto cycling of tabs (if running)

		var tabref=""

		try{

			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr

				tabref=document.getElementById(tabid_or_position)

			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr

				tabref=this.tabs[tabid_or_position]

		}

		catch(err){alert("Invalid Tab ID or position entered!")}

		if (tabref!="") //if a valid tab is found based on function parameter

			this.expandtab(tabref) //expand this tab

	},



	setpersist:function(bool){ //PUBLIC function to toggle persistence feature

			this.enabletabpersistence=bool

	},



	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")

		this.selectedClassTarget=objstr || "link"

	},



	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to

		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref

	},



	expandtab:function(tabref){

		var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand

		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through

		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""

		this.expandsubcontent(subcontentid)

		this.expandrevcontent(associatedrevids)

		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"

			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""

		}

		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers

			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)

	},



	expandsubcontent:function(subcontentid){

		for (var i=0; i<this.subcontentids.length; i++){

			var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)

			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value

		}

	},


	expandrevcontent:function(associatedrevids){

		var allrevids=this.revcontentids

		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface

			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it

			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"

		}

	},



	autorun:function(){ //function to auto cycle through and select tabs based on a set interval

		var currentTabIndex=this.automode_currentTabIndex //index within this.hottabspositions to begin

		var hottabspositions=this.hottabspositions //Array containing position numbers of "hot" tabs (those with a "rel" attr)

		this.expandtab(this.tabs[hottabspositions[currentTabIndex]])

		this.automode_currentTabIndex=(currentTabIndex<hottabspositions.length-1)? currentTabIndex+1 : 0 //increment currentTabIndex

	},



	cancelautorun:function(){

		if (typeof this.autoruntimer!="undefined")

			clearInterval(this.autoruntimer)

	},



	init:function(automodeperiod){

		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)

		var persisterror=true //Bool variable to check whether persisted tab position is valid (can become invalid if user has modified tab structure)

		this.automodeperiod=automodeperiod || 0

		for (var i=0; i<this.tabs.length; i++){

			this.tabs[i].tabposition=i //remember position of tab relative to its peers

			if (this.tabs[i].getAttribute("rel")){

				var tabinstance=this

				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers

				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)

				this.tabs[i].onclick=function(){

					tabinstance.expandtab(this)

					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)

					return false

				}

				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element

					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))

				}

				if (this.enabletabpersistence && parseInt(persistedtab)==i || !this.enabletabpersistence && this.getselectedClassTarget(this.tabs[i]).className=="selected"){

					this.expandtab(this.tabs[i]) //expand current tab if it's the persisted tab, or if persist=off, carries the "selected" CSS class

					persisterror=false //Persisted tab (if applicable) was found, so set "persisterror" to false

					//If currently selected tab's index(i) is greater than 0, this means its not the 1st tab, so set the tab to begin in automode to 1st tab:

					this.automode_currentTabIndex=(i>0)? 0 : 1

				}

			}

		} //END for loop

		if (persisterror) //if an error has occured while trying to retrieve persisted tab (based on its position within its peers)

			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr

		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){

			this.automode_currentTabIndex=this.automode_currentTabIndex || 0

			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)

		}

	} //END int() function

} //END Prototype assignment  

 function get_bmr() {
         if (document.bmr_calc.weight.value.length == 0 || document.bmr_calc.weight.value == 0 ) {
              alert('Weight field must not contain 0 or an empty value!'); return false; }
         if (document.bmr_calc.height.value.length == 0 || document.bmr_calc.height.value == 0) {
              alert('Height field must not contain 0 or an empty value!'); return false; }
         if (document.bmr_calc.age.value.length == 0 || document.bmr_calc.age.value == 0) {
              alert('Age field must not contain 0 or an empty value!'); return false; }

         if (document.bmr_calc.gender1[0].checked) {
            document.bmr_calc.result_bmr.value = 665.51+(9.463*(document.bmr_calc.weight.value))+(1.8496*(document.bmr_calc.height.value) * 2.54)-(4.6756*(document.bmr_calc.age.value));
         }
         if (document.bmr_calc.gender1[1].checked) {
            document.bmr_calc.result_bmr.value = 66.473+(13.751*(document.bmr_calc.weight.value))+(5.0033*(document.bmr_calc.height.value) * 2.54)-(6.55*(document.bmr_calc.age.value));
         }
         num1 = Math.pow(10, 2);
         document.bmr_calc.result_bmr.value = Math.round(document.bmr_calc.result_bmr.value * num1) / num1;
        }
		
function convertIntoMeters() {
            var h= eval(document.bmr_calc.height.value);
            if(h!=null && h!=0)
            {
                document.bmr_calc.heightmeter.value= (h / 100);
            }
            else
            {
                document.bmr_calc.heightmeter.value= 0;
            }
        }
		
 function get_whr() {
         if (document.whr_calc.waist.value.length == 0 || document.whr_calc.waist.value==0) {
              alert('Waist field must not contain 0 or an empty value!'); return false; }
         if (document.whr_calc.hip.value.length == 0 || document.whr_calc.hip.value==0) {
              alert('Hip field must not contain 0 or an empty value!'); return false; }

         num1 = Math.pow(10, 2);
         document.whr_calc.result_whr.value = document.whr_calc.waist.value / document.whr_calc.hip.value;
         document.whr_calc.result_whr.value = Math.round(document.whr_calc.result_whr.value * num1) / num1;
         if (document.whr_calc.gender[0].checked) {
            if (document.whr_calc.result_whr.value <= 0.80) {
               document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Good and you fall in the Low Risk category!"; }
            if ((document.whr_calc.result_whr.value > 0.80) && (document.whr_calc.result_whr.value < 0.85)) {
               document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Acceptable and you fall in the Moderate Risk category!"; }
            if (document.whr_calc.result_whr.value >= 0.85) {
               document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Poor and you fall in the High Risk category!"; }
         }
         if (document.whr_calc.gender[1].checked) {
            if (document.whr_calc.result_whr.value <= 0.95) {
               document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Good and you fall in the Low Risk category!"; }
            if ((document.whr_calc.result_whr.value > 0.95) && (document.whr_calc.result_whr.value <= 1.00)) {
               document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Acceptable and you fall in the Moderate Risk category!"; }
            if (document.whr_calc.result_whr.value > 1.00) {
               document.whr_calc.verdict_whr.value = "Your waist-to-hip ratio is Poor and you fall in the High Risk category!"; }
         }
        }
    
function isNumberKey(evt){
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
    
