/******
MOD-001	01/04/2007	ACN		Mark Batac			HD04333953			Plavix.com- Regulatory Stemi- Language updates
******/


function showNav(tierASelected,tierBSelected,tierCSelected) {
	//menu =  "menu" + menuSelected;
	tierA = "A" + tierASelected;
	tierB = "B" + tierBSelected;
	tierC = "C" + tierCSelected;
	tierB_container = tierA + "B_container";
	tierB_item = tierA + tierB;
	tierC_container = tierB_item + "C_container";
	tierC_item = tierB_item + tierC;
//alert(tierA+"|"+tierB+"|"+tierC+"|"+ tierB_item +"|"+ tierC_item);
	targetTierA = document.getElementById(tierA);
	targetTierBContainer = document.getElementById(tierB_container);
	targetTierB = document.getElementById(tierB_item);
	targetTierCContainer = document.getElementById(tierC_container);
	targetTierC = document.getElementById(tierC_item);

	if(targetTierA) {
		targetTierA.className = "selected";
	}
	if(targetTierBContainer) {
		targetTierBContainer.className = "visible";
	}
	if(targetTierB) {
		targetTierB.className = "selected";
	}
	if(targetTierCContainer) {
		targetTierCContainer.className = "visible";
	}
	if(targetTierC) {
		targetTierC.className = "selected";
	}
	
	
}

function showSafetyInfo(page) {
	safetyPage = "/bms/safety_info/safety-" + page + ".asp"
	safetyWindow = window.open(safetyPage,'Safety_Window','scrollbars=auto,toolbar=no,status=no,location=0,resizable=yes,menubar=no,width=500,height=400');
	safetyWindow.focus();
}

function addtoFavorites (loc,title) {
	if (window.external) {
		window.external.AddFavorite(loc,title);
	} else {
		alert("Sorry! Your browser doesn't support this function.");
	}
}

//email this page

function __doPostBack(eventTarget, eventArgument) {
		var theform;
		if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
			theform = document.forms["Form1"];
		}
		else {
			theform = document.Form1;
		}
		theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
		theform.__EVENTARGUMENT.value = eventArgument;
		theform.submit();
	}
//resize text
function makeLarger(){
	createCookie1('fontSize','2','10');
	if(document.getElementById('home_middle')){
		document.getElementById('home_middle').className = "font_basesize-large";
		//document.getElementById('home_footer').className = "font_basesize-large";
		//document.getElementById('home_footer_important_info').className = "font_basesize-large";
		
	} else {
		document.getElementById('sub_content').className = "font_basesize-large";
		var sub_lnav_callout = document.getElementById('sub_lnav_callout');
		if (sub_lnav_callout != null)
		{
		  sub_lnav_callout.className = "font_basesize-large";
		}
	}
	if (document.getElementById('fontsizetoggle') != null){
		document.getElementById('fontsizetoggle').innerHTML = '<a href="javascript:void(0);" onclick="javascript:urchinTracker(\'/plavix/smalltype\'); makeSmaller();"><img src="/images/smallType.gif" alt="Small Type" title="Small Type"></a>';
	}	
		
}

function makeSmaller(){
	
	createCookie1('fontSize','1','10');
	if(document.getElementById('home_middle')){
		document.getElementById('home_middle').className = "font_basesize-normal";
		//document.getElementById('home_footer').className = "font_basesize-normal";
		//document.getElementById('home_footer_important_info').className = "font_basesize-normal";
	} else {
		document.getElementById('sub_content').className = "font_basesize-normal";
		var sub_lnav_callout = document.getElementById('sub_lnav_callout');
		if (sub_lnav_callout != null)
		{
		  sub_lnav_callout.className = "font_basesize-normal";
		}
	}
/*MOD-001   changed '.../common/obsClickLarge.jsp\' to '/common/obsClickLarge.jsp\'*/
	if (document.getElementById('fontsizetoggle') != null){
		document.getElementById('fontsizetoggle').innerHTML = '<a href="javascript:void(0);" onclick="javascript:urchinTracker(\'/plavix/largetype\'); makeLarger();"><img src="/images/largeType.gif" alt="Large Type" title="Large Type"></a>';
	}
}


function sizeToggle(){
	
	var cookie = readCookie1('fontSize');	
	if(cookie == '1' || cookie == null) {
		makeSmaller();
	}

	else {
		makeLarger();
	}
	
}

/*window.onload=function()
{
	sizeToggle();
}*/

function displayCookie(){
	fontSize = readCookie1('fontSize');
	document.write(fontSize);
}

function createCookie1(name,value,days){

	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
//	if (days != -1) alert('Cookie\n' + ck + '\ncreated');
	document.cookie = ck;
}

function readCookie1(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;
}

function eraseCookie(name){
	createCookie1(name,"",-1);
}

/* function handles the interstitial toggle*/
	function toggleInterstitial(url, e){
		interstitial = document.getElementById('interstitial2');
		if (url == 'close'){
				interstitial.style.display = "none";
				//interstitialContainer.innerHTML= "";
				return false;
			} else {
				moveObject(interstitial, e );
				interstitial.style.display = "block";
				//following needs to be uncommented for firefox - ie does not like it
				interstitial_Btns = document.getElementById('interstitial_btns');
				interstitial_Btns.innerHTML='<p><a href="#" onclick="return toggleInterstitial(\'close\', event);">&#60;&#60;Go Back</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://'+url+'" target="_new">Continue to <strong>'+url+'</strong> &#62;&#62;</a></p>';
				//interstitial_btns.innerHTML='<p><a href="#" onclick="return toggleInterstitial(\'close\');">&#60;&#60;Go Back</a></p>';
			}
		
		return false;
	}
function moveObject( obj, e ) {
  // step 1
  //alert(windowY);
  	var tempX = 0;
  	var tempY = 0;
  	var offset = 5;
  	var objHolder = obj;
	var windowHeight =  windowSize();
	var scrollY = getScrollXY();
  // step 3
  if (document.all) {
	// tempX = event.clientX + document.body.scrollLeft;
    //tempY = event.clientY + document.body.scrollTop;
	 tempX = document.body.scrollLeft;
    tempY = document.body.scrollTop;
  } else {
    tempX = e.pageX;
    tempY = e.pageY;
  }
  var tempY = 1 * scrollY + (windowHeight * .25);
	//alert(windowHeight + " | " + scrollY + " | " + placeY);

  // step 4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}

  // step 5
  obj.style.top  = (tempY + offset) + 'px';
  //obj.style.left = (tempX + offset) + 'px';
  }
//get window height + width
function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  	return  myHeight;
}
  
  
  
  
  
//gets scroll
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
//  return [ scrOfX, scrOfY ];
  return [ scrOfY ];
}	
	
	
function goBack() {document.location.href=document.referrer}
function XopenInterstitial(page) {
		interstitialWindow = window.open(''+page+'.htm','toolbar=no,status=no,location=0,resizable=yes,close=yes,menubar=no,width=450,height=350');
		interstitialWindow.focus();
	}	
	
	
// following function opens plavix pop up to go to hcp site	
function open_window(url){
	ansver=window.open(url,"ansver","width=600,height=300,toolbar=no,directories=0,status=0,menubar=no,resizable=yes,scrollbars=yes");
}	



/* function added to empty flash div due to audio problem in IE 6 */

var flashProxy;

function closeFlash(hide, empty) {
divToHide = document.getElementById(hide);

// Added code to remove any trace of the flash movie from the div- the DOM supported childnode and innerHTML
element = document.getElementById(empty);
	while (element.firstChild) {
 	element.removeChild(element.firstChild);
	}
element.innerHTML = " ";

flashProxy.call('stop'); // Call to flash movie to stop payment

// Finally we hide the div
divToHide.style.display = "none";
}

function toggleFlash(url, e){
interstitial = document.getElementById('procrit_panel');
//interstitialMask = document.getElementById('popUpMask');
moveObject_v2(interstitial, e );

//Call Flash via JS
//new unique id
var uid = Math.floor(Math.random()*1000000);

//new proxy		
flashProxy = new FlashProxy(uid, 'experiment2','flash/JavaScriptFlashGateway.swf');

//Flash Embed
var tag = new FlashTag('flash/plavix_anima.swf', 375, 322, '7,0,0,0');
tag.addFlashVar('lcId',uid);
tag.setId('experiment2');
var temp = tag.toString();

//alert(""+temp);
//document.getElementById('panel_video').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="375" height="322" id="experiment2" align="middle" >'+temp+'</object>';
document.getElementById('panel_video').innerHTML = ''+temp+'';

//fp.call('stop');
return false;
}

function moveObject_v2( obj, e ) {
  // step 1
  //alert(windowY);
  	//var obj2 = document.getElementById('popUpMask');
  	var tempX = 0;
  	var tempY = 0;
  	var offset = 5;
  	var objHolder = obj;
	var windowHeight =  windowSize_v2();
	var scrollY = getScrollXY_v2();
  // step 3
  if (document.all) {
	// tempX = event.clientX + document.body.scrollLeft;
    //tempY = event.clientY + document.body.scrollTop;
	 tempX = document.body.scrollLeft;
    tempY = document.body.scrollTop;
  } else {
    tempX = e.pageX;
    tempY = e.pageY;
  }
  var tempY = 1 * scrollY + (windowHeight * .25);
	//alert(windowHeight + " | " + scrollY + " | " + placeY);

  // step 4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}

  // step 5
 //alert("jkkdsjf sdkf");
  obj.style.top  = (tempY + offset) + 'px';
	
	//obj2.style.top  = (tempY + offset) + 'px';
  //obj.style.left = (tempX + offset) + 'px';
	//new Effect.Appear('popUpMask'); 
	new Effect.Appear('procrit_panel'); 
	return false; 
  }
//get window height + width
function windowSize_v2() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  	return  myHeight;
}
  
//gets scroll
function getScrollXY_v2() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
//  return [ scrOfX, scrOfY ];
  return [ scrOfY ];
}	

// New Functions created for pop up flash divs 5/23/06

// Global Variables (used in createFlash and destroyFlash)

flashpop_container = "flashpop_container"; // The outer container- this is the physical div you've embedded in the page
flashpop_window = "procrit_panel"; // The window that flash movie plays in, this ID will match your style sheet
flashpop_header = "panel_hdr"; // The header of the window, this ID will match your style sheet
flashpop_close = "panel_x"; // The id of the close button container, this ID will match your style sheet
flashpop_video = "panel_video"; // the container of the actual flash movie, this ID will match your style sheet
page_container = "top_logo_hdr"; // the id of the overall page container.  We use this to center our flash div
pathToFlash = "/flash/"; // The path to the flash movie

function createFlash (id, file, width, height){
	var url = pathToFlash + file;
	

	// Build the container window
	var container = document.createElement("div");
	container.setAttribute('id', flashpop_window);

	// Build the header
	var hdr = document.createElement("div");	
	hdr.setAttribute('class', flashpop_header);

	// Build the Close button
	var panel = document.createElement("div");	
	panel.setAttribute('class', flashpop_close);
	
	// Create the link to close
	var closeButton = document.createElement("a");
	var urlString;
	urlString = "return closeFlash('" + id + "');";
	closeButton.setAttribute('onclick', 'destroyFlash("' + flashpop_window + '"); return false;');
	closeButton.setAttribute('href', '#'); 
	
	// The actual close button image
	var closeImage = document.createElement("img");
	closeImage.setAttribute('src', '/images/close_x.jpg');
	closeImage.setAttribute('alt', 'Close this animation');
	closeImage.setAttribute('width', '15');
	closeImage.setAttribute('height', '14');
	
	// Form up
	closeButton.appendChild(closeImage);
	panel.appendChild(closeButton);
	hdr.appendChild(panel);
	
	// Build the flash container
	var videoContainer = document.createElement("div");
	videoContainer.setAttribute('id', flashpop_video);
	
	// Form up - attach the header and flash container to the overall container window
	container.appendChild(hdr);
	container.appendChild(videoContainer);
	
	// Attach this to our hard coded DIV
	obj = document.getElementById(flashpop_container);
	obj.appendChild(container);
	document.getElementById(flashpop_container).innerHTML = document.getElementById(flashpop_container).innerHTML; // Necessary for IE6
	
	// Call SWFObject script to construct flash object
	var flashObj = new SWFObject(url, id, "375", "322", "7", "#ffffff");
	flashObj.write(flashpop_video);
	
	// Finally, position window and show
	moveWindow(flashpop_container, page_container);
	document.getElementById(flashpop_container).style.display = "block";
}


function destroyFlash (id) {
	// Due to a bug in IE6 with the audio, we must create a dummy flash object before destroying it.
	garbage = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\"><param name=\"movie\" value=\"/flash/garbage.swf\" /></object>";
	// Replace old with new
	document.getElementById(flashpop_window).innerHTML = garbage;
	element = document.getElementById(flashpop_container);
	// Remove all	
		while (element.firstChild) {
		element.removeChild(element.firstChild);
		}
	// Hide it 
	document.getElementById(flashpop_container).style.display = "none";
}

function moveWindow (obj, container) {
var leftPos;
var topPos;
var divCenter;
	// Use existing function to grab the Y coordinate for scrolling
var scrollY = getScrollXY_v2();
scrollY = parseInt(scrollY);

// Get the width of the container div so we can center to it

divWidth = document.getElementById(container).offsetWidth;

// Get the windows width and height

	if (window.innerWidth) {
	windowWidth = window.innerWidth;
	windowHeight = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
	windowWidth = document.documentElement.clientWidth;
	windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
	windowWidth = document.body.clientWidth;
	windowHeight = document.body.clientHeight;
	}

// Position the element on screen
leftPos = (windowWidth * .25);
topPos = windowHeight * .25;
document.getElementById(obj).style.left = leftPos + "px";	
document.getElementById(obj).style.top = topPos + scrollY + "px";
return false; 
}

function getInternetExplorerVersion(){
  // Returns the version of Internet Explorer or a -1
  // (indicating the use of another browser).

  var rv = -1; // Return value assumes failure
  if (navigator.appName == 'Microsoft Internet Explorer'){
    var ua = navigator.userAgent;
    var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
       rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
printPreview = false;
function openPrintPreview(url) {
var printPreview = "true";
var newURL = url + "&printPreview=" + printPreview;
window.open(newURL, "", "width=625, scrollbars=yes");	
//printerFriendlyView();
}

function printerFriendlyView() { 
  if(getInternetExplorerVersion() == -1){
 	document.styleSheets[0].disabled = true;
    document.styleSheets[1].disabled = false;   
 } else{
 document.styleSheets[0].href = "/css/print.css";
 }
      
}
function get(name) {
var q = unescape(location.search.substring(1)).split(/[=&]/);
	for (var j=0; j<q.length; j+=2) {
		if (q[j] == name) {
		return q[j+1];
		}
	}
return null;
}

function init() {
	if (get("printPreview") != null) {
	printerFriendlyView();
	}
}
var thisPage = window.location.href;
thisPage = thisPage.replace(/#/,"");
init();
