// store today's date in var
function getBrowser()
{
	if(navigator.appName.indexOf( "Netscape" ) != -1) 
	{
		// is netscape
		if(navigator.userAgent.indexOf( "Netscape/7" ) != -1) 
		{
			return "NS7";
		}
		else
		{
			// older then 7
			return "NS";
		}
	}
	else
	{
		// is IE
		return "IE";
	}
}

// master array obj to hold all created info objects in memory
var _info_array = new Array();
// calendar object constructor
//function contactInfo(name, xPos, yPos, captureMouse, termDonorInformation, termName, termAddress, termContactName, termPhone, termEmail)
function quickLink(name, xPos, yPos, captureMouse)
{
	// properties
	this.name = name;
	this.xPos = xPos;
	this.yPos = yPos;
	//this.hide = 1;
	if(typeof(captureMouse) == 'undefined') {
		this.captureMouse = false;
	} else {
		this.captureMouse = captureMouse;
	}

	// store the terms for the info box based on current language
	//this.termName = termName;
	//this.termAddress = termAddress;
	//this.termContactName = termContactName;
	//this.termPhone = termPhone;
	//this.termEmail = termEmail;
	//this.termDonorInformation = termDonorInformation;
	
	// methods
	this.show = showInfo;
	this.hide = hideInfo;
	this.chkToHide = chkToHide;
	this.chkShow = chkShow;
	
	// set mouse capture if required
	// set event handlers
	if(this.captureMouse)
	{
		if (document.layers) 
		{ // Netscape
		    document.captureEvents(Event.MOUSEMOVE);
		    document.onmousemove = captureMousePosition;
		} else if (document.all) 
		{ 
			// Internet Explorer
		    document.onmousemove = captureMousePosition;
		} else if (document.getElementById) 
		{ 
			// Netcsape 6
		    document.onmousemove = captureMousePosition;
		}
		
	}
	
	
	// init
	_info_array[_info_array.length + 1] = this.name;
	
	// CHANGE THIS
	inner_html = 'hi2u';
	
	// div code
	outp = '';
	outp += '<div id='+this.name+' style="background-color: #FFFFFF;width:250px; position:absolute;z-index:99;';
	outp += 'left:'+this.xPos+'px; top:'+this.yPos+'px; visibility:hidden;" ';
	outp += 'onmouseover="'+this.name+'.chkShow();" onmouseout="'+this.name+'.hide();">';
	outp += inner_html;
	outp += '</div>';
	
	document.write(outp);
	
//alert('2:'+ this.name);	
	
	
}

//-- PUBLIC VAR FOR BETA TOOL VISIBILITY --//
//-- defined in header-int.asp (var isBetaVisible = 0;)

//function setInnerHtml(objInfo,name,address,contactName,phone,email) {
function setInnerHtml(objInfo) {
	var text;
	var text2;
	
	text = 				''; //<div id="quickLinkContent" style="width:100% height="100%'>;
	text = 				'<div id="quickLinkContent" style="width:100% height=100%; border: 1px solid #555555; padding-left:5px; padding-right:5px; padding-top:3px; padding-bottom:3px;">';	
	text = text + '<table width="100%" cellpadding="0" cellspacing="0">';
	text = text + '<tr>';
	text = text + '<td align="middle" bgcolor="6A757C"><span class="quickLinkHeader">Research Tools</span></td>';
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	text = text + '<td width="1" bgcolor="#666666"><img src="images/spacer.gif" width="1"></td>';
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';
	text = text + '<td align="middle" bgcolor="6A757C"><span class="quickLinkHeader">Documents</span></td>';
	text = text + '</tr>'
	text = text + '<tr>';	
	
	text = text + '<td><a href="index.asp?toc=content&amp;id=11">Jurisprudence Citators</a></td>';
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	text = text + '<td width="1" bgcolor="#666666"><img src="images/spacer.gif" width="1"></td>';
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	
	text = text + '<td><a href="index.asp?toc=wtoDisputeDirectory&id=10">WTO Jurisprudence</a></td>';	
	//text = text + '<td><a href="index.asp?toc=content&amp;id=10">WTO Dispute Settlement Documents</a></td>';	
	
	text = text + '</tr>'
	text = text + '<tr>';	
	
	text = text + '<td><a href="index.asp?toc=content&amp;id=97">Full Text Search</a></td>';	
	
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	text = text + '<td width="1" bgcolor="#666666"><img src="images/spacer.gif" width="1"></td>';	
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	
	text = text + '<td><a href="index.asp?toc=otherWtoDSDocsCategories&id=10">Other WTO Dispute documents</a></td>';
	
	text = text + '</tr>';
	text = text + '<tr>';	
	text = text + '<td><a href="index.asp?toc=treatyInterp">Treaty Interpretation</a></td>';
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	text = text + '<td width="1" bgcolor="#666666"><img src="images/spacer.gif" width="1"></td>';	
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	

	text = text + '<td><a href="index.asp?toc=gattDisputeDirectory&tab=d">GATT 1947 & Code Dispute</a></td>';		
	
	text = text + '</tr>';
	text = text + '<tr>';	
	text = text + '<td><a href="index.asp?toc=termsPhrases">Terms Phrases</a></td>';
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	text = text + '<td width="1" bgcolor="#666666"><img src="images/spacer.gif" width="1"></td>';	
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	

	text = text + '<td><a href="index.asp?toc=negHistory">Uruguay Round Negotiating History</a></td>';		
	//text = text + '<td><a href="index.asp"></a></td>';		
	
	text = text + '</tr>'
	text = text + '<tr>';	
	text = text + '<td><a href="index.asp?toc=content&amp;id=53">Jurisprudence Pending</a></td>';
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	text = text + '<td width="1" bgcolor="#666666"><img src="images/spacer.gif" width="1"></td>';	
	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
	
	text = text + '<td>&nbsp;</td>';
	//text = text + '<td align="middle" bgcolor="6A757C"><span class="quickLinkHeader">Statistics</span></td>';
	
	text = text + '</tr>';
	
	if( isBetaVisible == 1 ){			
		text = text + '<tr>';	
		
		text2 = '<td><a href="index.asp?toc=mainAnnot" style="border:0px;">Annotated Agreements</a> - <span style="color:#E9B95F;font-size:0.75em;">BETA</span></td>';
	
		if( isBetaVisible == 1 ){
			text = text + text2;
		}else{
			text = text + '<td>&nbsp;</td>';
		}	
		text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
		text = text + '<td width="1" bgcolor="#666666"><img src="images/spacer.gif" width="1"></td>';	
		text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
		
		text = text + '<td>&nbsp;</td>';		
		//text = text + '<td><a href="index.asp?toc=DSStatistics&type=general">Dispute Settlement Statistics</a></td>';		
		
		text = text + '</tr>';				
	}
	
	text = text + '<tr>';	
	
	text2 = '<td><a href="index.asp?toc=content&amp;id=50" style="border:0px;">Navigator</a> - <span style="color:#E9B95F;font-size:0.75em;">BETA</span></td>';			


	//--- Task 1512 - for Phase II ---//
//	if( isBetaVisible == 1 ){
//		text = text + text2;
//	}else{
//		text = text + '<td>&nbsp;</td>';
//	}	
//	
//	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
//	text = text + '<td width="1" bgcolor="#666666"><img src="images/spacer.gif" width="1"></td>';	
//	text = text + '<td width="5" ><img src="images/spacer.gif" width="5"></td>';	
//	text = text + '<td><a href="index.asp"></a></td>';	
//	text = text + '</tr>';					
	text = text + '</table>';
//	text = text + '</table></div>';	

	document.getElementById(objInfo.name).innerHTML = text;

	//alert(objInfo.name + ' / '  + text);
	//alert('name: ' + objInfo.name);	
	//alert(document.getElementById(objInfo.name));
}
function chkShow() {
	this.to_hide = 0;
}
function showInfo() {
	//setInnerHtml(this,name,address,contactName,phone,email);
	//alert('1a');	
	setInnerHtml(this);
	//alert('1b');
	//document.getElementById(this.name).style.top  = yMousePos - document.body.offsetTop  + 'px';
	//document.getElementById(this.name).style.left = xMousePos - document.body.offsetLeft + 'px';

	var ht = document.getElementById('hrefQuickLink');		
	document.getElementById(this.name).style.top    = findPosY(ht)+16+'px';
	document.getElementById(this.name).style.left   = findPosX(ht)-10+'px';
	document.getElementById(this.name).style.width  = '320px';
	document.getElementById(this.name).style.Height = '300px';
	this.to_hide = 0;

	//alert('1c1:'+document.getElementById(this.name).style.top);
	//alert('1c2:'+document.getElementById(this.name).style.left);

	document.getElementById(this.name).style.visibility = "visible";
	// set focus on shown element to remove and blinking cursors which would shine thru layer

	//alert('1d');

	// loop through master array, ensuring that only this.name is shown, all others must hide
	for(i in _info_array) {
		if(_info_array[i] != this.name) {document.getElementById(_info_array[i]).style.visibility = "hidden";}
	}
	//alert('1e');	
}
function hideInfo(immediate)
{
	this.to_hide = 1;
	if(immediate != true) {
		setTimeout(this.name+'.chkToHide();',500);
	} else {
		this.chkToHide();
	}
}
function chkToHide()
{
	if(this.to_hide == 1) 
	{
		document.getElementById(this.name).style.visibility = "hidden";
	}
}
xMousePos = 0;
yMousePos = 0;
xMousePosMax = 0;
yMousePosMax = 0;

// capturing mouse position script
function captureMousePosition(e)
{
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
		xMousePos = window.event.clientX + document.documentElement.scrollLeft;
		yMousePos = window.event.clientY + document.documentElement.scrollTop;
		
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
		xMousePos = e.clientX + pageXOffset;
		yMousePos = e.clientY + pageYOffset;
		xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
