var email_valid = /^[a-zA-Z0-9\-\_\.]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
var pwd_alpha_valid = /[a-zA-Z]+/;
var pwd_digit_valid = /[0-9]+/;
var pwd_len_valid = /[a-zA-Z0-9]{6,20}/;

var acpe_valid = /[0-9\-]{4}[0-9\-]{4}[0-9\-]{3}[0-9\-]{4}[LHlhCc]{1}[0-9]{2}/;
var acpe_alpha_valid = /[LHlhCc]{1}/;
var acpe_digit_valid = /[0-9]{13}/;
var acpe_len_valid = /[a-zA-Z0-9\-]{17}/;

var pos_dec_valid = /[0-9\.]/;
var pos_int_valid = /[0-9]/;
var YN_valid = /[YyNn]{1}/;

var cr_card_valid = /[0-9]{13,16}/;

var newwin;
var timerId;
var datefield;
var dateyy;
var datemm;
var datedd;

function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
oncontextmenu='return false';

}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';

}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;

function ridspace(thestring) {
 while(''+thestring.charAt(thestring.length-1)==' ')
                      thestring=thestring.substring(0,thestring.length-1)
	return thestring;
}

function launchHelp() {
	alert("Contextual Help function goes here!");
}

function launchGloss() {
	alert("Insert glossary here!");
}

function logOut() {
	alert("Insert log off routine here!");
}

function winopen(strThisPage)
{
	var targeturl = strThisPage;
	var winfeatures = "scrollbars";

	var numWidth;
	var numHeight;
	var nonbrwsr;
	
 	//check number of arguments
	if(arguments.length == 1) {
   		//it's just the url, set the screen height and width
   		//if it's version 4 and above, use screen.width and screen.height
   		if (parseInt(navigator.appVersion) >= 4){
     			numWidth = screen.width;
     			numHeight = screen.height;
 		} 
		else {
     			// it's a low version -- set width and height manually
     			numWidth = 800;
     			numHeight = 600;
    		}
  	}
 	else if(arguments.length >= 3) {
     	numWidth = arguments[1];
     	numHeight = arguments[2];
  	}
	
	winfeatures=winfeatures += ",left="+40+",top="+40+",screenX="+40+",screenY="+40
	
	winfeatures=winfeatures += ",HEIGHT="+numHeight+",WIDTH="+numWidth
	
 	if(arguments.length >= 4) {
   		//other arguments are being passed in
   		for (i=3; i<arguments.length; i++) {
     		if(arguments[i] == "status") {
       			winfeatures += ",status";
      		}
     		if(arguments[i] == "toolbar") {
       			winfeatures += ",toolbar";
      		}
     		if(arguments[i] == "resizable") {
       			winfeatures += ",resizable";
 			}
			if(arguments[i] == "location") {
       			winfeatures += ",location";
			}
     		if(arguments[i] == "menubar") {
       			winfeatures += ",menubar";
 			}
 		}
	}
	
 	newwin = window.open("","",winfeatures);
	
	//test
    //newwin = window.open("","",'location,menubar,toolbar,resizable');
 		
	newwin.location = targeturl;
		
}

function preloadImages() { 
	// Based on CV_prerloadImages() v3.0 by Macromedia.
	// Modifications by O. Yearian, Convene.com, 2/2001.
	//
	// Simple preloading function
	var d;
	d=document; 
	if(d.images){ 
	    if(!d.CV_pre) {
	         d.CV_pre=new Array();
	    }
	    var i,j,a;
	    j=d.CV_pre.length;
	    a=preloadImages.arguments; 
	    for(i=0; i<a.length; i++) {
	     d.CV_pre[j]=new Image; 
	     d.CV_pre[j++].src=a[i];
	    }
	}
}

function findObj(n, d) {
	// Bassed on MM_findObj() v4.0 by Macromedia. 
	// Modifications by O. Yearian, Convene.com, 2/2001.
	//
	// Finds an object referenced by id or name within the document.
	// Always use this function in place of a direct reference to 
	// avoid problems with browsers' differing DOm implementations.			
	var p,i,x;  
	if(!d) d=document;      							//Default to document if no object specified
	if( (p=n.indexOf("?"))>0 && parent.frames.length) {
	    //
	    //for dealing with framesets. Like, I'm gonna use this?
	    //
	    d=parent.frames[n.substring(p+1)].document; 
	    n=n.substring(0,p);
	}
	if(!(x=d[n]) && d.all) {							//If d[n] doesn't return an object . . .
			x=d.all[n]; 								//. . . try the "all" array
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x=d.forms[i][n];								//Next, try the forms array
	}
	//
	//Call the function recursively for dealing with idiot NN4 DOM
	//
	for(i=0; !x && d.layers && i<d.layers.length; i++) {
	     x=findObj(n,d.layers[i].document);
	}
	//
	// Finally, try getElementByID() to cover the W3C (NN6) DOM
	//
	if(!x && document.getElementById) {
		x=document.getElementById(n);
	}
	return x;
}

function displayStatusMsg(msgStr) {  
	// Based upon MM_displayStatusMsg() v1.0 by Macromedia.
	// Modifications by O. Yearian, Convene.com, 2/2001.
	window.status=msgStr;
	document.CV_retVal = true;
}

function swapImage() {
	// Based upon MM_swapImage() v3.0 by Macromedia. 
	// Modifications by O. Yearian, Convene.com, 2/2001.
	//
	// Expects n arguments in groups of 3.
	// First is the object (image) id/name, last is the new source filename.
	// The function creates an array of swapped image objects, and assigns
	// an "oSrc" attribute used by swapImageRestore(). The 2nd argument
	// becomes the window status message.
	//
	// Example: onmouseover="swapImage('theImageId','Takes you somewhere else','img_over.gif');"
	var i,j,x,a,m;
	j=0;
	a=swapImage.arguments;
	document.CV_sr=new Array;
	for(i=0;i<(a.length-2);i+=3) {
		if((x=findObj(a[i]))!=null){
			document.CV_sr[j++]=x;
			if(!x.oSrc) x.oSrc=x.src; 
			x.src=a[i+2];
	    }
		m=a[i+1];
		displayStatusMsg(m);
	}
}

function swapImgRestore() { 
	//Based upon MM_swapImgRestore() v3.0 by Macromedia.
	var i,x,a;
	a=document.CV_sr; 
	for(i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++) 
	    x.src  = x.oSrc;
	window.status="";
}

function showHideBlocks() {
	// Based upon MM_showHideLayers() v3.0 by Macromedia. 
	// Modifications by O. Yearian, Convene.com, 2/2001.
	//
	// Expects n arguments in groups of 3.
	// First is the object ID, last is the toggle state, "show" or "hide".
	// We pass in the state strings appropriate to Netscape 4's worthless implementation
	// and then correct if we're dealing with a better browser. The second argument is
	// ignored if an empty string, otherwise it is passed to window.status. Note that it's
	// necessary for this function to have the ability to bypass displayStatusMsg(m). The
	// function must be used in conjunction with swapImage().
	var i,p,v,m,obj,args;
	args=showHideBlocks.arguments;
	for(i=0;i<(args.length-2);i+=3) {
		if((obj=findObj(args[i]))!=null) {
			v=args[i+2];
			if(obj.style) {
				obj=obj.style;
				v = (v=='show')?'visible':(v=='hide')?'hidden':v;
			}
			obj.visibility=v;
		}
		m=args[i+1];
		if(m!="") {
			displayStatusMsg(m);
		}
		else {
			document.CV_retVal = true;
		}
	}
}

function highlightBlocks() {
	// V 0.5
	// O.Yearian, Convene.com, 3/2001
	//
	// Expects n arguments in groups of 4:
	//    (Object ID, Status String, Background Color, Foreground Color)
	// I'll work out some defaults for future revisions.
	// Note that, for this to have any hope at all of working in NN 4
	// it should only be used on elements whose style attributes ahve been
	// set by an external stylesheet or a stylesheet embedded in the <head></head>
	var i,bc,fc,m,obj,args;
	args = highlightBlocks.arguments;
	// Loop through the arguments by 4
	
	
	for(i=0;i<(args.length-3);i+=4) {
		// First, find the object
		if((obj=findObj(args[i])) != null) {	//if found . . .
		
			bc = args[i+2];
			fc = args[i+3];
			
			if(obj.style) {
			   obj=obj.style;		//correct for MSIE DOM

			}
			
			
			//obj.backgroundColor = bc;
			obj.color = fc;
		}
		// Now, do the window status message, if any
		m=args[i+1];
		if(m != "") displayStatusMsg(m);
		else document.CV_retVal = true;
	}
}

function doubleSel(blockID){
	var theBlock;
	theBlock = blockID;
	highlightBlocks(theBlock,'','white','black');
}

function goNext(strUrl) {
	//var msg;
	//msg="Now loading " + strUrl + ".";
	//alert(msg);
	location.href = strUrl;
}

function moveNext(strUrl) {
	location.replace(strUrl);
}

function navAnchor(strHash) {
	//if (navigator) {
	//	alert("Going to " + strHash);
	//}
	self.location.hash = strHash;
}

function cvReloadPage(init) {
	// Based upon MM_reloadPage() v1.0 by Macromedia.
	// Modifications by O. Yearian, Convene.com, 2/2001.
	//
	// Reloads the current window if we're foolishly using NN4 and window is resized.
	if (navigator) {
		if (init==true) with (navigator) {
			if ((appName=="Netscape") && (parseInt(appVersion)==4)) {
				document.CV_pgW=innerWidth;
				document.CV_pgH=innerHeight;
				onresize=cvReloadPage(false);
			}
		}
		else if (innerWidth!=document.CV_pgW || innerHeight!=document.CV_pgH) {
			location.reload();
		}
	}
}

// fuction checks for numeric number > 0
function fpos_valid(objName) {
	var sNum = objName;
	var theNum;
	
	sNum.toString =  customToString;
	
	theNum = sNum.toString();
	
	if (!pos_int_valid.test(theNum)) {
		return false;
	}
	
	Num = parseFloat(theNum)
	
	if (Num <= 0) {
		return false;
	}
	
	return true;
}

// custom function for toString creation
function customToString() {
	//alert("this " + this)
	return this;
}

// check for valid date
function date_valid(objName) {
<!-- Original:  Mike Welagen (welagenm@hotmail.com) -->

var strDatestyle = "US"; //United States date style
//var strDatestyle = "EU";  //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;

var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;

var strMonthArray = new Array(12);

datefield = objName;

strMonthArray[0] = "January";
strMonthArray[1] = "February";
strMonthArray[2] = "March";
strMonthArray[3] = "April";
strMonthArray[4] = "May";
strMonthArray[5] = "June";
strMonthArray[6] = "July";
strMonthArray[7] = "August";
strMonthArray[8] = "September";
strMonthArray[9] = "October";
strMonthArray[10] = "November";
strMonthArray[11] = "December";


datefield.toString =  customToString

strDate = datefield.toString();


if (strDate.length < 1) {
	return true;
}


for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
	if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
		strDateArray = strDate.split(strSeparatorArray[intElementNr]);
		if (strDateArray.length != 3) {
			err = 1;
			return false;
		}
		else {
			strDay = strDateArray[0];
			strMonth = strDateArray[1];
			strYear = strDateArray[2];
		}

		booFound = true;
    }
}


if (booFound == false) {
	if (strDate.length>5) {
		strDay = strDate.substr(0, 2);
		strMonth = strDate.substr(2, 2);
		strYear = strDate.substr(4);
	}
	else {
		return false;
   }
}


if (strYear.length == 2) {
	strYear = '20' + strYear;
}

// US style
if (strDatestyle == "US") {
	strTemp = strDay;
	strDay = strMonth;
	strMonth = strTemp;
}


intday = parseInt(strDay, 10);
if (isNaN(intday)) {
	err = 2;

	return false;
}

intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
	for (i = 0;i<12;i++) {
		if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
			intMonth = i+1;
			strMonth = strMonthArray[i];
			i = 12;
	    }
	}
	if (isNaN(intMonth)) {
		err = 3;

		return false;
    }
}

intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
	err = 4;

	return false;
}



if (intMonth>12 || intMonth<1) {
	err = 5;

	return false;
}

if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
	err = 6;

	return false;
}

if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
	err = 7;

	return false;
}


if (intMonth == 2) {
	if (intday < 1) {
		err = 8;

		return false;
	}
	if (LeapYear(intYear) == true) {
		if (intday > 29) {
			err = 9;

			return false;
		}
	}
else {
	if (intday > 28) {
		err = 10;

		return false;
	}
}
}

if (strDatestyle == "US") {
	datefield = strMonthArray[intMonth-1] + " " + intday+", " + strYear;
	dateyy = strYear;
	datemm = strMonthArray[intMonth-1];
	datedd = intday
}
else {
	datefield = intday + " " + strMonthArray[intMonth-1] + " " + strYear;

}

return true;
}

function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}

// Always call this function once during page load in order to initialize
// the two variables by which we detect window resize events.
cvReloadPage(true);

<!-- begin script
//
//  Cookie Functions -- "Night of the Living Cookie" Version (25-Jul-96)
//
//  Written by:  Bill Dortch, hIdaho Design <bdortch@hidaho.com>
//  The following functions are released to the public domain.
//
//  This version takes a more aggressive approach to deleting
//  cookies.  Previous versions set the expiration date to one
//  millisecond prior to the current time; however, this method
//  did not work in Netscape 2.02 (though it does in earlier and
//  later versions), resulting in "zombie" cookies that would not
//  die.  DeleteCookie now sets the expiration date to the earliest
//  usable date (one second into 1970), and sets the cookie's value
//  to null for good measure.
//
//  Also, this version adds optional path and domain parameters to
//  the DeleteCookie function.  If you specify a path and/or domain
//  when creating (setting) a cookie**, you must specify the same
//  path/domain when deleting it, or deletion will not occur.
//
//  The FixCookieDate function must now be called explicitly to
//  correct for the 2.x Mac date bug.  This function should be
//  called *once* after a Date object is created and before it
//  is passed (as an expiration date) to SetCookie.  Because the
//  Mac date bug affects all dates, not just those passed to
//  SetCookie, you might want to make it a habit to call
//  FixCookieDate any time you create a new Date object:
//
//    var theDate = new Date();
//    FixCookieDate (theDate);
//
//  Calling FixCookieDate has no effect on platforms other than
//  the Mac, so there is no need to determine the user's platform
//  prior to calling it.
//
//  This version also incorporates several minor coding improvements.
//
//  **Note that it is possible to set multiple cookies with the same
//  name but different (nested) paths.  For example:
//
//    SetCookie ("color","red",null,"/outer");
//    SetCookie ("color","blue",null,"/outer/inner");
//
//  However, GetCookie cannot distinguish between these and will return
//  the first cookie that matches a given name.  It is therefore
//  recommended that you *not* use the same name for cookies with
//  different paths.  (Bear in mind that there is *always* a path
//  associated with a cookie; if you don't explicitly specify one,
//  the path of the setting document is used.)
//  
//  Revision History:
//
//    "Toss Your Cookies" Version (22-Mar-96)
//      - Added FixCookieDate() function to correct for Mac date bug
//
//    "Second Helping" Version (21-Jan-96)
//      - Added path, domain and secure parameters to SetCookie
//      - Replaced home-rolled encode/decode functions with Netscape's
//        new (then) escape and unescape functions
//
//    "Free Cookies" Version (December 95)
//
//
//  For information on the significance of cookie parameters, and
//  and on cookies in general, please refer to the official cookie
//  spec, at:
//
//      http://www.netscape.com/newsref/std/cookie_spec.html    
//
//******************************************************************
//
// "Internal" function to return the decoded value of a cookie
//
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//
//  Function to correct for 2.x Mac date bug.  Call this function to
//  fix a date object prior to passing it to SetCookie.
//  IMPORTANT:  This function should only be called *once* for
//  any given date object!  See example at the end of this document.
//
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
//
//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
//
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
//
//  Function to create or update a cookie.
//    name - String object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid.  If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).  
//
//  The first two parameters are required.  The others, if supplied, must
//  be passed in the order listed above.  To omit an unused optional field,
//  use null as a place holder.  For example, to call SetCookie using name,
//  value and path, you would code:
//
//      SetCookie ("myCookieName", "myCookieValue", null, "/");
//
//  Note that trailing omitted parameters do not require a placeholder.
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name,value,expires,path,domain,secure) {

  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires : "") + //.toGMTString()
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");

}

//  Function to delete a cookie. (Sets expiration date to start of epoch)
//    name -   String object containing the cookie name
//    path -   String object containing the path of the cookie to delete.  This MUST
//             be the same as the path used to create the cookie, or null/omitted if
//             no path was specified when creating the cookie.
//    domain - String object containing the domain of the cookie to delete.  This MUST
//             be the same as the domain used to create the cookie, or null/omitted if
//             no domain was specified when creating the cookie.
//
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}




// function to write the video speed to the cookie, build the new video speed based on the selected streaming speed
// open the RP and close the window that performs the test.
function showvideo(vidname,cknm,ckval,expdt,plnm,plval) {
						
		//attach the selected speed to the video name
		if (ckval == -1) {
			for (i=0;i<3;i++) {
				if ( document.testForm.test1[i].checked )
					var ckval1 = document.testForm.test1[i].value;
			}
		}
		else {
			ckval1 = ckval	
		}
		
		//locate the player choice
		if (plval == -1) {
			for (i=0;i<2;i++) {
				if ( document.testForm.elements[i].checked )
					plval1 = document.testForm.elements[i].value;
			}
		}
		else {
			plval1 = plval	
		}
		
		// get video file name
		var tmp = vidname;
		
		vidfile = vidname;
		
		// create the correct suffix depending on the user's choice of players
		if (plval1 == "r") 
			suffix = "ram";
		else if ( plval1 == "w")
			suffix = "wvx"
			
		// removed becuase of addition of wmv
		//suffix = tmp.substring(tmp.lastIndexOf(".")+1,tmp.length); 
		
		// create complete video file name including speed and suffix
		var newvidname=vidfile+ckval1+"."+suffix
		
		// set cookies for speed and player type
     	SetCookie(cknm,ckval1,expdt);
     	SetCookie(plnm,plval1,expdt);
		
		// pop up the video player
		window.location.href = "videoplayer.cfm?vid=" + escape(newvidname) + "&mp=" + plval1;
		
		// set timer to close the window shortly
		//timerId=setInterval("closewindow('"+newvidname+"', "+timerId+");",1000);
		
}

// function to write the video speed to the cookie
// and close the window that performs the test.
function saveSettings(vidname,cknm,ckval,expdt,plnm,plval) {
				
		//attach the selected speed to the video name
		if (ckval == -1) {
			for (i=0;i<3;i++) {
				if ( document.testForm.test1[i].checked )
					var ckval1 = document.testForm.test1[i].value;
			}
		}
		else {
			 ckval1 = ckval	
		}
		
		//locate the player choice
		if (plval == -1) {
			for (i=0;i<2;i++) {
				if ( document.testForm.elements[i].checked )
					var plval1 = document.testForm.elements[i].value;
			}
		}
		else {
			splval1 = plval	
		}
				
		// set cookies for speed and player type
     	SetCookie(cknm,ckval1,expdt);
     	SetCookie(plnm,plval1,expdt);
		
		// set timer to close the window shortly
		timerId=setInterval("closewindow('"+vidname+"', "+timerId+");",1000);
		
}


//pass a complete url to this function and it will close it in 1 second
function preclosewindow(nurl) {
	 
 	    timerId=setInterval("closewindow('"+nurl+"', "+timerId+");",100);
		//document.certForm.submit()
		
}

// close the window that contains the video href and reset the interval timer.
function closewindow(vn,tid) {
	
	if (location.href = vn) {
		self.close()
		rc = clearInterval(tid)
	}
}		