

function checkLogDisplay() {
	
	LogState=Get_Cookie('LoggedIn');
	//alert ('From Home is:' + fromhome);
	//alert (LogState);
	if (LogState == "yes") {
		
		changeElementsStyleByClass('div','secure','');
		changeElementsStyleByClass('div','public','none');
		changeElementsStyleByClass('li','secure','');
		changeElementsStyleByClass('a','secure','');
		changeElementsStyleByClass('a','public_only','none');
	} else {
		//alert ("logged out");
		
		changeElementsStyleByClass('div','secure','none');
		changeElementsStyleByClass('div','public','');
		changeElementsStyleByClass('li','secure','none');
		changeElementsStyleByClass('a','secure','none');
		changeElementsStyleByClass('a','public_only','');
	}
	
	//Reset Pharmacy Cookies
	
	
}

function resetCookies() {
	// reset cookies when navigating back to home page
	Set_Cookie( 'drugadded', 'no', 1, '/i:/it/websolutions/member_1_1/', '', '' );	
	Set_Cookie( 'pharmacyadded', 'no', 1, '/i:/it/websolutions/member_1_1/', '', '' );	
}

function logOut() {
	
	Set_Cookie( 'LoggedIn', 'no')
	window.location = "survey.html";
}


function logIn() {
	Set_Cookie( 'LoggedIn', 'yes')
	parent.window.location = "home_secure.html";
}


function trim (s) {
	var re, t;

	re = /\W/g;
	t = s.replace(re, '');      
	return (t);
}

function buildArray() {       
     this.length = buildArray.arguments.length;
     for (i = 0; i < buildArray.arguments.length; i++)
          this[i] = buildArray.arguments[i];
}




function toggle(e) {
	alert("here");
  if (e.style.display == "none") {
     e.style.display = "";
  } else {
     e.style.display = "none";
  }
}

function toggle3(e) {
//alert (e);
  	
	if ($(e).style.display == "none") {
		$(e).style.display = "";
	} else {
		$(e).style.display = "none";
	}
}	
function checkFaq(control) {
var row = control + "_row";
var box = control + "_box";
	if ($(box).style.display == "none") {
	$(row).className = "main_faq_question_open";
	Effect.toggle(box,'blind', { duration: .5 });
	
	
	} else {
	if ($(box).style.display == "") {
	$(row).className = "main_faq_question";
	Effect.toggle(box,'blind', { duration: .5 });
	}
	}
}


function toggleSection(control) {
var head = control + "_head";
var box = control + "_box";
//alert ("made it");
	if ($(box).style.display == "none") {
	
	$(head).className = "topic_head open";
	Effect.toggle(box,'blind', { duration: .5 });
	
	
	} else {
	if ($(box).style.display == "") {
	$(head).className = "topic_head";
	Effect.toggle(box,'blind', { duration: .5 });
	}
	}
}

function toggleBlind(e) {
//alert (e);
  	
	if ($(e).style.display == "none") {
		Effect.toggle(e,'blind', { duration: .5 });
	} else {
		Effect.toggle(e,'blind', { duration: .5 });
	}
}	

function turnON(e) {
//alert (e);
  	
	if ($(e).style.display == "none") {
		$(e).style.display = "";
	} else {
		$(e).style.display = "";
	}
}	

function turnOff(e) {
//alert (e);
  	
	if ($(e).style.display == "none") {
		$(e).style.display = "none";
	} else {
		$(e).style.display = "none";
	}
}	

function toggleBenefit(benefit) {
	
	var imageElement = benefit + '_image';
	var wrapper = benefit + '_wrapper';
	
	if (document.getElementById(wrapper).style.display == 'none') {
		 document.getElementById(wrapper).style.display = '';
		 document.getElementById(imageElement).src ='images/collapse_benefits.gif';
	} else {
		document.getElementById(wrapper).style.display = 'none';
		document.getElementById(imageElement).src ='images/expand_benefits.gif';
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function popupPage(url, x, y, w, h) {
	var opts = 'width=' + w + ',height=' + h + ',screenX=' + x + ',screenY=' + y + ',top=' + y + ',left=' + x + ',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes';
	var popup = window.open('' , '_blank', opts);
	popup.location.href = url; 

	return;
}  

function changeElementsStyleByClass(e,classname,value){

if(document.getElementsByTagName)//check for obj
   {
   var nodes = document.getElementsByTagName(e)
   var max = nodes.length
   for(var i = 0;i < max;i++)
      {
      var nodeObj = nodes.item(i);
      var attrMax = nodeObj.attributes.length
      for(var j = 0; j < attrMax; j++)
         {
          if(nodeObj.attributes.item(j).nodeName == 'class')
             {
             if(nodeObj.attributes.item(j).nodeValue == classname)
             nodeObj.style.display = value;
             }
         }
      }
   }
}

function Reset(e) {
			document.getElementById(e).value = '';
			document.getElementById(e).style.fontStyle = 'normal';
		}

// * Cookies for prototyping pharmacy flow.
// Will determine which results to show based on path taken.

//cookie_name = "dataCookie";
//var YouEntered;

function putCookie(cookie_name,cookie_value) {
	//alert (cookie_name + cookie_value)
	if(document.cookie != document.cookie) 
	{index = document.cookie.indexOf(cookie_name);}
	else 
	{ index = -1;}
	
	if (index == -1)
	{
	//YouEntered=cookie_value;
	//alert (YouEntered);
	document.cookie=cookie_name+"="+cookie_value+"; expires=0";
	}
}



/* Cookie #1 to determine if pharmacy location search was entered */

var pharmacyvisited;
var firstTime = true;
function getName() {
cookie_name = "pharmacylocation";
	//alert(document.cookie);
	if(document.cookie)
		{
		index = document.cookie.indexOf(cookie_name);
		if (index != -1)
			{
			namestart = (document.cookie.indexOf("=", index) + 1);
			nameend = document.cookie.indexOf(";", index);
			if (nameend == -1) {nameend = document.cookie.length;}
			YouWrote = document.cookie.substring(namestart, nameend);
			return YouWrote;
			}
		}
	}

if(firstTime){
	pharmacyvisited=getName();
	firstTime=false;
}

if (pharmacyvisited == "dataCookie")
{pharmacyvisited = "Nothing_Entered"}



function getCookieValue2(e) {
	
	var cookie_name1 = e;
	
	if(document.cookie)
		{
		index = document.cookie.indexOf(cookie_name1);
		if (index != -1)
			{
			namestart = (document.cookie.indexOf("=", index) + 1);
			nameend = document.cookie.indexOf(";", index);
			if (nameend == -1) {nameend = document.cookie.length;}
			cookie_value = document.cookie.substring(namestart, nameend);
			//alert (cookie_value);
			}
		}
		
	}
	
	
	
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
//alert ("setting cookie");
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
http://techpatterns.com/downloads/javascript_cookies.php
Set command: Set_Cookie( 'mycookie', 'visited 9 times', 30, '/', '', '' );

if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			
			return cookie_value;
			
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
		
	}
	if ( !b_cookie_found )
	{
		return null;
	}
	
}	

function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}




/*Current date script credit: */

var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")


