// JavaScript Document
function reDo(){ window.location.reload() }
    window.onresize = reDo;

//Define global variables
	    var timerID = null;
		var timerOn = false;
//		var timecount = 500;
//		var what = null;
//		var newbrowser = true;
//		var check = false;

//function drawHi() {
//	var mysplit = id.split("_");

//	document.write("<img src=\"../images/hi"+mysplit[0]+".gif\" alt=\"\" name=\"hi"+mysplit[0]+"\" width=\"529\" height=\"3\" id=\"hi"+mysplit[0]+"\">");
//}

function getQuittingClass() {
	var mysplit	= id.split("_");
	if (mysplit[0] == 2) {
		document.write("<li class=\"stepsOn\">");
		}
		else {
		document.write("<li class=\"steps\">");
		}
}
function getSuccessfulClass() {
	var mysplit	= id.split("_");
	if (mysplit[0] == 1) {
		document.write("<li class=\"rewardsOn\">");
		}
		else {
		document.write("<li class=\"rewards\">");
		}
}
function getResourceClass() {
	var mysplit	= id.split("_");
	if (mysplit[0] == 3) {
		document.write("<li class=\"helpOn\">");
		}
		else {
		document.write("<li class=\"help\">");
		}
}
function pageSubNavigation() {
	var mysplit	= id.split("_");
	if (mysplit[0] == 2 && mysplit[1] == 0) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGrey\"><a href=\"getready.asp\">Get Ready</a> &nbsp;|&nbsp; <a href=\"getsupport.asp\">Get Support</a> &nbsp;|&nbsp; <a href=\"skills.asp\">Learn New Skills</a> &nbsp;|&nbsp; <a href=\"medication.asp\">Medications</a> &nbsp;|&nbsp; <a href=\"staying.asp\">Staying Smoke-free</a></div>");
		}
		else if (mysplit[0] == 2 && mysplit[1] == 1) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGrey\"><a href=\"getready.asp\">Get Ready</a> &nbsp;|&nbsp; <a href=\"getsupport.asp\">Get Support</a> &nbsp;|&nbsp; <a href=\"skills.asp\">Learn New Skills</a> &nbsp;|&nbsp; <a href=\"medication.asp\">Medications</a> &nbsp;|&nbsp; <a href=\"staying.asp\">Staying Smoke-free</a></div>");
		}
		else if (mysplit[0] == 2 && mysplit[1] == 2) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGrey\"><span class=\"on\">Get Ready</span> &nbsp;|&nbsp; <a href=\"getsupport.asp\">Get Support</a> &nbsp;|&nbsp; <a href=\"skills.asp\">Learn New Skills</a> &nbsp;|&nbsp; <a href=\"medication.asp\">Medications</a> &nbsp;|&nbsp; <a href=\"staying.asp\">Staying Smoke-free</a></div>");
		}
		else if (mysplit[0] == 2 && mysplit[1] == 3) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGrey\"><a href=\"getready.asp\">Get Ready</a> &nbsp;|&nbsp; <span class=\"on\">Get Support</span> &nbsp;|&nbsp; <a href=\"skills.asp\">Learn New Skills</a> &nbsp;|&nbsp; <a href=\"medication.asp\">Medications</a> &nbsp;|&nbsp; <a href=\"staying.asp\">Staying Smoke-free</a></div>");
		}
		else if (mysplit[0] == 2 && mysplit[1] == 4) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGrey\"><a href=\"getready.asp\">Get Ready</a> &nbsp;|&nbsp; <a href=\"getsupport.asp\">Get Support</a> &nbsp;|&nbsp; <span class=\"on\">Learn New Skills</span> &nbsp;|&nbsp; <a href=\"medication.asp\">Medications</a> &nbsp;|&nbsp; <a href=\"staying.asp\">Staying Smoke-free</a></div>");
		}
		else if (mysplit[0] == 2 && mysplit[1] == 5) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGrey\"><a href=\"getready.asp\">Get Ready</a> &nbsp;|&nbsp; <a href=\"getsupport.asp\">Get Support</a> &nbsp;|&nbsp; <a href=\"skills.asp\">Learn New Skills</a> &nbsp;|&nbsp; <span class=\"on\">Medications</span> &nbsp;|&nbsp; <a href=\"staying.asp\">Staying Smoke-free</a></div>");
		}
		else if (mysplit[0] == 2 && mysplit[1] == 6) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGrey\"><a href=\"getready.asp\">Get Ready</a> &nbsp;|&nbsp; <a href=\"getsupport.asp\">Get Support</a> &nbsp;|&nbsp; <a href=\"skills.asp\">Learn New Skills</a> &nbsp;|&nbsp; <a href=\"medication.asp\">Medications</a> &nbsp;|&nbsp; <span class=\"on\">Staying Smoke-free</span></div>");
		}
		else if (mysplit[0] == 1 && mysplit[1] == 1) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavOrange\"><a href=\"readstories.asp\">Read Their Stories</a> &nbsp;|&nbsp; <a href=\"rewards.asp\">Rewards of Quitting</a> &nbsp;|&nbsp; <span class=\"on\">Top 10 Reasons to Quit</span></div>");
		}
		else if (mysplit[0] == 1 && mysplit[1] == 2) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavOrange\"><a href=\"readstories.asp\">Read Their Stories</a> &nbsp;|&nbsp; <a href=\"rewards.asp\">Rewards of Quitting</a> &nbsp;|&nbsp; <a href=\"topten.asp\">Top 10 Reasons to Quit</a></div>");
		}
		else if (mysplit[0] == 1 && mysplit[1] == 3) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavOrange\"><span class=\"on\">Read Their Stories</span> &nbsp;|&nbsp; <a href=\"rewards.asp\">Rewards of Quitting</a> &nbsp;|&nbsp; <a href=\"topten.asp\">Top 10 Reasons to Quit</a></div>");
		}
		else if (mysplit[0] == 1 && mysplit[1] == 0) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavOrange\"><a href=\"readstories.asp\">Read Their Stories</a> &nbsp;|&nbsp; <span class=\"on\">Rewards of Quitting</span> &nbsp;|&nbsp; <a href=\"topten.asp\">Top 10 Reasons to Quit</a></div>");
		}
		else if (mysplit[0] == 3 && mysplit[1] == 0) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGreen\"><a href=\"guides.asp\">Guides</a> &nbsp;|&nbsp; <a href=\"comprehensive.asp\">Comprehensive Websites</a> &nbsp;|&nbsp; <a href=\"quick.asp\">Quick Tips & Facts</a>  &nbsp;|&nbsp; <a href=\"programs.asp\">Programs & Support</a> &nbsp;|&nbsp; <a href=\"quitlines.asp\">Telephone Quitlines</a> &nbsp;|&nbsp; <a href=\"public.asp\">Public Health Organizations</a></div>");
		}
		else if (mysplit[0] == 3 && mysplit[1] == 1) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGreen\"><span class=\"on\">Guides</span> &nbsp;|&nbsp; <a href=\"comprehensive.asp\">Comprehensive Websites</a> &nbsp;|&nbsp; <a href=\"quick.asp\">Quick Tips & Facts</a>  &nbsp;|&nbsp; <a href=\"programs.asp\">Programs & Support</a> &nbsp;|&nbsp; <a href=\"quitlines.asp\">Telephone Quitlines</a> &nbsp;|&nbsp; <a href=\"public.asp\">Public Health Organizations</a></div>");
		}
		else if (mysplit[0] == 3 && mysplit[1] == 2) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGreen\"><a href=\"guides.asp\">Guides</a> &nbsp;|&nbsp; <span class=\"on\">Comprehensive Websites</span> &nbsp;|&nbsp; <a href=\"quick.asp\">Quick Tips & Facts</a>  &nbsp;|&nbsp; <a href=\"programs.asp\">Programs & Support</a> &nbsp;|&nbsp; <a href=\"quitlines.asp\">Telephone Quitlines</a> &nbsp;|&nbsp; <a href=\"public.asp\">Public Health Organizations</a></div>");
		}
		else if (mysplit[0] == 3 && mysplit[1] == 3) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGreen\"><a href=\"guides.asp\">Guides</a> &nbsp;|&nbsp; <a href=\"comprehensive.asp\">Comprehensive Websites</a> &nbsp;|&nbsp; <span class=\"on\">Quick Tips & Facts</span>  &nbsp;|&nbsp; <a href=\"programs.asp\">Programs & Support</a> &nbsp;|&nbsp; <a href=\"quitlines.asp\">Telephone Quitlines</a> &nbsp;|&nbsp; <a href=\"public.asp\">Public Health Organizations</a></div>");
		}
		else if (mysplit[0] == 3 && mysplit[1] == 4) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGreen\"><a href=\"guides.asp\">Guides</a> &nbsp;|&nbsp; <a href=\"comprehensive.asp\">Comprehensive Websites</a> &nbsp;|&nbsp; <a href=\"quick.asp\">Quick Tips & Facts</a>  &nbsp;|&nbsp; <span class=\"on\">Programs & Support</span> &nbsp;|&nbsp; <a href=\"quitlines.asp\">Telephone Quitlines</a> &nbsp;|&nbsp; <a href=\"public.asp\">Public Health Organizations</a></div>");
		}
		else if (mysplit[0] == 3 && mysplit[1] == 5) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGreen\"><a href=\"guides.asp\">Guides</a> &nbsp;|&nbsp; <a href=\"comprehensive.asp\">Comprehensive Websites</a> &nbsp;|&nbsp; <a href=\"quick.asp\">Quick Tips & Facts</a>  &nbsp;|&nbsp; <a href=\"programs.asp\">Programs & Support</a> &nbsp;|&nbsp; <span class=\"on\">Telephone Quitlines</span> &nbsp;|&nbsp; <a href=\"public.asp\">Public Health Organizations</a></div>");
		}
		else if (mysplit[0] == 3 && mysplit[1] == 6) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGreen\"><a href=\"guides.asp\">Guides</a> &nbsp;|&nbsp; <a href=\"comprehensive.asp\">Comprehensive Websites</a> &nbsp;|&nbsp; <a href=\"quick.asp\">Quick Tips & Facts</a>  &nbsp;|&nbsp; <a href=\"programs.asp\">Programs & Support</a> &nbsp;|&nbsp; <a href=\"quitlines.asp\">Telephone Quitlines</a> &nbsp;|&nbsp; <span class=\"on\">Public Health Organizations</span></div>");
		}
		else if (mysplit[0] == 3 && mysplit[1] == 7) {
		document.write("<div id=\"pageSubNavigation\" class=\"SubNavGreen\"><a href=\"guides.asp\">Guides</a> &nbsp;|&nbsp; <a href=\"comprehensive.asp\">Comprehensive Websites</a> &nbsp;|&nbsp; <a href=\"quick.asp\">Quick Tips & Facts</a>  &nbsp;|&nbsp; <a href=\"programs.asp\">Programs & Support</a> &nbsp;|&nbsp; <a href=\"quitlines.asp\">Telephone Quitlines</a> &nbsp;|&nbsp; <a href=\"public.asp\">Public Health Organizations</a></div>");
		}
		else  {
		}
	}
function SubheaderImage() {
	var mysplit	= id.split("_");
	SubpageId = mysplit[0];
	document.write("<img src=\"../images/headers/SubHeader_"+SubpageId+".gif\" alt=\"\" width=\"163\" border=\"0\" height=\"26\" style=\"display:block;\" />");
}

function headerImage() {
	pageId = id;
	document.write("<img src=\"../images/headers/"+pageId+".gif\" alt=\"\" width=\"398\" height=\"27\" border=\"0\" style=\"display:block;\" />");
}

//Purpose: Opens up new browser window according to PMUSA specs 011409
function openNewBrowserWindow(strURL)
			{
				var today = new Date();				
				var timestamp = today.getTime();

				//Begin WebTrends click-tracking
				try {
					if (WebTrends){//Verify that the WebTrends object exists, if it does not, we cannot continue
						if (WebTrends&&(typeof(_tag)=="undefined")){ 
							//If the WebTrends object exists, but an instance does not, instantiate a new object
							var _tag=new WebTrends();
							var _webTrendsExtender=new ALCSWebTrendsExtender();					
						}
						var url="";
						if ((strURL.toLowerCase().indexOf("redirect.asp?targeturl=")!=-1)||(strURL.toLowerCase().indexOf("redirect.asp?url=")!=-1)){
							//If the redirect is being used
							//Capture the URL of the anchor tag and pass the info to the WebTrends object
							url = strURL.substring(strURL.indexOf("=")+1);
						} else { //Otherwise use the value of strURL
							url = strURL;
						}						
						var host="";
						var uri="";
						var qry="";
						//RegEx for Parsing URL
						var urlRegEx = new RegExp(/^((https?):\/\/)?([^:\/\?\#\s]+)([^\?]+)?([\?]+.*)?$/); // changed 1/12/09
						//Parse the URL using a reg. expression, we cannot use JavaScript's e.hostname, e.pathname...etc
						var m = urlRegEx.exec(url);	
						if (m!=null){
							host=m[3];
							uri=m[4];
							qry=m[5]||"";
						} else {
							uri=url;
						}
						var title = "Offsite: " + host+uri+qry; //CHANGED 1/12/09
						var contentGroup = _webTrendsExtender.GetContentGroup();
						_tag.dcsMultiTrack("DCS.dcssip",host,"DCS.dcsuri",uri,"DCS.dcsqry",qry,"WT.ti",title,"WT.dl","24","WT.cg_n",contentGroup);						
					}									
				} catch (ex) {
					//Suppress error messages
				}
				//End WebTrends click-tracking
				window.open(strURL, timestamp, 'toolbar=yes,location=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes');
			}
// End new window script			
			
function aboutLink() {
	var mysplit	= id.split("_");
	if (mysplit[0] == 5 && mysplit[1] == 0) {
		document.write("About QuitAssist&reg;<!--<a href=\"../about/index.asp\">About QuitAssist&reg;</a>-->");
		}
		else {
		document.write("<a href=\"../about/index.asp\">About QuitAssist&reg;</a>");
		}
	}

function getguideLink() {
	var mysplit	= id.split("_");
	if (mysplit[0] == 4 && mysplit[1] == 0) {
		document.write("Download the QuitAssist&reg; Guide");
		}
		else {
		document.write("<a href=\"../getguide/index.asp\">Download the QuitAssist&reg; Guide</a>");
		}
	}
	

/*function switchLink() {
	var mysplit	= id.split("_");
	if (mysplit[0] == "z") {
		document.write("<span class=\"black\">QuitAssist En Espa&ntilde;ol</span>");
		}
		else {
		document.write("<a href=\"http://winstage.vml.com/philipmorris/quitassist_spanish/index_flash.asp\">QuitAssist En Espa&ntilde;ol</a>");
		}
	}


function transformExtLink(){
	docAddress = (""+document.location+"")
	docAddress = docAddress.toLowerCase()	
	
	engLoc = docAddress
		re1 = /\/quitassist\//
	spanLoc = docAddress
		re2 = /\/quitassist_spanish\//
		esLoc = "/quitassist_spanish/"
		enLoc = "/quitassist/"

	if (re1.test(engLoc)) {
		var str = docAddress.replace(/(^.*)\/quitassist\/(.*$)/, "$1"+ esLoc +"$2");
		document.location.href = (str); // prints "Two One Three"
	}
	if (re2.test(spanLoc)) {
		var str = docAddress.replace(/(^.*)\/quitassist_spanish\/(.*$)/, "$1"+ enLoc +"$2");
		document.location.href = (str); // prints "Two One Three"
	}
}
*/
function transformExtLink(){
	docAddress = (""+document.location+"");
	docAddress = docAddress.toLowerCase();	
	engLoc = docAddress;
		re1 = /\/en\//;
	spanLoc = docAddress;
		re2 = /\/es\//;
		esLoc = /es/;
		enLoc = /en/;

	if (re1.test(engLoc)) {
		var str = docAddress.replace(/(^.*)\/en\/(.*$)/, "$1"+ esLoc +"$2");
		document.location.href = (str);
	}
	if (re2.test(spanLoc)) {
		var str = docAddress.replace(/(^.*)\/es\/(.*$)/, "$1"+ enLoc +"$2");
		document.location.href = (str);
	}
}


function init() {
      //alert ("Running Init"+id);

      if (document.layers) {
            //  alert ("Running Netscape 4");
            layerRef="document.layers";
            styleSwitch="";
            visibleVar="show";
			screenSize = window.innerWidth;
			what ="ns4";
          } else if(document.all) {
              //  alert ("Running IE");
              layerRef="document.all";
              styleSwitch=".style";
              visibleVar="visible";
			  screenSize = document.body.clientWidth + 18;
			  what ="ie";
		  } else if(document.getElementById) {
            //  alert ("Running Netscape 6");
            layerRef="document.getElementByID";
            styleSwitch=".style";
            visibleVar="visible";
			what="moz";
		  } else {
		  	//alert("Older than 4.0 browser.");
			what="none";
			newbrowser = false;
 		  }
		//window.status='status bar text to go here';
		check = true;
  	 	}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function showLayer(layerName){
   if(check){
        		if (what =="none"){
        			return;
        			}
	        	else if (what == "moz"){
        			document.getElementById(layerName).style.visibility="visible";
        			}
        		else{
                  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
                  }
		 }
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}
}

function hideLayer(layerName){
        	if(check){
        		if (what =="none"){
        			return;
        			}
        		else if (what == "moz"){
        			document.getElementById(layerName).style.visibility="hidden";
        			}
        		else{
                  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
				}
        
        	}
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}
}

function hideAll(){
			//hideLayer('mnu1');
			//hideLayer('mnu2');
			//hideLayer('mnu3');
			//hideLayer('mnu4');
}

function startTime() {
	        if (timerOn == false) {
                timerID=setTimeout( "hideAll()" , timecount);
                timerOn = true;
	        }
}

function stopTime() {
	        if (timerOn) {
    	        clearTimeout(timerID);
                timerID = null;
                timerOn = false;
	        }
}

function onLoad(){
			init();
}


//Printer and email pop up
function openPopupWindow(strURL, intWidth, intHeight, strPopupOptions)
{
	
	var today = new Date();
	
	var timestamp = today.getTime();

	window.open(strURL,timestamp,"width="+intWidth+",height="+intHeight+","+strPopupOptions);
}