function emailpage(){
var urlToOpen = "email.asp?loc="+escape(window.location);
PopUp = window.open( urlToOpen, 'Popup', 'width=450,height=500,menubar=no,scrollbars=yes,resizable=yes' );
}

function getSizeDifferences() {
parent = window.opener;
parentform = parent.document.forms[0];
difleft = window.screenLeft - parentform.Left.value;
diftop = window.screenTop - parentform.Top.value;
difwidth = window.document.body.clientWidth - parentform.Width.value;
difheight = window.document.body.clientHeight - parentform.Height.value;
// alert ("difleft= " + difleft + "  window.screenLeft=" + window.screenLeft + "\ndiftop=" + diftop + "  window.screenTop=" + window.screenTop + "\ndifwidth=" + difwidth + "  clientWidth=" + window.document.body.clientWidth + "\ndifheight=" + difheight + "  clientHeight=" + window.document.body.clientHeight);
}

function startList() {
	for (navCount=1; navCount<=1; navCount++) {
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("nav"+navCount);
			if( navRoot != null ){
				for (i=0; i<navRoot.childNodes.length; i++) {
					node = navRoot.childNodes[i];
					if (node.nodeName=="LI") {
						node.onmouseover=function() {
							this.className+=" over";
						}
						node.onmouseout=function() {
							this.className=this.className.replace(" over", "");
						}
					}
				}
			}
		}
	}
}

// This function calls the OnLoad event.
function doOnLoadTasks(){
	//This function resides in the Standards.JS document
	startList();
}

function inputValidation(form){
	var errorText;
	// Valid friends email
	errorText = form.ValidationField1.value;
	 if ( !validEmail( form.friendsEmail.value ) ){
		alert(errorText);
		form.friendsEmail.focus();
		return;
	}
	//Validate name
	errorText = form.ValidationField2.value;
	if (form.name.value == ""){
		alert(errorText);
		form.name.focus();
		return;
	}
	//Validate users email address
	errorText = form.ValidationField3.value;
	 if ( !validEmail( form.yourEmail.value ) ){
		alert(errorText);
		form.yourEmail.focus();
		return;
	}
	form.submit();
}
function validEmail( email ){
	return ( ( email.length > email.indexOf( "." ) + 1 ) && email.indexOf( "." ) > 2 ) && ( email.indexOf( "@" ) > 0 );
}


function createMailto(sourceForm) {
  
 
  var to      = sourceForm.friendsEmail.value;
  var subject = "I thought you might find this interesting";
  var body    = sourceForm.note.value;
  var urlSend = sourceForm.pageLoc.value + "\n\n";
  
  var urltext = "";

  if ( !validEmail( to ) ){
		alert("Please enter a correctly formatted email address for your friend");
		sourceForm.friendsEmail.focus();
		return;
  }

  if (to != "") {
    urltext += to;
  }

  if (subject != "") {
    urltext = addDelimiter(urltext);
    urltext += "Subject=" + escape(subject);
  }
  
  if (body != "") {
    urltext = addDelimiter(urltext);
    urltext += "Body=" + escape(urlSend + body);
  }
  
   urltext = "mailto:" + urltext;

  testMailto(urltext)
}

function addDelimiter(inputString) {
  var inString = inputString;

  if (inString.indexOf("?") == -1) {
    inString += "?";
  }
  else {
    inString += "&";
  }
  return inString;
}

function testMailto(loc) {
  var doc = loc;

  if (doc.indexOf("HREF=") != -1) {
    var doc = doc.substring(doc.indexOf("HREF=")+6, doc.indexOf(">")-1);
  }

  window.location = doc;
  window.close();
}

function emailCheck(email) {

        var emailvar = email
        var emailparts = emailvar.split("@")
        var emailnameonly = ""
        var minimumextlength = 2
        var maximumextlength = 4
        var urltestchar = ""
        var charok = 0
        var acceptable = new Array("a","b","c","d","e","f","g","h","i","j",
        "k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J",
        "K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","_",
        ".","1","2","3","4","5","6","7","8","9","0","@","_")
    if(email == "")
	{
    	alert("Please enter an email address");
	    return false;
	}	

// check to see if there are any @'s in the string
        if (emailparts.length > 2) 
        {
          alert("Please enter only one @ character in your email address.")
          return false
        }
        if (emailparts.length <= 1)
        {
          alert("Please include one @ character in your email address.")
          return false
        }
// There is one @ - now check for a dot 
// and data before and after the @

        var emailurl=(emailparts[emailparts.length - 1])
        for (var i=0; i < emailparts.length-1; i++) 
          {
          emailnameonly=emailnameonly+emailparts[i]
          }

// Examine emailurl for a dot and data in front of it 
// and two or three characters after the last dot

        var urlparts = emailurl.split(".")

// check to see if there are any dot's in the string
// more than one is ok

        if (urlparts.length <= 1)
        {
          alert("There are no dots in the domain portion of your email address.")
          return false
       }

// Check to see how long the last urlpart is
// Must be either two or three characters long
       
       if (urlparts[urlparts.length - 1].length < minimumextlength || 
           urlparts[urlparts.length-1].length > maximumextlength)
        {
          alert("The domain name extension must have 2 - 4 characters.")
		  return false
        }

// Check all characters of the address to make sure there are no
// invalid characters - default allows the use of an underscore
// although that is technically not allowed in a domain name
// it's not that big a risk as it is allowed in the email name.

        for (i=0; i < emailvar.length-1; i++) 
          {
            urltestchar = emailvar.substr(i,1)
            for (var ii=0; ii < acceptable.length; ii++) 
            {
              if (urltestchar == acceptable[ii])
              {
                charok = 1
              }
            }
              if (charok == 0)
            {  
              alert("You've entered an invalid character in your email address.")
              return false
            }
            charok = 0
          }

// check to make sure the length of the string prior to the 
// extension is greater than minimumextlength

        if (emailurl.length-urlparts[urlparts.length - 1].length-1 < minimumextlength)
        {
          alert("You've entered an incorrect domain name for your email address.  It should be at least 2 characters.")
          return false
        }

// check to make sure the length of the string prior to the 
// domain is greater than minimumextlength

        if (emailnameonly.length < minimumextlength)
        {
          alert("You've entered an invalid email name. It must be at least two characters long.")
          return false
        }

	return true;
}
function fullScreen(theURL) {
window.open(theURL, '', 'fullscreen=yes, scrollbars=auto');
}

function openWin(sURL) {
		window.open(sURL,null,'toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,top=10,left=50,width=750,height=550');

}

function openWinSmall(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=10,left=50,width=480,height=60');
}

function openWinRate(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,top=200,left=100,width=680,height=350');

}


function openWinChart(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=10,left=50,width=500,height=500');

}

function openWinChartSmaller(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=10,left=50,width=500,height=400');

}

function openWinfact(sURL) {
		window.open(sURL,null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,top=300,left=200,width=205,height=200');

}

	function shareboxrevealBF() { // Show, hide or add to territory selector box
		document.getElementById('shareboxBF').style.display = 'block';
	}

	function shareboxhideBF() { 	// Clear the contents of the box and hide the div
		document.getElementById('shareboxBF').style.display = 'none';  
	}

	function writesharelinkBF() {
		document.write("<li id='ptshare'><a href='#' target='_self' class='shareicon' onclick='shareboxrevealBF(); return false;'>" + sharetitle + "</a></li>");
	}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


