﻿// JS File Used By General Lexapro Site Pages. Includes stylesheet switching cookie inclusion in Onload functionality.

/*print page function*/
function print_page(){ 

if ( navigator.platform.toLowerCase().indexOf("mac") != -1 && 
!window.netscape){ 
alert("The browser version you are currently running is not supported. Please press Command + P to open the print dialog box."); 


}else{ 
window.print(); 
} 
}

/***********************Cookie functions and opening window by setting cookie**********************************/
function openLinkAndSetCookies(url)
{
	//Set the cookie
	Set_Cookie( 'Animate', 'Y', 1, '/', '', '' );
	window.location.href = url;
}

//COOKIE FUNCTIONS
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
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" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
	
// this deletes the cookie when called
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";
}
	
/****************************************************************************************************/


/* Open window*/

function openWindow(theURL,winName,features) { //v2.0
  var newWindow = window.open(theURL,winName,features);
  newWindow.focus();
}

/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_over'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_over'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

//window.onload = initRollovers;

function ClearField(TextBox) {
	TextBox.value = '';
}

function handleEnter (event, buttonReference) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		buttonReference.click();
		return false;
	} 
	else
		return true;
}  

//Code for cookies for WEBTRENDS REPORTS - PLEASE DO NOT DELETE
 var date = new Date();
 date.setTime(date.getTime()+(365*24*60*60*1000));
 var expires = "; expires="+date.toGMTString();

 window.onload = function(e) {
   document.cookie = "lexapro=website"+expires+"; path=/";
   initRollovers();
   //stylesheet cookies
   var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
 }

 window.onunload = function(e) {
  document.cookie = "lexapro=website"+expires+"; path=/";
  //stylesheet cookies
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}
// POPUP WINDOW CONFIRMATION TO LEAVE Lexapro.COM
	function exitPop(url) {

     	  	newwin = window.open("../../confirmNewWindow.aspx?url=" + url, "exitWin", 'toolbar=0,location=0,directories=0,scrollbars=0,status=0,menubar=0,resizable=0,width=400,height=175');

     	  	newwin.creator = top;

			newwin.focus();
			return false;
	}
		function go(url) {
		//window.opener.location.href=url;
		window.open(url);
		//window.open.=url;
		window.close(self);
		return false;
	}
	
// GLOSSARY POP UP WINDOW
function PopUp(ref)
{	
	var strFeatures="toolbar=no,status=no,menubar=no,location=no"
	strFeatures=strFeatures+",scrollbars=yes,resizable=no,height=320,width=500"
	
	newWin = window.open(ref,"TellObj",strFeatures);
       newWin.opener = top;
}

function confirm_ex(anchor)
  {
    if (confirm('You are now leaving the Lexapro (escitalopram oxalate) Website. Links to other Websites are provided as a service to you. Forest accepts no responsibility for the content of other Websites. Would you like to continue?'))
    {
    anchor.href += '&confirm=1';
	return true;
    }
    return false;
  }
function confirmRus_ex(anchor)
  {
    if (confirm('Вы теперь оставляете Lexapro (escitalopram oxalate) Вебсайт. Связи с другими Вебсайтами обеспечиваются как обслуживание к Вам. Forest не несет никакой ответственности за содержание других Вебсайтов. Хотите ли Вы продолжить?'))
    {
    anchor.href += '&confirm=1';
	return true;
    }
    return false;
  }
  
// code for survey DO NOT REMOVE
