// jQuery custom funcs ---------
jQuery.fn.center = function () {
      this.css("position","absolute");
      this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
	  this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
      return this;
}

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


//<![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 ZooMenu() {
    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("ZooMenu.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() {
          ZooMenu.mouseOver(this.getAttribute('id'));
        };

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

  }//ZooMenu

  var ZooMenu = new ZooMenu();

//]]>

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

  var topVal;
  var leaving = "<p>You have just clicked on a link that will take you outside the NeurogesX web site. NeurogesX, Inc. does not monitor or imply any endorsement of outside web sites and is not responsible for the content of outside web sites.</p><p>Click \"OK\" to proceed to this third-party web site or \"CANCEL\" to return to NeurogesX.com site.</p>";
  var leavingQutenza = "You are know leaving the NeurogesX corporate website and will be directed to the Qutenza product site.";
  
  $(document).ready(function () {
	
  	$("a.prompt, area.prompt").click(function(e) {
		topVal = null;
		topVal = e.pageY - 10 + "px";
		destiNation = $(this).attr("href");
		doLeave(destiNation, leaving, false);
		return false;	
	});
	
	$("a.prompt-qutenza, area.prompt-qutenza").click(function(e) {
		topVal = null;
		topVal = e.pageY - 10 + "px";
		destiNation = $(this).attr("href");
		doLeave(destiNation, leavingQutenza, false);
		return false;	
	});
	
  
  });
  
  function doLeave(href, msg, cancel) {
	
	$("#divFloatPop").center();
	$("#divFloatPop").fadeIn("normal");
	$("#divFloatPop").html(msg);
	$("#divFloatPop").append('<div style="clear: both; height: 25px"><!-- 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 +'" target="_blank" onclick="stay();">OK</a>');
	} else {
		$("#divFloatPop").append('<a href="#" onclick="return stay();">OK</a>');	
	}
	
  }
  
  function stay() {
		destiNation = '';
		$("#divFloatPop").fadeOut("normal");
		return false;	  
  }