// Common JavaScript library, 20 Feb 2001

var imgDir="http://www.2point.com/images/";browserName = navigator.appName;browserVer = parseInt ( navigator.appVersion );version = "n2";
if ( browserName == "Netscape" && browserVer >= 3 ) version = "n3";if ( browserName == "Microsoft Internet Explorer" && browserVer >=4 ) version = "e4";
if ( version == "n3" || version == "e4" ) {
b1dn = new Image();b1dn.src = imgDir+"NavHomeoff.gif";b1up = new Image();b1up.src = imgDir+"NavHomeon.gif";
b2dn = new Image();b2dn.src = imgDir+"leftnavsuccess.jpg";b2up = new Image();b2up.src = imgDir+"leftnavsuccess_over.jpg";
b3dn = new Image();b3dn.src = imgDir+"leftnavwebinar.jpg";b3up = new Image();b3up.src = imgDir+"leftnavwebinar_over.jpg";
b4dn = new Image();b4dn.src = imgDir+"LeftNavFindReseller.jpg";b4up = new Image();b4up.src = imgDir+"LeftNavFindReseller_over.jpg";
b5dn = new Image();b5dn.src = imgDir+"LeftNavRequestMore.jpg";b5up = new Image();b5up.src = imgDir+"LeftNavRequestMore_over.jpg";
b6dn = new Image();b6dn.src = imgDir+"LeftNavcontact.jpg";b6up = new Image();b6up.src = imgDir+"LeftNavcontact_over.jpg";
}

  function hiLite(imgDocID,imgObjName) {
  if ( version == "n3" || version == "e4" ) {
  document.images[imgDocID].src = eval(imgObjName + ".src")
  }
}

// Image rollover management
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function flipImage(url, names){
if(navigator.appVersion.lastIndexOf("MSIE 3.0") == -1) document[names].src = url;
}
// image toggle for IE and Netscape 
// e.g. imgsw('happy','happyon.gif') e.g. imgsw('happy','happyoff.gif')
function imgsw(name,a) {
   if (document.images){
      document.images[name].src=a;
}
}
// for main menu and redirector
function bgRoll(strTextColor,strBgColor)
{
	window.event.srcElement.style.backgroundColor = strBgColor;
	window.event.srcElement.style.color = strTextColor;
	window.event.cancelBubble = true;
}
// for main menu and redirector
function fntRoll(strTextColor)
{
	window.event.srcElement.style.color = strTextColor;
	window.event.cancelBubble = true;
}
// open a new windows
function GetNewWindow(urladdr)
{
   var hWnd = window.open(urladdr,"MSCalendar1","width=230,height=190,toolbar=no,resizable=no,scrollbars=no,screenX=50,ScreenY=50,left=100,top=100");
  // if (hWnd.focus != null) hWnd.focus();  
}
// open a new windows (older version)
function OpenWindow(urladdr, intwidth, intheight, scrollbars)
{
   var hWnd = window.open (urladdr,"NewWindow","width="+ intwidth +",height="+ intheight +",toolbar=no,resizable=no,scrollbars=" + scrollbars + ",screenX=50,ScreenY=50,left=100,top=100");
}


//enter limit in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
function begintimer(){
if (!document.images)
return
if (parselimit==1){
window.status='Times up! Your page will being disconnected from the server anytime. Please copy and paste your content and try it later...'
Timermsg()}
else{ 
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left"
else
curtime=cursec+" seconds left"
window.status=curtime
setTimeout("begintimer()",1000)
}
}

// Timeout Error Messge
// from: Tony Lai
function Timermsg() {
alert("You have 5 minutes left before connection timeout, Please save your page ");
} 

// Super function, check user input Date(mm,dd,yy)
// working  with another function:
// chkMonth(), leapYear(year) and getDays()
function chkday(mm,dd,yy){
mm=Number(mm)
dd=Number(dd)
yy=Number(yy)
a = getDays(mm,yy)
a = a + 1  
if ((dd > 0) && (dd < a)){
return false }
else{return true}
}
function chkMonth(month){
if ((month > 0) && (month < 13)){
return false }
else{return true}
}
function leapYear(year) {
if (year % 4 == 0) // basic rule
return true // is leap year
/* else */ // else not needed when statement is "return"
return false // is not leap year
}
function getDays(month, year) {
// create array to hold number of days in each month
var ar = new Array(13)
ar[1] = 31 // January
ar[2] = (leapYear(year)) ? 29 : 28 // February
ar[3] = 31 // March
ar[4] = 30 // April
ar[5] = 31 // May
ar[6] = 30 // June
ar[7] = 31 // July
ar[8] = 31 // August
ar[9] = 30 // September
ar[10] = 31 // October
ar[11] = 30 // November
ar[12] = 31 // December
return ar[month]
}
// function, check user input email address textbox object
function chkemail(email){
// have basic email checking
if (email.value == "")
{
	alert("Please enter a value for the email address field.");
	email.focus();
	return (false);
}
  var checkOK = "@";
  var checkStr = email.value;
  var allValid = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++){
      if (ch == checkOK.charAt(j)){
				allValid = true;}
    }
  }
  if (!allValid)
  {
    alert("Email address is missing \"@\" ");
    email.focus();
    return (false);
  }
  var checkOK = ".";
  var checkStr = email.value;
  var allValid = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++){
      if (ch == checkOK.charAt(j)){
				allValid = true;}
    }
  }
  if (!allValid)
  {
    alert("Email address is missing \".\" ");
    email.focus();
    return (false);
  }
  var checkOK = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_.-";
  var checkStr = email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Email address is invalid.");
    email.focus();
    return (false);
  }
	else
	{
    return (true);
	}
}
//round to 2 decimal place
function roundit(which){
return Math.round(which*100)/100
}
function checkDate(sDate)	//Julia (mm/dd/yyyy format )
{   
 var iPos;
 var iDay;
 var iMonth;
 var iYear;
 var MyDate;

 blCorrect=false;
 pos=sDate.search('/');
 if(pos!=2)return false;
 iMonth=(sDate.substring(0,pos));
 sDate=sDate.substr(pos+1);
 pos=sDate.search('/');
 if(pos!=2)return false;
 iDay=(sDate.substring(0,pos));
 sDate=sDate.substr(pos+1);                         
 if(sDate.length!=4)return false;
 iYear=(sDate);
 if(iYear<1799)return false;
 MyDate=new Date(iYear,iMonth-1,iDay);
 if(iYear==MyDate.getFullYear()
 && (iMonth-1)==MyDate.getMonth()
 && (iDay==MyDate.getDate())) return true;
 return false;
}
function checkDigLet(sDig)	//Julia
{
   var regularexpression =/[^A-Za-z0-9]/i;
   var checkStr=new String("");  
   checkStr = sDig;
   if (checkStr.search(regularexpression)!=-1) return false;
   return true;
}
function checkDig(sDig)	//Julia
{
   var regularexpression =/[^0-9]/i;
   var checkStr=new String("");  
   checkStr = sDig;
   if (checkStr.search(regularexpression)!=-1) return false;
   return true;
}
function checkDigAndDot(sDig)	//Julia (check for dd..d.d format. To modify, change regular expression as you like!)
{
   var regularexpression =/^\d*\.\d{1}$/;
   var checkStr=new String(""); 
   var notvalid=true; 
   checkStr = sDig;
   notvalid = !isValid(regularexpression,checkStr);
   if (notvalid) 
   {
	return false;
   }
   return true;
}
function isValid(pattern, str) //Julia
{
	return pattern.test(str);
}

function stripChars(pattern, str)	//Julia	(see example below)
{
	return (str.replace(pattern,""));
}

//*** Validate email Function ***
function IsValidEmail(src) {
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(src);
  }

//
// This function is for the standard validating of required form fields
// It checks to see if the REQUIRED field is present "sFIELDNAME"
// If the field exists, the validation check is completed
// If the field does not exist the validation for that field is bypassed
// Standard required field names are:
// sName  sTitle  sClientID sBPID sCoName sAddress sCity sStateProv
// sZipPostal sCountry sTelephone sFax sEmail
// If the field is not a required field, then you can use the field name
// without the preceeding "s"
// Any required fields, unique to a specific form, must be validated using
// a JavaScript within the form code.


function sValidate(theForm)

{

if (theForm.sName)
{
if (theForm.sName.value == "")
{
alert("Please enter your name in the \"Name\" field.")
theForm.sName.focus()
return (false)
}
}

if (theForm.sTitle)
{
if (theForm.sTitle.value.length < 1)
{
alert("Please enter your company title in the \"Title\" field.")
theForm.sTitle.focus()
return (false)
}
}

if (theForm.sClientID)
{
if (theForm.sClientID.value.length < 1)
{
alert("Please enter your client ID number in the \"Client ID\" field.")
theForm.sClientID.focus()
return (false)
}
}

if (theForm.sBPID)
{
if (theForm.sBPID.value.length < 1)
{
alert("Please enter your Business Partner ID in the \"BP ID\" field.")
theForm.sBPID.focus()
return (false)
}
}

if (theForm.sCoName)
{
if (theForm.sCoName.value == "")
{
alert("Please enter your company's name in the \"Company\" field.")
theForm.sCoName.focus()
return (false)
}
}
if (theForm.sAddress)
{
if (theForm.sAddress.value == "")
{
alert("Please enter the address of your company in the \"Address\" field.")
theForm.sAddress.focus()
return (false)
}
}
if (theForm.sCity)
{
if (theForm.sCity.value == "")
{
alert("Please enter your city in the \"City\" field.")
theForm.sCity.focus()
return (false)
}
}
if (theForm.sStateProv)
{
if (theForm.sStateProv.value.length < 2)
{
  alert("Please enter your state or province.")
  theForm.sStateProv.focus()
  return (false)
}
}
if (theForm.sZipPostal)
{
if (theForm.sZipPostal.value == "")
{
alert("Please enter your zip or postal code.")
theForm.sZipPostal.focus()
return (false)
}
}

if (theForm.sCountry)
{
if (theForm.sCountry.value == "")
{
alert("Please enter your country.")
theForm.sCountry.focus()
return (false)
}
}
if (theForm.sTelephone)
{
if (theForm.sTelephone.value == "")
{
alert("Please enter your telephone number.")
theForm.sTelephone.focus()
return (false)
}
}
if (theForm.sEmail)
{
if (!chkemail(theForm.sEmail))
{
theForm.sEmail.focus();
return (false);
}
}
// If we made it to here, everything's valid, so return true
 return (true)
}
