/* NAVIGATION SCRIPTS */
/* Navigation for index page */
/* Popup window for DIA animation from Home page navigation  */
function popWindow(url,params){
myWin=window.open(url,title,params,true)
;
myWin.focus();
}
var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = 20  // default, pixels from screen left to window left
  var d_winTop = 20   // default, pixels from screen top to window top
  winName = "popWin" + winCount++ //unique name for each pop-up window
  closePopWin()           // close any previously opened pop-up window
  if (openPopWin.arguments.length >= 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  if (openPopWin.arguments.length == 6)  // location specified
    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
  else
    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
  popWin = window.open(winURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + winFeatures)
  }
function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
  }
function getLocation(winWidth, winHeight, winLeft, winTop){
  return ""
  }
/* For displaying linked page in previous window (PDF from start.html, ftp download window) */
function loadinprev(url, closeSelf){
	self.opener.location = url;
	if(closeSelf) self.close();
	}
/* For Flash on index.htm */
function homeFlash()
{
/* If this browser understands the mimeTypes property and recognizes the MIME Type //"application/x-shockwave-flash" display Flash ...  */
     if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
     {
      document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="315" height="315" class="fltrt" id="EPIndex" align="right">');
      document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="flash/EPIndex.swf" /><param name="quality" value="high" />');
      document.write('<param name="scale" value="exactfit" /><param name="bgcolor" value="#ffffff" />');
      document.write('<embed src="flash/EPIndex.swf" quality="high" scale="exactfit" bgcolor="#ffffff" width="315" height="315" class="fltrt" name="EPIndex" align="right" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
     }
/*    ...display the equivalent image */
     else 
     {
     document.write('<img src="images/EPIndex.jpg" width="315" height="315" alt="Entrypoint Plus" align="right" id="home-img">');
     }
}
/* For headers */
function topFlash()
{
     document.write('<img src="images/EntrypointPage.jpg" width="315" height="100" alt="Entrypoint Plus for Clinical Trials">');
}
/* Define images for sales.htm, support.htm and download.htm pages; not used--doesn't work if user enters the entire URL for the page rather than navigating */
function supImages()
{
var supImg_array = new Array ("sales","support","download","product", "resources");
var supDesc_array = new Array ("Sales","Support","USB Cable","Entrypoint CRF Template", "Clinical Trials");
/* get name of page */
var the_url = self.location;
the_url = "\"" + the_url + "\"";
var lead_slashes = the_url.indexOf("//");
/* USE THIS FOR TESTING DIRECTORY) */
/* var domain_start = lead_slashes + 33; */
var domain_start = lead_slashes + 25;
var without_resource = the_url.substring(domain_start, the_url.length);
var extension_beg = without_resource.indexOf(".");
var this_page = without_resource.substring(0, extension_beg);
var this_image = "images/" + this_page + ".jpg";
document.write('<img src="' + this_image + '" align="right" alt="' + this_page + '" width="375" height="350" id="home-img">');
}
/* Popup window for 21 CFR Part 11 PDF */
function popWindow(url,params){
myWin=window.open(url,title,params,true)
;
myWin.focus();
}
var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = 20  // default, pixels from screen left to window left
  var d_winTop = 20   // default, pixels from screen top to window top
  winName = "popWin" + winCount++ //unique name for each pop-up window
  closePopWin()           // close any previously opened pop-up window
  if (openPopWin.arguments.length >= 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  if (openPopWin.arguments.length == 6)  // location specified
    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
  else
    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
  popWin = window.open(winURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + winFeatures)
  }
function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
  }
function getLocation(winWidth, winHeight, winLeft, winTop){
  return ""
  }
  
/* for closing popup windows; CONDOR popups use */
function closeIt() 
{
  close();
}
/* End of popup window */
/* For sales.htm link */
function salesContact()
{
			 part1 = "John";
			 part2 = "Brayman";
             part3 = "entrypointplus";
             part4 = ".com";
			 subject = "Entrypoint Plus Sales Information";
             document.write('<a href=\"mailto:' + part1 + part2 + '@' + part3 + part4 + '?SUBJECT=' + subject + '\">');
             document.write('John Brayman<\/a>');
			
}
/* For support.htm */
function supportContact()
{
             part1 = "support";
             part3 = "entrypointplus";
             part4 = ".com";
			 subject = "Entrypoint Technical Support";
             document.write('<a href=\"mailto:' + part1 + '@' + part3 + part4 + '?SUBJECT=' + subject + '\">');
             document.write('Email<\/a>');
}
/* For ep500.htm error message */
function webContact()
{
             part1 = "webmaster";
             part3 = "phoenixsoftware";
             part4 = ".com";
			 subject = "Error 500";
             document.write('<a href=\"mailto:' + part1 + '@' + part3 + part4 + '?SUBJECT=' + subject + '\">');
             document.write('webmaster<\/a>');
}
/* For EP demo first page */
function demoFlash()
{
      document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="660" height="550">');
	  document.write('<param name="movie" value="images/EPIntro.swf"><param name="quality" value="high">');
	  document.write('<embed src="images/EPIntro.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="660" height="550"></embed></object>');
}
/* For EP demo menu */
function menuFlash()
{
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="660" height="400" id="epmenu" align="middle">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="images/epmenu.swf">');
document.write('<param name="quality" value="high"><param name="bgcolor" value="#ffffff">');
document.write('<embed src="images/epmenu.swf" quality="high" bgcolor="#ffffff" width="660" height="400" name="images/epmenu" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
document.write('</object>');
}
/* For CRF templates demo buttons */
function defineImages()
{
// for start button
s1=new Image
s1.src="http://www.entrypointplus.com/images/s1.jpg"
s2=new Image
s2.src="http://www.entrypointplus.com/images/s2.jpg"
// for back button
b1=new Image
b1.src="http://www.entrypointplus.com/images/b1.jpg"
b2=new Image
b2.src="http://www.entrypointplus.com/images/b2.jpg"
// for next button
n1=new Image
n1.src="http://www.entrypointplus.com/images/n1.jpg"
n2=new Image
n2.src="http://www.entrypointplus.com/images/n2.jpg"
// for end button
e1=new Image
e1.src="http://www.entrypointplus.com/images/e1.jpg"
e2=new Image
e2.src="http://www.entrypointplus.com/images/e2.jpg"
}
/* For Demo buttons */
function defineDemoImages()
{
// for start button
s1=new Image
s1.src="../images/s1.jpg"
s2=new Image
s2.src="../images/s2.jpg"
// for back button
b1=new Image
b1.src="../images/b1.jpg"
b2=new Image
b2.src="../images/b2.jpg"
// for next button
n1=new Image
n1.src="../images/n1.jpg"
n2=new Image
n2.src="../images/n2.jpg"
// for end button
e1=new Image
e1.src="../images/e1.jpg"
e2=new Image
e2.src="../images/e2.jpg"
}
/* For download page; obsolete */
function enter()
{
   user = document.frm.user.value;
   pass = document.frm.pwd.value;
   document.frm.user.value = "";
   document.frm.pwd.value = "";
   window.open("ftp://"+user+":"+pass+"@phoenixsoftware.com/start.html", 'ftp_window', 'width=570,height=650,left=20,top=10,address=no,status=no,resizable=yes');
   }
/* For download page by version number */
function dwnld()
{
   user = document.frm.user.value;
   pass = document.frm.pwd.value;
   version = document.frm.version.value;
 if ((user == "") || (pass == ""))
   {
   alert("Please fill in the user ID and password");
   }
 else if ((version == "") || (version == "select"))
   {
   alert("Please select a version");
   }
  else
   {
   window.open("ftp://"+user+":"+pass+"@phoenixsoftware.com/download_list"+version+".htm", 'ftp_window', 'width=775,height=690,address=no,status=no,resizable=yes');
   }
}
/* For testing download page */
function dwnld_test()
{
   user = document.frm.user.value;
   pass = document.frm.pwd.value;
   version = document.frm.version.value;
 if ((user == "") || (pass == ""))
   {
   alert("Please fill in the user ID and password");
   }
 else if ((version == "") || (version == "select"))
   {
   alert("Please select a version");
   }
  else
   {
   window.open("ftp://"+user+":"+pass+"@phoenixsoftware.com/download_list"+version+"_3col.htm", 'ftp_window', 'width=775,height=700,address=no,status=no,resizable=yes');
   }
}
/* EVALUATION.PHP FUNCTIONS */
/* Validation (old script) */
function checkrequired(which) {
var pass=true;
if (document.images) 
{
  for (i=0;i<which.length;i++) 
  {
    var tempobj=which.elements[i];
    if (tempobj.name.substring(0,8)=="required") 
    {
      if (((tempobj.type=="text"||tempobj.type=="textarea")&&
      tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
      tempobj.selectedIndex==0)) 
	  {
        pass=false;
        break;
      }
    }
  }
}
if (!pass) 
{
  shortFieldName=tempobj.name.substring(8,30).toUpperCase();
  if (tempobj.name == "requiredFirstName")
  {
    shortFieldName = "First Name";
  }
  else if (tempobj.name == "requiredLastName")
  {
    shortFieldName = "Last Name";
  }
  else if (tempobj.name == "requiredCompany")
  {
    shortFieldName = "Company";
  }
  else if (tempobj.name == "requiredAddress1")
  {
    shortFieldName = "Address";
  }
  else if (tempobj.name == "requiredCity")
  {
     shortFieldName = "City";
  }
  else if (tempobj.name == "requiredState")
  {
    shortFieldName = "State/Province";
  }
  else if (tempobj.name == "requiredZip")
  {
    shortFieldName = "Zip/Postal Code";
  }
  else if (tempobj.name == "requiredPhone")
  {
    shortFieldName = "Phone";
  }
  else if (tempobj.name == "requiredEmail")
  {
    shortFieldName = "Email";
  }
  else if (tempobj.name == "requiredNumUsers")
  {
    shortFieldName = "Number of Users/Workstations";
  }
  else if (tempobj.name == "requiredEvalBeginMonth")
  {
    shortFieldName = "Evaluation Month";
  }
  else if (tempobj.name == "requiredEvalBeginDay")
  {
    shortFieldName = "Evaluation Date";
  }
  else if (tempobj.name == "requiredEvalBeginYear")
  {
    shortFieldName = "Evaluation Year";
  }
alert("Please fill in the "+shortFieldName+" field.");
return false;
}
else
return true;
}
/* End of validation script */

/* Validate email address */
function emailCheck (emailStr) {
/* Does email address match 
   the user@domain format; separates 
   the user name from the domain. */
var emailPat=/^(.+)@(.+)$/
/* Pattern for matching all special characters, 
   not allowed in the address,
   including ( ) < > @ , ; : \ " . [ ];  */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* Characters allowed in a user name or domain name  
   by stating which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* Pattern applies if user name is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* For domains that are IP addresses, rather than symbolic names,
   e.g., joe@[123.124.233.4] is a legal email address. 
   NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   A word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// Pattern that describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* Pattern that describes the structure of a standard symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

/* Determine whether the email address is valid. */

/* Pattern breaks up user@domain into
   pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* This address doesn't fit the standard format */
	alert("Email address does not match standard format (check @ and .'s).")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if user is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("Invalid email user name.")
    return false
}

/* Validate IP address if the email address is at an IP address */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Invalid IP address.")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Invalid domain name.")
    return false
}

/* domain name seems valid; make sure that it ends in a
   three-letter word (com, edu, gov, etc.) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Break up the domain to get a count of 
   how many atoms it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two-letter or three-letter word.
   alert("The email address must end in a three-letter domain, or two-letter country code.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This email address is missing a host name."
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid
return true;
}
// end of email checking routine

/* Get current and future years for evaluation period year */
function getYears()
{
var t_date = new Date();
var t_year = t_date.getFullYear();
if (t_year < 1900) {
t_year = t_year + 1900;
}
var date = t_year - 1;
var future = t_year + 5;  
document.writeln ("<OPTION value=\"\">Year");
do {
date++;
document.write ("<OPTION value=\"" + date + "\">" + date + "");
}
while (date < future)
document.write (" ");
}
/* Create hidden prod field */
function prod()
{
document.write("<input type='hidden' name='Prod' id='Prod' value='<?php print $prod?>'>");
}
