function setfirstfocus(formnum)
{
var bFound = false;
formnum = formnum-1
if (formnum < 0)
{
fornum = 0
}

  // for each form
  for (f=formnum; f < document.forms.length; f++)
  {
    // for each element in each form
    for(i=0; i < document.forms[f].length; i++)
    {
      // if it's not a hidden element
      if (document.forms[f][i].type != "hidden")
      {
        // and it's not disabled
        if (document.forms[f][i].disabled != true)
        {
            // set the focus to it
            document.forms[f][i].focus();
            var bFound = true;
        }
      }
      // if found in this element, stop looking
      if (bFound == true)
        break;
    }
    // if found in this form, stop looking
    if (bFound == true)
      break;
  }
}

function setfirstfocusitem(formnum,itemnum)
{
var bFound = false;
formnum = formnum-1
if (formnum < 0)
{
fornum = 0
}
itemcount = 0
  // for each form
  for (f=formnum; f < document.forms.length; f++)
  {
    // for each element in each form
    for(i=0; i < document.forms[f].length; i++)
    {
      // if it's not a hidden element
      if (document.forms[f][i].type != "hidden")
      {
        // and it's not disabled
        if (document.forms[f][i].disabled != true)
        {
            // set the focus to it
	    itemcount = itemcount + 1
	    if (itemcount == itemnum)
	    {
	       document.forms[f][i].focus();
               var bFound = true;
	    }
        }
      }
      // if found in this element, stop looking
      if (bFound == true)
        break;
    }
    // if found in this form, stop looking
    if (bFound == true)
      break;
  }
}
function setfirstfocusitemold()
{
// set the focus to it
document.forms[1][0].focus();
}


function gotolink( TheSelection ) 
{
TheIndex = TheSelection.selectedIndex; 
TheValue = TheSelection.options[TheIndex].value;

//Check whether to open a new window or not
if (TheIndex > 9)
	{
	TheSelection.selectedIndex = 0;
	window.open(TheValue);
	}
else
	{
	TheSelection.selectedIndex = 0;
	window.location.href = TheValue;	
	}
}

function setSelectionRange(input, selectionStart, selectionEnd)
{
if 
(input.setSelectionRange)
{
input.focus();
input.setSelectionRange(selectionStart,selectionEnd);
}
else if (input.createTextRange)
{
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character',selectionEnd);
range.moveStart('character',selectionStart);
range.select();
}
}


function imageSwap(imageSource,name,season)
{
	document.images[name].src = "../cta/images/" + season + "/" + imageSource
}


function oldimageSwap(imageSource,name)
{
	document.images[name].src = "../cta/images/<% response.write ctastyle %>/" + imageSource
}


function checkEmail(myform) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myform.EmailAddress.value)){
return (true)
}
// alert("Invalid E-mail Address! Please re-enter.") 
return (false)
}

// Cookie Functions

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


