

function submitGatePage()
{
	document.frmGate.act.value = "submit";
	document.frmGate.submit();
}

function SetOrderValue()
{

	var iChecked;
	var iIndex;
	var sValue;
	iChecked=1;	
	for(iIndex=0;iIndex<document.forms[0].rdbSort.length;iIndex++)
	{
		if (document.forms[0].rdbSort[iIndex].checked==true)
			{
				iChecked*=0;
				sValue=document.forms[0].rdbSort[iIndex].value;
			}
		else
			iChecked*=1;
	}
	if (iChecked==1) 
	{
		alert("Please select one of the two radio buttons under option 1.");
	}
	else
	{
		document.forms[0].action=document.forms[0].action+"?Criteria="+sValue;
		document.forms[0].hdnOrderSelected.value=sValue;
		document.forms[0].hdnOperation.value="Sort";
		document.forms[0].submit(); 
	}

	return false;

}


function ShowAll()
{
	document.forms[0].action=document.forms[0].action+"?DesiredPage=All";
	document.forms[0].submit(); 
}


var bIE = (navigator.appVersion.indexOf("MSIE") != -1)? true :false;
var bNS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion, 10) == 4)? true : false;
var bNS6andUp = (navigator.appName == "Netscape" && parseInt(navigator.appVersion, 10) >= 5)? true : false;
var bMac=false;

  if(navigator.userAgent.indexOf('IRIX') != -1)
    { var OpSys = "Irix"; }
  else if((navigator.userAgent.indexOf('Win') != -1) &&
  (navigator.userAgent.indexOf('95') != -1))
    { var OpSys = "Windows95"; }
  else if(navigator.userAgent.indexOf('Win') != -1)
    { var OpSys = "Windows3.1 or NT"; }
  else if(navigator.userAgent.indexOf('Mac') != -1)
    { var OpSys = "Macintosh"; 
	bMac=true;
	}
  else { var OpSys = "other"; }





function CheckSelected()
{
	var iChecked;
	var iIndex;
	var sValue;
	
	iChecked=1;	
	for(iIndex=0;iIndex<document.forms[0].rdbSearch.length;iIndex++)
	{
		if (document.forms[0].rdbSearch[iIndex].checked==true)
			{
				iChecked*=0;
				sValue=document.forms[0].rdbSearch[iIndex].value;
			}
		else
			iChecked*=1;
	}
	if (iChecked==1) 
	{
		alert("Please select one of the radio buttons under Option 2: Step 1.");
	}
	else
	{
		document.forms[0].txtSearchText.value=Trim(
		document.forms[0].txtSearchText.value);
		if (document.forms[0].txtSearchText.value=="")
		{
		alert("Please enter the search text.");
		document.forms[0].txtSearchText.focus();
		return false;	

		}
		else 
		{
			document.forms[0].hdnOperation.value="Search";
			document.forms[0].hdnSearchField.value= sValue;
			document.forms[0].action=document.forms[0].action+"?Criteria="+document.forms[0].hdnSearchField.value+"&text="+document.forms[0].txtSearchText.value;
			document.forms[0].submit(); 

		}
	}
	return false;
}
  

function Trim(TRIM_VALUE){
	
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}

} //End Function

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;
	
	while(iTemp > -1)
	{
	if(VALUE.charAt(iTemp) == w_space)
	{
	}
	else
	{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
	}
	iTemp = iTemp-1;
	} //End While
return strTemp;
} //End Function

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;
	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space)
	{
	}
	else
	{
		strTemp = VALUE.substring(iTemp,v_length);
		break;
	}
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function ResizeWindow(sUrl)
{
	 sUrlOpen=sUrl;
	 var newreference = window.open(sUrl,"secondary","width=600,height=400,scrollbars=yes,toolbar=no,status=yes,resizable=yes,menubar=no,location=no,top=100,left=70");
if (!(bMac==true))
     newreference.focus();

}

function ResizeWindowWithToolBar(sUrl)
{
	 sUrlOpen=escape(sUrl);
	 var newreference = window.open("/Utilities/UrlDisplay.asp?URL="+sUrlOpen,"secondary","width=600,height=400,scrollbars=yes,toolbar=yes,status=yes,resizable=yes,menubar=yes,location=yes,top=100,left=70");
if (!(bMac==true))
     newreference.focus();
}

function ResizeWindowForOtherExtLinks(sUrl)
{
	 sUrlOpen=escape(sUrl);
	 var newreference = window.open(sUrl,"secondary","width=600,height=400,scrollbars=yes,toolbar=yes,status=yes,resizable=yes,menubar=yes,location=yes,top=100,left=70");
if (!(bMac==true))
     newreference.focus();
}

function ResizeWindowForOtherPDF(sUrl)
{
	 sUrlOpen=sUrl;
	 var newreference = window.open("/Utilities/UrlDisplay.asp?URL="+sUrl,"secondary","width=600,height=400,scrollbars=yes,toolbar=no,status=yes,resizable=yes,menubar=no,location=no,top=100,left=70");
if (!(bMac==true))
     newreference.focus();
}

function openFootNote(sUrl)
{
	 sUrlOpen=sUrl;	 
	 var newreference = window.open(sUrl,"secondary","width=600,height=80,scrollbars=yes,toolbar=no,status=yes,resizable=yes,menubar=no,location=no,top=100,left=70");
if (!(bMac==true))
     newreference.focus();
}



function Validate()
{

	if (document.forms[0].hdnSearchField.value=="" ) 
	{
			return false;

	}
	else
	{

		document.forms[0].txtSearchText.value=Trim(
		document.forms[0].txtSearchText.value);
		if (document.forms[0].txtSearchText.value=="")
		{
			return false;	
		}
	}
}



function Goto(n)
{
	document.forms[0].action=document.forms[0].action+"?DesiredPage="+n;
	document.forms[0].submit();

}

function OpenInSecondary(sUrl)
{
	 sUrlOpen=sUrl;
	 window.close();
	 var newreference = window.open(sUrl,"secondary","width=600,height=400,scrollbars=yes,toolbar=yes,status=yes,resizable=yes,menubar=yes,location=yes,top=100,left=70");
if (!(bMac==true))
     newreference.focus();	 

}

//This function is not being used. Previously it was being used by PhilipMorrisUsaLink.asp
function OpenInNewWindow(sUrl)
{
	 sUrlOpen=sUrl;
	 var newreference = window.open(sUrl,"Link","width=500,height=250,scrollbars=yes,toolbar=no,status=yes,resizable=yes,menubar=no,location=no,top=100,left=70");
if (!(bMac==true))
     newreference.focus();
}


function InitSettings()
{
	document.frmGate.hdnWidth.value = screen.width;
	document.frmGate.hdnHeight.value = screen.height;
}


function OpenFootNotesLink(sUrl){	 
	
	 window.close(); 
	 var newreference = window.open("/Utilities/UrlDisplay.asp?URL="+sUrl,"Link","width=600,height=400,scrollbars=yes,toolbar=yes,status=yes,resizable=yes,menubar=no,location=yes,top=100,left=70");	 
if (!(bMac==true))
     newreference.focus();   
}

