<!--

function checkSpecials() {
    var subEventsTable = document.getElementById("subEvents");
    var rows = subEventsTable.getElementsByTagName("tr");
    var disabledColor = "#ddd";

    var cellText = rows[4].getElementsByTagName("td")[0].childNodes[0].innerHTML.toUpperCase();
    var specialText = cellText.indexOf("SPECIAL");

    var session1Check = rows[1].getElementsByTagName("td")[3].getElementsByTagName("input")[0];
    var session2Check = rows[2].getElementsByTagName("td")[3].getElementsByTagName("input")[0];
    var session3Check = rows[3].getElementsByTagName("td")[3].getElementsByTagName("input")[0];
    var specialCheck = rows[4].getElementsByTagName("td")[3].getElementsByTagName("input")[0];

    if (specialText != -1) {
        if (session1Check.checked && session2Check.checked && session3Check.checked) {
            session1Check.disabled = true;
            session2Check.disabled = true;
            session3Check.disabled = true;

            session1Check.checked = false;
            session2Check.checked = false;
            session3Check.checked = false;

            rows[1].style.backgroundColor = disabledColor;
            rows[2].style.backgroundColor = disabledColor;
            rows[3].style.backgroundColor = disabledColor;

            specialCheck.checked = true;
        }
        else if (specialCheck.checked) {
            session1Check.disabled = true;
            session2Check.disabled = true;
            session3Check.disabled = true;

            session1Check.checked = false;
            session2Check.checked = false;
            session3Check.checked = false;

            rows[1].style.backgroundColor = disabledColor;
            rows[2].style.backgroundColor = disabledColor;
            rows[3].style.backgroundColor = disabledColor;
        }
        else {
            session1Check.disabled = false;
            session2Check.disabled = false;
            session3Check.disabled = false;

            rows[1].style.backgroundColor = "#fff";
            rows[2].style.backgroundColor = "#fff";
            rows[3].style.backgroundColor = "#fff";
        }
    }
}

/*
function setFormFocus() {
    alert (window.document.forms[0] ? 'form' : 'no form')
    }
*/
/*
    function setFormFocus() {
        if (document.forms.length > 0) {
            alert("no");
            //document.forms[0].elements[0].focus();
        }
        else {
            alert("yes");
          }
    }

    onload = setFormFocus();
*/

var new_fieldname = ""
function check(form,x)
{
  //If you would like to use this script please do not remove the next 4 lines
  var set_up_var = 1
  var message = ""
  var more_message = ""
  var showmsg = "no"
  if (set_up_var == 1)
  {
    x = x - 1
    for (var i = 0; i <= x; i++)
    {
      var messenger = form.elements[i].name
      messenger = messenger.substring(0, 2)
      var fieldname = form.elements[i].name
      fieldname = fieldname.substring(2)

      {
        if (messenger == "r_") // Required Data
        {
          more_message = r_check(form,x,fieldname,i)
        }
        else if (messenger == "i_") // numeric
        {
          more_message = i_check(form,x,fieldname,i)
        }
        else if (messenger == "p_") // positive numeric
        {
          more_message = p_check(form,x,fieldname,i)
        }
        else if (messenger == "d_") // date
        {
          more_message = d_check(form,x,fieldname,i)
        }
        else if (messenger == "e_") // email
        {
          more_message = e_check(form,x,fieldname,i)
        }
        else if (messenger == "f_") // File Name
        {
          more_message = f_check(form,x,fieldname,i)
        }
        else if (messenger == "s_") // No space for password
        {
          more_message = s_check(form,x,fieldname,i)
        }
        else if (messenger == "l_") // if value is less than compare
        {
          more_message = l_check(form,x,fieldname,i)
        }
        else if (messenger == "g_") // if value is greater than compare
        {
          more_message = g_check(form,x,fieldname,i)
        }


        if (more_message != "")
        {
          if (message == "")
          {
            message = more_message
            more_message=""
          }
          else
          {
            message = message + "\n" + more_message
            more_message=""
          }
        }
        if (message > "")
        {
          showmsg = "yes"
        }
      }
    }
    //This code will prevent a submit if data is incoorect
    if (showmsg == "yes")
    {
      alert("The following form field(s) were incomplete or incorrect:\n\n" + message + "\n\n Please complete or correct the form and submit again.")
    }
    else
    {
      form.submit()
    }

    //This code will just warn and then submit if OK is selected.
    //if (showmsg == "yes")
    //{
    //if (confirm("The following form field(s) were incomplete or incorrect:\n\n" + message + "\n\n Please complete or correct the form and submit again."))
    //form.submit()
    //}
    //else
    //{
    //form.submit()
    //}
  }
  else
  {
    alert ("The copyright information has been changed. \n In order to use this javascript please keep the copyright information intact. \n\n Script Name: Form Validator ver 2.0 \n Copyright: (c) 1998 - Art Lubin / Artswork \n Email: perflunk@aol.com")
  }
}


/****************************/
// OPEN TARGET IN NEW WINDOW
// For opening a new browser window.
/****************************/
function externalLinks() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
        anchor.target = "_blank";
    }
}
window.onload = externalLinks;

/****************************/
// EMM Public site new pop-up window
// for footer information
/****************************/
function popUp(location) {
    newWindow = window.open(location, "name", "status=yes, toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=yes, width=500, height=300");
    if (window.focus) {
        newWindow.focus();
    }
}

/****************************/
// DYNAMICALLY RESIZES FONTS FOR ADMIN SITE
/****************************/
itg_fontsize = 1;
function ChangeFontSize(size)	{
    if (document.getElementById('container')) {
        document.getElementById('container').style.fontSize = size + "em";
    }
    if (document.getElementById('containerIntro')) {
        document.getElementById('containerIntro').style.fontSize = size + "em";
    }
}
function IncreaseFontSize(size)	{
	if(itg_fontsize < 3)
		itg_fontsize = itg_fontsize + size;
	ChangeFontSize(itg_fontsize);
}
function DecreaseFontSize(size)	{
	if(itg_fontsize > .5)
		itg_fontsize = itg_fontsize + size;
	ChangeFontSize(itg_fontsize);
}

/****************************/
// This will do a check to see if the required field is supplied or not.
// Written by Pankaj on 01/23/04
/****************************/
function r_check(form,x,fieldname,i)
{
  var msg_addition = ""
  new_fieldname = fieldname
  for (var y = 0; y <= x; y++)
  {
    if ((form.elements[y].type == "radio" || form.elements[y].type == "checkbox") && form.elements[y].name == new_fieldname && form.elements[y].checked == true)
    {
      msg_addition = ""
      break
    }
    else if ((form.elements[y].type == "radio" || form.elements[y].type == "checkbox") && form.elements[y].name == new_fieldname && form.elements[y].checked == false)
    {
      msg_addition = form.elements[i].value
    }
    else if (form.elements[y].type == "select-one")
    {
      var l = form.elements[y].selectedIndex
      if (form.elements[y].name == fieldname && form.elements[y].options[l].value != "")
      {
        msg_addition = ""
        break
      }
      else if (form.elements[y].name == fieldname && form.elements[y].options[l].value == "")
      {
        msg_addition = form.elements[i].value
      }
    }
    else if (form.elements[y].name == fieldname && form.elements[y].value == "" && form.elements[y].type != "radio" && form.elements[y].type != "checkbox" && form.elements[y].type != "select-one")
    {
      msg_addition = form.elements[i].value
      break
    }
    else if (form.elements[y].name == fieldname && form.elements[y].value != "" && form.elements[y].type != "radio" && form.elements[y].type != "checkbox" && form.elements[y].type != "select-one")
    {
      msg_addition = ""
    }
  }
  return(msg_addition)
}

/*
This will make sure you enter a numeric value into the input boxes which tie to numeric database values.
Written by Pankaj on 01/22/2004
*/
function i_check(form,x,fieldname,i)
{
  for (var y = 0; y <= x; y++)
  {
    if (form.elements[y].name == fieldname)
    break
  }

  var msg_addition = ""
  var decimal = ""
  inputStr = form.elements[y].value.toString()

  if (inputStr == "")
  {
    //msg_addition = form.elements[i].value
  }
  else
  {
    for (var c = 0; c < inputStr.length; c++)
    {
      var oneChar = inputStr.charAt(c)
      if (c == 0 && oneChar == "-" || oneChar == "."  && decimal == "")
      {
	if (oneChar == ".")
	{
	  decimal = "yes"
	}
	continue
      }
      if (oneChar < "0" || oneChar > "9")
      {
        msg_addition = form.elements[i].value
      }
    }
  }
  return(msg_addition)
}

/*
This will validate the input field for positive numeric value only
Added by Pankaj on 05/14/2004 to stop user entering negative values for certain fields
*/
function p_check(form,x,fieldname,i)
{
  for (var y = 0; y <= x; y++)
  {
    if (form.elements[y].name == fieldname)
      break
  }

  var msg_addition = ""
  var decimal = ""
  var negative = ""
  var nonNumber = ""
  inputStr = form.elements[y].value.toString()

  if (inputStr == "")
  {
    //msg_addition = form.elements[i].value
  }
  else
  {
    var dotExists = 0;
    for (var c = 0; c < inputStr.length; c++)
    {
      var oneChar = inputStr.charAt(c)
      if (c == 0 && oneChar == "." && decimal == "")
      {
	if (oneChar == "." && dotExists == 0)
	{
          dotExists = 1;
	}

	if (oneChar == "-")
	{
	  negative = "yes"
	}
        if ( (oneChar < "0" || oneChar > "9") && decimal == "" && nonNumber == "")
        {
	  nonNumber = "yes"
        }
      }
      if (c > 0 && oneChar == "." && dotExists == 1)
      {
	nonNumber = "yes"
      }
      if (oneChar == "." && decimal == "")
      {
        dotExists = 1
        decimal = "yes"
      }
      if (oneChar == "-" && negative == "")
      {
        negative = "yes"
      }
      if ( (oneChar < "0" || oneChar > "9" ) && nonNumber == "" && decimal == "")
      {
	nonNumber = "yes"
      }
      if ( negative == "yes" || nonNumber == "yes" )
      {
	msg_addition = form.elements[i].value
      }
    }
  }
  return(msg_addition)
}

/*
You can use this to validate email address formats
*/
function e_check(form,x,fieldname,i)
{
  for (var y = 0; y <= x; y++)
  {
    if (form.elements[y].name == fieldname)
      break
  }

  var msg_addition = ""
  period = ".";

  if (form.elements[y].value == "" || form.elements[y].value.indexOf ('@', 0) < 3)
    error = 1;

  {
    test = form.elements[y].value.indexOf('.', form.elements[y].value.indexOf ('@', 0))
    if (test != -1)
    {
      error = 0;
    }
    else
    {
      error=1;
    }
  }

  if (error == 1)
  {
    msg_addition = form.elements[i].value
  }
  else
  {
    new_length = form.elements[y].value.length - test
    if (new_length == 4 || new_length == 3 || (new_length >= 5 && form.elements[y].value.indexOf ('.', (test+1)) != -1))
    {
      msg_addition = ""
    }
    else
      msg_addition = form.elements[i].value;
  }
  return(msg_addition)
}

/*
This will make sure you format the date correctly
Date must be in MM/DD/YY format OR M/D/YY or a MIX of the two
*/
function d_check(form,x,fieldname,i)
{
  for (var y = 0; y <= x; y++)
  {
    if (form.elements[y].name == fieldname)
      break
  }

  var msg_addition = ""
  var sDate = form.elements[y].value
  var finalDate = sDate;

  if (sDate != "")
  {
    // Introduced by Pankaj to convert date automatically to desired format
    if (sDate.length < 10)
    {
      var splitData = sDate.split("-");
      if (splitData.length < 3)
      {
      }
      else
      {
        if (splitData[1].length <2)
          finalDate = splitData[0] + "-" + "0" + splitData[1];
        else
          finalDate = splitData[0] + "-" + splitData[1];

        if (splitData[2].length <2)
          finalDate = finalDate + "-" + "0" + splitData[2];
        else
          finalDate = finalDate + "-" + splitData[2];
      }
    }
    sDate = finalDate;
    form.elements[y].value = finalDate;
    // end of new additions
    if (isDate(sDate,"yyyy-MM-dd"))
    {
    }
    else
    {
      msg_addition = form.elements[i].value
    }
  }
  //to allow NO validation unless r_ specified CLOSING
  return(msg_addition)
}

/*
This will make sure you enter a valid file name into the input boxes which tie to file naming database values.
Written by Pankaj on 07/30/2004
*/
function f_check(form,x,fieldname,i)
{
  for (var y = 0; y <= x; y++)
  {
    if (form.elements[y].name == fieldname)
    break
  }

  var msg_addition = ""
  inputStr = form.elements[y].value.toString()
  var valid = true
  for (var c = 0; c < inputStr.length; c++)
  {
    var each_char = inputStr.charAt(c)
    // Now see if this character exists in the allowed Characters
    var n = 0
    var char_str = charSetFileName()
    if (char_str.indexOf(each_char) < 0)
    {
      valid = false
      break;
    }
  }
  if (!valid)
    msg_addition = form.elements[i].value
  return(msg_addition)
}

/*
This will make sure you do not enter a space for password.
Written by Pankaj on 01/12/2005
*/
function s_check(form,x,fieldname,i)
{
  for (var y = 0; y <= x; y++)
  {
    if (form.elements[y].name == fieldname)
    break
  }

  var msg_addition = ""
  inputStr = form.elements[y].value.toString()
  var valid = true
  for (var c = 0; c < inputStr.length; c++)
  {
    var each_char = inputStr.charAt(c)
    // Now see if this character exists in the allowed Characters
    if (each_char == " ")
    {
      valid = false
      break;
    }
  }
  if (!valid)
    msg_addition = form.elements[i].value
  return(msg_addition)
}


/*
This will check if the input is an integer
*/
function isInteger(sDate)
{
  var new_msg = "true"
  inputStr = sDate.toString()
  for (var i = 0; i < inputStr.length; i++)
  {
    var oneChar = inputStr.charAt(i)
    if ((oneChar < "0" || oneChar > "9") && oneChar != "/")
    {
      new_msg = "false"
    }
  }
  return (new_msg)
}

function doall(script_name, copyright, email)
{
  var code = 0
  var test = script_name + copyright + email
  for (var a = 0; a < test.length; a++)
  {
    var each_char = test.charAt(a)
    var x = asc(each_char)
    code += x
  }
  return (code)
}

function asc(each_char)
{
  var n = 0
  var char_str = charSetStr()
  for (i = 0; i < char_str.length; i++)
  {
    if (each_char == char_str.substring(i, i+1))
    {
      break
    }
  }
  return i + 32
}

function charSetStr()
{
  var str
  str = ' !"#$%&' + "'" + '()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
  return str
}

function charSetFileName()
{
  var str
  str = '-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'
  return str
}

// This will help in asking a confirm question
function confirmMe(a)
{
  var conf = confirm(a);
  return conf;
}

// This will show the alert that you are doing something
function alertMe(a)
{
  alert(a);
}

/*-------------------------------------------------------------------*/
//          ROLLOVER DISPLAY FOR EQ MARKETING SITE HOME PAGE
/*-------------------------------------------------------------------*/
// Last modified by Tito: 10/04/2005
// Simple rollover to display divs with content in the main photo area.
// Divs layer are repositioned with mouseover event.

function reMove(id) { // Function used to move element back to original position.
    var photoSub = document.getElementById(id);
    var elements = document.getElementById("photoContainer").getElementsByTagName("a");
    for (var i = 0; i < elements.length; i++) {
        //var element = elements[i];
        elements[i].onmouseout = function() {
            photoSub.style.left = -1000 + "px";
        }
    }
}

function displayInfo(id) { // Function changes LEFT position to be displayed on screen.
	if (document.getElementById) {
        var photoSub = document.getElementById(id);     // Identify the ID of elements which will be moved.
        if (id) {
            photoSub.style.left = 370 + "px";           // New left position of element.
            reMove(id);                                 // Call function to move back to original left position.
            if (opera) {                                // Change mouse cursor to "hand" ONLY for OPERA.
                this.style.cursor = "pointer";
            }
	    }
    }
}
/*-------------------------------------------------------------------*/

/*-------------------------------------------------------------------*/
//                 NAVIGATION MENUS FOR ADMIN SITE
/*-------------------------------------------------------------------*/
// Last modified: 10/19/2004
// Clicking after a menu is displayed will either hide the menu if clicked
// outside it or not do anything thing if clicked inside.  Clicking inside
// will be set to null, although the links in the menu will remain active.
// The positioning and repositioning of the menu mask applies ONLY to Internet Explorer.

    // Set menuOver variable to false; needed for clicking anywhere on the document to hide div menus.
    var menuOver = false;
    var ie = document.all; // Check for IE
    var opera = navigator.userAgent.indexOf("Opera") >= 0;  // Check for Opera

    // Get the object id's.
    function getObj(name) {
        if (document.getElementById) {
            this.obj = document.getElementById(name);
            this.style = document.getElementById(name).style;
        }
    }

    // Displays and toggles the div menus.
    // Also hides the div menu by clicking its corresponding link.
    function displayMenus(id) {
    	if (document.getElementById) {
            var subNavDiv = document.getElementById(id);
        	var menus = document.getElementById("nav").getElementsByTagName("div");
    		if (subNavDiv.style.display != "block") {
                for (var i = 0; i < menus.length; i++) {
    				menus[i].style.display = "none";
                }
                subNavDiv.style.display = "block";
            }
            else {
                subNavDiv.style.display = "none";
            }
    	}
    }

    // Finds X (left) position of link menu item and add 10.
    // Menu div will appear relative to these coordinates.
    function findLinkX(lnk) {
        var posX = 0;
        if (lnk.offsetParent) {
    	    while (lnk.offsetParent) {
                posX += lnk.offsetLeft;
                lnk = lnk.offsetParent;
            }
            return posX + 10;
        } else {
            return lnk.x + 10;
        }
    }

    // Finds Y (top) position of link menu item.
    // Menu div will appear relative to these coordinates.
    function findLinkY(lnk) {
        var posY = 0;
        if (lnk.offsetParent) {
    	    while (lnk.offsetParent) {
                posY += lnk.offsetTop;
                lnk = lnk.offsetParent;
            }
            return posY - 94;
        } else {
            return lnk.y - 94;
        }
    }

    // Get the height of the menu div and subtract 5.
    // Needed to adjust height of mask to the height of a menu div.
    function findMenuH(id) {
        h = document.getElementById(id);
        return h.offsetHeight - 5;
    }

    // This function sets the menu system into play.
    function setMenus(id,lyr,lnk) {
        displayMenus(id);
        var newH = findMenuH(id);
        var x = new getObj(lyr);
        var m = new getObj(id);
        var linkPosY = findLinkY(lnk);
        var linkPosX = findLinkX(lnk);

        if (document.getElementById(id).style.display == 'block') {
            if(ie && !opera) { // Apply new top position, new left position, and new height to menu mask FOR IE ONLY.
                x.style.top = linkPosY + 'px';
                x.style.left = linkPosX + 'px';
                x.style.height = newH + 'px';
            }
            document.onclick = function() {
                if(!menuOver) { // Hide div menu when clicking anywhere outside the menu itself.
                    document.onclick = function() {
                        document.getElementById(id).style.display = 'none';
                        document.getElementById('startnavigation1').focus();
                        if(ie && !opera) { // Return menu mask to initial position off the page FOR IE ONLY.
                            x.style.top = -300 + 'px';
                            x.style.left = -300 + 'px';
                        }
                    }
                    document.onkeydown = function(e) { // Hide div menu by pressing the 'Esc' key.
                        k = document.all?window.event.keyCode:e.which;
                        if(k == 27) {
                            if(document.getElementById(id).style.display == "block") {
                                document.getElementById(id).style.display = 'none';
                                document.getElementById('startnavigation1').focus();
                                if(ie && !opera) { // Return menu mask to initial position off the page FOR IE ONLY.
                                    x.style.top = -300 + 'px';
                                    x.style.left = -300 + 'px';
                                }
                            }
                        }
                    }
                }
            }
        }
        // Apply new top position and new left position of menu div relative to the menu link.
        m.style.top = linkPosY + 'px';
        m.style.left = linkPosX + 'px';
    }

//                          END NAVIGATION MENUS
/*-------------------------------------------------------------------*/


/*-------------------------------------------------------------------*/
//                DISPLAY HELP TOPICS FOR ADMIN SITE
/*-------------------------------------------------------------------*/
// Clicking on a help topic link will display a div with an iframe inside.
// The iframe's source is the help content.
// Tito, 01-25-05

    function displayHelp(id) {
        if(document.getElementById) {
            var helpDiv = document.getElementById(id);
            if(helpDiv.style.display != "block") {
                helpDiv.style.display = "block";
		helpDiv.refresh;
            }
            else {
                helpDiv.style.display = "none";
            }
        }
    }

    function findHelpLinkX(lnk) {
        var posX = 0;
        if (lnk.offsetParent) {
    	    while (lnk.offsetParent) {
                posX += lnk.offsetLeft;
                lnk = lnk.offsetParent;
            }
            return posX;
        } else {
            return lnk.x;
        }
    }

    function findHelpLinkY(lnk) {
        var posY = 0;
        if (lnk.offsetParent) {
    	    while (lnk.offsetParent) {
                posY += lnk.offsetTop;
                lnk = lnk.offsetParent;
            }
            return posY + 25;
        } else {
            return lnk.y + 25;
        }
    }
    /*
    function findClass() {
        var name = document.getElementsByTagName("div").getAttribute("class");
        window.alert(name);
    }

    function getElementsByAttributeValue(tagName, attrName, attrValue) {
        var els = document.getElementsByTagName(tagName);
        var attsEls = new Array();
        for (var j = 0; j < els.length; j++) {
            if (els[j].getAttribute(attrName) == attrValue) {
                attsEls[attsEls.length] = els[j];
            }
        }
        return attsEls;
    }*/

    function setHelp(id,lnk) {
        displayHelp(id);
        var m = new getObj(id);
        var linkPosY = findHelpLinkY(lnk);
        var linkPosX = findHelpLinkX(lnk);

        if (document.getElementById(id).style.display == "block") {
            m.style.top = linkPosY + "px";
            //m.style.left = linkPosX + "px";
            m.style.left = "25%";
        }
    }
/*-------------------------------------------------------------------*/

// These are for textarea validations
function taLimit(limit)
{
  var taObj=event.srcElement;
  if (taObj.value.length==limit*1) return false;
}

function taCount(visCnt,limit)
{
  var taObj=event.srcElement;
  if (taObj.value.length>limit*1) taObj.value=taObj.value.substring(0,limit*1);
  if (visCnt) visCnt.innerText=limit-taObj.value.length;
}

function filterOptions(elem,elemfltr)
{
 var objElem = document.getElementById(elem);
 var objFltr = document.getElementById(elemfltr);
 var fltrVal = objFltr.value;
 var fltrLen = fltrVal.length;
 var optsLen = objElem.options.length;
 var foundRemove = true;
 var remCount = 0;

 for(var i=0; i < optsLen ; i++)
 {
   var currOpt = objElem.options[(i-remCount)];
   var currOptText = currOpt.text;

   var currOptTextSeg = currOptText.substring(0,fltrLen);
   if(currOptTextSeg.toUpperCase() != fltrVal.toUpperCase())
   {
     objElem.options[(i-remCount)] = null;
     remCount++;
   }
 }
}

function popUp(URL)
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=400');");
}

function popUpSmall(URL)
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=250');");
}

function popUpImage(URL)
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=950,height=550');");
}

// Added by Pankaj for Ordering of Any Database Fields using Selector
// Under Test --- Will be deleted if doesnt serve the purpose
// Do Not modify any part of this script
function moveUpList(listField) {
   if ( listField.length == -1) {  // If the list is empty
      alert("There are no values which can be moved!");
   } else {
      var selected = listField.selectedIndex;
      if (selected == -1) {
         alert("You must select an entry to be moved!");
      } else {  // Something is selected
         if ( listField.length == 0 ) {  // If there's only one in the list
            alert("There is only one entry!\nThe one entry will remain in place.");
         } else {  // There's more than one in the list, rearrange the list order
            if ( selected == 0 ) {
               alert("The first entry in the list cannot be moved up.");
            } else {
               // Get the text/value of the one directly above the hightlighted entry as
               // well as the highlighted entry; then flip them
               var moveText1 = listField[selected-1].text;
               var moveText2 = listField[selected].text;
               var moveValue1 = listField[selected-1].value;
               var moveValue2 = listField[selected].value;
               listField[selected].text = moveText1;
               listField[selected].value = moveValue1;
               listField[selected-1].text = moveText2;
               listField[selected-1].value = moveValue2;
               listField.selectedIndex = selected-1; // Select the one that was selected before
            }  // Ends the check for selecting one which can be moved
         }  // Ends the check for there only being one in the list to begin with
      }  // Ends the check for there being something selected
   }  // Ends the check for there being none in the list
}

function moveDownList(listField) {
   if ( listField.length == -1) {  // If the list is empty
      alert("There are no values which can be moved!");
   } else {
      var selected = listField.selectedIndex;
      if (selected == -1) {
         alert("You must select an entry to be moved!");
      } else {  // Something is selected
         if ( listField.length == 0 ) {  // If there's only one in the list
            alert("There is only one entry!\nThe one entry will remain in place.");
         } else {  // There's more than one in the list, rearrange the list order
            if ( selected == listField.length-1 ) {
               alert("The last entry in the list cannot be moved down.");
            } else {
               // Get the text/value of the one directly below the hightlighted entry as
               // well as the highlighted entry; then flip them
               var moveText1 = listField[selected+1].text;
               var moveText2 = listField[selected].text;
               var moveValue1 = listField[selected+1].value;
               var moveValue2 = listField[selected].value;
               listField[selected].text = moveText1;
               listField[selected].value = moveValue1;
               listField[selected+1].text = moveText2;
               listField[selected+1].value = moveValue2;
               listField.selectedIndex = selected+1; // Select the one that was selected before
            }  // Ends the check for selecting one which can be moved
         }  // Ends the check for there only being one in the list to begin with
      }  // Ends the check for there being something selected
   }  // Ends the check for there being none in the list
}


function addVal (listField,hiddenField)
{
  var len = listField.length;
  var index = 0;
  var data_array = new Array();
  var data_string = "";
  while (index < len)
  {
    var v = listField[index].value;
    data_array[index] = v;
    var tempStr = (index + 1) + "#" + v;
    if (index == len -1)
      data_string = data_string + tempStr;
    else
      data_string = data_string + tempStr + "::";
    index++;
  }
  hiddenField.value = data_string;
}

// Copy Profile Information to Billing Information
// Author: Pankaj Lawande
// Date: 04/29/2005

function copyBillingAddressFromProfile(form)
{
  if (form.USR_BILL_TO_ADDRESS1.value!=form.USR_ADDR1.value)
    form.USR_BILL_TO_ADDRESS1.value=form.USR_ADDR1.value;
  else
    form.USR_BILL_TO_ADDRESS1.value="";

  if (form.USR_BILL_TO_ADDRESS2.value!=form.USR_ADDR2.value)
    form.USR_BILL_TO_ADDRESS2.value=form.USR_ADDR2.value;
  else
    form.USR_BILL_TO_ADDRESS2.value="";

  if (form.USR_BILL_TO_CITY.value!=form.USR_CITY.value)
    form.USR_BILL_TO_CITY.value=form.USR_CITY.value;
  else
    form.USR_BILL_TO_CITY.value="";

  if (form.USR_BILL_TO_STATE.value!=form.USR_STATE.value)
    form.USR_BILL_TO_STATE.value=form.USR_STATE.value;
  else
    form.USR_BILL_TO_STATE.value="";

  if (form.USR_BILL_TO_POSTAL_CODE.value!=form.USR_POSTAL_CODE.value)
    form.USR_BILL_TO_POSTAL_CODE.value=form.USR_POSTAL_CODE.value;
  else
    form.USR_BILL_TO_POSTAL_CODE.value="";
}

// Copy Profile Information to Payment Information
// Author: Pankaj Lawande
// Date: 04/29/2005

function copyPaymentAddressFromProfile(form)
{
  if (form.USR_PAYMENT_TO_ADDRESS1.value!=form.USR_ADDR1.value)
    form.USR_PAYMENT_TO_ADDRESS1.value=form.USR_ADDR1.value;
  else
    form.USR_PAYMENT_TO_ADDRESS1.value="";

  if (form.USR_PAYMENT_TO_ADDRESS2.value!=form.USR_ADDR2.value)
    form.USR_PAYMENT_TO_ADDRESS2.value=form.USR_ADDR2.value;
  else
    form.USR_PAYMENT_TO_ADDRESS2.value="";

  if (form.USR_PAYMENT_TO_CITY.value!=form.USR_CITY.value)
    form.USR_PAYMENT_TO_CITY.value=form.USR_CITY.value;
  else
    form.USR_PAYMENT_TO_CITY.value="";

  if (form.USR_PAYMENT_TO_STATE.value!=form.USR_STATE.value)
    form.USR_PAYMENT_TO_STATE.value=form.USR_STATE.value;
  else
    form.USR_PAYMENT_TO_STATE.value="";

  if (form.USR_PAYMENT_TO_POSTAL_CODE.value!=form.USR_POSTAL_CODE.value)
    form.USR_PAYMENT_TO_POSTAL_CODE.value=form.USR_POSTAL_CODE.value;
  else
    form.USR_PAYMENT_TO_POSTAL_CODE.value="";
}

// Copy Billing Information to Payment Information
// Author: Pankaj Lawande
// Date: 04/29/2005

function copyPaymentAddressFromBilling(form)
{
  if (form.USR_PAYMENT_TO_ADDRESS1.value!=form.USR_BILL_TO_ADDRESS1.value)
    form.USR_PAYMENT_TO_ADDRESS1.value=form.USR_BILL_TO_ADDRESS1.value;
  else
    form.USR_PAYMENT_TO_ADDRESS1.value="";

  if (form.USR_PAYMENT_TO_ADDRESS2.value!=form.USR_BILL_TO_ADDRESS2.value)
    form.USR_PAYMENT_TO_ADDRESS2.value=form.USR_BILL_TO_ADDRESS2.value;
  else
    form.USR_PAYMENT_TO_ADDRESS2.value="";

  if (form.USR_PAYMENT_TO_CITY.value!=form.USR_BILL_TO_CITY.value)
    form.USR_PAYMENT_TO_CITY.value=form.USR_BILL_TO_CITY.value;
  else
    form.USR_PAYMENT_TO_CITY.value="";

  if (form.USR_PAYMENT_TO_STATE.value!=form.USR_BILL_TO_STATE.value)
    form.USR_PAYMENT_TO_STATE.value=form.USR_BILL_TO_STATE.value;
  else
    form.USR_PAYMENT_TO_STATE.value="";

  if (form.USR_PAYMENT_TO_POSTAL_CODE.value!=form.USR_BILL_TO_POSTAL_CODE.value)
    form.USR_PAYMENT_TO_POSTAL_CODE.value=form.USR_BILL_TO_POSTAL_CODE.value;
  else
    form.USR_PAYMENT_TO_POSTAL_CODE.value="";
}
/****************************/

/*****************************/
// New Date Validation Script
// Author: Pankaj
// Date: May 24th 2005
/*****************************/
function getDateFromFormat(val,format)
{
  val=val+"";
  format=format+"";
  var i_val=0;
  var i_format=0;
  var c="";
  var token="";
  var token2="";
  var x,y;
  var now=new Date();
  var year=now.getYear();
  var month=now.getMonth()+1;
  var date=1;
  var hh=now.getHours();
  var mm=now.getMinutes();
  var ss=now.getSeconds();
  var ampm="";

  while(i_format < format.length)
  {
    c=format.charAt(i_format);
    token="";
    while((format.charAt(i_format)==c) &&(i_format < format.length))
    {
      token += format.charAt(i_format++);
    }
    if(token=="yyyy")
    {
      if(token=="yyyy"){x=4;y=4;}

      year=_getInt(val,i_val,x,y);

      if(year==null){return 0;}
      i_val += year.length;
    }
    else if(token=="MM")
    {
      month=_getInt(val,i_val,token.length,2);
      if(month==null||(month<1)||(month>12))
      {
        return 0;
      }
      i_val+=month.length;
    }
    else if(token=="dd")
    {
      date=_getInt(val,i_val,token.length,2);
      if(date==null||(date<1)||(date>31))
      {
        return 0;
      }
      i_val+=date.length;
    }
    else
    {
      if(val.substring(i_val,i_val+token.length)!=token)
      {
        return 0;
      }
      else
      {
        i_val+=token.length;
      }
    }
  }

  if(i_val != val.length)
  {
    return 0;
  }

  if(month==2)
  {
    if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) )
    {
      if(date > 29)
      {
        return 0;
      }
    }
    else
    {
      if(date > 28)
      {
        return 0;
      }
    }
  }

  if((month==4)||(month==6)||(month==9)||(month==11))
  {
    if(date > 30)
    {
      return 0;
    }
  }

  //var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();
}

function isDate(val,format)
{
  var date=getDateFromFormat(val,format);
  if(date==0)
  {
    return false;
  }
  return true;
}

function _getInt(str,i,minlength,maxlength)
{
  for(var x=maxlength;x>=minlength;x--)
  {
    var token=str.substring(i,i+x);

    if(token.length < minlength)
    {
      return null;
    }
    if(_isInteger(token))
    {
      return token;
    }
  }
  return null;
}

function _isInteger(val)
{
  var digits="1234567890";
  for(var i=0;i < val.length;i++)
  {
    if(digits.indexOf(val.charAt(i))==-1)
    {
      return false;
    }
  }
  return true;
}

/*
This will check if the field value is less than the compare value.
Written by Pankaj on 09/14/2005
*/
function l_check(form,x,fieldname,i)
{
  var msg_addition = "";
  var valid = true;

  var compareFieldVal =  "form." + fieldname + ".value";
  if (eval(compareFieldVal) != "")
  {
    if (form.COMPARE_DATE.value < eval(compareFieldVal))
      valid = false;
  }

  if (!valid)
    msg_addition = form.elements[i].value

  return(msg_addition)
}

/*
This will check if the field value is greater than the compare value.
Written by Pankaj on 09/14/2005
*/
function g_check(form,x,fieldname,i)
{
  var msg_addition = "";
  var valid = true;

  var compareFieldVal =  "form." + fieldname + ".value";
  if (eval(compareFieldVal) != "")
  {
    if (form.COMPARE_DATE.value > eval(compareFieldVal))
      valid = false;
  }

  if (!valid)
    msg_addition = form.elements[i].value

  return(msg_addition)
}

//-->
