 /**
 * 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 = "";}
        if(typeof textareaCtrl == "undefined"){textareaCtrl = "";}
    try
    { 
		// reset error messages
		var resetArr = new Array(valCtrls, confirmCtrls, dateCtrl, birthdateCtrl, emailCtrl, monthyearCtrl, ageCtrl,  radioCtrl, zipCtrl, phoneCtrl, pageErrorCtrl, stateCtrl, textareaCtrl);	
		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;
			    }
			}
	    }
	}

    //check textarea
	    		if (typeof sharestoryCtrl != 'undefined' && sharestoryCtrl != "")
	    		{
	    			var ctrl = sharestoryCtrl;
	    			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 (element.value.length > 2000)
	    				    {
	    					showElement(id+"|ERROR");
	    						rv = false;
	    				    }   				
	    				}
	    		   	 }
			}
 
	/* * * * * * * * *
	 * BEGIN LYRICA SPECIFIC 
	 * Check if address is required for Stepping Forward Signup
	 */
	//Does the checkbox exist?
	if(document.getElementById("Q11900|A14572"))
	{	
		//Checkbox Exists
		//Is the checkbox checked?
		if(isChecked(document.getElementById("Q11900|A14572")))
		{
			//Checkbox Checked
			//Address
			if(empty(document.getElementById("Q10017|A10017")))
			{
				showElement("Q10017|A10017|ERROR");
				rv = false;
			}
			//City
			if(empty(document.getElementById("Q10019|A10019")))
			{
				showElement("Q10019|A10019|ERROR");
				rv = false;
			}
			//Zip
			if(empty(document.getElementById("Q10021|A10021")))
			{
				showElement("Q10021|A10021|ERROR");
				rv = false;
			}
		}	
		else
		{
			//Checkbox Not Checked
			//Fields Not Required hide elements
			hideElement("Q10017|A10017|ERROR");
			hideElement("Q10019|A10019|ERROR");
			hideElement("Q10021|A10021|ERROR");
		}
	}

	/* 
	 * 
	 * END LYRICA SPECIFIC
	 * * * * * * */

    }
    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;           
}



//*********************************************************************************
// 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
//*********************************************************************************


/*********************************************************************************
 * DIAGNOSTIC TOOL VALIDATION
 *********************************************************************************/

function submitFromAnchor(formID) 
{	
	var questionsList = document.forms[formID]["questions"];
	var questionsArr = questionsList.value.split(",");
	var optionalRadioList = document.forms[formID]["optionalradio"];
	var optionalArr = optionalRadioList.value.split(",");
	var controlsToHide = new Array();
	var numberOfControlsToHide = 0;
	var allSelected = true;			
	var answerArr;
	var answerArr2;
	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 (var i = 0; i < questionsArr.length; i++)
		{	
			answerArr = document.forms[formID][questionsArr[i]];
			errorElem = questionsArr[i] + "|ERROR";
			questionDiv = questionsArr[i] + "|QUESTION";
			buttonChecked = false;
			
			if(answerArr != undefined)
			{
				for (var 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;
					}
				}
			}
			else
			{
				buttonChecked = true;
			}
			
			// show error message
			if (!buttonChecked)
			{
				showElement(errorElem);
				showElement(questionDiv);
				allSelected = false;
			}
			else 
			{
				// question validated -> hide question
				controlsToHide[numberOfControlsToHide] = questionDiv;
				numberOfControlsToHide = numberOfControlsToHide + 1;
			}
		}
		
		// loop through optional questions
		for (var i = 0; i < optionalArr.length; i++)
		{	
			answerArr2 = document.forms[formID][optionalArr[i]];
			errorElem = optionalArr[i] + "|ERROR";
			questionDiv = optionalArr[i] + "|QUESTION";
			
			if(answerArr2 != undefined)
			{
				for (var j = 0; j < answerArr2.length; j++)
				{
					if (answerArr2[j].checked)
					{
						// add selected Q|A pair to the result string
						var qaPair = answerArr2[j].name + "|" + answerArr2[j].value + ",";
						if (formResults.indexOf(qaPair) < 0)
						{
							formResults = formResults + qaPair;
						}
						break;
					}
				}
			}
			// question validated -> hide question
			controlsToHide[numberOfControlsToHide] = questionDiv;
			numberOfControlsToHide = numberOfControlsToHide + 1;
		}

		
		// loop thru questions with checkbox answers to store selected values into formResults variable
		for (var 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 (var i=0; i<numberOfControlsToHide; i++)
			{
				hideElement(controlsToHide[i]);
			}				
		}
			
	}
	catch (e)
	{
		alert (e.name);
	}
}

/**********************
 *  QUIZ VALIDATION
 **********************/
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|ERROR");
      for(var i=0; i<valCtrls.length; i++) 
      {
            var id = valCtrls[i];
            hideElement(id+"|ERROR");
      }

      // 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);
    }
}

/**********************\
|*  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";
	}    
}

/**
 * Clear Default text in textbox 
 * 
 *	@elemID		The ID of the html element text box that will be cleared.
 *
 *	Writen by:	Bryce Acer
 *	Date:		1/6/2006
 */
function clearDefault(elemID)
{
	if (elemID.defaultValue==elemID.value) elemID.value = ""
}/**
 * 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;
	}
}

// <!-- Exit Survey Popup script after 6 minutes. -->
//var t=setTimeout("exitsurvey()",360000);
//function confirmExit()
//{
//   var agree=confirm("Thank you for visiting FIBROCENTER.COM. Please help us improve this site by answering a few questions.");
//	if (agree)
//		{
//			exitsurvey();
//		}
//		else
//		{
//			return false ;
//		}
//}
var Expdays=30;
//***********************************************************************************************
// Cookie related functions 

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name + "=" + value + expires + "; path=/";

}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
//******************************************************************************************************
// Open Window - 

function openWindow(v_sURL, v_sName, v_sFeatures)
{
	winRef = window.open(v_sURL, v_sName, v_sFeatures);
	
}


//function exitsurvey() 
//{
//		
//		var count = readCookie('viewedSurvey');
//		if (count == null)
//		{
//			var agree=confirm("Thank you for visiting FIBROCENTER.COM. Please help us improve this site by answering a few questions.");
//			if (agree)
//				{
//					createCookie('viewedSurvey', 1, Expdays);
//					var lLeft =(screen.width - 680)/2;
//					var lTop = (screen.height - 500)/2;
//					openWindow('http://www.fibrocenter.com/content/survey.jsp','survey','width=680,height=500,top=' + lTop.toString() + ',left=' + lLeft.toString() + ',resizable=yes,scrollbars=yes,align=left,border=0')
//				}
//			else
//				{
//				createCookie('viewedSurvey', 1, Expdays);
//				return false;
//				}
//				
//		}			

//		else 
//		{ 
//		count++; 
//		createCookie('viewedSurvey', count, Expdays); 
//		}  // End --> 
//}
// End --> 
function faq_resize(x)
{
	var faq_state_check;
	var z;
	z = document.getElementById(x).className;
	faq_state_check = z.indexOf('collapse');
	if(faq_state_check>0)
	{
		 document.getElementById (x).className = "faq_a_text_expand";
	} 
	else 
	{
				document.getElementById (x).className = "faq_a_text_collapse";
	}
}


//check Box Functions


 function getChkBI()
 {
    if(document.getElementById('Q10526|').checked==true)
    {
       document.getElementById('hdnQ10526|').value="BI";
    }
    else
    {
        document.getElementById('hdnQ10526|').value="";
    }
 }
 
 
  function getChkNI()
 {
    if(document.getElementById('Q13571|').checked==true)
    {
       document.getElementById('hdnQ13571|').value="NI";
    }
    else
    {
        document.getElementById('hdnQ13571|').value="";
    }
 }
 
 
function getHiddenValue(objCntrl,objhdn)
{
    objhdn.value = objCntrl.value;
}

function getChkbox(objControl,objHiddenControl)
{


    if(document.getElementById(objControl).checked)
    {
        getHiddenValue(document.getElementById(objControl),document.getElementById(objHiddenControl));
    }
    else
    {
        document.getElementById(objHiddenControl).value = "";
    }
}
  
 
 //Function to Get the checked values of radio button and check box
function getOptionalQuestion(objControl,objHiddenControl)
 {

    getRadioValue(document.getElementById(objControl),document.getElementById(objHiddenControl));
 }
 
 /* Including this function for the Forms  for getting the values of selected answers in to the
 hidden variables*/
    
    function getRadioValue(objCntrl,objhdn)
    {
      objhdn.value = objCntrl.value;
    }
    
    
    //For Phone Number

     function GetPhNumber()
        {
           document.getElementById("Q10012|A10012").value = document.getElementById("txt_hnp_Phone0").value + document.getElementById("txt_hnp_Phone1").value + document.getElementById("txt_hnp_Phone2").value; 
        }
   //For BookMark
   function bookmark(title,url)
  {
  if (window.sidebar) // firefox
  window.sidebar.addPanel(title, url,'http://www.fibrocenter.com/');
  else if(document.all)// ie
  window.external.AddFavorite(url, title);
  }

//For Site Catalyst

function GoToPartnerUrl(urlId, name, link) {
   PartnerLinkClicked(name,link); 
   url = null; 
   switch(urlId) {
      case '1' : {
         url = "http://www.pfizer.com/pfizer/mn_terms.jsp"; 
         break; 
         }
      case '2' : {
         url = "http://www.pfizer.com/general/privacy.jsp"; 
         break; 
         }
      case '3' : {
         url = "http://www.pfizer.com/home/"; 
         break; 
         }   
      }
  if(url) {
      window.location = url; 
      }
 }
 //make a promise tools and Resources Form submit 
 function callFormSubmit()
            {
            FormSubmit();
            if(document.getElementById("make_a_promise_form"))document.getElementById("make_a_promise_form").submit();
            }
function callUnsubscribeFormSubmit()
            {
            FormSubmit();
            if(document.getElementById("unsubscribe_form"))document.getElementById("unsubscribe_form").submit();
            }
function callTellaFriendFormSubmit()
            {
            FormSubmit();
            if(document.getElementById("frmTellaFriend"))document.getElementById("frmTellaFriend").submit();
            }
            


var SessionValue ="";   
        
function GetSessionValue(key) {
   try {
      xmlHttp = new XMLHttpRequest(); 
      }
   catch (e) {
      try {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); 
         }
      catch (e) {
         try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
            }
         catch (e) {
            alert("Your browser does not support AJAX!"); 
            return false; 
            }
         }
      }
   url = "GetSessionValue.aspx?key=" + key + "&dummy=" + new Date().getTime(); 
   xmlHttp.open("GET", url, false); 
  // xmlHttp.onreadystatechange = UpdateSessionValue; 
   xmlHttp.send(null); 
      if(xmlHttp.status == 200)
      {
         SessionValue = xmlHttp.responseText; 
      }
     return SessionValue;
   }

