function back()
{
	window.history.back()
	}
	
function forward()
{
	window.history.forward()
	
}




function exitSite(destination)
{

	openWin(window.root + 'exit_site.aspx?destination=' + destination ,'pop_up','width=605,height=500,scrollbars=auto');
}


function exitSanofi(destination)
{

	openWin(window.root + 'exit_site_aventis.aspx?destination=' + destination ,'pop_up','width=605,height=263,scrollbars=auto');
}


function exitSanofiSite(destination)
{

	openWin(window.root + 'exit_site_aventis.aspx?destination=' + destination ,'pop_up','width=605,height=263,scrollbars=auto');
}








function openPrintWindow(page_uri,crc,showfair,pagetit,pagehea) {
openWin('/consumer/common/OpenPrinterFriendly.do?crc='+escape(crc)+'&pagehea='+escape(unescape(pagehea))+'&pagetit='+escape(unescape(pagetit))+'&showfair='+escape(showfair)+'&page_uri='+escape(page_uri),'Print','toolbar=yes,menubar=yes,scrollbars=yes,status=no,width=590,height=600,top=(screen.availHeight-600)/2, left=(screen.availWidth-600)/2');
}

function openMailWindow(pagetitle) {
		if (window.location.href.indexOf('?') == -1){
	openWin('/consumer/common/email.do?pageLink='+escape(document.location.href)+'&pageTitle='+escape(unescape(pagetitle)),'Email','resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=yes,width=590,height=630,top=(screen.availHeight-380)/2, left=(screen.availWidth-480)/2');
		}
		else {
	openWin('/consumer/common/email.do?pageLink='+escape(document.location.href)+'&pageTitle='+escape(unescape(pagetitle)),'Email','resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=yes,width=590,height=630,top=(screen.availHeight-380)/2, left=(screen.availWidth-480)/2');
		}
}

dayName = new Array ("SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY")
monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

now = new Date()

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];}}
}





var theImages = new Array() 

 

theImages[0] = '/images/information/stories/1.gif' 
theImages[1] = '/images/information/stories/2.gif' 
theImages[2] = '/images/information/stories/3.gif' 
theImages[3] = '/images/information/stories/4.gif' 
 


var j = 0 
var p = theImages.length; 
var preBuffer = new Array() 
for (i = 0; i < p; i++){ 
   preBuffer[i] = new Image() 
   preBuffer[i].src = theImages[i] 
} 
var whichImage = Math.round(Math.random()*(p-1)); 
function showImage(){ 
document.write('<img src="'+theImages[whichImage]+'">'); 
} 

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_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 MM_openBrWindow(theURL,winName,features) { //v2.0
  openWin(theURL,winName,features);
}


function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
toGoTo = "http://www.aventis.com/";

function openEmailWindow(){
	
	//var thisUrl = "/information/EmailToAFriend.jsp?pageLink="+escape(document.location.href)"+title="+escape(document.title);
	var thisUrl = '/information/EmailToAFriend.jsp?title='+escape(document.title)+'&pageLink='+escape(document.location.href);
	MM_openBrWindow(thisUrl,'email','width=515,height=475,menubar=0,toolbar=0,resizable=0,scrollbars=0');
}
function popUp(newURL){
  toGoTo='warning.html?shawn='+newURL;
  Jiminy=window.open(toGoTo,'Jiminy','width=500,height=400');
}
function sendThrough() {
  Jiminy.close();
  DestiNation=window.open(toGoTo,'theTarget','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
  //document.location.href=toGoTo;  
}



// constructor function (x,y optional)
function writeObj(id,wd,ht,x,y) {
	
	if (!id) return;	// for when writeObj used as prototype
	if (document.getElementById||document.all) {
		this.el = (document.getElementById)? document.getElementById(id): document.all[id];
		this.css = this.el.style;	this.doc = this.el;
		this.css.width=wd+"px"; this.css.height=ht+"px";
  } else if (document.layers) {
		var lyrRef = getLyrRef(id,document);	// in case id nested
		// create layer inside to write to
		// in case id relative positioned
		this.el = new Layer(wd,lyrRef);	
		lyrRef.resizeTo(wd,ht);
		this.el.visibility = "inherit";	// new Layer initially hidden
		this.doc = this.el.document;	// write to inner layer
		// use outer layer for shifting, show/hide
		this.css = this.el.parentLayer; 
	} else return null; // (if not ...byId or ...all or ...layers)
	var px = (document.layers)? "": "px";
	this.x = x || 0;	if (x) this.css.left = this.x+px;
	this.y = y || 0;	if (y) this.css.top = this.y+px;
	this.obj = id+"Object"; eval(this.obj+"=this");	// used by banner
}

//  Methods
function dw_writeLyr(cntnt) {
	if (typeof this.doc.innerHTML!="undefined") {
      this.doc.innerHTML = cntnt;
  } else if (document.layers) {
			this.doc.write(cntnt);
			this.doc.close();
  }
}

function dw_show() { this.css.visibility = "visible"; }
function dw_hide() { this.css.visibility = "hidden"; }

function dw_shiftTo(x,y) {
	if (x!=null) this.x=x; if (y!=null) this.y=y;	
	if (this.css.moveTo) { 
		this.css.moveTo(Math.round(this.x),Math.round(this.y)); 
	} else { 
		this.css.left=Math.round(this.x)+"px"; 
		this.css.top=Math.round(this.y)+"px"; 
	}
}

function dw_shiftBy(x,y) {
	this.shiftTo(this.x+x,this.y+y);
}


writeObj.prototype.writeLyr = dw_writeLyr;
writeObj.prototype.show = dw_show;
writeObj.prototype.hide = dw_hide;
writeObj.prototype.shiftTo = dw_shiftTo;
writeObj.prototype.shiftBy = dw_shiftBy;


function getScrollY() {
	var scroll_y = 0;
	if (document.documentElement && document.documentElement.scrollTop)
		scroll_y = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) 
		scroll_y = document.body.scrollTop; 
	else if (window.pageYOffset)
		scroll_y = window.pageYOffset;
	else if (window.scrollY)
		scroll_y = window.scrollY;
	return scroll_y;
}

function getScrollX() {
	var scroll_x = 0;
	if (document.documentElement && document.documentElement.scrollLeft)
		scroll_x = document.documentElement.scrollLeft;
	else if (document.body && document.body.scrollLeft) 
		scroll_x = document.body.scrollLeft; 
	else if (window.pageXOffset)
		scroll_x = window.pageXOffset;
	else if (window.scrollX)
		scroll_x = window.scrollX;
	return scroll_x;
}



function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}

function openWin( windowURL, windowName, windowFeatures) {
     winhandle = window.open( windowURL, windowName, windowFeatures ) ;
	 try {
	 	winhandle.focus();
	}
	catch(err) {
		alert("To view this information, please disable your popup blocker or add www.aventisoncology.com to your safe list");
	}
};



// Upload Functions Start


  function getFileName(fullPath) {
    var ffullname = fullPath;
    var fname = "-1";
    ffullname =ffullname.toUpperCase();
    if ((fullPath != "") && (fullPath!=null) )
      fname=ffullname.substring(ffullname.lastIndexOf("\\") + 1,ffullname.length);
    return fname;

  }




function searchFileList(ff,destFileList) {


     fileNameList = new Array(5) ;
     fileNameList[0] = getFileName(ff.fileToAdd0.value);
     fileNameList[1] = getFileName(ff.fileToAdd1.value);
     fileNameList[2] = getFileName(ff.fileToAdd2.value);
     fileNameList[3] = getFileName(ff.fileToAdd3.value);
     fileNameList[4] = getFileName(ff.fileToAdd4.value);
     fsubmit = "0" ;
     fmessage = "" ;
     overwrite = "";
     for (var j = 0; j < fileNameList.length; j++) {
       if (fileNameList[j]!="-1")
         fsubmit = "1" ;  
     }
     
    if (fsubmit=="0") {
       alert("Select one or more files to submit!");
       return ;
    }
  
  
   
     for (var i = 0; i < destFileList.length; i++)
       for (var j = 0; j < fileNameList.length; j++) {
        if (fileNameList[j]!="-1")
          if (destFileList[i]==fileNameList[j]) {
            if (fmessage == "")
                fmessage =  fileNameList[j] ;
             else
                fmessage =  fmessage + "," +  fileNameList[j] ;
            fsubmit = "0"
          }
     }
     
     if (fsubmit=="0") {
     fmessage =  fmessage + " already exists in the destination directory!Press OK to overwrite any existing files in the destination directory"
      var return_value = confirm(fmessage);
       if ( return_value == true ) {
        ff.submit();  
       } else {
         return null ;
       }
     } else {
        ff.submit();  
     }
 


}

// Upload Functions End

//helper methods for form validation
function isblank(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

function validEmail (email) {//N
			 //first check for presence of invalid characters
				var invalidChars = " /:,;"
				for (i=0; i<5; i++) {//G
				badChar = invalidChars.charAt(i)
				if (email.indexOf(badChar,0) > -1) {//H
						return (false);
					}//-H
					
				}//-G    
				//next check for presence of one @ character
				var atPos = email.indexOf("@",1);
					if (atPos == -1) {//I
						return (false);
				}//-I
				if (email.indexOf("@",atPos+1) > -1) {//J
						return (false);
				}//-J
				//next check for period
				var periodPos = email.indexOf(".",atPos);
				if (periodPos == -1) {//K
						return (false);
				}//-K
				if (periodPos+3 > email.length) {//L
						return (false);
				}//-L
		return (true);
	}//-N
	
function validateEmailToFriendForm(f)
{
	var message = "";
	if (isblank(f.toAddress.value))
	{
		message += "- Recipient's e-mail address is required.\n";
	}
	else
	{
		if (!validEmail(f.toAddress.value))
		{
			message += "- Recipient's e-mail address must be a valid e-mail address.\n";
		}
	}
	
	if (isblank(f.yourName.value))
	{
		message += "- Your name is required.\n";
	}
	
	if (isblank(f.fromAddress.value))
	{
		message += "- Your e-mail address is required.\n";
	}
	else
	{
		if (!validEmail(f.fromAddress.value))
		{
			message += "- Your e-mail address must be a valid e-mail address.\n";
		}
	}
	
	if (!message)
	{
		return true;
	}
	else
	{
		alert(message);
		return false;
	}
}

function verifyKeyword(document)
	{
		var errorText="";
		var errorFlag=false;
		//document.keywordform.productname.value=document.keywordform.product.options[document.keywordform.product.selectedIndex].text;
		if(document.keywords.value=='')//check if the keywords entered are null
		{
			alert("Please enter the keywords");
			return false;
		}
		else
		{
			var keywords = document.keywords.value;
			if(keywords.indexOf(",")==0)// check if the keywords start with ,
			{
				errorText += "The keywords should not start with comma(,) \n";
				errorFlag=true;
			}
			if(keywords.lastIndexOf(",")==(keywords.length)-1)// check if the keyword end with comma
			{
				errorText += "The keywords should not end with comma(,) \n";
				errorFlag=true
			}
			if(keywords.indexOf(",,") != -1)// check if there are consecutive keywords
			{
				errorText += "Consecutive commas not allowed \n";
				errorFlag=true
			}
		}
		
		
		if(keywords.indexOf(" ")  == 0)
		{
			errorText += "Keyword should not start with a space \n";
			errorFlag=true
		}
		
		len = keywords.length

		if(keywords.charAt(len-1)  == ' ')
		{
			errorText += "Keyword should not end with a space \n";
			errorFlag=true
		}
		
		//keyword = keyword.trim();

		keywordArray = keywords.split(" ");
		
		if(keywordArray.length > 6)
		{
			errorText += "Single phrase in keywords entered for a letter \ncan contain maximum up to 6 words only  \nYou have entered a phrase \'"+keywords+"\' \nwhich contains " + keywordArray.length +" words ";
			errorFlag=true
		}
		
		if(errorFlag==true)// if there is error alert the user
		{
			alert(errorText);
			return false;
		}
				
		var productText="";
		var selectedFlag=false;
		
		return true;
	}

function verifyComments(feedForm)
{
	var errorText ="Please fill in all the information \n";
	var errorFlag=false;

	if(feedForm.yourName.value == '')
	{
		errorText += "-Name \n";
		errorFlag=true;
	}
	
	if(feedForm.comment.value == '')
	{
		errorText += "-Comment \n";
		errorFlag=true;
	}
	

	if(feedForm.fromAddress.value == '')
	{
		errorText += "-Email \n";
		errorFlag=true;
	}else
	{
		if(!validEmail2(feedForm.fromAddress.value))
		{	
			errorText += "-Email not valid \n";
			errorFlag=true;
		}
	}
	 
	if(errorFlag)
	{
		alert(errorText);
		return false;
	}
}

function validEmail2 (emailStr)
		 {
		
		/*if(i=0;i<emailStr.length; i++)
		{
			if(email.charAt(i)=="#" || email.charAt(i)=="*" ||  email.charAt(i)=="$" ||  email.charAt(i)=="&" ||  email.charAt(i)=="^" ||  email.charAt(i)=="!")
		}*/
		/* The following pattern is used to check if the entered e-mail address
		   fits the user@domain format.  It also is used to separate the username
		   from the domain. */
		var emailPat=/^(.+)@(.+)$/
		/* The following string represents the pattern for matching all special
		   characters.  We don't want to allow special characters in the address. 
		   These characters include ( ) < > @ , ; : \ " . [ ]    */
		var specialChars="\\(\\)<>#!%^&*$@,;:\\\\\\\"\\.\\[\\]"
		/* The following string represents the range of characters allowed in a 
		   username or domainname.  It really states which chars aren't allowed. */
		var validChars="\[^\\s" + specialChars + "\]"
		/* The following pattern applies if the "user" is a quoted string (in
		   which case, there are no rules about which characters are allowed
		   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		   is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")"
		/* The following pattern applies for domains that are IP addresses,
		   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		   e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		/* The following string represents an atom (basically a series of
		   non-special characters.) */
		var atom=validChars + '+'
		/* The following string represents one word in the typical username.
		   For example, in john.doe@somewhere.com, john and doe are words.
		   Basically, a word is either an atom or quoted string. */
		var word="(" + atom + "|" + quotedUser + ")"
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		/* The following pattern describes the structure of a normal symbolic
		   domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		
		
		/* Finally, let's start trying to figure out if the supplied address is
		   valid. */
		
		/* Begin with the coarse pattern to simply break up user@domain into
		   different pieces that are easy to analyze. */
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
		  /* Too many/few @'s or something; basically, this address doesn't
			 even fit the general mould of a valid e-mail address. */
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		
		// See if "user" is valid 
		if (user.match(userPat)==null) {
			// user is not valid
			  return false
		}
		
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		   host name) make sure the IP address is valid. */
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			// this is an IP address
			  for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					return false
				}
			}
			return true
		}
		
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			   return false
		}
		
		/* domain name seems valid, but now make sure that it ends in a
		   three-letter word (like com, edu, gov) or a two-letter word,
		   representing country (uk, nl), and that there's a hostname preceding 
		   the domain or country. */
		
		/* Now we need to break up the domain to get a count of how many atoms
		   it consists of. */
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) {
		   // the address must end in a two letter or three letter word.
			  return false
		}
		
		// Make sure there's a host name preceding the domain.
		if (len<2) {
		   var errStr="This address is missing a hostname!"
		   return false
		}
		
		// If we've gotten this far, everything's valid!
		return true;
	}
	
//newly added functions for search

function submitSearchForm()
{
 if (validateSearchForm()) {
    window.location=window.root+'searchResults.aspx?q='+document.getElementById("ctl00_search1_searchText").value;
   }
    return false;
}

function validateSearchForm()
{
    var valid = true;
    if (document.getElementById('ctl00_search1_searchText').value == "Search" || 
    document.getElementById('ctl00_search1_searchText').value.length == 0 ) {
 	    window.alert ("Please enter a search text.");
  		valid = false;
 	}
 	else
 	{
 	    var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
 		for (var i = 0; i < document.getElementById('ctl00_search1_searchText').value.length; i++) {
  		    if (iChars.indexOf(document.getElementById('ctl00_search1_searchText').value.charAt(i)) != -1) {
  			    window.alert ("Your search text has special characters. \nThese are not allowed.\nPlease remove them and try again.");
  			    valid = false;
  			    break;
  	        }
        }
     }
     return valid;
}
function doClear(theText)
{ 
    if (theText.value == theText.defaultValue) 
    {
        theText.value = "";
    }
} 