function OpenWind(url){
	popUp(url);
}

function DrugInfoPopUp(DrugID){
	var Url = "http://hipformulary.hipusa.com/showpem.asp?DDId=" + DrugID
	popUp(Url,500,400);
}
	
function popUp(URL,x,y) {
  day = new Date();
  id = day.getTime();
  if (typeof x=='undefined') {
  	x = '500';
	}
	if (typeof y=='undefined') {
	y = '400';
  }
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+ x +",height="+ y +"');");
}

function PrintFormPopUp(){
	window.open("PrintPrescription.aspx","_blank", "height=600,width=800,status=no,toolbar=no,menubar=no,top=40,left=40")
}

function EnforceMaxLen(textBox,MaxLen){
	if( textBox.value.length > MaxLen){
		alert("There is a " + MaxLen + " character limit");
		textBox.value = textBox.value.substring(0,MaxLen); 
		textBox.focus();
		}
}







//Following is the code to validate whether the text inside an input like textbox is a number or not.
//This returns true or false based on the input type containing number only or alphanumeric characters.
function IsAnyNumbers(TestValue){
	    if (((TestValue / TestValue) != 1) && (TestValue != 0)){
			return false;	
		}
		else{
		
			if(TestValue <= 0){
				return false;
			}
			else{
				return true;
			}
		}

}



// DRAGGING CODE

var popup_elDrag = null;
/***********************************************************************
* popup_mouseDown
*
************************************************************************/
function popup_mouseDown(ele) {
	if (!popup_elDrag) {
		
		popup_elDrag = ele; 
		popup_elDrag.style.cursor = "move";

		dragOffset = getAbsolutePos(popup_elDrag);
		
		dragOffset.x -= document.body.scrollLeft + event.clientX;
		dragOffset.y -= document.body.scrollTop + event.clientY;
		
		document.onmousemove = popup_mouseMove;
		document.onmouseup = popup_mouseUp;
		
	}
	return false;
}


/***********************************************************************
* popup_mouseUp
*
************************************************************************/
function popup_mouseUp() {
	if (popup_elDrag) popup_elDrag.style.cursor = "default";
  popup_elDrag = null;
	document.onmousemove = null;
	document.onmouseup = null;
}


/***********************************************************************
* popup_mouseMove
*
************************************************************************/
function popup_mouseMove() {
	if (popup_elDrag) {
		var pos=getAbsolutePos(popup_elDrag);
		pos.x = popup_elDrag.offsetLeft - pos.x + dragOffset.x + document.body.scrollLeft + event.clientX;
		pos.y = popup_elDrag.offsetTop - pos.y + dragOffset.y + document.body.scrollTop + event.clientY;
		
		popup_elDrag.style.left = pos.x;
		popup_elDrag.style.top = pos.y;
	}
	return true;
}			


function getAbsolutePos(el,stop) {
	var r = { x: 0, y: 0 };
	while(el && el!=stop) {
	    // offsets do not take zoom into account.
		var zoom = el.style.zoom;
		if (zoom) {
			var f = parseFloat(zoom);
			if (zoom.indexOf("%")>=0) f/=100;
			r.x *= f;
			r.y *= f;
		}
		r.x += el.offsetLeft;
		r.y += el.offsetTop;
		el=el.offsetParent;
	}
	return r;
};





