//This hides the image if no image is available. You can substitute another image, change the value of the image's alt attribute, or 
//(as shown below) simply prevent the element from being rendered at all. Thomas/ donovan 
// Current Page Reference
//finds various parts of url whick I will call myurl donovan

var myhost = ("localhost");
function getURL(myurl) {
myurl.dir = location.href.substring(0,location.href.lastIndexOf('\/'));
myurl.dom = myurl.dir; if (myurl.dom.substr(0,7) == 'http:\/\/') myurl.dom = myurl.dom.substr(7);
else if (myurl.dom.substr(0,8) == 'https:\/\/') myurl.dom = myurl.dom.substr(8);
myurl.path = ''; var pos = myurl.dom.indexOf('\/'); if (pos > -1) {myurl.path = myurl.dom.substr(pos+1); myurl.dom = 
myurl.dom.substr(0,pos);}
myurl.page = location.href.substring(myurl.dir.length+1,location.href.length+1);
pos = myurl.page.indexOf('?');if (pos > -1) {myurl.page = myurl.page.substring(0, pos);}
pos = myurl.page.indexOf('#');if (pos > -1) {myurl.page = myurl.page.substring(0, pos);}
myurl.ext = ''; pos = myurl.page.indexOf('.');if (pos > -1) {myurl.ext =myurl.page.substring(pos+1); myurl.page = 
myurl.page.substr(0,pos);}
myurl.file = myurl.page;
if (myurl.ext != '') myurl.file += '.' + myurl.ext;
if (myurl.file == '') myurl.page = 'index';
myurl.args = location.search.substr(1).split("?");
return myurl;
}

var myurl = new Object();
getURL(myurl);

function ImageLoadFailed() 
{
	window.event.srcElement.style.display = "None";
}


function ImageLoadFailed2() 
{
	window.event.srcElement.style.display = "None"; 
}

// code that only runs for pages in localhost only      
function ImageLoadnologo() 
{
		
	if (myurl.dom != myhost){window.event.srcElement.src = "/store/images/logos/noLogo44.gif";} else {
		// code that only runs on live site
		//window.event.srcElement.src = "../store/images/logos/noLogo44.gif";
	window.event.srcElement.style.display = "None";
} 
	
}
      
// code that only runs for pages in localhost only      
function pharmphoto() 
{
		
	if (myurl.dom != myhost){window.event.srcElement.src = "/store/images/pharmphoto/noPhoto.jpg";} else {
		// code that only runs on live site
		//window.event.srcElement.src = "../store/images/pharmphoto/noPhoto.jpg";
	window.event.srcElement.style.display = "None";
} 
	
}      
      
// code that only runs for pages in localhost only      
/*function loadHelp() 
{	
	if (myurl.dom != myhost){ document.helpIFrame.src = "/store/help/index.aspx"; } 
	else { document.helpIFrame.src = "/cdsv2/store/help/index.aspx"; }
}

function loadSurvey() 
{	
	if (myurl.dom != myhost){ document.surveyIFrame.src = "/store/survey/frmSurveyFront.aspx"; } 
	else { document.surveyIFrame.src = "/cdsv2/store/survey/frmSurveyFront.aspx"; }
}*/
      
function calendar(dateBox)
{
	//used to launch the calendar page to select a date
	window.open('../datePicker.aspx?field=' + dateBox ,'calendarPopup','width=260,height=280,resizable=no');
}

function updateParent(newURL) {
    window.opener.location.href = newURL
    }
    
function highlight(rowObj, strColor) {
	rowObj.style.backgroundColor = strColor;
	}
	
function link(menuurl) {
	window.location.href = (menuurl);
	}

function fnHelpTour(iVal){// -- Opens help window and site tour
	var appName = navigator.appName;
	var features = '';
	if(appName=='Microsoft Internet Explorer'){
		features = 'menubar=yes,width=675,resizable=yes,scrollbars=yes';
	}
	else{
		features = 'menubar=yes,width=675,resizable=yes,scrollbars=yes';
	}
	switch(iVal){
		case 1:
			features+=',height=415';
			newWin = window.open('/store/Help/index.aspx', '',features);
			return;
		case 2:
			features+=',height=550';
			newWin = window.open('/store/Help/sitetour.asp', '',features);
			return;
	}
	
}

function ValidateForm(me) {

	if (document.IMCAccessForm.searchString.value == "") {
		alert("Please enter word(s) to search for.");
		document.IMCAccessForm.searchString.focus();
		return false;
	}
	
	return true;
}

function playsound(n) {
	browser = (navigator.appName);
	if (browser == "Netscape") {
		PrintWindow = window.open(n,
			"PrintWindow",
			"toolbar=no,left=10,top=80,width=350,height=150,directories=no,status=no,scrollbars=no,resizable,menubar=no");
		PrintWindow.focus();
	}
	else {
		location = n;
		}
}


function printwindow() {
	msiever = parseInt(navigator.appVersion.charAt(22));
	browser = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4 )) || 
	((navigator.appName == "Microsoft Internet Explorer") && 
	(parseFloat(navigator.appVersion) == 4.0) && (msiever > 4)))

	if (browser) {
		window.print();
	}
	else {
		alert(' Sorry, you are using an older version of the Web browser which does not support this print feature.\n Please select print from the File menu.')
	}
}

function open_print_version(n) {
	PrintWindow = window.open(n,
		"PrintWindow",
		"toolbar=no,left=10,top=80,width=680,height=480,directories=no,status=no,scrollbars=yes,resizable,menubar=yes")
	PrintWindow.focus()
}	

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) { //v3.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); 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 copyRxName(toField, fromField)
{
	document.getElementById(toField).value = document.getElementById(fromField).value;
	
}

		isIE=document.all;
		isNN=!document.all&&document.getElementById;
		isN4=document.layers;
		isActive=false;

		function HelpMoveInit(e){
		  topOne=isIE ? "BODY" : "HTML";
		  whichOne=document.getElementById("HelpLayer");
		  ActiveOne=isIE ? event.srcElement : e.target;
		  while (ActiveOne.id!="titleBar"&&ActiveOne.tagName!=topOne){
		    ActiveOne=isIE ? ActiveOne.parentElement : ActiveOne.parentNode;
		  }
		  if (ActiveOne.id=="titleBar"){
		    offsetx=isIE ? event.clientX : e.clientX;
		    offsety=isIE ? event.clientY : e.clientY;
		    nowX=parseInt(whichOne.style.left);
		    nowY=parseInt(whichOne.style.top);
		    MoveEnabled=true;
		    document.onmousemove=Move;
		  }
		}
		
		function MoveInit(e){
		  topOne=isIE ? "BODY" : "HTML";
		  whichOne=document.getElementById("SurveyLayer");
		  ActiveOne=isIE ? event.srcElement : e.target;
		  while (ActiveOne.id!="titleBar"&&ActiveOne.tagName!=topOne){
		    ActiveOne=isIE ? ActiveOne.parentElement : ActiveOne.parentNode;
		  }
		  if (ActiveOne.id=="titleBar"){
		    offsetx=isIE ? event.clientX : e.clientX;
		    offsety=isIE ? event.clientY : e.clientY;
		    nowX=parseInt(whichOne.style.left);
		    nowY=parseInt(whichOne.style.top);
		    MoveEnabled=true;
		    document.onmousemove=Move;
		  }
		}

		function Move(e){
		  if (!MoveEnabled) return;
		  whichOne.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
		  whichOne.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
		  return false;
		}

		function MoveN4(whatOne){
		  if (!isN4) return;
		  N4=eval(whatOne);
		  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
		  N4.onmousedown=function(e){
		    N4.captureEvents(Event.MOUSEMOVE);
		    N4x=e.x;
		    N4y=e.y;
		  }
		  N4.onmousemove=function(e){
		    if (isActive){
		      N4.moveBy(e.x-N4x,e.y-N4y);
		      return false;
		    }
		  }
		  N4.onmouseup=function(){
		    N4.releaseEvents(Event.MOUSEMOVE);
		  }
		}

		function ToggleFloatingLayer(DivID, iState) // 1 visible, 0 hidden
		{
		    if(document.layers)	   //NN4+
		    {
		       document.layers[DivID].visibility = iState ? "show" : "hide";
		    }
		    else if(document.getElementById)	  //gecko(NN6) + IE 5+
		    {
		        var obj = document.getElementById(DivID);
		        //if visible, position div layer in center of page
		        if (iState)
		        {
					
					//get coord
					var xcoord = Math.abs(document.body.clientWidth/2-450);	//450 is half of div layer size
					var ycoord = Math.abs(document.body.clientHeight/2-325);	//325 is half of div layer size
					//alert("Width: " + xcoord + "\n\rHeight: " + ycoord);
									
					obj.style.left=xcoord ;
					obj.style.top=ycoord ;
		        }
		        obj.style.visibility = iState ? "visible" : "hidden";	        
		    }
		    else if(document.all)	// IE 4
		    {
		        document.all[DivID].style.visibility = iState ? "visible" : "hidden";
		    }
		}
		
		  function CancleDlg(e) {
			if (document.all){
				if(event.keyCode==9) event.returnValue=false;
			} else {
				if(e.witch==9) e.preventDefault();
			}
		 }

		 function StopProp(e) {
			if (document.all){
				event.cancelBubble=true;
			} else {
				e.stopPropagation();
			}
		 }		
