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 SearchValidator(JustinForm) 
{
	if(JustinForm.Criteria.value == "") 
	{
    	alert("Please enter a keyword to search for.");
        JustinForm.Criteria.focus();
        return(false);	
	}
	return true;
}

function just_email(put_form_field_here, who) 
{
    // this is e-mail validation function
    var emailStr = put_form_field_here;
    var emailPat=/^(.+)@(.+)$/
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
    var validChars="\[^\\s" + specialChars + "\]"
    var quotedUser="(\"[^\"]*\")"
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom=validChars + '+'
    var word="(" + atom + "|" + quotedUser + ")"
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
    var matchArray=emailStr.match(emailPat)
    if (matchArray==null) 
    {
    	alert(who + " e-mail address seems to be incorrect (check @ and .'s)")
    	return false
    }
    var user=matchArray[1]
    var domain=matchArray[2]
    if (user.match(userPat)==null) 
    {
        alert("The email address doesn't seem to be valid.")
        return false
    }
    var IPArray=domain.match(ipDomainPat)
    if (IPArray!=null) 
    {
	  for (var i=1;i<=4;i++) 
	  {
	    if (IPArray[i]>255) 
	    {
	        alert("Destination IP address is invalid!")
		return false
	    }
      }
      return true
    }
    var domainArray=domain.match(domainPat)
    if (domainArray==null) 
    {
    	alert("The domain name doesn't seem to be valid.")
        return false
    }
    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) 
    {
        alert("The address must end in a three-letter domain, or two letter country.")
        return false
    }
    if (len<2) 
    {
        var errStr="This address is missing a hostname!"
        alert(errStr)
        return false
    }
    return true;
}
// end of just_email function

function form_validator2(emailFriend)
{	
	if(emailFriend.SenderName.value == "") 
	{
         alert("Please enter your name.");
         emailFriend.SenderName.focus();
         return(false);
    }
	if (!just_email(emailFriend.SenderEmail.value,"Your"))
	{
		emailFriend.SenderEmail.focus();
		return(false);
	}
	
	if(emailFriend.friendName.value == "") 
	{
         alert("Please enter your friend's name.");
         emailFriend.friendName.focus();
         return(false);	
	}
	if (!just_email(emailFriend.friendEmail.value,"Your friend's"))
	{
		emailFriend.friendEmail.focus();
		return(false);
	}
	return true;
}

function leaveSite(site,urlid)
{
       var msg ='Please note: You are about to leave this site to go to another Bristol-Myers Squibb/Sanofi Pharmaceuticals Partnership site.';
       if (confirm(msg) == 1) 
       {
        		var obsPage = site+"?urlId="+urlid;
    			window.open(obsPage, 'perceptions','toolbar=yes,width=600,height=400,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes,location=yes');
        }
    }



    function demoLegal() {

        /*var width = 860;
        var height = 400;
        var left = (screen.width - width) / 2;
        var top = (screen.height - height) / 2;
        var params = 'width=' + width + ', height=' + height;
        params += ', top=' + top + ', left=' + left;
        params += ', directories=no';
        params += ', location=no';
        params += ', menubar=no';
        params += ', resizable=no';
        params += ', scrollbars=no';
        params += ', status=no';
        params += ', toolbar=no';
        params += ', copyhistory=no';*/
        webaddress = 'http://www.padcoalition.org/resources/'
        var viewimageWin = window.open(webaddress, '_blank');
        return false;


    }
		
function leaveSite2(site,urlid) 
{
       var msg = 'Please note: You are about to leave the Bristol-Myers Squibb/Sanofi Pharmaceuticals Partnership Padfacts.com site. The site you are linking to is not controlled or endorsed by the Bristol-Myers Squibb/Sanofi Pharmaceuticals Partnership, and we are not responsible for the content provided on that site. Your linking to any off-site page or other site is at your own risk.';
       if (confirm(msg) == 1) 
       {
        		var obsPage = site+"&urlId="+urlid;
  			window.open(obsPage, 'perceptions','toolbar=yes,width=600,height=400,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes,location=yes');
       	}
}


//function NetscapeLinkWindow(netscapelink) 
//{
//    PopUp = window.open(netscapelink,"NetscapeLinkWindow",'height=125,width=400,location=no,scrollbars=no,menubars=no,toolbar=no,resizable=yes');
//}

//function privacyLegalWindow(netscapelink) 
//{
//    PopUp = window.open(netscapelink,"PrivacyLegalWindow",'height=400,width=700,location=no,scrollbars=yes,menubars=no,toolbar=no,resizable=yes');
//}

//function CreateExternalWindow(input) 
//{
//	PopUp = window.open(input, 'perceptions','toolbar=yes,width=600,height=400,directories=yes,status=yes,scrollbars=yes,resizable=yes,menubar=yes');
//}

//function CreateBMSWindow(input)	
//{
//  PopUp = window.open(input, 'perceptions', 'toolbar=yes,width=600,height=400,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes,location=yes');
//}

//function popup(path,width,height)
//{
//    clickpop=window.open(path,"clickpop","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,top=100,left=100,width=" + width + ",height=" + height + "\"")
//}
//function open_movie(url)
//{ 
//	ansver=window.open(url,"ansver","width=375,height=350,toolbar=no,directories=0,status=0,menubar=no,resizable=no,scrollbars=no");
//}
// function MM_jumpMenu(targ,selObj,restore)
// { 
//        //v3.0
//        eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
//        if (restore) selObj.selectedIndex=0;
// }

/* 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();
}

function InvokeFloodlightTagOnClick(category) {
    var newimage = document.createElement('script');
    var axel = Math.random() + "";
    var a = axel * 10000000000000;
    var source = "http://fls.doubleclick.net/activityj;src=2381095;type=padls528;cat=" + category + ";ord=" + a + "?"
    newimage.setAttribute("src", source);
}