//extras-----------------------
function OpenWin(URL,h,w) {
	newWindow=window.open(URL,"","height="+h+",width="+w+",resizable=1,scrollbars=1");
	}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}


//////// ----- GLOBAL VARIABLE ----- /////////

var gStrAppend = 'inCtx11';
var gStrAlert = 'Please enter a keyword to search.';


//////// ----- GLOBAL VARIABLE ----- /////////


function siteSearch() {
	var term = document.getElementById("term").value ;
	if (term == '') {
		alert(gStrAlert);
		return false ;
	}else{
		var search_href = '/content/search.htm?' + gStrAppend + 'txtKeyword=' + term + '&' + gStrAppend + 'cmdKeywordSearch=search&' + gStrAppend + 'txtMode=site';
		//alert(search_href);
		window.location.href = search_href ;
	}
	window.event.cancelBubble = true;
	window.event.returnValue = false;
}


function onKeyPress(e) {

	NS4 = (document.layers)? true:false
	IE4 = (document.all)? true:false
	docom = (document.getElementById) ? true:false

	var keycode;
	var strName = navigator.appName;

	if (NS4) keycode = e.which
	else if (IE4) keycode = window.event.keyCode
	else if (docom)	keycode = e.keyCode

	if (keycode == 13) {
		if((IE4)&&(navigator.platform=='MacPPC')){
			document.frm.HiddenClick.value = '';
			//strName = strName + ' : ' + navigator.platform
			alert(strName)
		}else{
			siteSearch()
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
	}
}





////////////////////////////////////////////////
////////// ----- REGULAR SEARCH ----- //////////
//--------------------------------------------//

function siteSearchMain() {
	var term = document.getElementById(gStrAppend + "txtKeyword").value ;
	var qu = '' ;
	if (term == '') {
		alert(gStrAlert);
		event.returnValue=false;
		return false ;
	}else{
		cmsForm.action = '/content/search.htm';
		cmsForm.submit();
		event.returnValue=false;
	}
}

function onKeyPressMain(e, oCtrl) {

	NS4 = (document.layers)? true:false
	IE4 = (document.all)? true:false
	docom = (document.getElementById) ? true:false

	var keycode;
	var strName = navigator.appName;

	if (NS4) keycode = e.which
	else if (IE4) keycode = window.event.keyCode
	else if (docom)	keycode = e.keyCode

	if (keycode == 13) {
		if((IE4)&&(navigator.platform=='MacPPC')){
			document.frm.HiddenClick.value = '';
			//strName = strName + ' : ' + navigator.platform
			alert(strName)
		}else{
			siteSearchMain()
		}
	}
}


/////----- ENTER KEY FIX FOR FIRE FOX ------
var formSet = document.getElementsByTagName("form");
var theForm = formSet[0]

if(theForm != null)
{
      theForm.onkeypress = function(e)
      {
            var kc;
            if(window.event) { kc = window.event.keyCode; }
            else if(e.keyCode) { kc = e.keyCode; }
            else{ kc = e.which; }

            if(kc == 13) {
                  return false;
            }
      }
}


//--------------------------------------------//
////////// ----- REGULAR SEARCH ----- //////////
////////////////////////////////////////////////





////////////////////////////////////////////////
////////// ----- ADVANCE SEARCH ----- //////////
//--------------------------------------------//

function setDates(fdate, edate) {
	var start_dt = document.getElementById(gStrAppend + 'txtStartDate') ;
	var end_dt = document.getElementById(gStrAppend + 'txtEndDate');
	start_dt.value = fdate ;
	end_dt.value = edate ;
}

function calcDate(rng) {
	var x = new Date()
	var y = new Date()
	x.setDate(x.getDate() - 1)

	var oRange = document.getElementById('range');
	if (rng == '7') {
		y.setDate(x.getDate() - 7)
	} else if (rng == '30') {
		y.setMonth(x.getMonth() - 1)
	} else if (rng == '90') {
		y.setMonth(x.getMonth() - 3)
	} else if (rng == '365') {
		y.setYear(x.getFullYear() - 1)
	}
	if (rng == 'B' || rng == 'D') {
		setDates('','') ;
	} else {
		fdate = parseInt(y.getMonth()+1) + '/' + y.getDate() + '/' + y.getFullYear()
		edate = parseInt(x.getMonth()+1) + '/' + x.getDate() + '/' + x.getFullYear()
		setDates(fdate, edate)
	}
}

//--------------------------------------------//
////////// ----- ADVANCE SEARCH ----- //////////
////////////////////////////////////////////////



////////////////////////////////////////////////
////////// ----- inCalendar ----- //////////////
//--------------------------------------------//
function SetDropdownName(strThis){
	var strT;
	return true;
	if (strThis != null){
		strT = strThis.name;
		strT = strT.substring(0, strT.length-4);
		document.getElementById('hidDropPrefix').value = strT;
	}
}
//--------------------------------------------//
////////// ----- inCalendar ----- //////////////
////////////////////////////////////////////////


//////// ----- GLOBAL VARIABLE ----- /////////

var gStrUrl1 = 'search.asp'


//////// ----- GLOBAL VARIABLE ----- /////////

function siteSearch1() {
	//alert("here")
	var oObj = document.getElementById("SiteSearchUrl");
	if(oObj != null){
		//alert(document.getElementById("SiteSearchUrl").value);
		gStrUrl1 = document.getElementById("SiteSearchUrl").value;
	}

	var term = document.getElementById("q").value ;
	var client = document.getElementById("client").value ;
	var proxystylesheet = document.getElementById("proxystylesheet").value ;
	var output = document.getElementById("output").value ;
	var site = document.getElementById("site").value ;



	if (term == '') {
		alert(gStrAlert);
		return false ;
	}else{
		var search_href = '/' + gStrUrl1 + '?' + 'client=' + client + '&proxystylesheet=' + proxystylesheet + '&output=' + output + '&site=' + site + '&q=' + term + '&btnSearch=Search';
		//alert(search_href);
		window.location.href = search_href ;
	}
	window.event.cancelBubble = true;
	window.event.returnValue = false;
}

function siteSearch2() {
	//alert("here")

	if(oObj != null){
		//alert(document.getElementById("SiteSearchUrl").value);
		gStrUrl1 = document.getElementById("SiteSearchUrl").value;
	}
	var oObj = document.getElementById("SiteSearchUrl");


	var term = document.getElementById("q").value ;
	var client = document.getElementById("client").value ;
	var proxystylesheet = document.getElementById("proxystylesheet").value ;
	var output = document.getElementById("output").value ;
	var site = document.getElementById("site").value ;

		if (term == '') {
		alert(gStrAlert);
		return false ;
	}else{


		var search_href = '/' + 'SearchPress.asp' + '?' + 'client=' + client + '&proxystylesheet=' + proxystylesheet + '&output=' + output + '&site=' + site + '&q=' + term + '&btnSearch=Search';
		//alert(search_href);
		window.location.href = search_href ;
	}
	window.event.cancelBubble = true;
	window.event.returnValue = false;
}

function siteSearch3() {
	//alert("here")

	if(oObj != null){
		//alert(document.getElementById("SiteSearchUrl").value);
		gStrUrl1 = document.getElementById("SiteSearchUrl").value;
	}
	var oObj = document.getElementById("SiteSearchUrl");


	var term = document.getElementById("q").value ;
	var client = document.getElementById("client").value ;
	var proxystylesheet = document.getElementById("proxystylesheet").value ;
	var output = document.getElementById("output").value ;
	var site = document.getElementById("site").value ;

		if (term == '') {
		alert(gStrAlert);
		return false ;
	}else{


		var search_href = '/' + 'SearchMember.asp' + '?' + 'client=' + client + '&proxystylesheet=' + proxystylesheet + '&output=' + output + '&site=' + site + '&q=' + term + '&btnSearch=Search';
		//alert(search_href);
		window.location.href = search_href ;
	}
	window.event.cancelBubble = true;
	window.event.returnValue = false;
}

function onKeyPress1(e) {

	NS4 = (document.layers)? true:false
	IE4 = (document.all)? true:false
	docom = (document.getElementById) ? true:false

	var keycode;
	var strName = navigator.appName;

	if (NS4) keycode = e.which
	else if (IE4) keycode = window.event.keyCode
	else if (docom)	keycode = e.keyCode

	if (keycode == 13) {
		if((IE4)&&(navigator.platform=='MacPPC')){
			document.frm.HiddenClick.value = '';
			//strName = strName + ' : ' + navigator.platform
			alert(strName)
		}else{
			siteSearch1()
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
	}
}


function onKeyPress2(e) {

	NS4 = (document.layers)? true:false
	IE4 = (document.all)? true:false
	docom = (document.getElementById) ? true:false

	var keycode;
	var strName = navigator.appName;

	if (NS4) keycode = e.which
	else if (IE4) keycode = window.event.keyCode
	else if (docom)	keycode = e.keyCode

	if (keycode == 13) {
		if((IE4)&&(navigator.platform=='MacPPC')){
			document.frm.HiddenClick.value = '';
			//strName = strName + ' : ' + navigator.platform
			alert(strName)
		}else{
			siteSearch2()
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
	}
}

function onKeyPress3(e) {

	NS4 = (document.layers)? true:false
	IE4 = (document.all)? true:false
	docom = (document.getElementById) ? true:false

	var keycode;
	var strName = navigator.appName;

	if (NS4) keycode = e.which
	else if (IE4) keycode = window.event.keyCode
	else if (docom)	keycode = e.keyCode

	if (keycode == 13) {
		if((IE4)&&(navigator.platform=='MacPPC')){
			document.frm.HiddenClick.value = '';
			//strName = strName + ' : ' + navigator.platform
			alert(strName)
		}else{
			siteSearch3()
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
	}
}









////////////////////////////////////////////////
////////// ----- SITE ----- //////////////
//--------------------------------------------//


//Sub Menu Functions
var open_menu='';
function show(s){
	if(open_menu!='' && document.getElementById(open_menu)) document.getElementById(open_menu).style.display='none';
	if(document.getElementById(s)) document.getElementById(s).style.display='block';
	open_menu=s;
}

//Popup document window
function openPDF(f){
  var w=750, h=500;
  var x=0, y=0;
  x=(screen.availWidth-w)/2;
  y=(screen.availHeight-h)/2;
  newwin = window.open(f, 'PDF', "title='PDF',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=" + w + ",height=" + h + ",left=" + x + ",top=" + y);
  return false;
}

function openView(f){
  var w=750, h=500;
  var x=0, y=0;
  x=(screen.availWidth-w)/2;
  y=(screen.availHeight-h)/2;
  newwin = window.open(f, 'PDF', "title='PDF',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + w + ",height=" + h + ",left=" + x + ",top=" + y);
  return false;
}

function openSite(f){
  var w=800, h=500;
  var x=0, y=0;
  x=(screen.availWidth-w)/2;
  y=(screen.availHeight-h)/2;
  newwin = window.open(f, 'NYSAR', "title='NYSAR',toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=" + w + ",height=" + h + ",left=" + x + ",top=" + y);
  return false;
}

function openPage(f){
  var w=759, h=500;
  var x=0, y=0;
  x=(screen.availWidth-w)/2;
  y=(screen.availHeight-h)/2;
  newwin = window.open(f, 'NYSAR', "title='NYSAR',toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=" + w + ",height=" + h + ",left=" + x + ",top=" + y);
  return false;
}

function openArea(f){
  var w=759, h=535;
  var x=0, y=0;
  x=(screen.availWidth-w)/2;
  y=(screen.availHeight-h)/2;
  newwin = window.open(f, 'NYSAR', "title='NYSAR',toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=" + w + ",height=" + h + ",left=" + x + ",top=" + y);
  return false;
}

function openTemplate(f){
  var w=800, h=580;
  var x=0, y=0;
  x=(screen.availWidth-w)/2;
  y=(screen.availHeight-h)/2;
  newwin = window.open(f, 'PDF', "title='PDF',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=" + w + ",height=" + h + ",left=" + x + ",top=" + y);
  return false;
}



var frameworkPath
function FramePath(path)
{
frameworkPath = path ;
}

//--------------------------------------------//
////////// ----- SITE ----- //////////////
////////////////////////////////////////////////




function hasLoggedIn() {
  var loggedin = document.getElementById('HasLoggedIn');
  if (loggedin != null) {
     var text = loggedin.innerHTML;
     if (text == 'N') {
	return false ;
     } else {
        return true;
     }

  }
  return true ;
}


