//for rollover image swapping
function swapImg(iRef,iName,scn)
{
  tmp=eval("document."+iRef);
  tmp.src="images/"+scn+"/"+iName+".jpg";
}
function swapImg2(iRef,iName,scn)
{
  tmp=eval("document."+iRef);
  tmp.src="../images/"+scn+"/"+iName+".jpg";
}


function winPop(url)
{
  window.open(url,"popup","status=no,width=500,height=400,status=no,toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=no,addressbar=no");
}

function winPop2(show)
{
  window.open("../popup2.asp?shw="+show, "popup","status=no,width=400,height=500,locationbar=no,scrollbars=no,menubar=no");
}

function prevExercise(user,eID)
{
  var path;
  if (user=="n")
    path="../";
  else
    path="";
    
  window.open(path+"popExercise.asp?eID="+eID, "ExercisePreview","status=no,width=500,height=600,locationbar=no,scrollbars=yes,menubar=no,resizable=no,address=no,addressbar=no,location=no",false);
}


function openPrint(user,ID) {
  var path;
  if (user=="n")
    path="../";
  else
    path="";

	window.open(path+"printwkOut.asp?ID="+ID,'prnt',"height=600,width=400,status=no,toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=no,addressbar=no",false);
}


function openCal(op,op1) {
	window.open("calendar/popup_cal.asp?op="+op+"&op1="+op1,'cal',"height=225,width=220,status=no,toolbar=no,scrollbars=no,menubar=no,location=no,resizable=no",false);
}

function chkForm()
{
  var frm=document.forms[0];
  
  if ((frm.realname.value=="") || (frm.email.value==""))
    alert("Please fill in the required fields.");
  else
    frm.submit();
}

//***************************************************************
//  set past workout ID
//***************************************************************
function setPastWorkout(frmobj)
{
      var frm=frmobj;
      var frmOb=document.forms[0];
      frmOb.ID2.value=frm.options[frm.selectedIndex].value;
      frmOb.submit();
}

//***************************************************************
//  set exercise category
//***************************************************************
function setExerCat(frmobj,catNum)
{
      var frm=frmobj;
      frm.catNum.value=catNum;
      frm.submit();
}

//***************************************************************
//  show exercise form field
//***************************************************************
function exerciseOther(frmobj,id1)
{
      var frm=frmobj;
      //frm.exerID.value=eNum;
      if (frm.options[frm.selectedIndex].value == 0)
      {
        document.getElementById(id1).style.display = 'block';
        document.getElementById(id1).focus();
      }
        else{document.getElementById(id1).style.display = 'none';
      }
      
}
//***************************************************************
//  show exercise form field 2
//***************************************************************
function exerciseOther2(frmobj,id1,id2)
{
      var frm=frmobj;
      selVal=eval("frm."+id2+".options[frm."+id2+".selectedIndex]");
      if (selVal.value == 0)
      {
        document.getElementById(id1).style.display = 'block';
        document.getElementById(id1).focus();
      }
        else{document.getElementById(id1).style.display = 'none';
      }
      
}


//***************************************************************
//  Check workout form for workout name
//***************************************************************
function checkWkOut(frmobj,st)
{
  var frm=document.forms[0];
    frm.mode.value=st;

     if (frm.wkoutName.value=="")
       alert("Please enter a workout name."); 
     else 
      frm.submit();
}

//***************************************************************
//  set variables to update for workouts
//***************************************************************
function setExercise(frmobj,type,pos,rowID,st,ed,eID,eName)
{
  var frm=document.forms[0];
     frm.type.value=type;
     frm.arrayPos.value=pos;
     frm.rowID.value=rowID;
     frm.mode.value=st;
     frm.evDate.value=ed;
     exSel=eval("frm."+eID+".options[frm."+eID+".selectedIndex]");
     exName=eval("frm."+eName);
     msg1="Please enter in the exercise."
      // alert(frm.type.value); 
      //alert(frm.mode.value); 

     if ((frm.type.value=="wkName") && (frm.wkoutName.value==""))
       alert("Please enter a workout name."); 
     else if (exSel.value == 0)
       if (exName.value=="")
       {
       alert(msg1);
       exName.focus();
       }
       else
         frm.submit();
     else 
       frm.submit();
}

//***************************************************************
//  check for email for ebook
//***************************************************************
function eBookEml(frmobj)
{
  var frm=document.forms[0];
	 
     if ((frm.eml1.value=="") && (frm.eml2.value==""))
       alert("Please enter at least one email address."); 
     else 
       frm.submit();
}
//***************************************************************
//  set variables to update for workouts
//***************************************************************
function setExercise2(frmobj,type,pos,rowID,st,ed)
{
  var frm=document.forms[0];
     frm.type.value=type;
     frm.arrayPos.value=pos;
     frm.rowID.value=rowID;
     frm.mode.value=st;
     frm.evDate.value=ed;
	 
     if ((frm.type.value=="wkName") && (frm.wkoutName.value==""))
       alert("Please enter a workout name."); 
     else 
       frm.submit();
}

//***************************************************************
//  set variables to update for workouts
//***************************************************************
function setMemberExercise(frmobj,type,pos,rowID,st,ed,eID,eName)
{
  var frm=document.forms[0];
     frm.type.value=type;
     frm.arrayPos.value=pos;
     frm.rowID.value=rowID;
     frm.mode.value=st;
     frm.evDate.value=ed;
     exName=eval("frm."+eName);
     msg1="Please type an exercise name."
      // alert(frm.type.value); 
      //alert(frm.mode.value); 

       if (exName.value=="")
       {
       alert(msg1);
       exName.focus();
       }
       else
         frm.submit();
}

//***************************************************************
//  set variables to update for workouts
//***************************************************************
function setMemberExercise2(frmobj,type,pos,rowID,st,ed,eID,eName)
{
  var frm=document.forms[0];
     frm.type.value=type;
     frm.arrayPos.value=pos;
     frm.rowID.value=rowID;
     frm.mode.value=st;
     frm.evDate.value=ed;
         frm.submit();
}
//***************************************************************
//  check Member registration
//***************************************************************

  function chkFrmMember(frmObj)
  {
   
		var frm = frmObj;
		var chk = false;
		  msg1 = "Please fill in all required fields.";
		  msg2 = "Please enter at least one phone number.";
		  msg3 = "Please enter a numberic value.";

		if ((frm.fName.value=="")||(frm.lName.value=="")||(frm.userName.value=="")||(frm.pssw.value=="")||
		   (frm.dd.value=="")||(frm.mm.value=="")||(frm.yy.value=="")||(frm.emailAddr.value=="")||(frm.occupation.value=="")||(frm.streetAddr.value=="")||
		   (frm.city.value=="")||(frm.province.value=="")||(frm.country.value=="")||(frm.postalCode.value==""))
		    alert(msg1);
		else if ((frm.hArea.value=="")&&(frm.homePhone.value=="")&&(frm.wArea.value=="")&&(frm.workPhone.value=="")
				&&(frm.cArea.value=="")&&(frm.cellPhone.value==""))
			  alert(msg2);
		else
		  chk=true;

		if (chk)
		{ 		   
		  frm.submit();
		}
   }

//***************************************************************
//  check edit Member
//***************************************************************

  function chkEditMember(frmObj,status)
  {
   
		var frm = frmObj;
		var chk = false;
		  msg1 = "Please fill in all required fields.";
		  msg2 = "Please enter at least one phone number.";
       
        if (status=="ca")
        {    frm.sbmt.value="Cancel Account";
		  chk=true;
        }
        else
        {
			if ((frm.fName.value=="")||(frm.lName.value=="")||
			  (frm.birthDate.value=="")||(frm.emailAddr.value=="")||(frm.occupation.value=="")||(frm.streetAddr.value=="")||
			   (frm.city.value=="")||(frm.province.value=="")||(frm.country.value=="")||(frm.postalCode.value==""))
			    alert(msg1);
			else if ((frm.homePhone.value=="")&&(frm.workPhone.value=="")&&(frm.cellPhone.value==""))
				  alert(msg2);
			else
			{
			  chk=true;
			  frm.sbmt.value="Update";
			}
		}

		if (chk)
		{
		  frm.submit();
		}
   }

//***************************************************************
//  check edit Member
//***************************************************************

  function chkPsswMember(frmObj)
  {
   
		var frm = frmObj;
		var chk = false;
		  msg1 = "Please fill in all required fields.";

		if ((frm.userName.value=="")||(frm.pssw.value==""))
		    alert(msg1);
		else
		{
		  chk=true;
		  frm.sbmt.value="Update";
		}

		if (chk)
		{
		  frm.submit();
		}
   }

//***************************************************************
//  check trainer registration
//***************************************************************

  function chkFrmTrainer(frmObj)
  {
   
		var frm = frmObj;
		var chk = false;
		  msg1 = "Please fill in all required fields.";
		  msg2 = "Please enter at least one phone number.";
		  msg3 = "Please enter a numberic value.";

		if ((frm.fName.value=="")||(frm.lName.value=="")||(frm.userName.value=="")||(frm.userPassword.value=="")||
		   (frm.dd.value=="")||(frm.mm.value=="")||(frm.yy.value=="")||(frm.emailAddr.value=="")||(frm.streetAddr.value=="")||
		   (frm.city.value=="")||(frm.province.value=="")||(frm.country.value=="")||(frm.postalCode.value==""))
		    alert(msg1);
		else if ((frm.hArea.value=="")&&(frm.homePhone.value=="")&&(frm.cArea.value=="")&&(frm.cellPhone.value==""))
			  alert(msg2);
		else
		  chk=true;

		if (chk)
		{ 		   
		  frm.submit();
		}
   }

//***************************************************************
//  check profile stats 
//***************************************************************

  function chkFrmStats(frmObj)
  {
   
		var frm = frmObj;
		var chk = true;
		  msg1 = "Please enter a numberic value for ";


		if (frm.weight.value!="")
		{
		  if (isNaN(frm.weight.value))
		  {
		    alert(msg1+"weight.");
		     chk=false;
		  }
		}
		
		 if (document.getElementById('ft'))
		{
		 if (frm.ft.value!="")
		 {
		  if (isNaN(frm.ft.value)||isNaN(frm.inch.value))
		  {
		    alert(msg1+"height.");
		     chk=false;
		  }
		 } 
		}
		
		if (frm.ffm.value!="")
		{
		  if (isNaN(frm.ffm.value))
		  {
		    alert(msg1+"fat free mass.");
		     chk=false;
		  }
		}
		
		if (frm.fat.value!="")
		{
		  if (isNaN(frm.fat.value))
		  {
		    alert(msg1+"fat mass.");
		     chk=false;
		  }
		}
		
		if (frm.fatPercent.value!="")
		{
		  if (isNaN(frm.fatPercent.value))
		  {
		    alert(msg1+"fat percent.");
		     chk=false;
		  }
		}
		
		if (frm.hr.value!="")
		{
		  if (isNaN(frm.hr.value))
		  {
		    alert(msg1+"heart rate.");
		     chk=false;
		  }
		}
		
		if (frm.shoulder.value!="")
		{
		  if (isNaN(frm.shoulder.value))
		  {
		    alert(msg1+"shoulder.");
		     chk=false;
		  }
		}
		
		if (frm.chest.value!="")
		{
		  if (isNaN(frm.chest.value))
		  {
		    alert(msg1+"chest.");
		     chk=false;
		  }
		}
		
		if (frm.bicep.value!="")
		{
		  if (isNaN(frm.bicep.value))
		  {
		    alert(msg1+"bicep.");
		     chk=false;
		  }
		}
		
		if (frm.waist.value!="")
		{
		  if (isNaN(frm.waist.value))
		  {
		    alert(msg1+"waist.");
		     chk=false;
		  }
		}
		
		if (frm.abdomen.value!="")
		{
		  if (isNaN(frm.abdomen.value))
		  {
		    alert(msg1+"abdomen.");
		     chk=false;
		  }
		}
		
		if (frm.hips.value!="")
		{
		  if (isNaN(frm.hips.value))
		  {
		    alert(msg1+"hips.");
		     chk=false;
		  }
		}
		
		if (frm.thigh.value!="")
		{
		  if (isNaN(frm.thigh.value))
		  {
		    alert(msg1+"thigh.");
		     chk=false;
		  }
		}
		
		if (frm.calf.value!="")
		{
		  if (isNaN(frm.calf.value))
		  {
		    alert(msg1+"calf.");
		     chk=false;
		  }
		}

		if (chk)
		{ 		   
		  frm.submit();
		}
   }
   
   
   //***************************************************************
//  check package 
//***************************************************************

  function chkPackage(frmObj)
  {
   
		var frm = frmObj;
		var chk = true;
		  msg = "Please enter all required information.";
		  msg1 = "Please enter a numberic value for ";


		if (frm.totSessions.value!="")
		{
		  if (isNaN(frm.totSessions.value))
		  {
		    alert(msg1+"total sessions purchased.");
		     chk=false;
		  }
		}else alert(msg);
		
		
		if (frm.rate.value!="")
		{
		  if (isNaN(frm.rate.value))
		  {
		    alert(msg1+"rate.");
		     chk=false;
		  }
		}else alert(msg);
		

		if (chk)
		{ 		   
		  frm.submit();
		}
   }

function showDiv(obj,totPrice,duration)
{
  if(document.getElementById){
    divs=document.getElementById("cont").getElementsByTagName("DIV");
    divs2=document.getElementById("cont2").getElementsByTagName("DIV");
    divs3=document.getElementById("cont3").getElementsByTagName("DIV");
    
    num=obj;
  for(i=0;i<divs.length;i++){
    if (divs[i].className=="txt"){ 
      if(i==num)
      {divs[i].style.display = "block";
       divs2[i].style.display = "block";
       divs3[i].style.display = "block";
       document.apForm.a3.value=totPrice;
       document.apForm.p3.value=duration;
      }
      else{
      divs[i].style.display = "none";
      divs2[i].style.display = "none";
      divs3[i].style.display = "none";
      }
    } 
  }
  }
  //alert(document.apForm.a3.value);
}
  
 //***********************************  
 // Tool Tips  
 //***********************************
	var dhtmlgoodies_tooltip = false;
	var dhtmlgoodies_tooltipShadow = false;
	var dhtmlgoodies_shadowSize = 4;
	var dhtmlgoodies_tooltipMaxWidth = 350;
	var dhtmlgoodies_tooltipMinWidth = 100;
	var dhtmlgoodies_iframe = false;
	var tooltip_is_msie = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('opera')==-1 && document.all)?true:false;
	function showTooltip(e,tooltipTxt)
	{
		
		var bodyWidth = Math.max(document.body.clientWidth,document.documentElement.clientWidth) - 20;
	
		if(!dhtmlgoodies_tooltip){
			dhtmlgoodies_tooltip = document.createElement('DIV');
			dhtmlgoodies_tooltip.id = 'dhtmlgoodies_tooltip';
			dhtmlgoodies_tooltipShadow = document.createElement('DIV');
			dhtmlgoodies_tooltipShadow.id = 'dhtmlgoodies_tooltipShadow';
			
			document.body.appendChild(dhtmlgoodies_tooltip);
			document.body.appendChild(dhtmlgoodies_tooltipShadow);	
			
			if(tooltip_is_msie){
				dhtmlgoodies_iframe = document.createElement('IFRAME');
				dhtmlgoodies_iframe.frameborder='5';
				dhtmlgoodies_iframe.style.backgroundColor='#FFFFFF';
				dhtmlgoodies_iframe.src = '#'; 	
				dhtmlgoodies_iframe.style.zIndex = 100;
				dhtmlgoodies_iframe.style.position = 'absolute';
				document.body.appendChild(dhtmlgoodies_iframe);
			}
			
		}
		
		dhtmlgoodies_tooltip.style.display='block';
		dhtmlgoodies_tooltipShadow.style.display='block';
		if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='block';
		
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
		var leftPos = e.clientX + 10;
		
		dhtmlgoodies_tooltip.style.width = null;	// Reset style width if it's set 
		dhtmlgoodies_tooltip.innerHTML = tooltipTxt;
		dhtmlgoodies_tooltip.style.left = leftPos + 'px';
		dhtmlgoodies_tooltip.style.top = e.clientY + 10 + st + 'px';

		
		dhtmlgoodies_tooltipShadow.style.left =  leftPos + dhtmlgoodies_shadowSize + 'px';
		dhtmlgoodies_tooltipShadow.style.top = e.clientY + 10 + st + dhtmlgoodies_shadowSize + 'px';
		
		if(dhtmlgoodies_tooltip.offsetWidth>dhtmlgoodies_tooltipMaxWidth){	/* Exceeding max width of tooltip ? */
			dhtmlgoodies_tooltip.style.width = dhtmlgoodies_tooltipMaxWidth + 'px';
		}
		
		var tooltipWidth = dhtmlgoodies_tooltip.offsetWidth;		
		if(tooltipWidth<dhtmlgoodies_tooltipMinWidth)tooltipWidth = dhtmlgoodies_tooltipMinWidth;
		
		
		dhtmlgoodies_tooltip.style.width = tooltipWidth + 'px';
		dhtmlgoodies_tooltipShadow.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
		dhtmlgoodies_tooltipShadow.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';		
		
		if((leftPos + tooltipWidth)>bodyWidth){
			dhtmlgoodies_tooltip.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth)) + 'px';
			dhtmlgoodies_tooltipShadow.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth) + dhtmlgoodies_shadowSize) + 'px';
		}
		
		if(tooltip_is_msie){
			dhtmlgoodies_iframe.style.left = dhtmlgoodies_tooltip.style.left;
			dhtmlgoodies_iframe.style.top = dhtmlgoodies_tooltip.style.top;
			dhtmlgoodies_iframe.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
			dhtmlgoodies_iframe.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
		
		}
				
	}
	
	function hideTooltip()
	{
		dhtmlgoodies_tooltip.style.display='none';
		dhtmlgoodies_tooltipShadow.style.display='none';		
		if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='none';		
	}
	

