var JS_SEARCH_MISSING_ERROR = "Please enter your search criteria.";
var JS_SEARCH_FORMAT_ERROR = "Please enter valid search criteria.";
var JS_YOUR_NAME_MISSING_ERROR = "Please enter your name.";
var JS_FRIEND_NAME_MISSING_ERROR = "Please enter your friend's name.";
var JS_YOUR_EMAIL_MISSING_ERROR = "Please enter your e-mail address.";
var JS_FRIEND_EMAIL_MISSING_ERROR = "Please enter your friend's e-mail address.";
var JS_YOUR_NAME_FORMAT_ERROR = "Please use only letters and/or numerals.";
var JS_FRIEND_NAME_FORMAT_ERROR = "Please use only letters and/or numerals.";
var JS_EMAILADDRESS_MISSING_ERROR = "Please enter your e-mail address.";
var JS_EMAILADDRESS_FORMAT_ERROR = "Please enter a valid e-mail address.";
var JS_COMMENTS_MESSAGE_TOO_LONG = "Please enter maximum of 500 characters.";
function printPage(){
if (window.print) window.print();
else alert('Your browser does not support javascript printing.\nTo print this page, select File: Print from your menu.\nThis page is already printer friendly.');
}
function sendToFriend(objLink) {
// get the url of the document being sent
var strCurrentUrl = escape ( parent.document.URL ) ;
// get the page
of the document being sent
var strPageTitle = escape( parent.document.title );
//var strURLParams = '?pageToSend=' + strCurrentUrl + '&pageTitle=' + strPageTitle + '&mode=submitted';
var strURLParams = '?ForceUserDeserialize=-1&pageToSend=' + strCurrentUrl + '&pageTitle=' + strPageTitle + '&mode=submitted';
var strURL = objLink.href + strURLParams;
var strWindowProperties = 'width=800,height=600,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
// open the window
openWindow(strURL ,'send_to_a_friend', strWindowProperties);
// prevent any further code from executing
return false;
}
function openWindow(URL, Name, Args){
popupWin = window.open(URL, Name, Args);
popupWin.focus();
}
function isEmailChars(str){
var theText = /^[\@\.a-z0-9_-]+$/gi;
var result = str.match(theText);
if(result != null)return true;
else return false;
}
function isValidEmail(strEmail){
if (trim(strEmail)=='') return false;
if (!isEmailChars(strEmail)) return false;
var emailPattern = /^[a-z0-9]+([_.-][a-z0-9]+)*@[a-z0-9]+([-.][a-z0-9]+)*[.]{1}[a-z]{2,}$/gi;
var result = strEmail.match(emailPattern);
if(result != null) return true;
else return false;
}
function isAlphaNumeric(str){
var theText = /^([ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿa-zA-Z0-9]+[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ\'\s\.a-zA-Z0-9_-]*)$/;
var result = str.match(theText);
if(result != null) return true;
else return false;
}
function isMessageCommentLengthOK(strComment,len){
if ((trim(strComment)).length>len)return false;
return true;
}
blanks = " \t\n\r";
phoneNumberDelimiters = "()- ";
invalidChar="`!@#$%^&*||~?<>:;\"{}()[]\\/,";
period =".";
underscore="_";
dash ="-";
empty='';
open_bracket="(";
close_bracket=")";
slash="/";
space=" ";
apostrophe ="'";
intCharSet = "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ"
function validateForm(theForm){
if(theForm.textFriendName){
if(trim(theForm.textFriendName.value) == ""){
alert(JS_FRIEND_NAME_MISSING_ERROR);
theForm.textFriendName.focus();
return false;
}
else{
if(!isAlphaNumeric(trim(theForm.textFriendName.value))){
alert(JS_YOUR_NAME_FORMAT_ERROR);
theForm.textFriendName.focus();
return false;
}
theForm.textFriendName.value = trim(theForm.textFriendName.value);
}
}
if(theForm.textFriendEmail){
if(trim(theForm.textFriendEmail.value) == ""){
alert(JS_FRIEND_EMAIL_MISSING_ERROR);
theForm.textFriendEmail.focus();
return false;
}else{
if(!isValidEmail(trim(theForm.textFriendEmail.value))){
alert(JS_EMAILADDRESS_FORMAT_ERROR);
theForm.textFriendEmail.focus();
return false;
}
theForm.textFriendEmail.value = trim(theForm.textFriendEmail.value);
}
}
if(theForm.textYourName){
if(trim(theForm.textYourName.value) == ""){
alert(JS_YOUR_NAME_MISSING_ERROR);
theForm.textYourName.focus();
return false;
}
else{
if(!isAlphaNumeric(trim(theForm.textYourName.value))){
alert(JS_YOUR_NAME_FORMAT_ERROR);
theForm.textYourName.focus();
return false;
}
theForm.textYourName.value = trim(theForm.textYourName.value);
}
}
if(theForm.textYourEmail){
if(trim(theForm.textYourEmail.value) == ""){
alert(JS_YOUR_EMAIL_MISSING_ERROR);
theForm.textYourEmail.focus();
return false;
}else{
if(!isValidEmail(trim(theForm.textYourEmail.value))){
alert(JS_EMAILADDRESS_FORMAT_ERROR);
theForm.textYourEmail.focus();
return false;
}
theForm.textYourEmail.value = trim(theForm.textYourEmail.value);
}
}
if(theForm.textMessage){
if (!isMessageCommentLengthOK(trim(theForm.textMessage.value),500)){
alert(JS_COMMENTS_MESSAGE_TOO_LONG);
theForm.textMessage.focus();
return false;
}
}
return true;
}
function trim(inputString) {
// Removes leading and trailing spaces from the passed string. Also removes consetrimive spaces and replaces it with one space.
var returnValues = inputString;
var ch = returnValues.substring(0, 1);
while (ch == " ") { // Check for spaces at the beginning of the string
returnValues = returnValues.substring(1, returnValues.length);
ch = returnValues.substring(0, 1);
}
ch = returnValues.substring(returnValues.length-1, returnValues.length);
while (ch == " ") { // Check for spaces at the end of the string
returnValues = returnValues.substring(0, returnValues.length-1);
ch = returnValues.substring(returnValues.length-1, returnValues.length);
}
while (returnValues.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
returnValues = returnValues.substring(0, returnValues.indexOf(" ")) + returnValues.substring(returnValues.indexOf(" ")+1, returnValues.length); // Again, there are two spaces in each of the strings
}
return returnValues;
}
function trackEvent(type){
if (document.getElementById) document.getElementById('trackingFrame').src = 'tracking.asp?type=' + type;
}
function newWin(type,strUrl){
if (type=='stylePreview') window.open(strUrl,type,'width=780,height=500,top=0,left=0,statusbar=no,location=no,menubar=no,resizable=no,scrollbars=yes');
if (type=='content') window.open(strUrl,type,'width=600,height=500,top=0,left=0,location=no,resizable=no,scrollbars=yes');
if (type=='surveymonkey') window.open(strUrl,type,'width=600,height=600,top=0,left=0,location=no,menubar=no,status=no,resizable=no,scrollbars=yes');
}
function getRef(obj){
if(typeof obj == "string")
obj=document.getElementById(obj);
return obj;
}
function setClassName(obj, className){
getRef(obj).className= className;
}
function getClassName(obj){
obj = getRef(obj);
return obj.className;
}
function setStyle(obj, style, value){
getRef(obj).style[style]= value;
}
function getStyle(obj, style){
if(!document.getElementById) return;
var obj = getRef(obj);
var value = obj.style[style];
if(!value)
if(document.defaultView)
value = document.defaultView.
getComputedStyle(obj, "").getPropertyValue(style);
else if(obj.currentStyle)
value = obj.currentStyle[style];
return value;
}
// Switching between in news landing page
function setNewsTab (curIndex) {
var tab = $("#newsarchive .nav a");
var maxIndex = tab.length;
for (var x = 1; x <= maxIndex; x++) {
if (x==curIndex) {
document.getElementById('tab'+x).className='active';
document.getElementById('year'+x).className='content showBlock';
}
else {
document.getElementById('tab'+x).className='';
document.getElementById('year'+x).className='content hidden';
}
}
}
function getCookie(c_name,d_path)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
if (d_path.length>0) return d_path;
return "";
}