//Display the Recactedtext for Text Search Tool
function OpenRedactedText()
{
var win = window.open("", "RedactedText", "width=300,height=150,resizable=no"); // a window object
with (win.document) {
  open("text/html", "replace");
  write("<HTML><HEAD><TITLE>RedactedText</TITLE></HEAD><BODY style='font: normal 12px Arial;'>Search " + 
   '"' + "redacted texts" + '"' +
   " to avoid searching lengthy passages in reports, awards and decisions "  +
   "and annexes thereto that simply reiterate the arguments of the parties. This option also reduces " +
   "the size of the documents and makes browsing search results faster.</BODY></HTML>");
   close();
  }

}

//find the left of the screen position and place the div for video link in welcome page
function fVideoLink()
{
//Find firefox or IE
var firefox = document.getElementById&&!document.all

var ScreenWidth = window.screen.availWidth //gets the available width (Available Width)
var CenterWidth = ScreenWidth/2 //divides the width by 2 (Center Width)
if(firefox)
    var LeftPostiton = CenterWidth - 180  //find the left position
else
    var LeftPostiton = CenterWidth +90  //find the left position
//alert(LeftPostiton + "Screen"+ CenterWidth + "Sss" + ScreenWidth)
 document.getElementById('videoLinkDiv').style.left=LeftPostiton + 'px';
 document.getElementById('videoLinkDiv').style.right='0';
 document.getElementById('videoLinkDiv').style.top='90px';

}
function mOvr(src,clrOver){
	if (!src.contains(event.fromElement)){
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
	}
}
function mOut(src,clrIn){
	if (!src.contains(event.toElement)){
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	}
}
function mClk(src){
	if(event.srcElement.tagName=='TD')
		src.children.tags('A')[0].click();
}

function isEmpty(s)
{ 
	return ((s == null) || (s.length == 0)) 
}


var pdfWinObj
var lastPdfFile = ''
var lastDestCode = ''

function pdfWithDest(pdfFile, destCode) {
	if ( isEmpty(destCode) ) {
		destCode = 'Page=1' //when there's not destination code issue command to go to the 1st page in the file
	}
	
	pdfURL = pdfFile + '#' + destCode
	
	//the pdflink.htm page is just an empy page to fix problems while loading pdf files multiple times in the same open window
	pdfWinObj = window.open('/pdflink.htm', 'pdfWin')
	pdfWinObj = window.open(pdfURL, 'pdfWin')
	pdfWinObj.focus()
	
	lastPdfFile = pdfFile
	lastDestCode= destCode
	
//	return
}

function pdfWithDestTarget(pdfFile, destCode, targetwin) {
	if ( isEmpty(destCode) ) {
		destCode = 'Page=1' //when there's not destination code issue command to go to the 1st page in the file
	}
	
	if ( targetwin == '' )  {
		targetwin = 'pdfWin'
	}
	 
	pdfURL = pdfFile + '#' + destCode
	
	//the pdflink.htm page is just an empy page to fix problems while loading pdf files multiple times in the same open window
	pdfWinObj = window.open('pdflink.htm', targetwin)
	//refreshTarget(targetwin)	
	
	pausecomp(200) //pause to see if fix problem when switching between destination codes/closing/re-opening the same file
	pdfWinObj = window.open(pdfURL, targetwin)
	pausecomp(100) //pause to see if fix problem when switching between destination codes/closing/re-opening the same file	
	//pdfWinObj.location.reload()
	pdfWinObj.focus()
	
	lastPdfFile = pdfFile
	lastDestCode= destCode
	
//	return
}

function pausecomp(millis) 
{
	date = new Date();
	var curDate = null;
	
	do { var curDate = new Date(); } 
	while(curDate-date < millis);
} 


var pdfWinObj

function pdfWithDest3(pdfFile, destCode) {
	//this has to be changed to find a way to work better with the pdfs
	//alert( typeof(pdfWin))
	pdfURL = pdfFile + '#' + destCode
	popupWin = window.open(pdfURL,'pdfWin');
	popupWin.focus();
	pdfWinObj = popupWin
}


/*
var NextWin = 0;
var popupWins = new Array();
*/

/*
function pdfWithDest2(pdfFile, destCode) {
	var pdfWinObj;
	var WinName;
	var name1;
	
	pdfURL  = pdfFile + '#' + destCode;
	name1   = pdfFile;
		
	NextWin = NextWin + 1;
	name1    = 'pdfWin' + NextWin;
	popupWins[name1] = window.open(pdfURL,name1);
	popupWins[name1].focus();
	//	return
}


function pdfWithDest3(pdfFile, destCode) {
	var pdfWinObj;
	var WinName;
	var name1;
	
	pdfURL  = pdfFile + '#' + destCode;
	name1   = pdfFile;
	alert(pdfFile + destCode)
	
	//if ( typeof( popupWins[name1] ) == 'object' ) {
	if (typeof popupWins[name1] == 'object') {
		NextWin = NextWin + 1;
		name1    = name1 + NextWin;
		popupWins[name1] = window.open(pdfURL,name1);
	} else {
		popupWins[name1] = window.open(pdfURL,name1);
	}
	popupWins[name1].focus();
	//	return
}
*/


var targetWinObj
function refreshTarget(targetName) {
	targetWinObj = window.open('', targetName)
	targetWinObj.document.location.reload(true)
	targetWinObj.focus()
}

function FieldIsNotEmpty(fieldId, msg){
	var fld=document.getElementById(fieldId);
	var fldText;
	fldText = fld.value;
	if ( fldText == '') {
		alert(msg);
		fld.focus();		
		return false;
	}
    return true;
}

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30};
		if (i==2) {this[i] = 29};
   } 
   return this;
}

function DateIsValid(fieldId, allowEmpty){
	var dt=document.getElementById(fieldId);
	var strDate;
	strDate = dt.value;
	if (strDate == '' && allowEmpty == true ) {
		return true;
	}
	strDate = strDate.replace('-',dtCh);
	strDate = strDate.replace('-',dtCh);
	if (isDateVar(strDate)==false){
		dt.focus();
		return false;
	}
    return true;
}

function isDateVar(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day");
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date");
		return false;
	}
return true;
}

function adjustHeight( divID ){
	var x = document;
	
	var div_height = x.getElementById( divID ).offsetHeight;
	var min_height = 725;
	var max_height = 0;
	
	max_height = window.screen.availHeight;
	
	if( max_height >= min_height ){
		div_height_adjment = max_height - min_height;
		x.getElementById( divID ).style.height = div_height + (max_height - min_height);
	}
	
}

/**************************************** Start of Smart Navigation Code **********************************/
function GetScrollPosition(topleft) {
	var vtop, vleft;

	//alert('a: ');
		
	try 
	{
		if ( (document.documentElement.scrollTop) || (document.documentElement.scrollLeft) ) {
			vtop = document.documentElement.scrollTop;
   		vleft= document.documentElement.scrollLeft;
   		
   	} else if ( document.body.scrollTop	|| document.body.scrollLeft ) {
			vtop = document.body.scrollTop;
   		vleft= document.body.scrollLeft;
   		
		} else if ( document.pageYOffset || document.pageXOffset ) {
			vtop = document.pageYOffset;
   		vleft= document.pageXOffset;
   		
		} else {
			vtop = 0;
			vleft= 0;
		}
	}
	catch (Err)
	{
		vtop = 0;
		vleft = 0;
	}
	
	return (topleft == 'bottom' ? vleft : vtop);
}	

function SaveScrollPositionSimple(smartCookieName) {
	SaveScrollPositionSimpleFinal(smartCookieName,false,false)
}
function SaveScrollPositionSimplePage(smartCookieName,isParentStorage) {
	SaveScrollPositionSimpleFinal(smartCookieName, true, isParentStorage)
}

function SaveScrollPositionSimpleFinal(smartCookieName,pageStore,isParentStorage) {
	var vtop, vleft;
	var s1, s2, s3;
	
	try 
	{
		if ( (document.documentElement.scrollTop) || (document.documentElement.scrollLeft) ) {
			vtop = document.documentElement.scrollTop;
   		vleft= document.documentElement.scrollLeft;
   		
   	} else if ( document.body.scrollTop	|| document.body.scrollLeft ) {
			vtop = document.body.scrollTop;
   		vleft= document.body.scrollLeft;
   		
		} else if ( document.pageYOffset || document.pageXOffset ) {
			vtop = document.pageYOffset;
   		vleft= document.pageXOffset;
   		
		} else {
			vtop = 0;
			vleft= 0;
		}
	}
	catch (Err)
	{
		vtop = 0;
		vleft = 0;
	}
	
	//smart navigation for annotations
	if ( pageStore == false ) {
		setCookie(smartCookieName+'_top' ,vtop ,1);
		setCookie(smartCookieName+'_left',vleft,1);
	} else {
		setCookiePage(smartCookieName+'_top' ,vtop ,isParentStorage);
		setCookiePage(smartCookieName+'_left',vleft,isParentStorage);
	}
	
	//alert('b: ');
  //alert('b: ' + smartCookieName + '/' + vtop + '/' + vleft + '/' + document.documentElement.scrollTop + '/' + document.body.scrollTop);	
}	


function SaveScrollPosition(smartCookieName) {
	var vtop, vleft;

	//alert('a: ');
		
	try 
	{
		if ( (document.documentElement.scrollTop) || (document.documentElement.scrollLeft) ) {
			vtop = document.documentElement.scrollTop;
   		vleft= document.documentElement.scrollLeft;
   		
   	} else if ( document.body.scrollTop	|| document.body.scrollLeft ) {
			vtop = document.body.scrollTop;
   		vleft= document.body.scrollLeft;
   		
		} else if ( document.pageYOffset || document.pageXOffset ) {
			vtop = document.pageYOffset;
   		vleft= document.pageXOffset;
   		
		} else {
			vtop = 0;
			vleft= 0;
		}
	}
	catch (Err)
	{
		vtop = 0;
		vleft = 0;
	}
	
	//smart navigation for annotations
	setCookie(smartCookieName+'_top' ,vtop ,1);
	setCookie(smartCookieName+'_left',vleft,1);
	//alert('b: ');
  //alert('b: ' + smartCookieName + '/' + vtop + '/' + vleft + '/' + document.documentElement.scrollTop + '/' + document.body.scrollTop);	
  
  //setting this cookie we are able to quit the recursive/infinite call
  //if ( getCookie(smartCookieName+'_quit') == 'yes') {
  //	setCookie(smartCookieName+'_quit','',1);
  //	//alert('quit');
  //	return false;
  //}
  
  if ( smartCookieName != 'temp' ) {
  	setTimeout('SaveScrollPosition("'+smartCookieName+'")', 350); //<- this cant be to low as we noticed some problems like the browser thinking the pages hasnt completed finished loading
	}
	return false;
}	

function fixScrollPositionPDFWin(smartCookieName,pageStore, isParentStorage) {
	var vtop,vleft;
	//alert('a:');
	if ( pageStore == false ) {
		vtop = getCookie(smartCookieName+'_top');
		//alert('5:'+vleft+'/'+vtop);
	} else {
		vtop = getCookiePage(smartCookieName+'_top',isParentStorage);
		//alert('5:'+vleft+'/'+vtop);
	}
	
	//alert('5:'+vtop);
	
	pdfManWinQty = getCookie('pdfmanwinqty');
	
	//alert('6:'+pdfManWinQty);
	
	if ( pdfManWinQty == '' || pdfManWinQty == '0' ) {
		return;	
	}
	pdfManWinQty= parseInt(pdfManWinQty);
	vtop 				= parseInt(vtop);
	vtop				= vtop - (200*pdfManWinQty);
	vtop 				+= ''; //convert to string;
	//alert('9:'+vtop);
	
	if ( pageStore == false ) {
		setCookie(smartCookieName+'_top' ,vtop ,1);
		//alert('5:'+vleft+'/'+vtop);
	} else {
		setCookiePage(smartCookieName+'_top' ,vtop ,isParentStorage);
		//alert('5:'+vleft+'/'+vtop);
	}
	return true;
}

function RestoreScrollPositionSimple(smartCookieName) {
	RestoreScrollPositionSimpleFinal(smartCookieName,false,false)
}
function RestoreScrollPositionSimplePage(smartCookieName,isParentStorage) {
	RestoreScrollPositionSimpleFinal(smartCookieName, true, isParentStorage)
}

function RestoreScrollPositionSimpleFinal(smartCookieName,pageStore,isParentStorage) {
	var vtop,vleft;
	//alert('4:'+vleft+'/'+vtop);
	if ( pageStore == false ) {
		vtop = getCookie(smartCookieName+'_top');
		//alert('5:'+vleft+'/'+vtop);
		vleft= getCookie(smartCookieName+'_left');
	} else {
		vtop = getCookiePage(smartCookieName+'_top',isParentStorage);
		//alert('5:'+vleft+'/'+vtop);
		vleft= getCookiePage(smartCookieName+'_left',isParentStorage);
	}
	//alert('6:'+vleft+'/'+vtop);	
	scrollTo(vleft, vtop); // determined during run-time
	return false;
}

function RestoreScrollPosition(smartCookieName, timeCalled) {
	var vtop,vleft;
	
	vtop = getCookie(smartCookieName+'_top');
	vleft= getCookie(smartCookieName+'_left');

	scrollTo(vleft, vtop); // determined during run-time
	//document.documentElement.scrollTop = vtop;
	//alert('2: ' + vtop + '/' + vleft + '/' + document.documentElement.scrollTop + '/' + document.body.scrollTop);
	if ( timeCalled == 1 ) {
		//recall this function as sometimes some events seem to reset the scroll position, make sure it will work
		setTimeout('RestoreScrollPosition("'+smartCookieName+'",-1)', 10);
		setTimeout('RestoreScrollPosition("'+smartCookieName+'",-2)', 50);
		setTimeout('RestoreScrollPosition("'+smartCookieName+'",2)', 100);
	} else if ( timeCalled > 0 ) {
		//after 2nd call has been made to this function call the function to save the position and start the saving process
		//alert('9:'+timeCalled);
		setTimeout('SaveScrollPosition("'+smartCookieName+'")', 10);
	} 
	else { //do nothing
		//alert('1:'+timeCalled);	
	}
}

/**************************************** End of Smart Navigation Code **********************************/

	function showWinSize() {
		var winW = 630, winH = 460;

		if (parseInt(navigator.appVersion)>3) {
	 		if (navigator.appName=="Netscape") {
	  		winW = window.innerWidth-16;
	  		winH = window.innerHeight-16;
	 		}
	 		if (navigator.appName.indexOf("Microsoft")!=-1) {
	  		winW = document.body.offsetWidth-20;
	  		winH = document.body.offsetHeight-20;
	 		}
	 	}
 		alert(winW + '/' + winH);
 		return false;
	}
	
	//returns window client size (can be used for pop-ups and regular windows.
	//In IE it seems that the document.body.offsetHeight returns the height of the
	//body that has been filled with content which is not necessariarly the real
	//height of the window/pop-up that is visible to the user as some of the content
	//that is visible maybe be empty and is not part of the body height.
	function getWinHeight(SetDefaultValue) {
		var winH = SetDefaultValue;

		//alert('1:'+navigator.userAgent.toLowerCase());

		if (parseInt(navigator.appVersion)>3) {
	 		if (navigator.appName=="Netscape") {
	  		winH = window.innerHeight-16;
	 		}
	 		if (navigator.appName.indexOf("Microsoft")!=-1) {
	  		if ( navigator.userAgent.toLowerCase().indexOf('msie 7') > -1 ) {
	  			//winH = document.body.offsetHeight-20; //ie7
	  			winH = getIEClientHeight();
	  			//alert('2a:'+winH);	  		
	  		} else {
	  			winH = getIEClientHeight();
	  			//alert('2b:'+winH);	  		
	  		}
				//alert('2:'+winH+'/'+document.body.offsetHeight);	  		
	 		}
	 	}
 		return winH;
	}

function getIEClientHeight() {
	 var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myHeight;
}

//function getIEClientHeight()
//  {
//    // it is important to resize the window to the
//    // wanted values first, even if we won't get them.
//    //window.resizeTo(W, H);
//
////alert('1:');
//
//    // create the checkpoint element
//    var cp = document.createElement("div");
//    cp.style.position = "absolute";
//    cp.style.width = "0px";
//    cp.style.height = "0px";
//    cp.style.right = "0px";
//    cp.style.bottom = "0px";
//
////alert('2:');
//
//    // we can only read it's position after we
//    // insert it into the document
//    document.body.appendChild(cp);
//
////alert('3:');
//
//    // here we get the actual client size
//    var current_width = cp.offsetLeft;
//    var current_height = cp.offsetTop;
//
////alert('a:'+current_height);
//
//    // here we find out how much more we need
//    // in order to get to the needed W x H size
//    // (or in other words, we compute the size of
//    // window decorations: border, scroll bars, title)
//    //var dw = W - current_width;
//    //var dh = H - current_height;
//
//    // and _finally_ we get what we need
//    //window.resizeBy(dw, dh);
//
//    // we can safely delete the checkpoint now
//    document.body.removeChild(cp);
//    
//		//alert('a:'+current_height);		
//    
//    if ( navigator.userAgent.toLowerCase().indexOf('msie 7') > -1 ) {
//			current_height = current_height; //the top bars???
//			//alert('1:'+current_height);
//		} else {
//			current_height = current_height - 400; //ie6 top bars???
//			//alert('2:'+current_height);
//		}
//		if ( current_height < 0 ) {
//			current_height = 300;
//		}
//
//		//alert('c:'+current_height);		
//    return current_height;
//  }

function getWinWidth(SetDefaultValue) {
		var winW = SetDefaultValue;

		if (parseInt(navigator.appVersion)>3) {
	 		if (navigator.appName=="Netscape") {
	  		winW = window.innerWidth-16;
	 		}
	 		if (navigator.appName.indexOf("Microsoft")!=-1) {
	 			if ( navigator.userAgent.toLowerCase().indexOf('msie 7') > -1 ) {
	 				winW = getIEClientWidth();
	 			} else {
	 				//winW = document.body.offsetWidth-20;
	 				winW = getIEClientWidth();
	 			}
	 		}
	 	}
	 	return winW;
}

function getIEClientWidth() {
	var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight= document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight= document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myWidth;
}
	
//function getIEClientWidth()
//  {
//    // it is important to resize the window to the
//    // wanted values first, even if we won't get them.
//    //window.resizeTo(W, H);
//
////alert('1:');
//
//    // create the checkpoint element
//    var cp = document.createElement("div");
//    cp.style.position = "absolute";
//    cp.style.width = "0px";
//    cp.style.height = "0px";
//    cp.style.right = "0px";
//    cp.style.bottom = "0px";
//
////alert('2:');
//
//    // we can only read it's position after we
//    // insert it into the document
//    document.body.appendChild(cp);
//
////alert('3:');
//
//    // here we get the actual client size
//    var current_width = cp.offsetLeft;
//    var current_height = cp.offsetTop;
//
////alert('a:'+current_height);
//
//    // here we find out how much more we need
//    // in order to get to the needed W x H size
//    // (or in other words, we compute the size of
//    // window decorations: border, scroll bars, title)
//    //var dw = W - current_width;
//    //var dh = H - current_height;
//
//    // and _finally_ we get what we need
//    //window.resizeBy(dw, dh);
//
//    // we can safely delete the checkpoint now
//    document.body.removeChild(cp);
//		//current_width = current_width - 50; //bars???
//    return current_width;
//  }


function alltrim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

/***********************************************************************************/

function mainPageContent(cookiename, vaction) {
//alert('1:'+	vaction);
	setCookie(cookiename, vaction, 365)
	if ( vaction == 'show' ) {
		document.getElementById('hrefMainPageContentShow').style.display='none';		
		document.getElementById('hrefMainPageContentMinimize').style.display='';
		document.getElementById('maincontenttext').style.display='';
		document.getElementById('maincontenttext2').style.display='none';
	} else {
		document.getElementById('hrefMainPageContentShow').style.display='';		
		document.getElementById('hrefMainPageContentMinimize').style.display='none';
		document.getElementById('maincontenttext').style.display='none';
		document.getElementById('maincontenttext2').style.display='';
	}
	
//alert('2:'+	vaction);	
	return false;
}

/***********************************************************************************/

	function checkAgreeIcons(showIcons) {
		var str, i, currId, obj;
		
		//alert('1');
		
		//loop twice to apply changes to the different possible html tags
		for ( i = 1; i <= 2; i++ ) {
		
		    if ( i == 1 )
		        currId = 'bodytext';
		    else
		        currId = 'bodytextdynamic';
		    
		    obj = document.getElementById(currId);
		    
		    if ( obj ) {
		    
		        str = document.getElementById(currId).innerHTML;
        		
		        //alert('a0');	
		        //alert(str.substring(1,10));
		        if ( (showIcons == '0') || (showIcons == '' && str.indexOf('agreeexternalblank') == -1) ) {
        			
			        //alert('a91');					
			        str = str.replace(/agreeexternallink/g,'agreeexternalblank');
			        str = str.replace(/agreeinternallink/g,'agreeinternalblank');
        			
			        document.getElementById('acheckAgreeIcons1').style.display='none';
			        document.getElementById('acheckAgreeIcons2').style.display='';
        			
			        //alert('a1');			
			        setCookie('agreeBodyIcons', '0', 5);
			        //alert('b1');			
		        } else {
			        str = str.replace(/agreeexternalblank/g,'agreeexternallink');
			        str = str.replace(/agreeinternalblank/g,'agreeinternallink');
        			
			        document.getElementById('acheckAgreeIcons1').style.display='';
			        document.getElementById('acheckAgreeIcons2').style.display='none';
        			
			        setCookie('agreeBodyIcons', '1', 5);			
		        }
        		
		        //alert('2');
        		
		        document.getElementById(currId).innerHTML = str;
    		
		        //alert('3');
    		
		        //document.getElementById('divtabPDF').style.display='none';
		   
		   } //if ( obj )   
		
		} 
		
		//bodytext
		
		return false;
	}
	
	function initAgreeIcons() {
		if ( getCookie('agreeBodyIcons') == null ) {
			//alert('a: null');
		} else {
			//alert('a:'+getCookie('agreeBodyIcons'));
			if ( getCookie('agreeBodyIcons') == '0' ) {
				checkAgreeIcons('0');
			}
		}
		return false;
	}
	

/***********************************************************************************/


function showLoadingWin(titleWin, toDefinedLater, divid, width1, height1) {
	try {
		//alert('1');
		if (typeof divid   == 'undefined' ) divid   = 'msgdiv'; //optional argument
		if (typeof height1 == 'undefined' ) height1 = '250px'; //optional argument
		if (typeof width1  == 'undefined' ) width1  = '280px'; //optional argument
		
		if (divid   == '' ) divid   = 'msgdiv'; //optional argument
		if (height1 == '' ) height1 = '250px'; //optional argument
		if (width1  == '' ) width1  = '280px'; //optional argument
		
				
		if (typeof titleWin   == 'undefined' ) titleWin   = '';
		if ( titleWin == '' ) {
		    titleWin = 'Please Wait...';
		}
		
		//alert('2:'+divid);
		document.forms[0].fuzziness.style.display = 'none';
		document.forms[0].fuzziness.style.visibility = 'hidden';

	}
	catch (Err)
	{
	}	
	//alert(titleWin);
	divwin=dhtmlwindow.open('divbox', 'div', divid, titleWin, 'width='+width1+',height='+height1+',left=200px,top=150px,resize=1,resizable=no,scrolling=0,center=1');
	return true;
}

function showWinFrame(url1, winTitle, winW, winH ) {
    var win7, winH, winW, htmlContent, msgWin, urlString;
    //var w = 480, h = 340;

//    winH = 280;
//    winW = 280;
//		if (document.all) {
//		   /* the following is only available after onLoad */
//		   w = document.body.clientWidth;
//		   h = document.body.clientHeight;
//		}
//		else if (document.layers) {
//		   w = window.innerWidth;
//		   h = window.innerHeight;
//		}
//
//		var leftPos = (w-winW)/2;
//		var topPos  = (h-winH)/2;

	
//		urlString = folderAspFile+"loadingWin.asp?loadmessage="+loadMessage;
//		msgWin = window.open(urlString, 'msgFTSWin', 'width='+winW+',height='+winH+',top='+topPos+',left='+leftPos+',status=no,scrollbars=no,resizable=no');
//    msgWin.focus();
    		
		//ajax, iframe, inline
		//alert(url1+'/'+winW+'/'+winH);
		win7=dhtmlwindow.open("winframe7", "iframe", url1, winTitle, "width="+winW+",height="+winH+",status=no,center=1,scrolling=0,scrollbars=no,resize=1,resizable=yes");
		win7.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
			return true; //window.confirm("Close window 1?");
		}
		win7.show();
		
		return true;
	}
	
function showWinModal(url1, winTitle, winW, winH ) {
    var win777, winH, winW, htmlContent, msgWin, urlString;

	//ajax, iframe, inline
	//alert(url1);
	win777=dhtmlmodal.open("winframe777Modal", "iframe", url1, winTitle, "width="+winW+",height="+winH+",status=no,center=1,scrolling=1,scrollbars=no,resize=1");
	win777.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
		return true; //window.confirm("Close window 1?");
	}
	win777.show();
	
	return true;
	}	
	
function showShortTitles() {
    var urlString;
    var win1, winH, winW;
    
    urlString = 'shorttitles.asp';
    
    /************************************************************************
    	This fixes a problem that when opening and closing the same window and
    	clicking on a PDF link would make the PDF to be opened in new windows 
    	instead of its own iframe probably something related to the div/iframe 
    	elements being duplicated on the html code.
    ************************************************************************/

    //alert('1:'+urlString);
        
    winH = getWinHeight(550);
    winW = getWinWidth(400);
    
    winH -= 50;
    winW -= 200;
    
    if ( winW < 350 ) {
    	winW = 350;
    }
    
    if ( winH < 400 ) {
    	winH = 400;
    }

	//alert(getIEClientHeight(500));
	//alert(winW + '/' + winH)
	
	//alert(urlString);
	win1=dhtmlmodal.open("shortTitleWin", "iframe", urlString, "Short Titles", "width="+winW+",height="+winH+",status=no,center=1,scrolling=1,scrollbars=yes,resize=1,resizable=yes", "recal");
	win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
		return true; //window.confirm("Close window 1?");
	}

	win1.show();
	//alert('9');		
	
	return false;
}

function showLearningCentre() {
    var urlString;
    var win1, winH, winW;
    
    urlString = 'learningcentre/dsp_learningCentre.asp';
    
    /************************************************************************
    	This fixes a problem that when opening and closing the same window and
    	clicking on a PDF link would make the PDF to be opened in new windows 
    	instead of its own iframe probably something related to the div/iframe 
    	elements being duplicated on the html code.
    ************************************************************************/

    //alert('1:'+urlString);
        
    winH = getWinHeight(750);
    winW = getWinWidth(780);
    
    winH -= 50;
    winW -= 50;

	//alert(getIEClientHeight(500));
	//alert(winW + '/' + winH)
	
	//alert(urlString);
	//alert(urlString);
	win1=dhtmlmodal.open("learningcentreWin", "iframe", urlString, "Learning Centre", "width="+winW+",height="+winH+",status=no,center=1,scrolling=1,scrollbars=yes,resize=1,resizable=yes", "recal");
	win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
		return true; //window.confirm("Close window 1?");
	}

	win1.show();
	//alert('9');		
	
	return false;
}

function setAnchor(anchorName, timeDelay) {
	//alert('here temp 0');
	if ( anchorName != '' ) {
		//alert('here temp 1');
		//alert('here temp 2:'+'document.location.href ='+anchorName);
		goToAnchor(anchorName);
		//call again 2nd and 3rd time to make sure no other event will reset
		setTimeout('goToAnchor("'+anchorName+'")', 10);
		setTimeout('goToAnchor("'+anchorName+'")', timeDelay);
		//document.location.href=anchorName;
		//alert('here temp 3');
	}
	return false;
}

function goToAnchor(anchorName) {
	//alert('1');
	if ( anchorName.indexOf('#') == -1 ) {
			anchorName = '#' + anchorName;
			//alert('2');
	}
	//alert('here temp 1: document.location.href ='+anchorName);
	window.location.href = anchorName;
	//alert('here temp 2');
	//document.location.href=anchorName;
	//alert('here temp 2: document.location.href ='+anchorName);
	return false;
}

//this function can be used for debugging and html code view
function openArticleCitatorMore(leveldir) {
		//termWin = window.open(urlString, 'termPhraseWin', 'width=800,height=600,status=no,scrollbars=yes,resizable=yes')
    //termWin.focus();
    //Task 1286
		//alert('1');
    
    var win1, winH, winW;
    
    /************************************************************************
    	This fixes a problem that when opening and closing the same window and
    	clicking on a PDF link would make the PDF to be opened in new windows 
    	instead of its own iframe probably something related to the div/iframe 
    	elements being duplicated on the html code.
    ************************************************************************/
    //alert('1:'+urlString);
        
    //winH = getWinHeight(550);
    
    //alert('a0:'+firstCall+'/'+winW+'/'+winH);
    
    winW = getWinWidth(800);
    
    //alert('a1:'+firstCall+'/'+winW+'/'+winH);
    
    winH = 300;
    winW -= 160;
    //saveWinW = winW;
    //saveWinH = winH;
    //firstCall = '0'; 
    //alert('a2:'+winW+'/'+winH);

		//alert(getIEClientHeight(500));
		//alert(winW+'/'+winH);
		
		//alert('3:');
		var dir = '';
		if ( leveldir == '1' ) {
			dir = '../';
		}
		
		//in a popup modal window freezes everything
		if ( leveldir == '3' ) {
		    win1=dhtmlwindow.open("articlecitatormore", "iframe", dir + "showheadertext.asp?toc=content&page=articlecitator", "More on the Article Citator", "width="+winW+",height="+winH+",status=no,center=1,scrolling=1,scrollbars=yes,resize=1,resizable=yes", "recal");
		    win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
			    return true; //window.confirm("Close window 1?");
		    }
		} else {
    		//alert('5');
			win1=dhtmlmodal.open("articlecitatormore", "iframe", dir + "showheadertext.asp?toc=content&page=articlecitator", "More on the Article Citator", "width="+winW+",height="+winH+",status=no,center=1,scrolling=1,scrollbars=yes,resize=1,resizable=yes", "recal");
	    	win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
		    	return true; //window.confirm("Close window 1?");
		    }
		}    
		//alert('3');
		win1.show();
		return false;
	}
	
//this function can be used for debugging and html code view
function openJurCitatorMore(leveldir) {
		//termWin = window.open(urlString, 'termPhraseWin', 'width=800,height=600,status=no,scrollbars=yes,resizable=yes')
    //termWin.focus();
    //Task 1286
		//alert('1');
    
    var win1, winH, winW;
    
    /************************************************************************
    	This fixes a problem that when opening and closing the same window and
    	clicking on a PDF link would make the PDF to be opened in new windows 
    	instead of its own iframe probably something related to the div/iframe 
    	elements being duplicated on the html code.
    ************************************************************************/
    //alert('1:'+urlString);
        
    //winH = getWinHeight(550);
    
    //alert('a0:'+firstCall+'/'+winW+'/'+winH);
    
    winW = getWinWidth(800);
    
    //alert('a1:'+firstCall+'/'+winW+'/'+winH);
    
    winH = 300;
    winW -= 160;
    //saveWinW = winW;
    //saveWinH = winH;
    //firstCall = '0'; 
    //alert('a2:'+winW+'/'+winH);

		//alert(getIEClientHeight(500));
		//alert(winW+'/'+winH);
		
		//alert('3:');
		var dir = '';
		if ( leveldir == '1' ) {
			dir = '../';
		}
		//alert('5');
		
		win1=dhtmlmodal.open("jurcitatormore", "iframe", dir + "showheadertext.asp?toc=content&page=jurcitator&id=154", "More on the Jurisprudence Citators", "width="+winW+",height="+winH+",status=no,center=1,scrolling=1,scrollbars=yes,resize=1,resizable=yes", "recal");
		win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
			return true; //window.confirm("Close window 1?");
		}
		//alert('3');
		win1.show();
		return false;
	}


function DocSummary(togFlag, objId) {
	//alert('1: '+togFlag);
	if ( togFlag == '1' ) {
		document.getElementById('summarytxt'+objId).style.display='';
		document.getElementById('minussummary'+objId).style.display='';
		document.getElementById('plussummary'+objId).style.display='none';
	}
	else {
		document.getElementById('summarytxt'+objId).style.display='none';
		document.getElementById('minussummary'+objId).style.display='none';
		document.getElementById('plussummary'+objId).style.display='';		
	}
	//alert('2: '+togFlag);
	return false;
}

function ToggleElement(eleId, onoff) {
	//alert('1: '+eleId+'/'+onoff);
	document.getElementById(eleId).style.display=onoff;
	return false;
}

//this function can be used for debugging and html code view
function openNavAnnotWinNew(urlString, title1) {
    var winH, winW;

    winH = getWinHeight(550);
    //alert('a0:'+firstCall+'/'+winW+'/'+winH);

    winW = getWinWidth(800);
    //alert('a1:'+firstCall+'/'+winW+'/'+winH);
    Win1 = window.open(urlString, 'navAnnotWin', 'width='+winW+',height='+winH+',status=no,scrollbars=yes,resizable=yes')
    Win1.focus();
	return false;
}
	
//function openNavAnnotWinNew(urlString, title1) {
//  var winH, winW;
//  
//  winH = getWinHeight(550);
//  //alert('a0:'+firstCall+'/'+winW+'/'+winH);
//  
//  winW = getWinWidth(800);
//  //alert('a1:'+firstCall+'/'+winW+'/'+winH);
//  
//  winH -= 50;
//  winW -= 160;
//  //winW = 760;
//  //if ( winH > 300 ) {
//  //	winH = 300;
//  //}
//  //alert('a2:'+winW+'/'+winH + '/' + urlString);
//    
//	win1=dhtmlwindow.open("navAnnotWin", "iframe", urlString, title1, "width="+winW+",height="+winH+",status=no,scrolling=1,scrollbars=yes,resize=1,resizable=yes", "recal");
//	win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
//		return true; //window.confirm("Close window 1?");
//	}
//	//alert('3');
//	win1.show();
//	return false;
//}

	var timeWin = 0;
	function openSelector_JurisCitator(urlString, openModal) {
		//termWin = window.open(urlString, 'termPhraseWin', 'width=800,height=600,status=no,scrollbars=yes,resizable=yes')
        //termWin.focus();
        //Task 1286
        //alert('1:'+openModal);
        
        var win1, winH, winW;
        
        urlString	+= '&pdfCounter='+timeWin;
        timeWin		+= 100; //maximum 100 PDF links on the page
        
        //alert('2:'+urlString);
            
        winH = getWinHeight(410);
        
        //alert('3:'+urlString);
        
        winW = getWinWidth(600);
        
        winH = Math.round(winH * 0.90);
        winW = Math.round(winW * 0.97);
        
        //alert('4:'+winH+'/'+winW);
    
        if ( openModal.toUpperCase() == "Y" ) {
		    win1=dhtmlmodal.open("JurisCitator", "iframe", urlString, "WTO Jurisprudence Citator", "width="+winW+",height="+winH+",status=no,scrolling=1,scrollbars=yes,resize=1,resizable=yes,center=1", "recal");
		    win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
			    return true; //window.confirm("Close window 1?");
		    }
		    win1.show();
		} else {
		    //window.open(urlString, 'navAnnotWin', 'width='+winW+',height='+winH+',status=no,scrollbars=yes,resizable=yes')
		    win1=dhtmlwindow.open("JurisCitator", "iframe", urlString, "WTO Jurisprudence Citator", "width="+winW+",height="+winH+",status=no,scrolling=1,scrollbars=yes,resize=1,resizable=yes,center=1", "recal");
		    win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
			    return true; //window.confirm("Close window 1?");
		    }
		    win1.focus();
		}  
		
		//alert('5');
	
		enableTooltips();
		
		//alert('now');
		//enableTooltips('JurisCitator');
		return false;
	}

//this function can be used for debugging and html code view
function openManageProfile() {
	//termWin = window.open(urlString, 'termPhraseWin', 'width=800,height=600,status=no,scrollbars=yes,resizable=yes')
    //termWin.focus();
    //Task 1286
	//alert('1');
    
    var win1, winH, winW;
    
    //alert('1:'+urlString);
        
    //winH = getWinHeight(550);
    
    //alert('a0:'+firstCall+'/'+winW+'/'+winH);
    
    winW = getWinWidth(800);
    
    //alert('a1:'+firstCall+'/'+winW+'/'+winH);
    
    winH = 480;
    winW -= 160;
 	
	win1=dhtmlmodal.open("jurcitatormore", "iframe", "dsp_changeUserName.asp", "Manage Profile", "width="+winW+",height="+winH+",status=no,center=1,scrolling=1,scrollbars=yes,resize=1,resizable=yes", "recal");
	win1.onclose=function(){ //Run custom code when window is being closed (return false to cancel action):
		return true; //window.confirm("Close window 1?");
	}
	//alert('3');
	win1.show();
	return false;
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function


function reloadWin(winURL) {
    
    window.location = winURL;
}

function newwingeneric(url1, winname, width1, height1, menubar1, resizable1, toolbar1, location1, scrollbars1, status1){
  newwin = window.open(url1, winname,"width="+width1+",height="+height1+",menubar="+menubar1+",resizable="+resizable1+",toolbar="+toolbar1+",location="+location1+",scrollbars="+scrollbars1+",status="+status1)
  newwin.focus()
}

/******** the function below returns a path to the root folder based on the current url ********/
function getRootPath() {
    var url, arr, i, countLevel, startCount, ret;
    url = window.location.href;
    //alert('1:'+url);
    arr = url.split('/');
    //alert('2:'+arr.length);
    startCount = 0;
    countLevel = 0;
    for (i = arr.length-1; i >= 0; i--) {
        arr[i] = arr[i].toLowerCase();
        //alert('2a:'+arr[i]);
        if ( arr[i].indexOf('.asp') > -1 || arr[i].indexOf('.htm') > -1 ) {
            startCount = 1;
            //alert('3:'+arr[i]);
        }    
        else {
            if ( arr[i].indexOf('localhost') > -1 || arr[i].indexOf('.com') > -1 || arr[i].indexOf('.ca') > -1 )
                break;
            
            if ( startCount == 1 ) {
                //alert('4:'+arr[i]);
                countLevel ++;
            }    
        }    
        //alert(arr[i]);
    }
    
    ret = '';
    if ( countLevel > 0 ) {
        for (i = 1; i <= countLevel; i++) {
            ret += '../'
        }
    }
    //alert('9:'+ret);
    return ret;
}