//=======POPUP WINDOW STARTS=======================
function newWindow(url) {

// initialize global var for new window object
// so it can be accessed by all functions on the page
var newWind 
var left,top,height,width
height=screen.availHeight-200
width=screen.availWidth-20
top=0
left=2
// set flag to help out with special handling for window closing
var isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false
// make the new window and put some stuff in it
// left=250 and top=350

	newWind = window.open(url,"Help","toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,HEIGHT=" + height +",WIDTH="+ width +",LEFT="+ left +",TOP="+ top)

	// take care of Navigator 2
	if (newWind.opener == null) {
		newWind.opener = window
	}
	//newWind.document.close()
}

//=======POPUP WINDOW STARTS=======================
function newSizeWindow(url,height,width,top,left) {
var newWind 
//var left,top,height,width
//height=screen.availHeight-200
//width=screen.availWidth-20
//top=0
//left=2
var isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false
	newWind = window.open(url,"Help","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,HEIGHT=" + height +",WIDTH="+ width +",LEFT="+ left +",TOP="+ top)

	if (newWind.opener == null) {
		newWind.opener = window
	}
}

// close subwindow, including ugly workaround for IE3
function closeWindow() {
	if (isIE3) {
		// if window is already open, nothing appears to happen
		// but if not, the subwindow flashes momentarily (yech!)
		newWind = window.open("","subwindow","HEIGHT=200,WIDTH=200")	
	}
	if (newWind && !newWind.closed) {
		newWind.close()
	}
}
//=======POPUP WINDOW ENDS=======================

//=======APPL WINDOW STARTS=======================
function jsApplPopup(pURL) {
var newWind 
var left,top,height,width
height=screen.availHeight-100
width=screen.availWidth
top=0
left=0
var isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false
	newWind = window.open(pURL,"Help","toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,HEIGHT=" + height +",WIDTH="+ width +",LEFT="+ left +",TOP="+ top)
	if (newWind.opener == null) {
		newWind.opener = window
	}
	newWind.document.close()
}
//=======APPL WINDOW ENDS=======================


//=======MESSAGE WINDOW STARTS=======================
function MessageWindow(url) {

// initialize global var for new window object
// so it can be accessed by all functions on the page
var newWind 
var left,top,height,width
height=300
width=300
top = (screen.availHeight/2) - (height/2)
left = (screen.availWidth/2) - (width/2)
// set flag to help out with special handling for window closing
var isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false
// make the new window and put some stuff in it
// left=250 and top=350

	newWind = window.open(url,"Help","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,HEIGHT=" + height +",WIDTH="+ width +",LEFT="+ left +",TOP="+ top)
	// take care of Navigator 2
	if (newWind.opener == null) {
		newWind.opener = window
	}
	newWind.document.close()
}
// close subwindow, including ugly workaround for IE3
function closeWindow() {
	if (isIE3) {
		// if window is already open, nothing appears to happen
		// but if not, the subwindow flashes momentarily (yech!)
		newWind = window.open("","subwindow","HEIGHT=200,WIDTH=200")	
	}
	if (newWind && !newWind.closed) {
		newWind.close()
	}
}
//=======MESSAGE WINDOW ENDS=======================

//======= CLIENT DATE TIME STARTS =======================
function getClockTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var ap = "AM";
   if (hour   > 11) { ap = "PM";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
   if (hour   < 10) { hour   = "0" + hour;   }
   if (minute < 10) { minute = "0" + minute; }
   if (second <10) { second = "0" + second; }
   var day = now.getDate();
   var month = now.getMonth();
   var year = now.getYear();

   var dateString = parseInt(month)+1 + 
                    '/' + 
                    parseInt(day) + 
                    '/' + 
                    year

   var timeString = hour + 
                    ':' + 
                    minute + 
                    ':' + 
                    second + 
                    " " + 
                    ap;
   return dateString + ' - ' + timeString;
}
//======= CLIENT DATE TIME ENDS =======================

//=======PRINTING STARTS=======================

function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}

//=======PRINTING ENDS=======================


//======= SET FOCUS STARTS =======================

function JSetFocus(controlname){
	var txt=eval('document.'+controlname);
	txt.focus();
}

//======= SET FOCUS ENDS =======================

//======= PRINT WITHOUT PRINT DIALOG BOX STARTS =======================
// SWATHI SOFT SOLUTIONS
// This accesses a built-in Windows command that can perform Magic!
// And yes, this is a Windows ONLY solution.
// In fact, it only works in IE. :(
//
//          INPUT: intOLEcmd   = integer between 1 and 37,only a few are of use
//                 intOLEparam = parameter integer for function - optional
//         OUTPUT: none
//   DEPENDANCIES: none
//
//           NOTE: intOLEparam is not optional in the Object call,
//                 I just made it optional here to make life easier.
//                 All command values use '1' execept print, thus my reasoning.
//
//        EXAMPLE: // This prints given window/frame WITHOUT prompt!
//                 <button onClick="objWinName.ieExecWB(6, -1)">
//                    Print Me! - No Prompt!
//                 </button>
//
//                 // This prints given window/frame WITH prompt!
//                 <button onClick="objWinName.ieExecWB(6)">
//                    Print Me! - Prompt
//                 </button>
//
// 	           // This will display the Print Preview window
//                 <button onClick="objWinName.ieExecWB(7)">
//                    Print Preview
//                 </button>
//
//         VALUES: intOLEcmd has these possible values
//                 OLECMDID_OPEN         = 1
//                 OLECMDID_NEW          = 2    warning, this kills IE windows!
//                 OLECMDID_SAVE         = 3
//                 OLECMDID_SAVEAS       = 4
//                 OLECMDID_SAVECOPYAS   = 5    note: does nothing in IE
//                 OLECMDID_PRINT        = 6    note: give '-1' as param - no prompt!
//                 OLECMDID_PRINTPREVIEW = 7
//                 OLECMDID_PAGESETUP    = 8
//         Others have no use in IE

function IEPrint( intOLEcmd, intOLEparam )
{
	// Create OLE Object
	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';

	// Place Object on page
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);

	// if intOLEparam is not defined, set it
	if ( ( ! intOLEparam ) || ( intOLEparam < -1 )  || ( intOLEparam > 1 ) )
		intOLEparam = 1;

	// Execute Object
	WebBrowser1.ExecWB( intOLEcmd, intOLEparam );

	// Destroy Object
	WebBrowser1.outerHTML = "";
}
//======= PRINT WITHOUT PRINT DIALOG BOX ENDS =======================


//=======EDITABLE COMBO STARTS=======================

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function check_Combo(txtbox,combobox,layername) {
MM_showHideLayers(layername,'','hide');
var objtxt = eval("document."+document.forms[0].name+"."+txtbox);
var objcombo = eval("document."+document.forms[0].name+"."+combobox);
var flag="";
	for (k=0;k<objcombo.options.length;k++) {
		if (objtxt.value==objcombo.options[k].text) {
			break;
		}
		else {
			if (k==objcombo.options.length-1) {
				flag="no";
			}
		}
	}
	if (flag=="no") {
		objtxt.select();
		objtxt.focus();
		alert("Please select the correct item");
		return;
	} else {
		jsSubmit(objtxt);
	}
}

function check_Combo1(objtxt,objcombo) {
var flag="";
	for (k=0;k<objcombo.options.length;k++) {
		if (objtxt.value==objcombo.options[k].text) {
			break;
		}
		else {
			if (k==objcombo.options.length-1) {
				flag="no";
			}
		}
	}
	if (flag=="no") {
		objtxt.select();
		objtxt.focus();
		alert("Please select the correct item");
		return;
	} else {
		jsSubmit(objtxt);
	}
}

function get_keyvalue(){
isNetscape=(document.layers);
result = (isNetscape) ? keyStroke.which : event.keyCode;
return result;
}

function get_combovalue(txtbox,combobox,layername) {
var objtxt = eval("document."+document.forms[0].name+"."+txtbox);
var objcombo = eval("document."+document.forms[0].name+"."+combobox);
keyHandler(get_keyvalue(),objtxt,objcombo,layername);
}


function keyHandler(KeyValue,objtxt,objcombo,layername) {
	switch (KeyValue) {
	case 38: 
		j=objcombo.selectedIndex;
		j=j-1;
		if (j>=0) {
			objcombo.options[j].selected=true;
		}
		break	
		
	case 40: 
		j=objcombo.selectedIndex;
		j=j+1;
		if (j<objcombo.options.length) {
			objcombo.options[j].selected=true;
		}
		break
		
	case 13:
		j=objcombo.selectedIndex;
		objtxt.value=objcombo.options[j].text;
		MM_showHideLayers(layername,'','hide');
		check_Combo1(objtxt,objcombo);
		break;
	
	case 0:
		j=objcombo.selectedIndex;
		objtxt.value=objcombo.options[j].text;
		MM_showHideLayers(layername,'','hide');
		check_Combo1(objtxt,objcombo);
		break;
	}
}

function get_text(txtbox,combobox,layername) {
var objtxt = eval("document."+document.forms[0].name+"."+txtbox);
var objcombo = eval("document."+document.forms[0].name+"."+combobox);
var txtlen=(objtxt.value).length;
keyHandler(get_keyvalue(),objtxt, objcombo,layername);
KeyValue=get_keyvalue();
	if (KeyValue!=38 && KeyValue!=40 && KeyValue!=13) {
		for (i=0;i<objcombo.options.length;i++) {
			var tmp=objcombo.options[i].text;
			if (objtxt.value==tmp.substring(0,txtlen)) {
				objcombo.options[i].selected=true;
				break;
			}
		}
	}
}

function UCase(Cntrl){
var txt=eval("document." + Cntrl);
var str=txt.value;
txt.value=str.toUpperCase();
}

function jsSubmit(CntrlName) {
	var CntrlName = CntrlName.name;
	var CntrlName = ('hdd'+CntrlName.substring(3,CntrlName.length));
	var CntrlName = eval("document.forms[0]." + CntrlName);	
	if (CntrlName=='[object]') {
		if (CntrlName.value==1) {
			document.forms[0].hddWhichControl.value=CntrlName.name;
			document.forms[0].submit();
		}
	}
}

//=======EDITABLE COMBO ENDS=======================

function newNoReSizeWindow(url,height,width,top,left) {
var newWind 
//var left,top,height,width
//height=screen.availHeight-200
//width=screen.availWidth-20
//top=0
//left=2
var isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false
	newWind = window.open(url,"Help","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,HEIGHT=" + height +",WIDTH="+ width +",LEFT="+ left +",TOP="+ top)

	if (newWind.opener == null) {
		newWind.opener = window
	}
}