// script for shadow
//alert('====>'+window.root+'<====');
	
function RollOn(objPic)
{
	objPic.src=objPic.src.replace("_off","_on");
}

function RollOff(objPic)
{
	objPic.src=objPic.src.replace("_on","_off");
}

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 change(id, newClass) 
{
    identity=document.getElementById(id); identity.className=newClass;
}
function openAnimation(url,props) {
    openWin(window.root+url,'DVTAnimation',props);
}


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_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_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;
}


function openWin( windowURL, windowName, windowFeatures) 
{
    window.open( windowURL, windowName, windowFeatures );
}

function closeWin() 
{
	setTimeout("self.close()",500);
}

function RedirWin(url)
{
        openWin(url);
}

// excapes url that will be passed
// for use with multiple querystrings
function exitEscape(destination)
{
    destination = escape(destination);
    openWin(window.root+'exitsite_pop.aspx?destination=' + destination ,'pop_up','width=580,height=400,scrollbars=yes');
}

function openReferences(id) 
{
	if (id == null) 
	{
		openString = window.root+'references.aspx';
	} 
	else {
		openString = window.root+'references.aspx' + id;
	}
	openWin(openString,'References','toolbar=no,menubar=no,scrollbars=yes,status=no,width=570,height=480,top=(screen.availHeight-600)/2, left=(screen.availWidth-600)/2');
}
function openReferenceshcp(id) 
{
	if (id == null) 
	{
		openString = window.root+'referenceshcp.aspx';
	} 
	else {
		openString = window.root+'referenceshcp.aspx' + id;
	}
	openWin(openString,'References','toolbar=no,menubar=no,scrollbars=yes,status=no,width=570,height=480,top=(screen.availHeight-600)/2, left=(screen.availWidth-600)/2');
}

function exitSite(destination)
{
	openWin(window.root+'exitsite_pop.aspx?destination=' + destination ,'pop_up','width=580,height=400,scrollbars=yes');
}

function exitConsumerSite(destination)
{
	openWin(window.root+'exitsite_pop.aspx?destination=' + destination ,'pop_up','width=580,height=350,scrollbars=no');
}

function exitToSanofiAventisSite(destination)
{
	openWin(window.root+'interstitial_pop.aspx?logo=full&destination=' + destination ,'pop_up','width=500,height=300,scrollbars=auto');
}

function openComingSoon()
{
	openWin('/common/comingsoon.do' ,'pop_up','width=560,height=400,scrollbars=yes');
}

function demonstration()
{
	openWin('/common/demonstration.do' ,'pop_up','width=560,height=530,scrollbars=yes');
}

function openPI()
{
	openWin('http://products.sanofi-aventis.us/lovenox/lovenox.html' ,'pop_up','width=450,height=500,scrollbars=yes');
}

function OpenPopup(filename)
{
	openWin(filename,'pop_up','width=580,height=400,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes');
}

function OpenPopupNoScrollbars(filename)
{
	openWin(filename,'pop_up','width=580,height=400,scrollbars=no');
}

function Animations(filename)
{
	openWin(filename,'pop_up','width=640,height=480,scrollbars=no,toolbar=no,menubar=no,resizable=yes');
}

function confirmHcp()
{ 
	var bln = confirm('This information is intended for U.S. Healthcare Professionals.\nIf you are a Healthcare Professional, click ok to continue.');
	if (bln)
	{
		window.location.href=window.root+'hcp/default.aspx';
	}
}

function writeCookie(name, value, hours) {
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire; }

function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function showISI() {
	MM_showHideLayers('divFlash','','show')
	window.document.lovenox_scroller_ci.Play();
}



// excapes url that will be passed
// for use with multiple querystrings
function exitEscape(destination)
{
    destination = escape(destination);
    openWin(window.root+'exitsite_pop.aspx?destination=' + destination ,'pop_up','width=580,height=400,scrollbars=yes');
}


function submitSearchForm()
{
    if (validateSearchForm()) {
        window.location=window.root + 'hcp/search_results.aspx?q=' + document.getElementById("ctl00_Top2_SearchText").value;
    }
    return false;
}

function submitSearchFormPatient()
{
    var searchTerm = "ctl00_top1_SearchText";
    if (validateSearchForm(searchTerm)) {
        window.location=window.root + 'consumer/search_results_intermediate.aspx?q=' + document.getElementById(searchTerm).value;
    }
    return false;
}

function validateSearchForm(searchTerm)
{
    var valid = true;
    
    if (document.getElementById(searchTerm).value.length == 0 ) {
 	    window.alert ("Please enter a search text.");
  		valid = false;
 	}
 	else
 	{
 	    var iChars = "!@#$%^&*()+=-[]\';,.{}|\":<>?";
 		for (var i = 0; i < document.getElementById(searchTerm).value.length; i++) {
  		    if (iChars.indexOf(document.getElementById(searchTerm).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;
}

//send to a friend validations
function validateMultipleEmails(source, args) 
{
    args.IsValid = true;
    
    var emails = document.getElementById('ctl00_ContentPlaceHolder1_send_to_friend_page_control1_ToEmailAddress').value;
    if (emails != "") {
        var email = emails.split(';');
        for (var i = 0; i < email.length; i++) {
            if (!validateEmail(email[i])) {
                args.IsValid = false;
                return;
            }
        }
    }
}

function validateEmail(email) {
    var objRegExp  = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2,3})$/
    return objRegExp.test(email);
}

function gotoGlossary(term) 
{
    window.location = window.root+ 'hcp/Glossary.aspx#'+term;
}

function openMoa()
{
    openWin(window.root + 'docs/swf/physician/moa.htm','Moa','width=800,height=600,scrollbars=no');
}

function openAnim(url,props) {
    openWin(window.root+url,'DVTAnimation',props);
}


function openKyr(loc)
{
    var props = 'width=580,height=600,toolbar=no,scrollbars=yes,menubar=yes,resizable=yes';
    openWin(window.root + loc,'kyrsub',props);
}

function goHref(loc)
{
    opener.location.href = window.root + loc;
}

function gameSpot(fromId, toId)
{
    /*var temp = document.getElementById(fromId).value;
    document.getElementById(toId).value = temp;*/
}

function showAnswer(classname)
{
    var counter;
    if(classname == "ga")
    {
        counter = 51;
    }else{
        counter = 32;
    }

    var di;
    for(var i = 1; i <= counter; i++)
    {
        di=document.getElementById(classname + i);
        di.style.display = "block";
        di.style.outline= "white solid 0px";
    }
}


/* * * * * * * * * * * * * */
/* Spotlight PDF Tracking */
function trackclick(cat) {
	var axel = Math.random() + "";	
	var num = axel * 1000000000000000000;
	var spotpix = new Image();
	spotpix.src = 'http://ad.doubleclick.net/activity;src=1283220;type=loven425;cat='+cat+';ord=1;num=' + num + ';?';
}
