 /**
 * Form Validation    
 */
function validateForm()
{
    var rv=true;
    if(typeof valCtrls == "undefined"){valCtrls = "";}
	if(typeof confirmCtrls  == "undefined"){confirmCtrls = "";}
	if(typeof urlAgeError == "undefined"){urlAgeError = "";}
	if(typeof dateCtrl  == "undefined"){dateCtrl = "";}
	if(typeof birthdateCtrl  == "undefined"){birthdateCtrl = "";}
	if(typeof birthdateCtrl18  == "undefined"){birthdateCtrl18 = "";}
	if(typeof emailCtrl  == "undefined"){emailCtrl = "";}
	if(typeof monthyearCtrl  == "undefined"){monthyearCtrl = "";}
	if(typeof ageCtrl  == "undefined"){ageCtrl = "";}
	if(typeof ageCtrl18  == "undefined"){ageCtrl18 = "";}
	if(typeof radioCtrl == "undefined"){radioCtrl = "";}
	if(typeof zipCtrl  == "undefined"){zipCtrl = "";}
	if(typeof phoneCtrl  == "undefined"){phoneCtrl = "";}
	if(typeof pageErrorCtrl == "undefined"){pageErrorCtrl = "";}
	if(typeof stateCtrl == "undefined"){stateCtrl = "";}
    
    try
    { 
		// reset error messages
		var resetArr = new Array(valCtrls, confirmCtrls, dateCtrl, birthdateCtrl, emailCtrl, monthyearCtrl, ageCtrl,  radioCtrl, zipCtrl, phoneCtrl, pageErrorCtrl, stateCtrl);	
		for(var i=0; i<resetArr.length; i++)
		{
			var resetCtrl = resetArr[i];
			for(var j=0; j<resetCtrl.length; j++) 
			{
				var id = resetCtrl[j];
				if(!empty(id))
				{
					hideElement(id+"|ERROR");
				}
			}
		}

		// check if empty
		if (valCtrls != "")
		{
			for(var i=0; i<valCtrls.length; i++) 
			{	
				var id = valCtrls[i];
				if(document.getElementById(id)){
					var element = document.getElementById(id);
				}else{
					var element = "undefined";
				}
				if(empty(element))
				{
					showElement(id+"|ERROR");
					//elem.focus(); 
					rv=false;
				}
			}
		}

        // check if the values are the same
        if (typeof confirmCtrls != "undefined" || confirmCtrls != "")
        {
	        for(var i=0; i<confirmCtrls.length / 2; i=i+2) 
	        {
	            var id1 = confirmCtrls[i];
	            var confirmElem1 = document.getElementById(id1);
	
	            var id2 = confirmCtrls[i+1];
	            var confirmElem2 = document.getElementById(id2);
	
	            if (confirmElem1.value != confirmElem2.value)
	            { 
					showElement(id2+"|ERROR");         
		            //confirmElem2.focus();
		            rv=false;
	            }
	        }
        }

		// check if value is a date
		if (dateCtrl != "")
		{
			var ctrl = dateCtrl; 
			for(var i=0; i<ctrl.length;i++)
			{
				var id = ctrl[i];
				var element = document.getElementById(id);
				if(!empty(element))
				{
					var value = document.getElementById(id).value;
				    if (!isDate(value))
				    {
						showElement(id+"|ERROR");
						rv = false;
				    }
				}	
		    }
		}

        //check birthdate
		if (birthdateCtrl != "" || birthdateCtrl18 != "")
		{
			if(birthdateCtrl != "")
			{
				//Validation variables for 14+
				var birthdateId = birthdateCtrl;
				var validAge = 14;
			}
			else
			{
				//Validation variables for 18+
				var birthdateId = birthdateCtrl18;
				var validAge = 18;
			}
			
			var birthdateElem = document.getElementById(birthdateId);
		    var birthdateStr = birthdateElem.value;
		    if (birthdateStr.length > 0)
		    {
			    if (!isDate(birthdateStr))
			    { 
					showElement(birthdateId+"|ERROR");                   
					rv = false;                    
			    }
				else
			    {
					// check if user is of age
					var birthdateArr = new Array();
					birthdateArr = birthdateStr.split('/');
					var birthMonth = birthdateArr[0];
					var birthDay = birthdateArr[1];
					var birthYear = birthdateArr[2];

			       if (getAge(birthMonth, birthDay, birthYear) < validAge)
			       { 
						if(urlAgeError == 'undefined'){alert("No Age Redirect URL defined");}
						if(urlAgeError != 'undefined')
						{
							window.location.href = urlAgeError;                     
						}
						rv = false;
			       }
			    }
		    }
		}

		 //check email
		if (emailCtrl != "")
		{
			var ctrl = emailCtrl;
			for(var i=0; i<ctrl.length;i++)
			{
				var id = ctrl[i];
				var element = document.getElementById(id);
				if(!empty(element))
				{
					var value = document.getElementById(id).value;
				    if (!isEmail(value))
				    {
						showElement(id+"|ERROR");
						rv = false;
				    }
				}	
		    }
		}

		//check zip code
		if (zipCtrl != "")
		{
			var ctrl = zipCtrl;
			for(var i=0; i<ctrl.length;i++)
			{
				var id = ctrl[i];
				var element = document.getElementById(id);
				if(!empty(element))
				{
				    var value = document.getElementById(id).value;
				    if (!isZip(value))
				    {
				    	showElement(id+"|ERROR");
						rv = false;
				    }
				}
		    }
		}

	    //check month year
	    if (monthyearCtrl != "")
	    {
	    	var ctrl = monthyearCtrl;
			for(var i=0; i<ctrl.length; i++)
			{
				var id = ctrl[i];
				
				var element = document.getElementById(id);
				if(!empty(element))
				{
					var element = document.getElementById(id);
					var value = element.value;
					var regxp = /^\d?\d\/\d\d\d\d$/;
					if (!regxp.test(value))
					{ 
						showElement(id+"|ERROR");
						rv = false;
					}
	
					var time=new Date();
					var currentYear=time.getYear();
	
					var valArr = new Array();
					valArr = value.split('/'); //Split MM/YYYY
					var monthVal = valArr[0];
					var yearVal = valArr[1];
					if(monthVal < 1 || monthVal > 12 || yearVal < currentYear)
					{
						showElement(id+"|ERROR");
						rv = false;
					}
				}
			}
		}

		//check Age
		if (ageCtrl != "" || ageCtrl18 != "")
		{
			if (ageCtrl != "")
			{
				//Validation variables for 14+
				var ageList = ageCtrl;
				var regXU = /^(Under 13)$/;
				var validAge = 14;
			}
			else
			{
				//Validation variables for 18+
				var ageList = ageCtrl18;
				var regXU = /^(Under 18)$/;
				var validAge = 18;
			}
			for(var i=0; i<ageList.length;i++)
			{
				var id = ageList[i];
				var element = document.getElementById(id);
				if(!empty(element))
				{
					var ageID = document.getElementById(id);
					var ageStr = ageID.value;  //AnswerID|Value
					var ageArr = new Array();
					ageArr = ageStr.split('|'); //Split string
					var ageAnwerID = ageArr[0];
					var ageVal = ageArr[1];
					var regX = /^\d\d?\d$/;
					

					// check if user is under 14 years of age
					if (regXU.test(ageVal))
					{ 
						if(urlAgeError == 'undefined'){alert("No Age Redirect URL defined");}
						if(urlAgeError != 'undefined')
						{
							window.location.href = urlAgeError;                     
						}
						rv = false;
					}
					else if (!regX.test(ageVal))
					{
						
					}
					else if (ageVal < validAge)
					{
						if(urlAgeError == 'undefined'){alert("No Age Redirect URL defined");}
						if(urlAgeError != 'undefined')
						{
							window.location.href = urlAgeError;                     
						}
						rv = false;
					}
				}
			}
		}

		//Check Radio Buttons
		if (radioCtrl != "")
		{
			var ctrl = radioCtrl;
			var test = false;
			for (i = 0; i < ctrl.length; i++)
			{
				//Get Group Name
				var radioGroupName = ctrl[i];
				if (!testRadio(radioGroupName))
				{				
					showElement(radioGroupName+"|ERROR");
					rv = false;
				}
			}
		}

		//check phone
		if (phoneCtrl != "")
		{
			var ctrl = phoneCtrl;
			for(var i=0; i<ctrl.length;i++)
			{
				var id = ctrl[i];
				var element = document.getElementById(id);
				if(!empty(element))
				{
				    var value = document.getElementById(id).value;
				    if (!isPhone(value))
				    {
				    	showElement(id+"|ERROR");
					rv = false;
				    }
				}
		    }
		}

    }
    catch (e)
    {
    	alert("Validate Form Error: " + e.name);
        rv = false;
    }
    if (!rv) 
    {	
    	showElement(pageErrorCtrl+"|ERROR");
        window.location.href = "#top";
    }
  
    else
    {
    	//run this after no error occur
    	hideElement(pageErrorCtrl+"|ERROR");

    }
    
    return rv;
    
}

function submitForm(formID)
{
	document.forms[formID].submit();
}


function getAge(birthMonth, birthDay, birthYear)
{
    var now = new Date();
    var yearNow = now.getFullYear();
    var monthNow = now.getMonth();
    var monthNow = monthNow + 1; 
    var dateNow = now.getDate();
    
    var yearAge = yearNow - birthYear;            
    
    if (monthNow >= birthMonth)
    {
        var monthAge = monthNow - birthMonth;
    }    
    else
    {
        yearAge--;
        var monthAge = 12 + monthNow - birthMonth;
    }            
    
    if (dateNow >= birthDay)
    {
        var dateAge = dateNow - birthDay;             
        
    }    
    else
    {
        monthAge--;
        var dateAge = 31 + dateNow - birthDay;             
    
        if (monthAge < 0)
        {
            monthAge = 11;
            yearAge--; 
        }
    }

    return yearAge;           
}


function validateEmailAFriend()
{
    var rv = true;

    try
    {
        for(var i=0; i<valCtrls.length; i++) 
        {
            var id = valCtrls[i];
            hideElement(id+"|ERROR")
        }
    
        //All fields Required
        for(var i=0; i<valCtrls.length; i++) 
        {
            var id = valCtrls[i];
            var elem = document.getElementById(id);
            
            if (elem.value.length == 0)
            {
				showElement(id+"|ERROR");
                rv=false;
            }
        }
        
        //Check for valid email
        if (rv)
        {   
            
            var senderEmailAddr = document.getElementById("senderemail").value;
            
            if (!isEmail(senderEmailAddr))
            {
                showElement("senderemail|ERROR");
                rv = false;
            }
            
            var recipientEmailAddr = document.getElementById("recipientemail").value;
            if (!emailRegxp.test(recipientEmailAddr))
            {
                showElement("recipientemail|ERROR");
                rv = false;
            }
        }
    }
    catch (e)
    {
        alert (e);
        rv = false;
    }
        
    return(rv);
}

//*********************************************************************************
// Begin: Date validation functions
//*********************************************************************************

var dtCh= "/";
var minYear=1800;
var maxYear=2100;

function isInteger(s){
    var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
        this[i] = 31
        if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
        if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr)
{
    var daysInMonth = DaysArray(12)
    var pos1=dtStr.indexOf(dtCh)
    var pos2=dtStr.indexOf(dtCh,pos1+1)
    var strMonth=dtStr.substring(0,pos1)
    var strDay=dtStr.substring(pos1+1,pos2)
    var strYear=dtStr.substring(pos2+1)
    strYr=strYear
    if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
    if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
    }
    
    month=parseInt(strMonth)
    day=parseInt(strDay)
    year=parseInt(strYr)
    if (pos1==-1 || pos2==-1){
        return false
    }
    if (strMonth.length<1 || month<1 || month>12){
        return false
    }
    if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
        return false
    }
    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
        return false
    }
    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
        return false
    }
    return true
}

//*********************************************************************************
// END: Form Validation
//*********************************************************************************





//*********************************************************************************
// EMAIL A FRIEND VALIDATION
//*********************************************************************************

function validateEmailAFriend()
{
	var rv = true;

	try
	{
		for(var i=0; i<valCtrls.length; i++) 
		{
			var id = valCtrls[i];
			hideElement(id+"|ERROR");
	  	}
	
		//All fields Required
		for(var i=0; i<valCtrls.length; i++) 
		{
			var id = valCtrls[i];
			var element = document.getElementById(id);
			if(empty(element))
			{
				showElement(id+"|ERROR");
				rv=false;
			}
	  	}
		
		//Check for valid email
		if (rv)
		{	
			var senderEmailAddr = document.getElementById("senderemail").value;
			if (!isEmail(senderEmailAddr))
			{
				showElement("senderemail|ERROR");
				rv = false;
			}
			
			var recipientEmailAddr = document.getElementById("recipientemail").value;
			if (!isEmail(recipientEmailAddr))
			{
				showElement("recipientemail|ERROR");
				rv = false;
			}
		}
	}
	catch (e)
	{
		alert (e);
		rv = false;
	}
		
	return(rv);
}

function submitFromAnchor(formID) 
{	
	var questionsList = document.forms[formID]["questions"];
	var questionsArr = questionsList.value.split(",");
	var controlsToHide = new Array();
	var numberOfControlsToHide = 0;
	var allSelected = true;			
	var answerArr;
	var buttonChecked;
	var errorElem;
	var questionDiv;

	try
	{			
		var formResults = "";


		
		// loop through questions with radiobutton answers to validate each question and store selected values into formResults variable
		for (i = 0; i < questionsArr.length; i++)
		{	
			answerArr = document.forms[formID][questionsArr[i]];
			errorElem = questionsArr[i] + "|ERROR";
			questionDiv = questionsArr[i] + "|QUESTION";
			buttonChecked = false;
			for (j = 0; j < answerArr.length; j++)
			{
				if (answerArr[j].checked)
				{
					buttonChecked = true;
					
					// add selected Q|A pair to the result string
					var qaPair = answerArr[j].name + "|" + answerArr[j].value + ",";
					if (formResults.indexOf(qaPair) < 0)
					{
						formResults = formResults + qaPair;
					}
					break;
				}
			}
			// show error message
			if (!buttonChecked)
			{
				showElement(errorElem);
				showElement(questionDiv);
				allSelected = false;
			}
			else 
			{
				// question validated -> hide question
				controlsToHide[numberOfControlsToHide] = questionDiv;
				numberOfControlsToHide = numberOfControlsToHide + 1;
			}
		}

		
		// loop thru questions with checkbox answers to store selected values into formResults variable
		for (i=0; i<document.forms[formID].elements.length; i++)
		{
			var elem = document.forms[formID].elements[i];
			if (elem.type=="checkbox")
			{	
				if (elem.checked)
				{
					// add checked Q|A pair into formResults string
					var qaPair = elem.name + "|" + elem.value + ",";
					if (formResults.indexOf(qaPair) < 0)
					{
						formResults = formResults + qaPair;
					}
				}
				// question validated -> hide question
				questionDiv = elem.name + "|QUESTION";
				controlsToHide[numberOfControlsToHide] = questionDiv;
				numberOfControlsToHide = numberOfControlsToHide + 1;
			}
		}

					
		//cleanup last comma character
		if (formResults.length > 0) { formResults = formResults.substring(0, formResults.length-1); }
		if (allSelected)
		{
			// save results in a cookie
			setCookie(getQuizCookieName(formID), formResults, new Date("1/1/2100"));
			
			// submit the form
			document.forms[formID].submit();
		}
		else
		{

			// show top-page error
			showElement("ERROR");
						
			// hide controls that passed validation
			for (i=0; i<numberOfControlsToHide; i++)
			{
				hideElement(controlsToHide[i]);
			}				
		}
			
	}
	catch (e)
	{
		alert (e.name);
	}
}

/**********************\
|*  Quiz
\**********************/
function getQuizCookieName(quizID)
{
	return "cwpQuiz_" + quizID;
}

var timerID;
function setRedirectTimer(url)
{
	timerID = self.setTimeout("redirectOnTimer('" + url + "')", 1000 * 10);
}
	
function redirectOnTimer(url)
{
	clearTimeout(timerID);
	window.location.href = url;
}

function takeAgain(quizID) 
{
	deleteCookie(getQuizCookieName(quizID));
	window.location.href=window.location.href;
}
function submitPollFromAnchor(formID) 
{		
	try
	{
		hideElement("main|ERROR");
		
		var questionsList = document.forms[formID]["questions"];
		var buttonsArr = questionsList.value.split(",");
		var allSelected = true;
		
		for (i=0; i<buttonsArr.length; i++)
		{	
			var buttonElem = document.forms[formID][buttonsArr[i]];				
			var buttonChecked = false;
			
			for (j=0; j<buttonElem.length; j++)
			{
				if (buttonElem[j].checked)
				{
					buttonChecked = true;
					break;
				}
			}
			
			if (!buttonChecked)
			{
				allSelected = false;
				break;
			}
		}
		
		if (!allSelected)
		{
			showElement("main|ERROR")
		}
		else
		{	
			document.forms[formID].submit();
		}
	}
	catch (e)
	{
		alert (e);
	}
}

/**********************\
|*  Quick Poll
\**********************/
function seePollResults(formID)
{
	document.forms[formID]["seeResults"].value = "true";
	document.forms[formID].submit();
}

/**********************\
|*  Printer Friendly
\**********************/
function turnOffPrintFriendly()
{
    window.location.href=document.referrer;
}

/**********************\
|*  Email a Friend
\**********************/
function resetForm()
{
    try
    {   
        // reset error messages
      hideElement("main");
      for(var i=0; i<valCtrls.length; i++) 
      {
            var id = valCtrls[i];
            hideElement(id);
      }

      // reset form fields
      for(var i=0; i<valCtrls.length; i++) 
      {
        var id = valCtrls[i];
        var elem = document.getElementById(id);
        if (elem.type == "radio")
        {
            var answerArr = document.forms["email_a_friend_form"][id];
            for (j = 0; j < answerArr.length; j++)
            {
                answerArr[j].checked = false;
            }
        }
        else
        {
          elem.value = "";
        }
      }
    }
    catch (e)
    {
        alert (e);
    }
}

function validateEmailForm()
{
    var rv=true;

    try
    {   
        // reset error messages
        hideElement("main");
        for(var i=0; i<valCtrls.length; i++) 
        {
            var id = valCtrls[i];
            hideElement(id);
        }

        // show error messages for empty fields. all fields required
        for(var i=0; i<valCtrls.length; i++) 
        {
            var id = valCtrls[i];
            var elem = document.getElementById(id);

            if (elem.type == "radio")           
            {
                var answerArr = document.forms["email_a_friend_form"][id];
                var buttonChecked = false;
                if (answerArr.type == "radio")
                {
                    //single radio button
                    buttonChecked = answerArr.checked;
                }
                else
                {
                    //group of radio buttons (2 or more)
	                for (j = 0; j < answerArr.length; j++)
	                {
	                    if (answerArr[j].checked)
	                    {
	                        buttonChecked = true;
	                        break;
	                    }
	                }
                }
                if (!buttonChecked)
                {
                    showElement(id);       
                    showElement("main");
                    rv = false;
                }
            }
            else
            {
                if (elem.value.length == 0)
                {
                    showElement(id);
                    showElement("main");
                    rv=false;
                }
            }
        }
        

        //check email addresses
        for(var i=0; i<emailCtrls.length; i++) 
        {
            var id = emailCtrls[i];
            var emailElem = document.getElementById(id);
            var email = emailElem.value;
            if (!isEmail(email))
            {
                showElement(id);
                showElement("main");
                rv = false;
            }
        }
    }
    catch (e)
    {
        alert (e);
        rv = false;
    }
    return rv;
}



/**********************\
|*  Cookies
\**********************/

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
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" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function getCookieforDisplayValueinTemp(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    cookieSet(name);
    return unescape(dc.substring(begin + prefix.length, end));
}

// For store the cookies into temporary folder.

function cookieSet(name)
{
    var cookieValue = getCookie(name); 
    if (document.cookie != document.cookie) 
    {
        index = document.cookie.indexOf(cookieValue);
    } else
    {
        index = -1;
    }
    if (index == -1) 
    {
        document.cookie= name + " = " + cookieValue+ ";expires=''";
    }
} 


/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create 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";
    }
}

/**
 * Determine whether a variable is considered to be empty based on its type
 * types = number, string, boolean, object, function, undefined
 * 
 *	@varable	A variable
 *
 *	Returns FALSE if var has a non-empty and non-zero value:
 *	"" (an empty string)
 *	null (an empty string)
 *	0 (an empty number)
 *	false (an empty boolean)
 *	0 (an empty value length of an object)
 *	null (an empty value of an object)
 *	undefined (an empty object type)
 */
function empty(variable)
{
	if(typeof variable == "number"){
		if (variable == 0){
			return true;
		}
	}
	else if (typeof variable == "string"){
		if(variable == null || variable == "" || variable.length < 0){
			return true;
		}
	}
	else if (typeof variable == "boolean"){
		if (variable == false){
			return true;
		}
	}
	else if (typeof variable == "object"){
		if (variable.value.length == 0 || variable.value == null){
			return true;
		}
	}
	else if (typeof variable == "function"){
		return false;
	}
	else if (typeof variable == "undefined"){
		return true;
	}
	else if (typeof variable == "null"){
		return true;
	}
	return false;
	 
}
/**
 * Determine whether a radio button is checked
 * 
 *	@radioGroupname		The name of the radio group that will be tested
 *
 *	Returns FALSE if a radio button is not checked.
 *	Returns TRUE if a radio button is checked.
 */
function testRadio(radioGroupName)
{
	var test = false;
	//Get Radio Buttons in Group
	
	var radioGroup = document.getElementsByName(radioGroupName);
	//Loop Through Each Button and Test if Checked
	for (i=0; i < radioGroup.length; i++)
	{
		if(radioGroup[i].checked)
		{
			test = true;
		}
	}
	return test;
}

/**
 * Validates Checkbox/Radio is checked
 * 
 *	@element	checkbox/Radio object
 */
function isChecked(element){
	if(element.checked){
		return true;
	}else{
		return false;
	}
}

/**
 * Validates Zip Code is 5 - 7 digits
 * 
 *	@zipValue		The value of the zipcode field
 */
 
function isZip(value)
{
	var regEx = /^(\d\d\d\d\d?\d?\d)$/;
	if(regEx.test(value)){
		return true;
	}else{
		return false;
	}	
}

/**
 * Validates Phone Number 123-456-7890
 * 
 *	@value	phone number entered into form
 */
function isPhone(value)
{
	var regEx = /\(?\d{3}\)?([-\/\.])\d{3}\1\d{4}/;
	if(regEx.test(value)){
		return true;
	}else{
		return false;
	}
}

/**
 * Validates Email Address
 * 
 *	@value	email address entered into form
 */
function isEmail(value)
{
	var regEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (regEx.test(value)){
		return true;
	}else{
		return false;
	}
}

/**
 * Show an HTML element 
 * 
 *	@elemID		The ID of the html element that will be displayed
 */
function showElement(elemID)
{
	if(document.getElementById(elemID))
	{
		document.getElementById(elemID).style.display="block";
	}
}

/**
 * Hide an HTML element 
 * 
 *	@elemID		The ID of the html element that will be hidden
 */
function hideElement(elemID)
{
	if(document.getElementById(elemID))
	{
		document.getElementById(elemID).style.display="none";
	}    
}/**
 * Validates State Abbreviation is Valid
 *
 * @value  state abbreviation entered into form
 */
function isState(value)
{
	var regEx = /^(AK|AL|AR|AS|AZ|CA|CO|CT|DC|DE|FL|FM|GA|GU|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MH|MI|MN|MO|MP|MS|MT|NB|NC|ND|NH|NJ|NM|NV|NY|OH|OK|OR|PA|PR|PW|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY)$/i;
	if (regEx.test(value)){
		return true;
	}else{
		return false;
	}
}

//************************Bellow function for redirecting menu url to respective location implimentation of site catalyst**********//
function GoToPartnerUrl(urlId, name, link) {
   PartnerLinkClicked(name,link); 
   url = null; 
   switch(urlId) {
      case '1' : {
         url = " http://www.pfizer.com/about/"; 
         break; 
         }
           }
  if(url) {
      window.location = url; 
      }
 }

//***************************************End of function SIte Catalyst Implimentation*********//