// JavaScript Document

var usrGlbl;  
var bsf = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var cd1 = '01234567890123456';
var mbType ;
var usrName;
var mbNb ; 	
var isLeader ;
var hq = location.href.indexOf(".hq.") > -1 ? 'hq.' : '';
var mb;
var Comment = '';
var isLoggedIn;
var CO;
getUsrGlbl(); 


//alert(location.href) ;

if (document.cookie.indexOf("ctx=asq") >-1) {
	document.cookie="prvctx=asq;path=/;domain=asq.org" ;
}
else if (document.cookie.indexOf("ctx=kc") >-1) {
	document.cookie="prvctx=kc;path=/;domain=asq.org" ;
}
else if (document.cookie.indexOf("ctx=qp") >-1) {
	document.cookie="prvctx=qp;path=/;domain=asq.org" ;
}
else if (document.cookie.indexOf("ctx=dv") >-1) {
	document.cookie="prvctx=dv;path=/;domain=asq.org" ;
}

if (location.href.indexOf("qualityprogress/") > -1 || location.href.indexOf("quality-progress/") > -1 ) {
	document.cookie="ctx=qp;path=/;domain=asq.org" ;
}
else if ( 
				location.href.indexOf("knowledge-center/") 				> -1
			|| 	location.href.indexOf("cost-of-quality/") 				> -1
			||	location.href.indexOf("economic_case/") 				> -1
			||	location.href.indexOf("food-safety/") 					> -1
			||	location.href.indexOf("innovation/") 					> -1
			||	location.href.indexOf("lean-six-sigma/") 				> -1
			||	location.href.indexOf("management-system-standards/")	> -1
			||	location.href.indexOf("social_responsibility/")			> -1
			||	location.href.indexOf("2008-futures-study/")			> -1
			||	location.href.indexOf("global-issues/")					> -1
			||	location.href.indexOf("healthcare-innovations/")		> -1
			||	location.href.indexOf("economy/")						> -1
		) {
	document.cookie="ctx=kc;path=/;domain=asq.org" ;
}
else if (location.href.indexOf("/divisions-forums/") > -1 ) {
	document.cookie="ctx=dv;path=/;domain=asq.org" ;
}
else {
	document.cookie="ctx=asq;path=/;domain=asq.org" ;
}

function WTlog(thislink) {
	//alert("Logging");
	if ( document.cookie.indexOf("qazqsa29") > 0 || document.cookie.indexOf("nonmsa29") > 0 ) {
		wrapDcsMultiTrack(thislink.href) ; 
	}
	else {
		document.cookie="wtdlay=" + thislink.href + ";path=/;domain=asq.org";
	}
	//alert("BCM TEST 9 APR 2009. thislink: " + thislink + " thislink.href: " + thislink.href);
	// pageTracker._trackPageview(thislink.href);
}

function WTFileTagging(thislink) {
	WTlog(thislink);
}

function WTlogDlay() {
	if (document.cookie.indexOf("wtdlay") > 0) {
		var startAt		= document.cookie.indexOf("wtdlay")+7; 
		var remainingPart	= document.cookie.substring(startAt);

		wturl = remainingPart.indexOf(";") >-1 	? remainingPart.substring(0,remainingPart.indexOf(";")) 
												: remainingPart ;
		wrapDcsMultiTrack(wturl) ;
		var passedTime  = new Date(new Date().getTime() - 60000);
		document.cookie="wtdlay=asq1;path=/;domain=asq.org;expires=" 	+ passedTime.toGMTString();
	}
}

function wrapDcsMultiTrack (mylink){
	thelink = mylink.replace(/http:.+\.asq.org/,"");
	dcsMultiTrack('DCS.dcssip','www.asq.org','DCS.dcsuri',thelink,'WT.ac','ASQ_NON_HTML') ;
	// if (location.href.indexOf(".hq.") > -1) { alert("FOR TESTING: thelink: " + thelink); } // show alert on hq
}

//This function is used for highlighting navigation to save on template numbers
function highlight(nav) {
    if (document.getElementById(nav) != null){ 
        document.getElementById(nav).className = 'selected'; //selected
    }
}

function highlightTab(tab,nav) {
	if (document.getElementById(tab) != null){ 
		document.getElementById(tab).className = 'overnav'; //selected
	}
	if (document.getElementById(nav) != null){
		document.getElementById(nav).className = 'selected'; //selected
	}
}
function checkSignInCookie(memberPage) {
	if (document.cookie.indexOf("qazqsa29") > 0) {
		if ( isNonMember(getUsrGlbl())  ) {
			// nothing
		}
		else {
			window.location.href  = memberPage;
		}
	}
}
function rot07(input){
    if (!input) return '';
    for (var output = '',i=0;i<input.length;i++) {
        character = input.charAt(i);
        position = cd1.indexOf(character);
        if (position > -1)
            character = cd1.charAt(position + 5);
        output += character;
    }
    return output;
}

function getUsrGlbl() {
	var allCookies = document.cookie.toString();
	if ( allCookies.indexOf("10.1.7.144") > -1) {
		//alert (allCookies);
	}

	if(document.cookie.toString().indexOf("nebsuc") > -1) {
		var startAt			= allCookies.indexOf("nebsuc")+7; 
		var remainingPart 	= allCookies.substring(startAt);

		usrGlbl = remainingPart.indexOf(";") >-1 	? remainingPart.substring(0,remainingPart.indexOf(";")) 
													: remainingPart ;
		usrGlbl= decode(usrGlbl) ;
		if (document.cookie.toString().indexOf("qazqsa29") > -1) {
			startAt			= allCookies.indexOf("qazqsa29")+9; 
			remainingPart 	= allCookies.substring(startAt);

			var mbNb = remainingPart.indexOf(";") >-1 	? remainingPart.substring(0,remainingPart.indexOf(";")) 
														: remainingPart ;
			this.mbNb = rot07(mbNb);
		}
		if (usrGlbl != null){
			var posa= usrGlbl.indexOf("~"); 
			var usrNm= usrGlbl.substring(0,usrGlbl.indexOf("~")); 
			var pos1 = usrGlbl.indexOf("~",usrGlbl.indexOf("~")+1)+1;
			var pos2 = usrGlbl.indexOf("~",pos1);

			this.usrGlbl = usrGlbl ;
			this.usrNm = usrNm ;
			this.mbType = this.usrGlbl.substring(pos1,pos2);

			pos1 = usrGlbl.indexOf("~CO:");
			if (pos1 > -1) {
				CO = usrGlbl.substring(pos1+4);
				if ( CO.indexOf("~") > -1 ) {
					CO = CO.substring(0,CO.indexOf("~"));
					//alert(CO);
				}
			}
			//alert(CO);

			// to support Ray's Flash NON-MEMBER introduction			
			var aYrFromNow = new Date(new Date().getTime() + (1000*3600*24*365) );
			//alert(aYrFromNow.toGMTString());
			document.cookie="mbtype=" + this.mbType + ";path=/;domain=asq.org;expires=" + aYrFromNow ;
			//alert("JR temp...\n" + usrGlbl);
			this.isLeader = (usrGlbl.indexOf("LEADER") > -1 ? 1 : 0) ;
			//alert("isLeader: " + this.isLeader);
		}
		return usrGlbl ;
	}
}


// *******************************************************
// member login fucntion for Quality Progress header area 
// *******************************************************
function dsplLgn2(site) {
//	alert(site);
	WTlogDlay() ;
	if (usrGlbl != null){

		if ( this.usrNm != null && this.usrNm != '') { 

		
			if ( 	location.href.indexOf("group-registration") == -1 &&
				( 	usrGlbl.indexOf("ORGANIZATION") > -1 || 
					usrGlbl.indexOf("SUSTAINING") > -1 || 
					usrGlbl.indexOf("SCHOOL") > -1 	|| 
					usrGlbl.indexOf("DISTRICT") > -1
				) 
			) {

				if (location.href.indexOf("/members/") > -1) {
					location.href = '/members/group-registration.html';
				}
			}

			/////  HEADER 
			var header ;

			if (site == 'qp') {
				header= 'Logged In as ' + this.usrNm  ;
			}
			else {
				mb = (isParticipant(usrGlbl) || isNonMember(usrGlbl) ) ? '' : 'members/'; 
				header= 'Logged In as ' + this.usrNm  + ' &nbsp;|&nbsp; <a href="http://www.' + hq + 'asq.org/log-out.html?prev=/qualityprogress">Log Out</a> &nbsp;|&nbsp; <a href="http://www.' + hq + 'asq.org/' + mb + 'account/manage-account.html">My Account</a> &nbsp;|&nbsp; <a href="http://www.' + hq + 'asq.org/perl/members/bookmarks.pl?action=viewbookmarks&ctx=qp">My Saved Articles</a> &nbsp;|&nbsp; <a href="http://www.' + hq + 'asq.org/" target="_blank">ASQ.org</a>' + (hq ? '' : '<META NAME="WT.rv" CONTENT="1"> ') ;

			}
			
			
			document.getElementById('loginarea2').innerHTML = header ; 


		}
		
	}
}


// *******************************************************
// regular member login header links
// *******************************************************
function dsplLgn(site) {
	//alert(site);
	WTlogDlay() ;

	if (usrGlbl != null){

		if ( this.usrNm != null && this.usrNm != '') { 

		
			if ( 	location.href.indexOf("group-registration") == -1 &&
				( 	usrGlbl.indexOf("ORGANIZATION") > -1 || 
					usrGlbl.indexOf("SUSTAINING") > -1 || 
					usrGlbl.indexOf("SCHOOL") > -1 	|| 
					usrGlbl.indexOf("DISTRICT") > -1
				) 
			) {
				//alert ("A " + usrGlbl) ;

				if (location.href.indexOf("/members/") > -1) {
					location.href = '/members/group-registration.html';
					return;
				}
			}
			else {
				//alert ("B " + usrGlbl) ;
			}

			/////  HEADER 
			var header ;

			if (site == 'qp') {
				header= 'Logged In as ' + this.usrNm  ;
			}
			else {
				mb = (isParticipant(usrGlbl) || isNonMember(usrGlbl) ) ? '' : 'members/'; 

				var SN = '';
				if (location.href.indexOf("SN=0") > -1 ) {
					document.cookie = "SN=0;path=/;domain=asq.org";
					SN = '' ; 
				}
				else if ( (document.cookie.indexOf("10.1.7.144") > -1 || document.cookie.indexOf("10.1.4.129") > -1 || location.href.indexOf("SN=1") > -1 || document.cookie.indexOf("SN=1") > -1) && location.href.indexOf("?NO") == -1) {
					SN = '<br/><img src="/img/templates/nonmember/header-member-login.gif" alt="Members Log In" /> <a href="/perl/members/registry/search/search_individual.pl"><span class="bluebold">Find Members</span></a> &nbsp;&nbsp;' ;
					SN = SN + '<script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script><a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s9.addthis.com/button1-share.gif" width="125" height="16" border="0" alt="" /></a> ' ; 
					SN = SN + '<a href="javascript:void(0)" alt="Comment, rate this content" onClick="Comment=window.open(\'/perl/members/comment_.pl\', \'Comment\', \'scrollbars=no,resizable=no,location=no,status=no,toolbar=no,menubar=no,width=470,height=350,top=160,left=420\');" ><span class="bluebold">Comment/Rate/Suggest</span><img src="/img/5stars2.gif"  border="0" alt="Comment, rate this content." /></a>' ;
					document.cookie = "SN=1;path=/;domain=asq.org";
				}
				else {
					SN = '' ; 
				}
// Made image links absolute for thePort 
				if (location.href.indexOf("community.asq.") > -1) {
					header= '<span class="bluebold">Logged In as ' + this.usrNm  + '</span> <br /> <a href="/editor/app/logout.aspx">Log Out</a> <img src="http://www.asq.org/img/templates/nonmember/header-member-logout.gif" />&nbsp;&nbsp;<a href="http://www.asq.org/account/manage-account.html">My Account</a> <img src="http://www.asq.org/img/templates/nonmember/header-my-account.gif" />&nbsp;&nbsp; <a href="http://www.asq.org/store/shopping_cart.html">View Shopping Cart</a> <img src="http://www.asq.org/img/templates/nonmember/header-shopping-cart.gif" />&nbsp;&nbsp;<a href="http://www.asq.org/qualityprogress/index.html" target="_blank">Quality Progress Magazine</a> <img src="http://www.asq.org/img/templates/nonmember/header-qp.gif" />' +  (hq ? '' : '<META NAME="WT.rv" CONTENT="1">') ;
				}
				else {
					header= '<span class="bluebold">Logged In as ' + this.usrNm  + '</span> <br /> <a href="http://www.' + hq + 'asq.org/log-out.html">Log Out</a> <img src="/img/templates/nonmember/header-member-logout.gif" />&nbsp;&nbsp;<a href="/' + mb + 'account/manage-account.html">My Account</a> <img src="/img/templates/nonmember/header-my-account.gif" />&nbsp;&nbsp; <a href="http://www.asq.org/store/shopping_cart.html">View Shopping Cart</a> <img src="/img/templates/nonmember/header-shopping-cart.gif" />&nbsp;&nbsp;<a href="http://www.asq.org/qualityprogress/index.html" target="_blank">Quality Progress Magazine</a> <img src="/img/templates/nonmember/header-qp.gif" />' +  (hq ? '' : '<META NAME="WT.rv" CONTENT="1">') ;
				}
			}

			/////  MEMBERSHIP RENEWAL  
			if ( 		usrGlbl.indexOf("RNU") 				> -1 ||
						usrGlbl.indexOf("RNL") 				> -1 ||
						usrGlbl.indexOf("RND") 				> -1 
				) {
				//if (p) {
				//	alert(usrGlbl);
				//}
				var message = getRenewMessage(this.usrGlbl) ; 
				if (message.length > 0) {
					header += ( '<br/>' + message + SN) ; 
				}
				else {
					header += SN ; 
				}
				if ( isGroup(usrGlbl) || isParticipant(usrGlbl) ) {
					if (document.getElementById('headTable') != null) {					
					document.getElementById('manage_URL').href 		= '/members/participant/manage-account.html' ;
					document.getElementById('manage_img').src 		= '/img/templates/manage-my-account.gif' ;
					document.getElementById('manage_img').alt 		= 'Manage My Account' ;
					document.getElementById('callout3_img').alt 	= 'Join ASQ' ;
					document.getElementById('callout3_img').src 	= '/img/templates/join-asq-today.gif' ;
					document.getElementById('callout3_url').href	= '/members/participant/join-asq.html' ;
					document.getElementById('MySectionsBlurb').style.display 	= 'block' ;
					document.getElementById('MyNetworksBlurb').style.display 	= 'block' ;
					document.getElementById('MyForumsBlurb').style.display		= 'block' ;
					document.getElementById('MyBoardsBlurb').style.display 		= 'block' ;
					}
				}

				/////  BENEFITS LINK 
				if (document.getElementById('headTable') != null) {
					//document.getElementById('quality_img').src = '/img/templates/home/we-are-quality.gif' ;
					if 		( usrGlbl.indexOf("ORG")>-1 || isParticipant(usrGlbl) ) {		
						document.getElementById('benefits_URL').href = '/members/participant/benefits-enterprise.html' ;
					}
					else if 	( usrGlbl.indexOf("SUSTAINING")>-1 ) {		
						document.getElementById('benefits_URL').href = '/members/participant/benefits-site.html' ;
					}
					else if 	( usrGlbl.indexOf("SCHOOL")>-1 ||  usrGlbl.indexOf("DISTRICT")>-1 ) {		
						document.getElementById('benefits_URL').href = '/members/participant/benefits-educational.html' ;
					}
					else if 	( usrGlbl.indexOf("NON-MEMBER")>-1 ) {		
						////document.getElementById('benefits_URL').href = '' ;
					}
				}

			}

			
			
			
			
			if ( location.href.indexOf("/membership/") > -1) {
				if ( isGroup(usrGlbl) || isParticipant(usrGlbl) || isNonMember(usrGlbl)) {
					// alert("its group or participant or NONMEMBER BCM 20 MAR");// nothing 
				}
				else {
					if (document.getElementById('membershipTabs') != null) {
						// alert("its NOT group or participant BCM 20 MAR \n " + usrGlbl);
						document.getElementById('membershipTabs').innerHTML= '<table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="/membership/members/your-benefits.html" id="ym">Your Membership<br />Benefits and Features</a></td><td><a href="/membership/members/did-you-know.html" id="dyk"><br />Did You Know...?</a></td><td><a href="/membership/members/renew.html" id="renew"><br />Renew</a></td><td><a href="/membership/members/get-involved.html" id="gi"><br />Get Involved</a></td><td><a href="/members/account/membership.html" id="uym">Upgrade Your<br />Membership</a></td></tr></table>';
						document.getElementById('callouts').innerHTML= 		 '<table border="0" width="620" cellspacing="0" cellpadding="0"><tr><td width="160" align="left" valign="top" class="bluecell"><img src="/img/templates/membership/persfull-photo.jpg" alt="Jenny Persfull" width="160" height="190" /></td><td width="310" align="left" valign="top" class="whiterightborder" id="teasercell"><img src="/img/templates/membership/persfull-blurb.gif" alt="Quality is about people" width="310" height="190" /></td><td width="150" align="left" valign="top" class="bluecell"><a href="/members/account/manage-account.html"><img src="/img/templates/manage-my-account-2.gif" alt="Manage my account" width="150" height="64" border="0" /></a><a href="/keepintouch.html"><img src="/img/templates/sign-up-asq-weekly.gif" alt="Sign up for the ASQ Weekly e-newsletter" width="150" height="64" border="0" /></a><a href="/java_members/portlets/execute/referMemberSetup"><img src="/img/templates/refer-a-member.gif" alt="Refer a member" width="150" height="62" border="0" /></a></td></tr></table>';
					}
				}
			}

			
			if ( location.href.indexOf("/global/") > -1) {
				if ( isGroup(usrGlbl) || isParticipant(usrGlbl) ) {
					// nothing 
				}
				else {
					if (document.getElementById('mainText') != null) {
						document.getElementById('mainText').innerHTML= '<p class="blueheadline">Take Advantage of Your ASQ Member Benefits!</p><p><strong><a href="/members/">My ASQ</a></strong> &ndash; Access the online member community. Find information tailored to your needs. Connect with members in your industry or area.</p><p><strong><a href="/members/news/newsletters/gazeta/index.html"><em>Gazeta Global</em></a></strong> &ndash; Read the current issue of this electronic newsletter written specifically for international members like you. There is also an archive of past issues.</p><p><strong><a href="/discuss/">International Quality Discussion Board</a></strong> &ndash; Discuss quality from an international perspective. Topics of discussion might include multinational operations, international standards, or even cultural and economic considerations as they impact the application of quality principles.</p>';
						document.getElementById('promoBoxes').innerHTML= 		 '';
						document.getElementById('secondaryNav').innerHTML= '<ul><li id="o"><a href="/global/membership/overview.html">Your Benefits</a></li><li id="m"><a href="/members/index.html">My ASQ</a></li></ul>';
					}
				}
			}
			
			
			if ( location.href.indexOf("/advocacy/") > -1) {
				if ( isGroup(usrGlbl) || isParticipant(usrGlbl) ) {
					// nothing 
				}
				else {
					if (document.getElementById('mainText') != null) {
						document.getElementById('mainText').innerHTML= '<p class="blueheadline">Network</p><p><strong>Quality Networks:</strong> You can <a href="/advocacy/network/my-networks.html">access the ASQ Networks you&#8217;ve already selected</a>. Or you can <a href="/communities/">peruse all the networks</a> to see if it&#8217;s time to join a new one.</p><p><strong><a href="/advocacy/network/my-sections.html">Your ASQ Sections:</a></strong> Get in touch with your local section and get involved.</p><p><strong><a href="http://www.asq.org/java_members/calendar/submitEvent.jsp">Create an Event:</a></strong> Are you organizing an ASQ-related event? We&#8217;ll help you spread the word.</p><p><strong><a href="http://www.hq.asq.org/discuss/">ASQ&#8217;s Interactive Community:</a></strong> Online options for connecting with others who share your interest in advocating quality.</p><p><strong>Help Us Make a Difference:</strong> Learn more about the power of quality, so you can more effectively carry the message to your peers and community.</p><ul class="bulletOrange"><li><a href="/learn-about-quality/cost-of-quality/overview/overview.html">The Cost of Quality:</a> Actually, it&#8217;s <em>not</em> having quality that costs us. Here&#8217;s a basic primer on the concept.</li><li><a href="/economic-case/">Making the Case for Quality:</a> Get an executive-level look at how quality pays in any organization and how to "make the case" for quality in your organization. Includes resources you can put to work immediately.</li></ul>';
						document.getElementById('promoBoxes').innerHTML= 		 '';
						document.getElementById('secondaryNav').innerHTML= '<ul><li id="o"><a href="/advocacy/network/">Overview</a></li><li id="n"><a href="/advocacy/network/my-networks.html">Quality Networks</a></li><li id="s"><a href="/advocacy/network/my-sections.html">Your ASQ Section</a></li><li id="ce"><a href="http://www.asq.org/java_members/calendar/submitEvent.jsp">Create Event</a></li><li id="ic"><a href="http://www.asq.org/discuss/">Interactive Community</a></li><li id="cq"><a href="/learn-about-quality/cost-of-quality/overview/overview.html">Cost of Quality</a></li><li id="cfq"><a href="/economic-case/">Case for Quality</a></li></ul>';
					}
				}
			}
			
			
// My ASQ sub-menu when logged in *******************************************************************************************
			
			
			//alert("JR tempo.." + "isNonMember(usrGlbl): " + isNonMember(usrGlbl) + usrGlbl);
			if ( isGroup(usrGlbl) ) {
					// nothing 
			}
			
			
			else if ( isParticipant(usrGlbl) ) { //show Manage Account sub menu and registered user links
				if (document.getElementById('myMenu')){
					document.getElementById('myMenu').style.display='block';
					};
				
			}
			
			else {
				if (document.getElementById('myMenu')){ //show My ASQ sub menu and member links
					document.getElementById('myMenu').style.display='block';
					};
				
			}
			
			
			document.getElementById('loginarea').innerHTML = header ; 


		}
		dsplCommentPrompt();
	}
	
	//Changes left nave links based on hq ================================================================================================================
	if (hq == "hq.") {
	$("a[href^='http://www.asq.org']")
	   .each(function()
	   { 
		  this.href = this.href.replace(/^http:\/\/www\.asq\.org/,"http://www.hq.asq.org");
	   });
	}

	
} // end of dsplLgn


// added for enterprise member names to show on My ASQ - rmk 20091109
function orgNameplate(){
	
	var whoThis = '';
	
	if ( this.CO && this.CO != "") {	
	//alert("YES: ORG name assigned in cookie");
		whoThis = 
		'<h2>My ASQ - Access to Your Membership</h2>' +
		'<p class="orgMemText">As an employee of ' + this.CO  + ', you have access to:</p>' ;	
                                   
		if (whoThis) {
			document.getElementById('orgMessageBox').innerHTML = whoThis ; 
        }

                 
	}
	else {
	//alert("NO: You have no ORG name assigned in cookie");
	  		whoThis = 
			'<h2>My ASQ - Access to Your Membership</h2>' +
			'<p>These membership tours show you how to:</p>' ;
		if (whoThis) {
			document.getElementById('orgMessageBox').innerHTML = whoThis ; 
        }
  
	}


}


// added for customer records login state for the upper right login box 20090618 rmk
function logBox(){

	var loginBox1 = '';

	if 		(typeof(mbType) == 'undefined') { } 
	else if (mbType.indexOf("NON-MEMBER") > -1 || mbType.indexOf("PARTICIPANT") > -1 ) {
		loginBox1 = 
			'<div id="regUserLogBox">' +
			'<h3>Your ASQ registration gives you:</h3>' +
			'<ul><li><a href="/account/manage-account.html">Account management</a></li>' +
			'<li>Quicker article access</li>' +
			'<li>Easier purchasing</li></ul>' +
			'<p>Need more from ASQ? <a href="/membership/benefits/index.html">Join ASQ today!</a></p>' +
            '</div>' ;

	}
	else {
		loginBox1 = 
			'<p>Member View</p>' +
            '<br />' ;
 
	}

	if (loginBox1) {
		document.getElementById('seeStatus').innerHTML = loginBox1 ; 
	}
	

}



// added for customer records login state for the left nav 20090618 rmk
function personalizeNav(){

	var htmlSnippet3 = '';

	if 		(typeof(mbType) == 'undefined') { } 
	else if (mbType.indexOf("NON-MEMBER") > -1 || mbType.indexOf("PARTICIPANT") > -1 ) {
		htmlSnippet3 = 
			'<h2><a href="http://www.' + hq + 'asq.org/account/manage-account.html"><img class="qualityBy" src="/img/templates/shared/manage-account.jpg" alt="Manage Account" width="160" height="29" border="0" /></a></h2>' +			
			'<ul class="blue">' +
			'<li><a href="http://www.' + hq + 'asq.org/account/my-certification.html">My Certifications</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/account/my-news.html">My News</a></li>' +
			//'<li><a href="/account/my-saved-articles.html">My Saved Articles</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/perl/members/bookmarks.pl?action=viewbookmarks&ctx=myasq">My Saved Articles</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/account/my-communities.html">My Communities</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/account/manage-account.html">My Account</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/membership/individuals/overview.html">Join ASQ</a></li>' +
			'</ul>';

	}
	else { //My ASQ links
		htmlSnippet3 = 
			'<h2><a href="http://www.' + hq + 'asq.org/members/index.html"><img class="qualityBy" src="/img/templates/shared/my-member-site.jpg" alt="My ASQ" width="160" height="29" border="0" /></a></h2>' +			
			'<ul class="blue">' +
			'<li><a href="http://www.' + hq + 'asq.org/members/certification/index.html">My Certifications</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/members/news/index.html">My News</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/perl/members/bookmarks.pl?action=viewbookmarks&ctx=myasq">My Saved Articles</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/members/communities/index.html">My Communities</a></li>' +
			'<li><a href="http://www.' + hq + 'asq.org/members/account/manage-account.html">My Account</a></li>' +
			'</ul>';
 
	}

	if (htmlSnippet3) {
		document.getElementById('snippet3').innerHTML = htmlSnippet3 ; 
	}

	
}











function getRenewMessage(usrGlbl) {
	var mths = new Array('','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
	var message = '';
	if ( document.cookie.indexOf("10.1.7.144") > -1) {
		//alert(usrGlbl);
	}
	if (usrGlbl.indexOf("~RN") > -1 ) {
		var ren = usrGlbl.substring(usrGlbl.indexOf("~RN")+1,usrGlbl.indexOf("~RN")+14);
//alert(ren);
//alert(ren);

		if ( ren != null && ren.length > 0) {
					
			var arrayRnDt = (ren.substring(3)).split("/");
			var mm 		= arrayRnDt[0];
			var m 		= mm.substring(0,1) == '0' ? mm.substring(1) : mm ;
			var dd 		= arrayRnDt[1];
			var d 		= dd.substring(0,1) == '0' ? dd.substring(1) : dd ;
			var yyyy 	= arrayRnDt[2];
			var yyyy2 	= parseInt(yyyy)+1;
			var formattedDate = mths[parseInt(m)] + ' ' + dd + ', ' + yyyy ;
//alert(yyyy);
//alert(yyyy2);
			// RNU ReNew Unpaid 
			// I don't think we need this because what membership wants to show is if the membership WILL EXPIRE, not if it ALREADY expired - Barry Mitchell 4/21/2008
			if ( 	 ren.indexOf("RNU") > -1) {

				var beginDate = new Date(yyyy,m-1,d);
				var currDate  = new Date();
				nbDaysSinceBeginDate = Math.round( (currDate-beginDate) / (1000*3600*24) ) ;

				var expiredMessage = nbDaysSinceBeginDate + ' days ago';

				if ( document.cookie.indexOf("10.1.7.") > -1) {
					if 		(nbDaysSinceBeginDate > 90) { expiredMessage = '+90 days ago '	}
					else if (nbDaysSinceBeginDate > 30) { expiredMessage = '+30 days ago ' 	}
					else if (nbDaysSinceBeginDate >  0) { expiredMessage = 'recently '		}
				}
				
				message = '<font color=red>Your membership has expired.</font> <a href="/membership/renew.html"><b><strong>Renew Now!</strong></b></a>' ;
			}
			// RNL ReNewaL
			// I borrowed code from above and switched it around to show messages to memberships who WILL EXPIRE - Barry Mitchell
			if (ren.indexOf("RNL") > -1) {
				
				var expiredMessage;
				var beginDate = new Date(yyyy,m-1,d);
				var currDate = new Date();
				
				nbDaystilRenewDate = Math.round( (beginDate-currDate) / (1000*3600*24) ) ;
				var everyThing = ren + ', ' + beginDate + ', ' + currDate + ', ' + nbDaystilRenewDate;
				//alert(everyThing);


					if 		(nbDaystilRenewDate <  1) { expiredMessage = 'Your membership has expired. <a href=\"/membership/renew.html\" class=\"ulined\"><strong>RENEW NOW</strong></a>.'		}
					else if (nbDaystilRenewDate < 30) { expiredMessage = 'Your membership will expire on ' + formattedDate + '.<br /><a href=\"/membership/renew.html\" class=\"ulined\"><strong>RENEW NOW</strong></a> to avoid interrupting your <a href=\"/membership/benefits/index.html\" class=\"ulined\">benefits</a>.' 	}
					else if (nbDaystilRenewDate < 90) { expiredMessage = 'Your membership will expire in less than 90 days. <a href=\"/membership/renew.html\" class=\"ulined\"><strong>RENEW NOW!</strong></a>' }
					if (expiredMessage != null) {
				  message = expiredMessage ;}
				  	//else {
						//everyThing = everyThing + 'This is from within RNL.';
						//alert(everyThing);
						//}
			}
			// RND ReNeweD
			else if ( ren.indexOf("RND") > -1 ) {
				   message = 'Membership Renewed ' + formattedDate + '. Thank you.';
			} 
			if ( document.cookie.indexOf("10.1.7.144") > -1) {
				//alert(usrGlbl);
			}
		}
	}

	if ( message.indexOf("undefined") > -1) { 
		message = '' ;
	}
	if (message != null){
	return message;}
	//else { everyThing = everyThing + 'This is from end of getRenewMessage.'
	//alert(everyThing);
		//}
}


function getPublMessage(usrGlbl) {
	var publDirName = location.href.substring(location.href.indexOf("/pub/")+5,location.href.lastIndexOf("/") ) ; 
	var usrBnefName;
	if (publDirName == 'qualityprogress'){
		publDirname = 'QP';
	}
	else if (publDirName == 'sixsigma'){
		publDirname = 'SSF';
	}
	return '<br>' + publDirName;
}

function decode(encStr) {
  var bits, decOut = '', i = 0;
  for(; i<encStr.length; i += 4){
    bits =
     (bsf.indexOf(encStr.charAt(i))    & 0xff) <<18 |
     (bsf.indexOf(encStr.charAt(i +1)) & 0xff) <<12 | 
     (bsf.indexOf(encStr.charAt(i +2)) & 0xff) << 6 |
      bsf.indexOf(encStr.charAt(i +3)) & 0xff;
    decOut += String.fromCharCode(
     (bits & 0xff0000) >>16, (bits & 0xff00) >>8, bits & 0xff);
    }
  if(encStr.charCodeAt(i -2) == 61)
    undecOut=decOut.substring(0, decOut.length -2);
  else if(encStr.charCodeAt(i -1) == 61)
    undecOut=decOut.substring(0, decOut.length -1);
  else undecOut=decOut;
  
  return unescape(undecOut);		//line add for chinese char
}

var gAutoPrint = true; // Flag for whether or not to automatically call the print function
function printFriendly()
{
	if (document.getElementById != null)
	{
		var html ;
		if (location.href.indexOf("/qualityprogress/") > -1) {
			html = '<HTML>\n<HEAD><link rel=\"stylesheet\" href=\"/quality_progress/qp-templates/includes/print.css\" type=\"text/css\"><style>#articleThumbs img {width:auto;height:auto;border:none;}</style>\n';
			html += '\n</HEAD>\n<BODY><table border=0 cellspacing=0 cellpadding=0 align=right><tr><td width=140 valign=top><img src=\"/quality_progress/qp-templates/img/logo-140x90-bw.gif\" border=0></td></tr></table>\n';
		}
		else {
			html = '<HTML>\n<HEAD><link rel=\"stylesheet\" href=\"/includes/global.css\" type=\"text/css\"><link rel=\"stylesheet\" href=\"/includes/audience.css\" type=\"text/css\">\n';
			html += '\n</HEAD>\n<BODY style=\"font: 11px/13px verdana, arial, sans-serif\"><table border=0 cellspacing=0 cellpadding=0 align=right><tr><td width=69 valign=top><img src=\"/img/templates/shared/asq_logo_s.gif\" border=0></td></tr></table>\n';
		}

		if (document.getElementById("printFriendly")) {
			var printPageElem = document.getElementById("printFriendly");
		}
		else if (document.getElementById("contentmiddlenorightorleft")) {
			var printPageElem = document.getElementById("contentmiddlenorightorleft");
		}
		else if (document.getElementById("contentmiddlenoright")) {
			var printPageElem = document.getElementById("contentmiddlenoright");
		}
		else if (document.getElementById("main")) {
			var printPageElem = document.getElementById("main");
		}
		
		
		
		if (printPageElem != null)
		{
				html += printPageElem.innerHTML;
		}
		else
		{
			alert("Could not find the printFriendly section in the HTML");
			return;
		}
			
		html += '\n<table width=95% border=0 cellspacing=0 cellpadding=5 align=center><tr><td><hr>Copyright &copy; 2005-2008 American Society for Quality. All rights reserved.<br>Republication or redistribution of ASQ content is expressly prohibited without the prior written consent.<br>ASQ shall not be liable for any errors in the content, or for any actions taken in reliance thereon.</td></tr></table></BODY>\n</HTML>';
		
		var printWin = window.open("","printFriendly");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, the printer friendly feature works\nonly in javascript enabled browsers.");
	}
}

function openNewWindow(theURL,winName,features) {
    			window.open(theURL,winName,features);
}

function isGroup(usr){
	if 	( 	usr.indexOf("ORG") 			> -1	|| 
			usr.indexOf("SCHOOL") 		> -1 	|| 
			usr.indexOf("SUSTAINING") 	> -1	||
			usr.indexOf("DISTRICT") 	> -1 ) {
		return true;
	}
}

function isParticipant(usr) {
	if 	( usr.indexOf("PARTICIPANT") >-1 ) {
		return true;
	}
}

function isNonMember(usr) {
	if 	( usr.indexOf("NON-MEMBER") >-1 ) {
		return true;
	}
	else {
		return false;
	}
}

function dsplCommentPrompt() {
	// now handled at server level 
	if (document.getElementById('linkorform') != null) {
		document.getElementById('linkorform').innerHTML = 
		'<div id="addComment"><hr>' + 
		'<form name="commentform" id="commentform" method="POST" action="/perl/members/comments.pl?action=comment" />' +
		'<p><label for="#">Name</label> <input type="text" name="cusname" size="40" /> <em><br />(required)</em></p> ' + 
		'<p><label for="#">Email</label> <input type="text" name="email" size="40" /> <em><br />(required, but will not be published)</em></p> ' +
		'<p><label for="#">Thoughts and Comments</label><br /><textarea name="comments" cols="60" rows="8"></textarea></p> ' +
		'<p><input type="submit" value="Submit" /></p> ' +
		'</form> </div>';
	}
}

function inSmallWindow(theUrl,param1,param2) {
	window.open(theUrl,"commentconfirm","width=435,height=435");
}

//outage message script to be called by specialMessage() in header.html
//BCM 18 DEC 2008

var today = new Date();
var active_date = new Date("December 23, 2009");
var expiration_date = new Date("January 4, 2010");
expiration_dateStr = expiration_date.toUTCString();

//here
function setCookie(cookieName, cookieValue, cookieExpires, cookiePath, cookieDomain)  
{
	cookieValue = escape(cookieValue);
	document.cookie = cookieName + "=" + cookieValue + "; expires=" + cookieExpires + "; path=" + cookiePath + "; domain=" + cookieDomain;
}
// here


function getCookie(name)
{ 
	var cookieString = document.cookie;
	var index = cookieString.indexOf(name + "=");

	if (index == -1)
		{ return null; }

	index = cookieString.indexOf("=", index) + 1;
	var endstr = cookieString.indexOf(";", index);

	if (endstr == -1) 
		{ endstr = cookieString.length; }

	return unescape(cookieString.substring(index, endstr));
}


function specialMessage()
{ 
	if (today <= expiration_date) {
		//alert('its earlier than ' + expiration_date);
		if (today >= active_date) {
			//alert('its after ' + active_date);
			var pagesviewed = getCookie('SpecialMessage');
			if (pagesviewed != 'shown') // if the user has seen the popup do not show it again.
				{ 
					window.open("/outage-message.html","survey","menubar=no,width=495,height=210,toolbar=no");
					document.cookie = 'SpecialMessage=shown;expires=' + expiration_dateStr + ';path=/;domain=asq.org';
				}
		}
		//else { alert('its before ' + active_date); }
	}
	//else { alert('its after ' + expiration_date); }
}


// *** toggle for article shell forms ***

var isMIE = 0;

function detectBrowser() //detectBrowser() is available for anyuse
{
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
if (browser=="Microsoft Internet Explorer") {
	 isMIE = 1;
	 }
}

// the following sets up toggle for form

if (document.getElementById('formSwitch')){
document.getElementById('formSwitch').onclick = toggleForm;
document.getElementById('formBlock').style.display = 'none';
}
if (document.getElementById('formSwitch2')){
document.getElementById('formSwitch2').onclick = toggleForm;
document.getElementById('formBlock').style.display = 'none';
}

var thehiddenForm = document.getElementById('formBlock');

function toggleForm(){

	if (isMIE == 1){

		if (thehiddenForm.style.display == 'inline-block') {
			thehiddenForm.style.display = 'none';

		} else {
			thehiddenForm.style.display = 'inline-block';
		}
	} else {
		if (thehiddenForm.style.display == 'block') {
			thehiddenForm.style.display = 'none';

		} else {
			thehiddenForm.style.display = 'block';

		}
	}

}

// the following is a generic strip of special characters
function stripHTML(string) { 
    return string.replace(/<(.|\n)*?>/g, ''); 
}

// the following is a generic cookie check for login, any member type
function checkLogin() {
	 if ( document.cookie.indexOf("qazqsa29") > -1 || document.cookie.indexOf("nonmsa29") > -1 || document.cookie.indexOf("qazqsa19")  > -1 ) {  
	 	isLoggedIn = 1	;
        }
	//alert (isLoggedIn);
}

function loginToggle(someid){
	//alert('loginToggle ' + someid);
	if (isLoggedIn)	{
		document.getElementById(someid).innerHTML = "<strong>something</strong>";
	}
}
