
// Code reviewed by Pankaj on 09/30/2003
//added by Mnaish Tiwari on 04/21/2003 for setting the position of the calender on the screen
var bFlag=true;

// overly simplistic test for IE
isIE = (document.all ? true : false);
// both IE5 and NS6 are DOM-compliant
isDOM = (document.getElementById ? true : false);

// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
function getAbsX(elt) {	return (elt.x) ? ((elt.x) >850 ? (elt.x -100): (elt.x)) :  getAbsPos(elt,"Left");}
function getAbsY(elt) { return (elt.y) ? (elt.y + 20) :	getAbsPos(elt,"Top"); }
function getAbsPos(elt,which) {
 iPos = 0;
 while (elt != null) {
  iPos += elt["offset" + which];
  elt = elt.offsetParent;
 }
 
 //Modified by Manish Tiwari on 04/21/2003 for setting the position of the calender on the screen
 if (bFlag == true) {
 	bFlag=false;
 	if (iPos > 850)
	return (iPos - 100);
	else
	return (iPos);
	}
else{
	bFlag=true;
	return (iPos + 20);
	}	
}

function getDivStyle(divname) {
 var style;
 if (isDOM) { style = document.getElementById(divname).style; }
 else { style = isIE ? document.all[divname].style
                     : document.layers[divname]; } // NS4
 return style;
}

function hideElement(divname) {
	getDivStyle(divname).visibility = 'hidden';
	
	if (gDivList != '') 
	{
		var DivArray = gDivList.split(",");
		for(i=0;i<= DivArray.length-1;i++)
		{
			DivVisible(DivArray[i]);
		}
	}
	//Set focus in the field
	//displayElement.focus();
	
}

// annoying detail: IE and NS6 store elt.top and elt.left as strings.
function moveBy(elt,deltaX,deltaY) {
 elt.left = parseInt(elt.left) + deltaX;
 elt.top = parseInt(elt.top) + deltaY;
}

function toggleVisible(divname) {

 divstyle = getDivStyle(divname);
 if (divstyle.visibility == 'visible' || divstyle.visibility == 'show') {
   divstyle.visibility = 'hidden';
 } else {
   fixPosition(divname);
   divstyle.visibility = 'visible';
 }
}

function DivVisible(divname) {

 divstyle = getDivStyle(divname);
 if (divstyle.visibility == 'visible' || divstyle.visibility == 'show') {
   divstyle.visibility = 'hidden';
 } else {
     divstyle.visibility = 'visible';
 }
}
//Added by Sudhir on 07 Aug 2003
function DivShow(divname) {
 divstyle = getDivStyle(divname);
 divstyle.visibility = 'visible';
}
function DivHide(divname) {
 divstyle = getDivStyle(divname);
 divstyle.visibility = 'hidden';
}
//end on 07 Aug 2003

function setPosition(elt,positionername,isPlacedUnder) {
 var positioner;
 if (isIE) {
	positioner = document.all[positionername];
	// Set elements left coordinate...
	elt.left = getAbsX(positioner);
 } 
 else {
  if (isDOM) {
    positioner = document.getElementById(positionername);
	// Set elements left coordinate...
	// The left property for the <DIV> doesnt seem to be available in netscape... but the right property is...
	// This is the reason the right property is set to positino the calendar <DIV>...
	elt.right = ( ( window.innerWidth - 185 ) - getAbsX(positioner) );
  } else {
    // not IE, not DOM (probably NS4)
    // if the positioner is inside a netscape4 layer this will *not* find it.
    // I should write a finder function which will recurse through all layers
    // until it finds the named image...
    positioner = document.images[positionername];
  }
 }

	elt.top = getAbsY(positioner) + (isPlacedUnder ? positioner.height : 0);
}
