// JavaScript Function Library
VENDOR = ''

// Check DOM support
if 	(document.getElementById)	DOMS = 3	// Supports Web Standard
else if	(document.all)		DOMS = 2	// Supports MS document.all
else if	(document.layers)	 	DOMS = 0	// Supports NS layers
else				DOMS = 0;	// No DOM gateway support

// Return DOM object pointer for appropriate DOM interface
function getObj(s) {
  switch(DOMS) { 
    case 1: return(document[s]);
    case 2: return(document.all[s]);
    case 3: return(document.getElementById(s));
  }
}

// Reset input field color when changed
function fldReset() { this.style.backgroundColor=''; this.style.borderColor='#bbbbbb'; }

// display error message, color error field, set 
function setErm(f,m) {
  alert(m);
  f.onchange = fldReset;
  f.style.backgroundColor="#ff9"; 
  f.style.borderColor="#f00"; 
  f.focus(); 
  return false;
}

// Check mailto form field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkMailform(s) {
   if (s.Name.value=='')		return setErm(s['Name'],		'You must enter your name to continue.')
   if (s.Telephone.value=='')		return setErm(s['Telephone'],		'You must enter your daytime phone number to continue.')
   if (s.EveTelephone.value=='')	return setErm(s['EveTelephone'],	'You must enter your evening phone number to continue.')
   if (s['MM_EMAILTO[]'][1].value=='')	return setErm(s['MM_EMAILTO[]'][1],	'You must enter your email address to continue.')
   if (s.Email.value=='')		return setErm(s['Email'],		'You must verify your email address to continue.')
   return true;
}

// Check manager registration form field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkMRegform(s) {
   if (s.rusername.value=='')			return setErm(s['rusername'],		'You must enter your username to continue.')
   if (s.rpw.value=='')			return setErm(s['rpw'],		'You must enter your password to continue.')
   if (s.rpwr.value=='')			return setErm(s['rpwr'],		'You must enter your Repeat Password to continue.')
   if (s.rpw.value!=s.rpwr.value)		return setErm(s['rpw'],		'Password and repeat password do not match.')
   if (s.TeamName.value=='')			return setErm(s['TeamName'],		'You must enter A Team Name to continue.')
   if (s.DivId.selectedIndex==0)		return setErm(s['DivId'],		'You must select a team division to continue.');

   if (s.firstname.value=='')			return setErm(s['firstname'],		'You must enter your first name to continue.')
   if (s.lastname.value=='')			return setErm(s['lastname'],		'You must enter your last name to continue.')
   if (s.dob.value=='')			return setErm(s['dob'],		'You must enter your date of birth to continue.')
   if (s.phone.value=='')			return setErm(s['phone'],		'You must enter your phone number to continue.')
   if (s.Address.value=='')			return setErm(s['Address'],		'You must enter your address to continue.')
   if (s.City.value=='')			return setErm(s['City'],		'You must enter your city to continue.')
   if (s.State.value=='')			return setErm(s['State'],		'You must enter your state to continue.')
   if (s.zip.value=='')			return setErm(s['zip'],		'You must enter your zipcode to continue.')
   if (s.countries_id.selectedIndex==0)		return setErm(s['countries_id'],	'You must select a country to continue.');
   if (s.email.value=='')			return setErm(s['email'],		'You must enter your email address to continue.')
   if (s.email.value.indexOf('@')==-1)		return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
   if (s.email.value.indexOf('.')==-1)		return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
   if (s.paymode.selectedIndex==0) {									// If paying by creditcard, check these fields
     if (s.billing_firstname.value=='')		return setErm(s['billing_firstname'],	'You must enter your Repeat Password to continue.')
     if (s.billing_lastname.value=='')		return setErm(s['billing_lastname'],	'You must enter your Repeat Password to continue.')
     if (s.billing_address.value=='')		return setErm(s['billing_address'],	'You must enter your Repeat Password to continue.')
     if (s.billing_city.value=='')		return setErm(s['billing_city'],	'You must enter your Repeat Password to continue.')
     if (s.billing_state.value=='')		return setErm(s['billing_state'],	'You must enter your Repeat Password to continue.')
     if (s.billing_zip.value=='')		return setErm(s['billing_zip'],	'You must enter your Repeat Password to continue.')
     if (s.billing_email.value=='')		return setErm(s['billing_email'],	'You must enter your Repeat Password to continue.')
     if (s.billing_email.value.indexOf('@')==-1)	return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
     if (s.billing_email.value.indexOf('.')==-1)	return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
     if (s.billing_phone.value=='')		return setErm(s['billing_phone'],	'You must enter your Repeat Password to continue.')
     if (s.CardType.selectedIndex==0)		return setErm(s['CardType'],		'You must select a credit card type to continue.');
     if (s.CardNumber.value=='')		return setErm(s['CardNumber'],	'You must enter your Repeat Password to continue.')
     if (s.CVV.value=='')			return setErm(s['CVV'],		'You must enter your Repeat Password to continue.')
     //if (s.cardMonth.selectedIndex==0)		return setErm(s['cardMonth'],		'You must select a credit card expiration month to continue.');
     //if (s.cardYear.selectedIndex==0)		return setErm(s['cardYear'],		'You must select a credit card expiration year to continue.');
   }
   return true;
}
// Check manager registration form field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkTRegform(s) {
   if (s.rusername.value=='')			return setErm(s['rusername'],		'You must enter your username to continue.')
   if (s.rpw.value=='')			return setErm(s['rpw'],		'You must enter your password to continue.')
   if (s.rpwr.value=='')			return setErm(s['rpwr'],		'You must enter your Repeat Password to continue.')
   if (s.rpw.value!=s.rpwr.value)		return setErm(s['rpw'],		'Password and repeat password do not match.')
   if (s.TeamName.value=='')			return setErm(s['TeamName'],		'You must enter A Team Name to continue.')
   if (s.DivId.selectedIndex==0)		return setErm(s['DivId'],		'You must select a team division to continue.');
   if (s.SkillLevel.selectedIndex==0)		return setErm(s['SkillLevel'],	'You must select a team skill level to continue.');
   if (s.tourId.selectedIndex==0)		return setErm(s['tourId'],		'You must select a tournament to continue.');

   if (s.firstname.value=='')			return setErm(s['firstname'],		'You must enter your first name to continue.')
   if (s.lastname.value=='')			return setErm(s['lastname'],		'You must enter your last name to continue.')
   if (s.dob.value=='')			return setErm(s['dob'],		'You must enter your date of birth to continue.')
   if (s.phone.value=='')			return setErm(s['phone'],		'You must enter your phone number to continue.')
   if (s.Address.value=='')			return setErm(s['Address'],		'You must enter your address to continue.')
   if (s.City.value=='')			return setErm(s['City'],		'You must enter your city to continue.')
   if (s.State.value=='')			return setErm(s['State'],		'You must enter your state to continue.')
   if (s.zip.value=='')			return setErm(s['zip'],		'You must enter your zipcode to continue.')
   if (s.countries_id.selectedIndex==0)		return setErm(s['countries_id'],	'You must select a country to continue.');
   if (s.email.value=='')			return setErm(s['email'],		'You must enter your email address to continue.')
   if (s.email.value.indexOf('@')==-1)		return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
   if (s.email.value.indexOf('.')==-1)		return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
   if (s.paymode.selectedIndex==0) {									// If paying by creditcard, check these fields
     if (s.billing_firstname.value=='')		return setErm(s['billing_firstname'],	'You must enter your Repeat Password to continue.')
     if (s.billing_lastname.value=='')		return setErm(s['billing_lastname'],	'You must enter your Repeat Password to continue.')
     if (s.billing_address.value=='')		return setErm(s['billing_address'],	'You must enter your Repeat Password to continue.')
     if (s.billing_city.value=='')		return setErm(s['billing_city'],	'You must enter your Repeat Password to continue.')
     if (s.billing_state.value=='')		return setErm(s['billing_state'],	'You must enter your Repeat Password to continue.')
     if (s.billing_zip.value=='')		return setErm(s['billing_zip'],	'You must enter your Repeat Password to continue.')
     if (s.billing_email.value=='')		return setErm(s['billing_email'],	'You must enter your Repeat Password to continue.')
     if (s.billing_email.value.indexOf('@')==-1)	return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
     if (s.billing_email.value.indexOf('.')==-1)	return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
     if (s.billing_phone.value=='')		return setErm(s['billing_phone'],	'You must enter your Repeat Password to continue.')
     if (s.CardType.selectedIndex==0)		return setErm(s['CardType'],		'You must select a credit card type to continue.');
     if (s.CardNumber.value=='')		return setErm(s['CardNumber'],	'You must enter your Repeat Password to continue.')
     if (s.CVV.value=='')			return setErm(s['CVV'],		'You must enter your Repeat Password to continue.')
     if (s.cardMonth.selectedIndex==0)		return setErm(s['cardMonth'],		'You must select a credit card expiration month to continue.');
     if (s.cardYear.selectedIndex==0)		return setErm(s['cardYear'],		'You must select a credit card expiration year to continue.');
   }
   return true;
}

function setPaymode(s) {
  if (s.value=="CH") {
    cca.style.display="none"; 
    cci.style.display="none"; 
  }
  else {  
    cca.style.display="block"; 
    cci.style.display="block"; 
  }
}

function regBillSame(s) {
  s.form.billing_firstname.value = s.form.firstname.value;
  s.form.billing_lastname.value  = s.form.lastname.value;
  s.form.billing_address.value   = s.form.Address.value;
  s.form.billing_city.value      = s.form.City.value;
  s.form.billing_state.value     = s.form.State.value;
  s.form.billing_zip.value       = s.form.zip.value;
  s.form.billing_email.value     = s.form.email.value;
  s.form.billing_phone.value     = s.form.phone.value;
}


function regBillSameEvent(s) {
  s.form.billing_firstname.value = s.form.XX_firstname.value;
  s.form.billing_lastname.value  = s.form.XX_lastname.value;
  s.form.billing_address.value   = s.form.XX_Address.value;
  s.form.billing_city.value      = s.form.XX_City.value;
  s.form.billing_state.value     = s.form.XX_State.value;
  s.form.billing_zip.value       = s.form.XX_zip.value;
  s.form.billing_email.value     = s.form.XX_email.value;
  s.form.billing_phone.value     = s.form.XX_phone.value;
}
function regBillSameInd(s) {
  s.form.billing_firstname.value = s.form.XX_FirstName.value;
  s.form.billing_lastname.value  = s.form.XX_LastName.value;
  s.form.billing_address.value   = s.form.XX_Address.value;
  s.form.billing_city.value      = s.form.XX_City.value;
  s.form.billing_state.value     = s.form.XX_States.value;
  s.form.billing_zip.value       = s.form.XX_Zip.value;
  s.form.billing_email.value     = s.form.XX_email.value;
  s.form.billing_phone.value     = s.form.XX_Phone.value;
}
function imgRot(s,pt,tm) {
  document.images[s].src = "images/"+s+"/"+pt+".jpg";
  ++pt;
  if (pt>6) { pt = 1 };
  setTimeout('imgRot("' + s + '",' + pt + ',' + tm + ')',tm);
}

function populate() {
  if (DOMS==0) {
    ns_marquee=document.ns_marquee.document.ns_marquee2
    ns_marquee.top=parseInt(marqueeheight)+8
    ns_marquee.document.write(marqueecontent)
    ns_marquee.document.close()
    actualheight=ns_marquee.document.height
  }
  else {
    cross_marquee=document.getElementById? document.getElementById('iemarquee') : document.all.iemarquee
    cross_marquee.style.top=parseInt(marqueeheight)+8+'px'
    cross_marquee.innerHTML=marqueecontent
    actualheight=cross_marquee.offsetHeight
  }
  lefttime=setInterval('scrollmarquee()',20)
}

function scrollmarquee(){
  if (DOMS==0) {
    if (ns_marquee.top>(actualheight*(-1)+8))  ns_marquee.top-=copyspeed
    else                                       ns_marquee.top=parseInt(marqueeheight)+8
  }
  else {
    if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))    cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+'px'
    else                                                            cross_marquee.style.top=parseInt(marqueeheight)+8+'px'
  }
}

function setmarquee() {
  var marqueewidth='165px'
  var marqueeheight='140px'
  var marqueespeed=1
  var pauseit=1

  var marqueecontent=content;

  marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) 
  var copyspeed=marqueespeed
  var pausespeed=(pauseit==0)? copyspeed: 0
  var iedom=document.all||document.getElementById
  var actualheight=''
  var cross_marquee, ns_marquee

  window.onload=populate

//if (iedom||document.layers) {
    with (document) {
      if (iedom) {
        write('<div style=\"background-color:#ffffdd;position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden\" onMouseover=\"copyspeed=pausespeed\" onMouseout=\"copyspeed=marqueespeed\">')
        write('<div id=\"iemarquee\" style=\"position:absolute;left:10px;top:0px;width:100%;\">')
        write('</div></div>')
      }
      else if (document.layers) {
        write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name=\"ns_marquee\">')
        write('<layer name=\"ns_marquee2\" width='+marqueewidth+' height='+marqueeheight+' left=0 top=0 onMouseover=\"copyspeed=pausespeed\" onMouseout=\"copyspeed=marqueespeed\"></layer>')
        write('</ilayer>')
      }
    }
//}
}

function assignAll(num) { 
  for (var i=0; i<num; i++) {
    document.forms['assignsel'].elements['assign['+i+']'].checked=true;  
  }
return false;
}

function verifyDelete(s)				{ return(confirm("Are you sure you want to delete " + s + "?")); }

function editUser(user_id,ADM_FUNC)			{ window.open('admin_users_edit.php?user_id='+user_id+'&ADM_FUNC='+ADM_FUNC,'user','height=500,width=600,scrollbars,resizable'); return false; }
function editNewUser(user_id,ADM_FUNC)			{ window.open('admin_newusers_edit.php?user_id='+user_id+'&ADM_FUNC='+ADM_FUNC,'newuser','height=300,width=300,scrollbars,resizable'); return false; }
function editSeason(SeasonId,ADM_FUNC)			{ window.open('admin_seasons_edit.php?SeasonId='+SeasonId+'&ADM_FUNC='+ADM_FUNC,'season','height=600,width=400,scrollbars,resizable'); return false; }
function editTeam(TeamId,DivId,ADM_FUNC)		{ window.open('admin_teams_edit.php?TeamId='+TeamId+'&DivId='+DivId+'&ADM_FUNC='+ADM_FUNC,'team','height=700,width=500,scrollbars,resizable'); return false; }
function editLink(id,ADM_FUNC)			{ window.open('admin_links_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'link','height=250,width=500,scrollbars,resizable'); return false; }
function editSpotlight(album_id,ADM_FUNC)		{ window.open('admin_spotlights_edit.php?album_id='+album_id+'&ADM_FUNC='+ADM_FUNC,'spotlight','height=250,width=500,scrollbars,resizable'); return false; }
function editPhoto(album_id,pic_id,ADM_FUNC)		{ window.open('admin_spotlight_album.php?album_id='+album_id+'&pic_id='+pic_id+'&ADM_FUNC='+ADM_FUNC,'photos','height=500,width=700,scrollbars,resizable'); return false; }
function editLocation(LocationId,ADM_FUNC)		{ window.open('admin_locations_edit.php?LocationId='+LocationId+'&ADM_FUNC='+ADM_FUNC,'location','height=600,width=600,scrollbars,resizable'); return false; }
function editNews(Id,ADM_FUNC)			{ window.open('admin_news_edit.php?Id='+Id+'&ADM_FUNC='+ADM_FUNC,'news','height=650,width=800,scrollbars,resizable'); return false; }
function editTeamImages(TeamId,theoption)			{ window.open('admin_userteampics.php?TeamId='+TeamId+'&option='+theoption,'teamimages','height=650,width=800,scrollbars,resizable'); return false; }
function editInsiderNews(Id,ADM_FUNC,AgeGroupId)			{ window.open('admin_insidernews_edit.php?Id='+Id+'&ADM_FUNC='+ADM_FUNC+'&AgeGroupId='+AgeGroupId,'innews','height=610,width=560,scrollbars,resizable'); return false; }
function editGuest(id,ADM_FUNC)			{ window.open('admin_guestbook_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'guest','height=550,width=560,scrollbars,resizable'); return false; }
function editEvent(id,ADM_FUNC)			{ window.open('admin_events_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'event','height=450,width=440,scrollbars,resizable'); return false; }
function editEventSchedule(id,ADM_FUNC)			{ window.open('admin_event_schedule_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'event','height=600,width=800,scrollbars,resizable'); return false; }
function editHandout(id,ADM_FUNC)			{ window.open('admin_handouts_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'handout','height=240,width=440,scrollbars,resizable'); return false; }
function editTourn(Id,SeasonId,ADM_FUNC)		{ window.open('admin_tournaments_edit.php?Id='+Id+'&SeasonId='+SeasonId+'&ADM_FUNC='+ADM_FUNC,'tourney','height=600,width=800,scrollbars,resizable'); return false; }
function editComment(Id,ADM_FUNC)			{ window.open('admin_comments_edit.php?Id='+Id+'&ADM_FUNC='+ADM_FUNC,'comment','height=500,width=540,scrollbars,resizable'); return false; }
function editWelcome()				{ window.open('admin_welcome_edit.php','welcome','height=600,width=600,scrollbars,resizable'); return false; }
function editFee(fees_type,ADM_FUNC)			{ window.open('admin_fees_edit.php?fees_type='+fees_type+'&ADM_FUNC='+ADM_FUNC,'fee','height=200,width=300,scrollbars,resizable'); return false; }
function editRegFee(id,ADM_FUNC)			{ window.open('admin_registration_fees_edit.php?registration_fee_id='+id+'&ADM_FUNC='+ADM_FUNC,'fee','height=400,width=500,scrollbars,resizable'); return false; }
function editBanner(id,ADM_FUNC)			{ window.open('admin_banners_edit.php?banner_id='+id+'&ADM_FUNC='+ADM_FUNC,'banners','height=600,width=800,scrollbars,resizable'); return false; }
function editDivision(DivId,SeasonId,ADM_FUNC)		{ window.open('admin_divisions_edit.php?DivId='+DivId+'&SeasonId='+SeasonId+'&ADM_FUNC='+ADM_FUNC,'division','height=400,width=440,scrollbars,resizable'); return false; }
function editLeaguereg(id)				{ window.open('admin_leaguereg_edit.php?id='+id,'leaguereg','height=550,width=550,scrollbars,resizable'); return false; }
function editWhocoming(id)				{ window.open('admin_whocoming_edit.php?id='+id,'whocoming','height=550,width=550,scrollbars,resizable'); return false; }
function editHsdivisions(id,ADM_FUNC)				{ window.open('admin_hsdivisions_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'hsdivisions','height=550,width=550,scrollbars,resizable'); return false; }
function editHelpwanted(id,ADM_FUNC)			{ window.open('admin_helpwanted_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'helpwanted','height=550,width=550,scrollbars,resizable'); return false; }
function editHelpwantedMgr(id,ADM_FUNC)			{ window.open('admin_manager_helpwanted_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'helpwanted','height=550,width=550,scrollbars,resizable'); return false; }
function editSuspension(id,ADM_FUNC)			{ window.open('admin_suspension_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'helpwanted','height=550,width=550,scrollbars,resizable'); return false; }
function editFPS(id,ADM_FUNC)			{ window.open('admin_fpspartners_edit.php?id='+id+'&ADM_FUNC='+ADM_FUNC,'FPSadmin','height=550,width=550,scrollbars,resizable'); return false; }
function viewAlbum(pic_id)				{ window.open('album_view.php?pic_id='+pic_id,'albumview','height=600,width=800,scrollbars,resizable'); return false; }
function editGame(SeasonId,DivId,GameId,ADM_FUNC,ADM_OP)	{ window.open('admin_games_edit.php?SeasonId='+SeasonId+'&DivId='+DivId+'&GameId='+GameId+'&ADM_FUNC='+ADM_FUNC+'&ADM_OP='+ADM_OP,'game','height=600,width=650,scrollbars,resizable'); return false; }
function editGow(Game_Id,ADM_FUNC)			{ window.open('admin_gameofweek_edit.php?Game_Id='+Game_Id+'&ADM_FUNC='+ADM_FUNC,'gameofweek','height=260,width=400,scrollbars,resizable'); return false; }
function editScore(DivId,GameId,Id,ADM_FUNC)		{ window.open('admin_scores_edit.php?DivId='+DivId+'&GameId='+GameId+'&Id='+Id+'&ADM_FUNC='+ADM_FUNC,'game','height=600,width=700,scrollbars,resizable'); return false; }
function editPitchStats(DivId,GameId,TeamId,ADM_FUNC)		{ window.open('admin_stats_pitch_edit.php?DivId='+DivId+'&GameId='+GameId+'&TeamId='+TeamId+'&ADM_FUNC='+ADM_FUNC,'stats','height=600,width=880,scrollbars,resizable'); return false; }
function editHitStats(DivId,GameId,TeamId,ADM_FUNC)		{ window.open('admin_stats_hit_edit.php?DivId='+DivId+'&GameId='+GameId+'&TeamId='+TeamId+'&ADM_FUNC='+ADM_FUNC,'stats','height=600,width=880,scrollbars,resizable'); return false; }
function editRoster(role,TeamId,user_id,Id,ADM_FUNC)	{ window.open('admin_rosters_edit.php?role='+role+'&TeamId='+TeamId+'&user_id='+user_id+'&Id='+Id+'&ADM_FUNC='+ADM_FUNC,'user','height=550,width=800,scrollbars,resizable'); return false; }
function selRoster(SeasonId,TeamId)			{ window.open('admin_rosters_sel.php?SeasonId='+SeasonId+'&TeamId='+TeamId,'selplayer','height=700,width=900,scrollbars,resizable'); return false; }
function showEvent(id)				{ window.open('event.php?id='+id,'event','height=340,width=300,scrollbars,resizable'); return false; }
function editPw()					{ window.open('admin_password_edit.php','password','height=260,width=400,scrollbars,resizable'); return false; }


function showPlayer(weblink,playerinfo)			{ window.open('showPlayer.php?weblink='+weblink+'&playerinfo='+escape(playerinfo),'showplayer','height=600,width=530,scrollbars,resizable'); return false; }

function GameChanger(gc_id,SeasonId)				{ window.open('admin_gamechanger_edit.php?gc_id='+gc_id+'&SeasonId='+SeasonId,'gc','height=500,width=600,scrollbars,resizable'); return false; }

function AgeCalculator()				{ window.open('age.php','age','height=400,width=500,scrollbars,resizable'); return false; }

