//------------------------------------------------------------
//				Page Header
//File Name			: CommFunctions.js
//Author			: Pradeep Kumar Vardhineni
//Purpose			: This Page contains a set of common JavaScript 
//						functions which can be used across the site.
//Included in		: Header Frame(VT_HeaderFrame.asp)
//------------------------------------------------------------

function openCalendar(o,strProp,oBtn){
	var sDate="";
	var bReturn=false;
	//ctr=o;
	var oParent = oBtn.offsetParent; 
	var oFrame=getFrameObject();
	var ileft = oFrame.event.screenX;
	var itop = oFrame.event.screenY + 8;
	//var sParam = "dialogWidth=300px;dialogHeight=320px;dialogLeft=" + ileft + "px;dialogTop=" + itop + "px;status=no;scroll=no;resizable=no;help=no;edge=sunken;unadorned=off;"
	var sParam = "dialogWidth=320px;dialogHeight=365px;dialogLeft=" + ileft + "px;dialogTop=" + itop + "px;status=no;location=center;scroll=no;resizable=no;help=no;edge=sunken;unadorned=off;"
	//'width=300,height=320,top=200,left=200,alwaysontop=yes,toolbar=no,location=center,directories=no,status=no,menubar=no,copyhistory=no,resizeable=no'
	sDate = showModalDialog("../DatePopUp.htm","",sParam);
		
	if ( sDate != "" && sDate != null && sDate !="undefined"){
		eval("o." + strProp + "=sDate;" );
		if(strProp=="value"){
			if(! o.disabled)
				o.focus();
		}
		else{ 
			oBtn.focus();
		}
		bReturn=true;
	}
	return bReturn;
}

function getFrameObject(){
	return top.BodyFrame;
}

function checkIntegerValues(){
	var oFrame=getFrameObject();
	var iKeyCode=oFrame.event.keyCode;
	if(iKeyCode < 48 || iKeyCode>57) oFrame.event.keyCode=0;
	/*for(var i=48;i<=57;i++)
		if(oFrame.event.keyCode==i) return;
	oFrame.event.keyCode=0;*/
}
function getErrorMsg(sErrCode){
	var msg = eval("top.TopFrame."+sErrCode)+"";
	if (msg =="undefined") msg="";
	return msg;
}
function populateDropDown(cmb,strValues){
	var i,oOpt,selNum=0;
	var arrValues;
	try{
	arrValues=strValues.split(",");

	for(i=1; i <=arrValues.length; i++){
		oOpt=document.createElement("OPTION");
	
		oOpt.text=arrValues[i];
		oOpt.value=arrValues[i-1];
		cmb.add(oOpt);
		i=i+1;
	}
	cmb.selectedIndex=selNum;
	}
	catch(e){
		alert("error in populatedrop down=" + e.message);
	}
}

function makeCursorBusy(){
		var iFramesCount=top.frames.length;
		var i;
		var oFrame;
		for(i=0;i<iFramesCount;i++){
			oFrame=top.frames(i);
			oFrame.document.body.style.cursor="wait";
		}
	}
function makeCursorDefault(){
	var iFramesCount=top.frames.length;
	var i;
	var oFrame;
	for(i=0;i<iFramesCount;i++){
		oFrame=top.frames(i);
		oFrame.document.body.style.cursor="default";
	}
}

