function move_in(img_name,img_src) {
	document.getElementById(img_name).src=img_src;
}

function move_out(img_name,img_src) {
	document.getElementById(img_name).src=img_src;
}

function PopUpImage(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function CreateBookmarkLink() {

 title = "eDrugSearch.com"; 
 url = "http://www.edrugsearch.com";

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }


function checkAll(obj,id){
 var numElems = document.getElementById(id).elements;
 var state=true;
 if (obj.checked){ state=true; }else{ state=false; }
 for (var i=0;i<numElems.length;i++){
  if (numElems[i].type=='checkbox'){
   if (numElems[i]!=obj){
    numElems[i].checked=state;
   }
  }
 }
}

function massManage(obj,id){
 var numElems = document.getElementById(id).elements;
 var state=true;
 if (obj.checked){ state=true; }else{ state=false; }
 for (var i=0;inumElems.length;i++){
  if (numElems[i].type=='checkbox'){
   if (numElems[i]!=obj){
    numElems[i].checked=state;
   }
  }
 }
}

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&&ia.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&&id.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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}




var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
}}

function findDOM(objectID,withStyle) {
var menuArea = "menuArea";
	if (withStyle == 1) {
		if (isID) { return (document.getElementById(objectID).style) ; }
		else { 
			if (isAll) { return (document.all[objectID].style); }
		else {
			if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
		};}
	}
	else {
		if (isID) { return (document.getElementById(objectID)) ; }
		else { 
			if (isAll) { return (document.all[objectID]); }
		else {
			if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
		};}
	}
}

function findLivePageWidth() {
	if (window.innerWidth != null)
		return window.innerWidth;
	if (document.body.clientWidth != null)
		return document.body.clientWidth;
	return (null);
}
	
function popUp(evt,objectID){
	if (isDHTML) { // Makes sure this is a DHTML browser
		var livePageWidth = findLivePageWidth();
		//alert(livePageWidth);
		domStyle = findDOM(objectID,1);
		dom = findDOM(objectID,0);
		state = domStyle.visibility;
		if (dom.offsetWidth) elemWidth = dom.offsetWidth;
		else { if (dom.clip.width)	elemWidth = dom.clip.width; }
		if (state == "visible" || state == "show")  { domStyle.visibility = "hidden"; }
		else {
			if (evt.pageY) { //Calculates the position for Navigator 4 
				topVal = evt.pageY + 4;
				leftVal = evt.pageX - (elemWidth / 2); 
			}
			else { 
				if (evt.y) { // Calculates the position for IE4
					topVal = evt.y + 4 + document.body.scrollTop;
					leftVal = evt.x - (elemWidth / 2) + document.body.scrollLeft;
				}
			}
		/*If the element goes off the page to the left, this moves it back */
			if(leftVal < 2) { leftVal = 2; }
			else { 
				if ((leftVal + elemWidth) > livePageWidth) { leftVal = leftVal - (elemWidth / 2); }
			}
			domStyle.top = topVal + 5; // Positions the element from the top
			domStyle.left = leftVal + 80; // Positions the element from the left
			domStyle.visibility = "visible"; // Makes the element visable 
		}
	}
	return false;
}

function addEvent(elm, evType, fn, useCapture)
{
	if (elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent){
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} else {
		elm['on'+evType] = fn;
	}
}

/*
			//Used for keyup and keydown.
			var selectedDiv = 0;
			var divMax = 0;

			function keyHandler(e) 
			{
			
				if ( document.frmSearch1.q.hasfocus && document.frmSearch1.d.value > '' )
				{
				  	document.getElementById('q').value = '';
					document.getElementById('d').value = '';
					document.getElementById('qty').value = '';
					document.getElementById('dosagetext').style.display="none";
					document.getElementById('d').style.display="none";
					document.getElementById('quantitytext').style.display="none";
					document.getElementById('qty').style.display="none";
					document.getElementById('suggest-drugname').style.display="none";
					document.getElementById('suggest-dosage').style.display="none";
					document.getElementById('suggest-quantity').style.display="none";
					document.getElementById('reset').style.display="none";
				}

				if(e.keyCode == 8  ) 
				{
			 	  if ( document.frmSearch1.q.hasfocus || document.frmSearch1.d.hasfocus || document.frmSearch1.qty.hasfocus  )
				  {
				  	document.getElementById('q').value = '';
					document.getElementById('dosagetext').style.display="none";
					document.getElementById('d').style.display="none";
					document.getElementById('quantitytext').style.display="none";
					document.getElementById('qty').style.display="none";
					document.getElementById('suggest-drugname').style.display="none";
					document.getElementById('suggest-dosage').style.display="none";
					document.getElementById('suggest-quantity').style.display="none";
					document.getElementById('reset').style.display="none";
				  } 				  				  
				}				
				
			}	

			//document.addEventListener("keydown", keyHandler, false);
			addEvent(document, "keydown", keyHandler, false);

 */