//------------------------------------------------------------------------------------------------
//11/3/04 following two variables are global variables that need to be set here, they are used in
//        the following two functions (LoadHomePageBanners, GoToHomePageBannerURL)
//------------------------------------------------------------------------------------------------
// delay between banners (in milliseconds)(currently set to 12 seconds)
var bannerDelay = 12000;

		
// Index of the homepage banner & current link
var curbannerindex = -1;

//10/30/04 this function is used in /common/global_header.asp to control dynamic banner rotation
function LoadHomePageBanners() {
	curbannerindex = ((curbannerindex + 1) % bannerURL.length);
	//window.alert('LoadHomePageBanners Function - curbannerindex = ' + curbannerindex);
	document.images["bannerImg"].src = bannerURL[curbannerindex];
	curTimeout = setTimeout("LoadHomePageBanners()", bannerDelay);
}

//10/30/04 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToHomePageBannerURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = linkURL[curbannerindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the home page block ad & current link
var curblockindex = -1;

//5/22/07 this function is used in Default.aspx to control dynamic block ad rotation
function LoadHomePageBlock() {
	curblockindex = ((curblockindex + 1) % blockURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["blockImg"].src = blockURL[curblockindex];
	curTimeout = setTimeout("LoadHomePageBlock()", bannerDelay);
}

//05/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToHomePageBlockURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = blocklinkURL[curblockindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}


// Index of the home page skyscraper ad & current link
var curskyscraperindex = -1;

//5/23/07 this function is used in Default.aspx to control dynamic block ad rotation
function LoadHomePageSkyscraper() {
	curskyscraperindex = ((curskyscraperindex + 1) % skyscraperURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["skyscraperImg"].src = skyscraperURL[curskyscraperindex];
	curTimeout = setTimeout("LoadHomePageSkyscraper()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToHomePageSkyscraperURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = skyscraperlinkURL[curskyscraperindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the news page skyscraper ad & current link
var newsskyscraperindex = -1;

//5/23/07 this function is used in Default.aspx to control dynamic block ad rotation
function LoadNewsPageSkyscraper() {
	newsskyscraperindex = ((newsskyscraperindex + 1) % newsskyscraperURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["newsskyscraperImg"].src = newsskyscraperURL[newsskyscraperindex];
	curTimeout = setTimeout("LoadNewsPageSkyscraper()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToNewsPageSkyscraperURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = newsskyscraperlinkURL[newsskyscraperindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the news page skyscraper ad & current link
var newsblockindex = -1;

//5/23/07 this function is used in Lane 9
//1/5/10 commented out the functionality here so that old stories won't break now that we have switched back to alternating ad instead of rotating
//1/14/10 switched back to rotating ads
function LoadNewsPageBlock() {
	newsblockindex = ((newsblockindex + 1) % newsblockURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["newsblockImg"].src = newsblockURL[newsblockindex];
	curTimeout = setTimeout("LoadNewsPageBlock()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToNewsPageBlockURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = newsblocklinkURL[newsblockindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the news page banner ads
var newsbannerindex = -1;

//5/23/07 this function is used in Lane 9
function LoadNewsPageBanner() {
	newsbannerindex = ((newsbannerindex + 1) % newsbannerURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["newsbannerImg"].src = newsbannerURL[newsbannerindex];
	curTimeout = setTimeout("LoadNewsPageBanner()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToNewsPageBannerURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = newsbannerlinkURL[newsbannerindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}


// Index of the camps page banner ads
var campsbannerindex = -1;

//5/23/07 this function is used on the /commong/banners/Camps.aspx page
function LoadCampsPageBanner() {
	campsbannerindex = ((campsbannerindex + 1) % campsbannerURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["campsbannerImg"].src = campsbannerURL[campsbannerindex];
	curTimeout = setTimeout("LoadCampsPageBanner()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToCampsPageBannerURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = campsbannerlinkURL[campsbannerindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the sidebar button #1
var sidebarbutton1index = -1;

//5/23/07 this function is used in Lane 9
function LoadSidebarButton1() {
	sidebarbutton1index = ((sidebarbutton1index + 1) % sidebarbutton1URL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["sidebarbutton1Img"].src = sidebarbutton1URL[sidebarbutton1index];
	curTimeout = setTimeout("LoadSidebarButton1()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToSidebarButton1URL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = sidebarbutton1linkURL[sidebarbutton1index];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the sidebar button #2
var sidebarbutton2index = -1;

//5/23/07 this function is used in Lane 9
function LoadSidebarButton2() {
	sidebarbutton2index = ((sidebarbutton2index + 1) % sidebarbutton2URL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["sidebarbutton2Img"].src = sidebarbutton2URL[sidebarbutton2index];
	curTimeout = setTimeout("LoadSidebarButton2()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToSidebarButton2URL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = sidebarbutton2linkURL[sidebarbutton2index];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the sidebar button #3
var sidebarbutton3index = -1;

//5/23/07 this function is used in Lane 9
function LoadSidebarButton3() {
	sidebarbutton3index = ((sidebarbutton3index + 1) % sidebarbutton3URL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["sidebarbutton3Img"].src = sidebarbutton3URL[sidebarbutton3index];
	curTimeout = setTimeout("LoadSidebarButton3()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToSidebarButton3URL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = sidebarbutton3linkURL[sidebarbutton3index];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the sidebar button #4
var sidebarbutton4index = -1;

//5/23/07 this function is used in Lane 9
function LoadSidebarButton4() {
	sidebarbutton4index = ((sidebarbutton4index + 1) % sidebarbutton4URL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["sidebarbutton4Img"].src = sidebarbutton4URL[sidebarbutton4index];
	curTimeout = setTimeout("LoadSidebarButton4()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToSidebarButton4URL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = sidebarbutton4linkURL[sidebarbutton4index];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the sidebar button #5
var sidebarbutton5index = -1;

//5/23/07 this function is used in Lane 9
function LoadSidebarButton5() {
	sidebarbutton5index = ((sidebarbutton5index + 1) % sidebarbutton5URL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["sidebarbutton5Img"].src = sidebarbutton5URL[sidebarbutton5index];
	curTimeout = setTimeout("LoadSidebarButton5()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToSidebarButton5URL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = sidebarbutton5linkURL[sidebarbutton5index];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the prep school page banner ads
var prepschoolbannerindex = -1;

//5/23/07 this function is used in Lane 9
function LoadPrepSchoolBanner() {
	prepschoolbannerindex = ((prepschoolbannerindex + 1) % prepschoolbannerURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["prepschoolbannerImg"].src = prepschoolbannerURL[prepschoolbannerindex];
	curTimeout = setTimeout("LoadPrepSchoolBanner()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToprepschoolbannerURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = prepschoolbannerlinkURL[prepschoolbannerindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the college new page banner ads
var collegebannerindex = -1;

//5/23/07 this function is used in Lane 9
function LoadCollegeBanner() {
	collegebannerindex = ((collegebannerindex + 1) % collegebannerURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["collegebannerImg"].src = collegebannerURL[collegebannerindex];
	curTimeout = setTimeout("LoadCollegeBanner()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoTocollegebannerURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = collegebannerlinkURL[collegebannerindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// 5/5/08 Index of the college new page banner ads
var TYMbannerindex = -1;

//5/5/08 this function is used in Lane 9
function LoadTYMBanner() {
	TYMbannerindex = ((TYMbannerindex + 1) % TYMbannerURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["TYMbannerImg"].src = TYMbannerURL[TYMbannerindex];
	curTimeout = setTimeout("LoadTYMBanner()", bannerDelay);
}

//5/5/08 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToTYMbannerURL() {
    //window.alert('GoToTYMbannerURL Function - curbannerindex = ' + curbannerindex);
	url = TYMbannerlinkURL[TYMbannerindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the Camps page skyscraper ad & current link
var CampsSkyscraperindex = -1;

//12/30/09 this function is used in global_footer to control dynamic block ad rotation
function LoadCampsSkyscraper() {
	CampsSkyscraperindex = ((CampsSkyscraperindex + 1) % CampsSkyscraperURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["CampsSkyscraperImg"].src = CampsSkyscraperURL[CampsSkyscraperindex];
	curTimeout = setTimeout("LoadCampsSkyscraper()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToCampsSkyscraperURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = CampsSkyscraperlinkURL[CampsSkyscraperindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

// Index of the Prep Schools page skyscraper ad & current link
var PrepSchoolsSkyscraperindex = -1;

//12/30/09 this function is used in global_footer to control dynamic block ad rotation
function LoadPrepSchoolsSkyscraper() {
	PrepSchoolsSkyscraperindex = ((PrepSchoolsSkyscraperindex + 1) % PrepSchoolsSkyscraperURL.length);
	//window.alert('LoadHomePageBlock Function - curbannerindex = ' + curbannerindex);
	document.images["PrepSchoolsSkyscraperImg"].src = PrepSchoolsSkyscraperURL[PrepSchoolsSkyscraperindex];
	curTimeout = setTimeout("LoadPrepSchoolsSkyscraper()", bannerDelay);
}

//5/23/07 this function is used in /common/global_header.asp to control dynamic banner rotation
function GoToPrepSchoolsSkyscraperURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = PrepSchoolsSkyscraperlinkURL[PrepSchoolsSkyscraperindex];
	window.open(url, "_blank","location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}


//5/01/06 new function to open a pop-up window to play video clip 
 function OpenVideoAd(filename) 
 {
        window.open("SubVideo.asp?filename="+filename,"VideoAd","location=no,status=no,toolbar=no,menubar=no,width=140,height=140,scrollbars=no,resizable=no,directories=no,top=96,left=0","no");
 }


// delay between buttons (in milliseconds)(currently set to 5 seconds)
var buttonDelay = 8000;

// Index of the current button & current link
var curbuttonindex = -1;

//10/26/05 this function is used in /common/global_header.asp to control dynamic button rotation
function LoadHomePageButtons() {
	curbuttonindex = ((curbuttonindex + 1) % buttonURL.length);
	//window.alert('LoadHomePageBanners Function - curbannerindex = ' + curbannerindex);
	document.images["buttonImg"].src = buttonURL[curbuttonindex];
	curButtonTimeout = setTimeout("LoadHomePageButtons()", buttonDelay);
}

//10/26/05 this function is used in /common/global_header.asp to control dynamic button rotation
function GoToButtonURL() {
    //window.alert('GoToHomePageBannerURL Function - curbannerindex = ' + curbannerindex);
	url = buttonlinkURL[curbuttonindex];
	window.open(url, "_self", "location=yes, status=yes, toolbar=yes, menubar=yes, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0 ", "yes");
}

//-------------------------------------
// end of banner rotation code section
//-------------------------------------

function SubmitMailingListSubscription()
{
	
	var siteid		= document.MailingList.siteid.value;
	var mlid		= document.MailingList.mlid.value;
	var activity	= document.MailingList.activity.value;
	var redirection	= document.MailingList.redirection.value;
	var email		= document.MailingList.email.value;
	
	//Check for an email address
	if (email == "")
	{
		alert("Please supply your email address.");
		return false;
	}
	
	//Subscribe
	if (document.MailingList.submitaction[0].checked == true)
	{
		document.location = "http://www.uptilt.com/functions/mailing_list.html?siteid=" + siteid + "&mlid=" + mlid + "&activity=" + activity + "&redirection=" + redirection + "&email=" + email;
	}
	//Unsubscribe
	else if (document.MailingList.submitaction[1].checked == true)
	{
		document.location = "http://www.swimmingworldmagazine.com/newsletter/unsubscribemessage.htm?siteid=" + siteid + "&mlid=" + mlid + "&activity=" + activity + "&redirection=" + redirection + "&email=" + email;
	}
}

//Opens new window to display the URL that is passed in
function OpenNewWindow(url) 
 {
    window.open(url);
 }
 
 //This function is used for security when loging on to the media section to get a media kit
 function MediaLogin(){
	document.cookie="login=False";
	var done=0;
	var username=document.login.username.value;
	username=username.toLowerCase();
	var password=document.login.password.value;
	password=password.toLowerCase();
	if (username=="swimmingworld" && password=="swimmedia") 
	  { 
	    window.location="media_kit_main.asp"; done=1; 
	    document.cookie="login=True";
	  }
	
	if (done==0) 
	  { 
	    alert("Invalid Login"); 
	    document.login.username.focus();
	    document.login.username.select();  
	  }
}


//This function is used to verify that a person has successfully logged on to the media section before
//allowing them to view the media kits.
//8/13/04 commented out transfer to default page because we are no longer requiring a login for media kit access
function VerifyMediaLogin(){
	var loginvalue="False";
	var allcookies = document.cookie;
	var pos=allcookies.indexOf("login=");
	if (pos != -1)
	   {
	     var start = pos + 6;
	     var end = allcookies.indexOf(";",start);
	     if (end == -1) end = allcookies.length;
	     loginvalue = allcookies.substring(start, end);
	     loginvalue = unescape(loginvalue);
	   }
	if (loginvalue !== "True") 
	  { 
	    //window.location="default.asp"; 
	  }
	  
	 
}
 
function checkNewsLetter() {
			var Email		= document.NewsLetter.Email.value;
			var sErr		= ""; 
		
			if (Email == "") 
				sErr += "\n\t* Email Address.";
			else if ((Email.indexOf("@") < 0) 
				|| (Email.indexOf(".") < 0))	
				sErr += "\n\t* VALID Email Address.";
			
			if (sErr == "")
				return true;
			else
			{
				sErr = "You must supply the following required information:\n" + sErr;
				alert(sErr);
				return false;
			}
		} 
		
 
 //Opens new window to display the URL that is passed in - used for premium Archive Section
function OpenNewSWMagWindow(filename) 
 {
    //document.title("test title")
    //window.open("http://65.110.72.225/" + url, "_blank", "location=no, status=no, toolbar=no, menubar=no, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0", "no");
    window.open("/premium/swimming_world/swpdf.asp?a=" + filename, "_blank","location=no,status=no,toolbar=no,menubar=no,width=800,height=600,scrollbars=yes,resizable=yes,directories=no,top=0,left=0","no");

    //window.open(url, "_sw"," ", "yes");
 }
 
  //Opens new window to display the URL that is passed in - used for premium Archive Section
function OpenNewSTMagWindow(filename) 
 {
    //document.title("test title")
    //window.open("http://65.110.72.225/" + url, "_blank", "location=no, status=no, toolbar=no, menubar=no, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0", "no");
    window.open("/premium/swimming_technique/stpdf.asp?a=" + filename, "_blank","location=no,status=no,toolbar=no,menubar=no,width=800,height=600,scrollbars=yes,resizable=yes,directories=no,top=0,left=0","no");

    //window.open(url, "_sw"," ", "yes");
 }
 
 //Opens new window to display the URL that is passed in - used for premium Archive Section
function OpenNewSMMagWindow(filename) 
 {
    //document.title("test title")
    //window.open("http://65.110.72.225/" + url, "_blank", "location=no, status=no, toolbar=no, menubar=no, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0", "no");
    window.open("/premium/swim/smpdf.asp?a=" + filename, "_blank","location=no,status=no,toolbar=no,menubar=no,width=800,height=600,scrollbars=yes,resizable=yes,directories=no,top=0,left=0","no");

    //window.open(url, "_sw"," ", "yes");
 }
 
 //Opens new window to display the URL that is passed in - used for premium Archive Section
function OpenNewLENMagWindow(filename) 
 {
    //document.title("test title")
    //window.open("http://65.110.72.225/" + url, "_blank", "location=no, status=no, toolbar=no, menubar=no, width=800, scrollbars=yes, resizable=yes, directories=no, top=0, left=0", "no");
    window.open("LENpdf.asp?a=" + filename, "_blank","location=no,status=no,toolbar=no,menubar=no,width=800,height=600,scrollbars=yes,resizable=yes,directories=no,top=0,left=0","no");

    //window.open(url, "_sw"," ", "yes");
 }
 
 //used in swimshop/LENwpdfdisplay.asp to display LEN magazine for download
 function openLENpdf(filename)
  {
   window.open("http://magazines.swimmingworld.com:9997/LEN-Magazine/" + filename, "display_pdf" );
  }
 
//used in premium/swimming_world/swpdfdisplay.asp to display SW archive
 function openSWpdf(filename)
  {
   window.open("http://magazines.swimmingworld.com:9997/SW/MagazinePDF/" + filename, "display_pdf" );
  }
  
  //used in premium/swimming_technique/stpdfdisplay.asp to display ST archive 
  function openSTpdf(filename)
  {
   window.open("http://magazines.swimmingworld.com:9997/ST/MagazinePDF/" + filename, "display_pdf" );
  }
  //used in premium/swim/smpdfdisplay.asp to display SM archive 
  function openSMpdf(filename)
  {
   window.open("http://magazines.swimmingworld.com:9997/SM/MagazinePDF/" + filename, "display_pdf" );
  }
 
 
function checkEnterTimeFields() {
		sFromCourse = document.enterTime.sFromCourse.options[0].selected;
		sToCourse = document.enterTime.sToCourse.options[0].selected;
		iEvent = document.enterTime.iEvent.options[0].selected;
		
		iMinutes = document.enterTime.iMinutes.value;
		iSeconds = document.enterTime.iSeconds.value;
		iHundredths = document.enterTime.iHundredths.value;
		
		sGender = document.enterTime.sGender.options[0].selected;	
		
		var sErrors = "";
		
		if (sFromCourse == true) {
			sErrors = sErrors + "\n\t* You must supply a course to convert from.";
		}		
		if (sToCourse == true) {
			sErrors = sErrors + "\n\t* You must supply a course to convert to.";
		}		
		for (var i=1; i < 3; i++) {
			if ((document.enterTime.sFromCourse.options[i].selected == true) &&
				(document.enterTime.sToCourse.options[i].selected == true)) {
			sErrors = sErrors + "\n\t* You cannot convert from the same course.";	
			}
		}
		if (iEvent == true) {
			sErrors = sErrors + "\n\t* You must supply an event.";
		}
		
		// 8/14/02 - commented out because we now have factors for these events
		//if (((document.enterTime.sFromCourse.options[1].selected == true) &&
		// 	 (document.enterTime.sToCourse.options[2].selected == true) &&
		// 	 (document.enterTime.iEvent.options[5].selected == true)) ||
		// 	((document.enterTime.sFromCourse.options[2].selected == true) &&
		// 	 (document.enterTime.sToCourse.options[1].selected == true) &&
		// 	 (document.enterTime.iEvent.options[5].selected == true)) ) {
	    //	sErrors = sErrors + "\n\t* There is no conversion factor for these courses and event.";	
		//}
			
		if (iMinutes != "") {			
			if (isPosInteger(iMinutes) == false) {
				sErrors = sErrors + "\n\t* You must supply your minutes time in integers.";	
			} else {
				if (iMinutes > 59) {
					sErrors = sErrors + "\n\t* You must supply your minutes time from 0 to 59.";
				}
			}
		}
		if (iSeconds != "") {
			if (isPosInteger(iSeconds) == false) {
				sErrors = sErrors + "\n\t* You must supply your seconds time in integers.";	
			} else {
				if (iSeconds > 59) {
					sErrors = sErrors + "\n\t* You must supply your seconds time from 0 to 59.";
				}
			}
		}
		if (iHundredths != "") {
			if (isPosInteger(iHundredths) == false) {
				sErrors = sErrors + "\n\t* You must supply your hundredths time in integers.";	
			}
		}	
				
		if (sGender == true) {
			sErrors = sErrors + "\n\t* You must supply your gender."
		}
	
		if (sErrors == "") {
			return true;
		} else {
			alert("Your form could not be submitted due to the following reasons\n" + sErrors);
			return false;
		}	
	}	
		
	/////////////////////////////////////////////////////
	// CHECKS FOR POSITIVE INTEGERS IN A STRING
	function isPosInteger(inputVal) {
		var inputStr = inputVal.toString();
		for (var i=0; i <inputStr.length; i++) {
			var oneChar = inputStr.charAt(i);
			if ((oneChar < "0") || (oneChar > "9")) {
				return false;
			}
		}
		return true;
	}
	
	//1/19/05 new send e-mail function to hide hardcoded e-mail addresses by not using mailto: links
	function SendEmail(PersonToContact, IncludeMessage) {
	    window.open("/contact_us_email1.asp?a="+PersonToContact+"&b="+IncludeMessage,"SPIEmail","resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,width=775,height=450,top=5,left=5");
   }
   
   //6/29/07 new send e-mail function to be used for the "Reaction Time" reader comments for a news story.
	function SendReactionTimeEmail(PersonToContact, IncludeMessage) {
	    window.open("/ReactionTimeEmail.asp?a="+PersonToContact+"&b="+IncludeMessage,"SPIEmail","resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,width=775,height=440,top=5,left=5");
   }
   
     //4/28/09 new function to open a pop-up window to play the Morning Swim Show 
     function OpenMSSPopUp() 
     {
            window.open("/MorningSwimShow/MSSPopupWindow.asp","MSSPopUp","titlebar=no,location=no,status=no,toolbar=no,menubar=no,width=354,height=420,scrollbars=no,resizable=no,directories=no,top=0,left=2000","false");
     }
     
       
     //5/12/09 new function to open a pop-up window with an ad when the MSS Pop-up is closed 
     function OpenMSSPopUpAd() 
     {
            window.open("/MorningSwimShow/MSSPopupAd.asp","MSSPopUpAd","titlebar=no,location=no,status=no,toolbar=no,menubar=no,width=354,height=420,scrollbars=no,resizable=no,directories=no,top=0,left=2000","false");
     }
     
     //6/8/10 new function to open a pop-up window to play the Ustream Player for the Swiminfo Ustream Account
     //not currently used
     function OpenUstreamSwiminfoPopUp() 
     {
            window.open("/common/UstreamPopupWindow-Swiminfo.asp","UstreamPopUp","titlebar=no,location=no,status=no,toolbar=no,menubar=no,width=354,height=420,scrollbars=no,resizable=no,directories=no,top=0,left=2000","false");
     }
     
     //6/8/10 new function to open a pop-up window to play the Ustream Player for the SwimmingWorld Ustream Account
     //not currently used
     function OpenUstreamSwimmingWorldPopUp() 
     {
            window.open("/common/UstreamPopupWindow-SwimmingWorld.asp","UstreamPopUp","titlebar=no,location=no,status=no,toolbar=no,menubar=no,width=354,height=420,scrollbars=no,resizable=no,directories=no,top=0,left=2000","false");
     }


   
