function trackflash(str) {
var s_account="genedev"
if (window.location.hostname.indexOf('tarceva-qa.gene.com') > -1) {
	s_account= "geneqa";
} else {
	if (window.location.hostname.indexOf('tarceva-ua.gene.com') > -1) {
		s_account="geneua";
	} else {
		if (window.location.hostname.indexOf('www.tarceva.com') > -1) {
			s_account="genetarceva,geneexternal";
		}
	}
}

var s=s_gi(s_account);s.prop1=str;s.linkTrackVars='prop1';void(s.tl(true,'o',str));
}

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 confirm_entry(whichURL) 
{
  var loc = whichURL;
  input_box=confirm('By selecting this link, you will be leaving Tarceva.com and going to a site that is not controlled by or affiliated with Genentech USA, Inc. The links to third-party sites are provided for informational purposes only and are not intended to guide prescribing decisions. Genentech is neither affiliated with nor endorses any of the aforementioned organizations.');
	if (input_box==true)
	{
    try {
      eventType = "outgoing"
      file_path = whichURL
      //production
    	if(location.href.indexOf("tarceva.com") > -1 ){
    	  pageTrackerProd1._trackEvent("Links", eventType, file_path);
          pageTrackerProd1._trackPageview(file_path);
      }else{
        //qa
        if(location.href.indexOf("tarceva-qa.gene.com") > -1 ){
          pageTrackerQA._trackEvent("Links", eventType, file_path);
          pageTrackerQA._trackPageview(file_path);
        }else{
          //ua
          if(location.href.indexOf("tarceva-ua.gene.com") > -1 ){
            pageTrackerUA._trackEvent("Links", eventType, file_path);
            pageTrackerUA._trackPageview(file_path);
          }
        }
      }
    } catch(err) {}
    	 
	// Output when OK is clicked 
	window.open(loc,'tarceva')
	}
	else
	{
	// Output when Cancel is clicked
	}
	
}

function confirm_hcp(hcpURL,channel,page)
{
	//do tracking if channel and page vars are passed to function
  if ((channel != undefined) && (page != undefined)) {
    trackChannelLink(channel,page);
  }
var loc = hcpURL;
input_box=confirm('The information contained in this section of the site is intended for U.S. healthcare professionals only.  Click OK if you are a healthcare professional.');
	if (input_box==true)
	{ 
	// Output when OK is clicked 
	document.location=loc;
	}
	else
	{
	// Output when Cancel is clicked
	}
}

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;
}

/*****************************************************************************/
/******************** LEFT-NAV CHANNEL LINK HANDLER **************************/
/*****************************************************************************/
function trackChannelLink(channel,current) {
  s.prop1 = 'new_channel:' + channel;
  s.prop2 = 'from:' + current;
  s.linkTrackVars = 'prop1,prop2';
  s.tl(true,'o','Link to channel: ' + channel + ' from: ' + current);
  return false;
}
/*****************************************************************************/
/**************************** FLASH HANDLERS *********************************/
/*****************************************************************************/
var so;

function writeFlashBanner(sect) {
  var nf = readCookie('noflash');
  if (nf != 'true') {
    if (sect == 'landing') {
      so = new SWFObject("/flash/swf/landing.swf", "tarceva", "790", "326", "8", "#fefefe");
    }
    else if (sect == 'welcome_email') {
      so = new SWFObject("/flash/swf/tarcevaWelcome.swf", "tarceva", "660", "249", "8", "#fefefe");
    }
    else if (sect == 'nsclc_pc_index') {
    	so = new SWFObject("/flash/swf/faq_mini.swf", "faq_mini", "660", "200", "8", "#fefefe");
    	so.addVariable("xml_path", "/flash/xml/nsclc_pc_faq_mini.xml");
    }
    else if (sect == 'pan_pc_index') {
    	so = new SWFObject("/flash/swf/faq_mini.swf", "faq_mini", "660", "200", "8", "#fefefe");
    	so.addVariable("xml_path", "/flash/xml/pan_pc_faq_mini.xml");
    }
    else {
      so = new SWFObject('/flash/swf/tarceva.swf', 'tarceva', '660', '240', '8', '#fefefe');
    }
    // adding new parameters to the object/embed:
    
    so.addParam('salign', 'T');
    so.addParam('scale', 'noscale');
    so.addParam('wmode', 'opaque');
    so.addParam("menu", "false");
    so.addParam("swLiveConnect", "true");
    so.addParam("allowScriptAccess", "always");
		
    so.addVariable('CONFIG_XML','/flash/xml/config.xml');
    so.addVariable('CONTENT_XML','/flash/xml/'+sect+'.xml');
    so.addVariable('SECTION',sect);
    
    
    if (sect == 'landing') {
      so.write('nonflash_banner_landing');
    }
    else if (sect == 'nsclc_pc_index') {
    	so.write('patNSCLC-banner');
    }
    else if (sect == 'pan_pc_index') {
    	so.write('patPan-banner');
    }           
    else {
      so.write('nonflash_banner_pc');
    }
    
    if (so.installedVer.major >= 8) {
      createCookie('flashvOK','true',365);
    }
    else {    
      removeVideoLink();
      createCookie('flashvOK','false',365);
    }
  } 
}

function disableFlash(noflash) {
  createCookie('noflash',noflash,365);
  if (noflash == 'true') {
    writeFlashBanner();
    return false;
  }
  else {
    location.reload();
    return true;
  }
}

//Removes the video link div from the dom.
function removeVideoLink(){
  if (document.all && !document.getElementById) {
    document.all['view-video-link'].style.style = 'none';
  }
  else {
    document.getElementById('view-video-link').style.display = 'none'; 
  }
}

//Links to passed URL parameter. 
function linkTo(u) {
  location.href = u;
} 


// urchinTracker function calls google analytics tracking for flash pieces
function urchinTracker(whichURL) 
{
  var loc = whichURL;

    try {
      eventType = ""
      file_path = whichURL
      //production
    	if(location.href.indexOf("tarceva.com") > -1 ){
        pageTrackerProd1._trackPageview(file_path);
      }else{
        //qa
        if(location.href.indexOf("tarceva-qa.gene.com") > -1 ){
          pageTrackerQA._trackPageview(file_path);
        }else{
          //ua
          if(location.href.indexOf("tarceva-ua.gene.com") > -1 ){
            pageTrackerUA._trackPageview(file_path);
          }
        }
      }
    } catch(err) {}
}

function doLinkEvent(whichURL) {
	urchinTracker(whichURL);
} 

function openPIPopup(whichURL) {
	window.open(whichURL,'tarceva','width=700,height=500,top=0,left=0');
	window.open('http://www.gene.com/gene/products/information/pdf/tarceva-prescribing.pdf','pi','width=700,height=500,top=16,left=16');
}
