
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;
}
//extras-----------------------
function OpenWin(URL,h,w) {
	newWindow=window.open(URL,"","height="+h+",width="+w+",resizable=1,scrollbars=1");
	}



//////// ----- GLOBAL VARIABLE ----- /////////

var gStrAppend = 'inCtx6';
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()
		}
	}
}

//--------------------------------------------//
////////// ----- 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 ----- //////////////
////////////////////////////////////////////////
