/*
  $Id: report.js,v 1.1 2006/08/17 14:21:26 karuppannan Exp $
  */



function toggle(elementName, id)
{
        var sel = document.getElementById(elementName + id);
        var tree = document.getElementById("treeImg"+id);
        if(sel.style.display == 'block')
        {
                sel.style.display = 'none';
                tree.src="images/side_arrow.gif";
                tree.width="5";
                tree.height="9";
        }
        else
        {
                sel.style.display = 'block';
                tree.src="images/down_arrow.gif";
                tree.width="9";
                tree.height="6";
        }
}

function adjustFrameHeightWidth(height, width)
{
	var obj = document.getElementById('result');
	obj.height = height + this.innerHeight;
	obj.width = width + 35;
}


/*
 | Browser object
 */
function ylib_Browser() {
 d=document;
 this.agt=navigator.userAgent.toLowerCase();
 this.major = parseInt(navigator.appVersion);
 this.dom=(d.getElementById)?1:0; // true for ie6, ns6
 this.ns=(d.layers);
 this.ns4up=(this.ns && this.major >=4);
 this.ns6=(this.dom&&navigator.appName=="Netscape");
 this.op=(window.opera? 1:0);
 this.ie=(d.all);
 this.ie4=(d.all&&!this.dom)?1:0;
 this.ie4up=(this.ie && this.major >= 4);
 this.ie5=(d.all&&this.dom);
 this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
 this.mac=(this.agt.indexOf("mac")!=-1);
}

var oBw = new ylib_Browser();

/* begin new */
function ylib_setX(o,x) {
	if(oBw.ns) { 
		o.left=x;
	} else if(typeof o.style.pixelLeft != 'undefined') {
		o.style.pixelLeft=x;
	} else {
		thisPos = parseInt(x);			// preventing NS UNcaught Exception Error in strict.dtd mode: converting value to integer in case passed as string
		thisPos += "px";
		o.style.left = thisPos;
	}
}
function ylib_setY(o,y) {
	if(oBw.ns) {
		o.top=y;
	} else if(typeof o.style.pixelTop != 'undefined') {
		o.style.pixelTop=y;
	} else {
		thisPos = parseInt(y);			// preventing NS UNcaught Exception Error in strict.dtd mode: converting value to integer in case passed as string
		thisPos += "px";
		o.style.top = thisPos;
	}
}

function ylib_getPageX(o) 
{ 
	var x=0; 
	if(oBw.ns) 
	{
		x=o.pageX; 
	}
	else 
	{ 
		while(eval(o)) 
		{
			x+=o.offsetLeft; 
			o=o.offsetParent; 
		} 
	} 
	return x; 
}

function ylib_getPageY(o) { var y=0; if(oBw.ns) y=o.pageY; else { while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; } } return y; }
/* end new */

function ylib_moveTo(o,x,y) { ylib_setX(o,x);ylib_setY(o,y); }

var dd;
function autoHide()
{
	if(eval(dd))
	{
		yreg_popLayer(dd);
	}
}

function yreg_popLayer(div,href,offx,offy,bid) 
{
	dialogObj = d.getElementById(div);
	var txt = 'td'+div;
	var f = d.getElementById(txt);
	if (dialogObj.style.display == 'none') 
	{
		dd = div;	
		hidedialog(dialogObj);	
		// if current popup is hidden, make sure all others are hidden.
		yreg_setLayerLocation(div,href,offx,offy);		
		dialogObj.style.display = 'block'; //show layer	
		if(f!=null) f.style.display = 'block'; //show layer	
		showHideCombos(dialogObj, ylib_getPageX(dialogObj), ylib_getPageY(dialogObj), 'hidden');
	
	} 
	else 
	{
		dd = null;	
		dialogObj.style.display = 'none'; //show layer	
		if(f!=null) f.style.display = 'none'; //show layer	
		showHideCombos(dialogObj, ylib_getPageX(dialogObj), ylib_getPageY(dialogObj), 'visible');
	}
}
function hidedialog(dialogObj)
{
	if (typeof prevDialogObj !="undefined")
	{
		if (ie4||ns6)
		{
			showHideCombos(prevDialogObj, ylib_getPageX(prevDialogObj), ylib_getPageY(prevDialogObj), 'visible');
			prevDialogObj.style.display ='none';
		}
	}
	prevDialogObj = d.getElementById(dialogObj.id);
}
function yreg_setLayerLocation(div,href,offx,offy) {
	var e = d.getElementById(div);
	//get position of link
	var x=ylib_getPageX(href);
	var y=ylib_getPageY(href);
	// check and set there is offset
	x= offx ? x + offx : x;
	y= offy ? y + offy : y;
	//move layer
	ylib_moveTo(e, x, y);
}



//Contents for menu 1
		
var menuwidth='60px' //default menu width
var menubgcolor='#FFFFFF'  //menu bgcolor
var disappeardelay=150  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

function writeDiv()
{
if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
}

function getposOffset(what, offsettype)
{
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null)
	{
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth)
{
	if (ie4||ns6)
	dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (menuwidth!="")
	{
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
	}
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	{
		showHideCombos(dropmenuobj, dropmenuobj.x, dropmenuobj.y, 'hidden');
		obj.visibility=visible
	}
	else if (e.type=="click")
	{
		showHideCombos(dropmenuobj, dropmenuobj.x, dropmenuobj.y, 'visible');
		obj.visibility=hidden
	}
}

function iecompattest()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge)
{
	var edgeoffset=0
	if (whichedge=="rightedge")
	{
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else
	{
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
	}
	return edgeoffset
}

function populatemenu(what)
{
	if (ie4||ns6)
	dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth)
{
	autoHide();
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)

	if (ie4||ns6)
	{
		var x = getposOffset(obj, "left");
		var y = getposOffset(obj, "top");
		dropmenuobj.x=x
		dropmenuobj.y=y+2
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}

	return clickreturnvalue()
}

function clickreturnvalue()
{
	if (ie4||ns6) return false
	else return true
}

function contains_ns6(a, b) 
{
	while (eval(b) && b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function dynamichide(e)
{
	if (ie4&&!dropmenuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu()
}

function hidemenu(e)
{
	if (typeof dropmenuobj!="undefined")
	{
		if (ie4||ns6)
		{
			showHideCombos(dropmenuobj, dropmenuobj.x, dropmenuobj.y, 'visible');
			dropmenuobj.style.visibility="hidden"
		}
	}
}

function delayhidemenu()
{
	if (ie4||ns6)
	delayhide=setTimeout("hidemenu()",disappeardelay)
	if (hidemenu_onclick=="yes")
	{
		document.onclick=
		function(e){};
	}
}

function clearhidemenu()
{
	if (typeof delayhide!="undefined")
	clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

