//<![CDATA[

  // --------------------------------------------------------------------------

  /*document.writeln('<script type="text/javascript" src="'+page.baseHref+'/js/swfobject.js"></script>');*/

  // --------------------------------------------------------------------------

  function printPage() {
    if (window.print) {
      window.print();
    } else {
      alert(page.noPrintMessage);
    }
  }

  // --------------------------------------------------------------------------

  function ZoomediaMenu() {
    this.ptr = null;
    this.timer = null;
    this.delay = 1000;

    this.init = function(id) {
      if (!document.getElementById) {
        return;
      }

      var div = document.getElementById(id);

      if (div) {
        this.build(div);
      }
    };

    this.setTimeOut = function(id) {
      this.timer = window.setTimeout("ZoomediaMenu.mouseOut('"+id+"');", this.delay);
    };

    this.mouseOver = function(id) {
      var element = document.getElementById(id);

      if (!element) {
        return;
      }

      if (this.ptr && this.timer) {
        window.clearTimeout(this.timer);
        this.timer = null;
        this.mouseOut(this.ptr);
      }

      element.className += ' over';

      //anchor tag
      element.childNodes[0].className += ' hover';

      this.ptr = id;
    };

    this.mouseOut = function(id) {
      var element = document.getElementById(id);

      if (!element) {
        return;
      }

      //li element
      element.className = element.className.replace(' over', '');

      //anchor tag
      element.childNodes[0].className = element.childNodes[0].className.replace(' hover', '');
    };

    this.build = function(ele) {
      var ul;

      for(var i=0; i < ele.childNodes.length; ++i) {
        if (ele.childNodes[i].nodeName.toLowerCase() == 'ul') {
          ul = ele.childNodes[i];
          break;
        }
      }

      if (!ul) {
        return;
      }

      for(i=0; i < ul.childNodes.length; ++i) {
        if (ul.childNodes[i].nodeName.toLowerCase() != 'li') {
          continue;
        }

        ul.childNodes[i].onmouseover = function() {
          ZoomediaMenu.mouseOver(this.getAttribute('id'));
        };

        ul.childNodes[i].onmouseout = function() {
          ZoomediaMenu.setTimeOut(this.getAttribute('id'));
        };
      }
    };

  }//ZoomediaMenu

  // --------------------------------------------------------------------------

  var ZoomediaMenu = new ZoomediaMenu();

  // --------------------------------------------------------------------------

  function ZoomediaGlossary() {
    this.show = function(d, event) {
      for(i=0; i<gloss_defs.length; i++){
        var e = gloss_defs[i];
        var aId = "gloss_"+e;
        var dId = "def_"+e;
        if(document.getElementById(dId)) {
          if((e == d) && (document.getElementById(dId).style.display != "block") ) {
              var dd = document.getElementById(dId);
              document.getElementById(aId).style.zIndex = "500";
              dd.style.display = "block";
            if(event.layerY) {
              //dd.style.top = event.pageY+'px';
              //dd.style.left = event.pageX+'px';
            } else {
              offset = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
              if(!offset) offset = 0; // stupid ie5/mac
              //dd.style.top = (offset + event.clientY)+'px';
              //dd.style.left = event.clientX+'px';
            }
          } else {
            this.hide(e);
          }
        }
      }
    };

    this.hide = function(d) {
      var aId = "gloss_"+d;
      var dId = "def_"+d;

      document.getElementById(aId).style.zIndex = 1;
      document.getElementById(dId).style.display = "none";
    };

  }//ZoomediaGlossary

  // --------------------------------------------------------------------------

  var ZoomediaGlossary = new ZoomediaGlossary();

  // --------------------------------------------------------------------------

function toggle(id) {

	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	} else {
		document.getElementById(id).style.display = "none";
	}

}

  // --------------------------------------------------------------------------

  function ZoomediaForm() {
    this.submit = function(form) {
      if (hbx) {
        hbx.pn += '+FORM+SUBMIT';
      }
      document.getElementById(form).submit();
    };
    this.formatNumber = function(value) {
      return value.replace(/[^\d.]/g, '');
    };
    this.formatTelephoneNumber = function(value) {
      return value.replace(/[^\d]/g, '');
    };
  }//ZoomediaForm


  var ZoomediaForm = new ZoomediaForm();

  // --------------------------------------------------------------------------
  
  // --- JS for the dhtml popup -----------------------------------------------
 
 
  function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
  }
  
  function getCookie(c_name) {
	if (document.cookie.length>0) {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1) { 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return false;
  }
  
var leavingUS = "You are now leaving the pages of www.gilead.com intended for U.S. audiences. The information in this section is intended for visitors outside of the United States.";
var leavingInt = "You are now leaving the pages of www.gilead.com intended for visitors outside of the United States. The information in this section is intended for U.S. audiences only.";
var destiNation;
var US = getCookie('US');
  
  $(window).load(function() {
	
	if (curPagename == "international_locations" && reFer != "local") {
		doLeaveUS(false, "/worldwide_operations");
		return false;
	}
	
	if (curTemplate == "international_location.tpl.php") {
		if (US != 1) {
			destiNation = "/international_locations";
			doLeaveUS(false, "/worldwide_operations");
			return false;
		}
		return true;
	}				  
						  
						  	
  });
  
  
  $(document).ready(function () {
	
  	$("a[href='/international_locations']").click(function() {
		destiNation = $(this).attr("href");
		doLeaveUS(destiNation, false);
		return false;	
	});
	
	if(curTemplate == "international_location.tpl.php") {
		$("a[href!='/international_locations']").not("div.int_locations a").click(function() {
			destiNation = $(this).attr("href");
			doLeaveInt(destiNation, false);
			return false;
		});
	}	
  
  });
  
  function doLeaveUS(href, cancel) {	
	
	$("#divFloatPop").fadeIn("normal");
	$("#divFloatPop").html(leavingUS);
	$("#divFloatPop").append('<div style="clear: both; height: 50px"><!-- c --></div>');
	
	if (cancel) {
		$("#divFloatPop").append('<a href="'+ cancel +'">Cancel</a>');
	} else {
		$("#divFloatPop").append('<a href="#" onclick="return stay();">Cancel</a>');	
	}
	
	if (href) {
		$("#divFloatPop").append('<a href="'+ destiNation +'" onclick="setCookie(\'US\', \'1\', null);">Continue</a>');
	} else {
		$("#divFloatPop").append('<a href="#" onclick="setCookie(\'US\', \'1\', null); return stay();">Continue</a>');	
	}
	
  }
  
  function doLeaveInt(href, cancel) {
		
	$("#divFloatPop").fadeIn("normal");
	$("#divFloatPop").html(leavingInt);
	$("#divFloatPop").append('<div style="clear: both; height: 50px"><!-- c --></div>');
	if (cancel) {
		$("#divFloatPop").append('<a href="'+ cancel +'">Cancel</a>');
	} else {
		$("#divFloatPop").append('<a href="#" onclick="return stay();">Cancel</a>');	
	}
	$("#divFloatPop").append('<a href="'+ destiNation +'">Continue</a>');
		
  }
  
  function stay() {
	destiNation = '';
	$("#divFloatPop").fadeOut("normal");
	return false;	  
  }

  // JS Redirect after Time
  function redirectWithSeconds(w,s) {
    var seconds = (s * 1000);
    setTimeout("location.href='"+w+"'", seconds);
  }

  // -------------------------------------------------------------------


//]]>


