//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;
}



function textSize() {
	//alert(dw_fontSizerDX.curSize);
	if (dw_fontSizerDX.curSize == 18)
  	{
		dw_fontSizerDX.reset();
	}
	else
	{
		dw_fontSizerDX.adjust(2);
	}
	
	return void(0);
}

//reset URL to correct url (fixes IP call and www. - note that this also resets to non-ssl URL)
	if (document.location.host != "centegra.org") {
		document.location.href = "http://centegra.org" + document.location.pathname + document.location.search;
	};


//////// ----- GLOBAL VARIABLE ----- /////////

var gStrAppend = 'inCtx7';
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&' + gStrAppend + 'txtExcludeBranchIds=4,16';
		window.location.href = search_href ;
	}
    window.event.cancelBubble = true;
	window.event.returnValue = false;


	//e.stopPropagation works only in Firefox.
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}
	
}


function entersiteSearch(e) {


	evt = e || window.event;

	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&' + gStrAppend + 'txtExcludeBranchIds=4,16';
		window.location.href = search_href ;
	}
	
	NS4 = (document.layers)? true:false
        
        if (window.event) {
        	evt.cancelBubble = true;
		evt.returnValue = false;
	}


	//e.stopPropagation works only in Firefox.
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}

}


function siteSearchEncy(e) {

	var term = '' ;
	if (document.getElementById("txtSearchGS") != null) {
	   term = document.getElementById("txtSearchGS").value ;
	}
	if (term == '') { 
		alert(gStrAlert);
		return false ; 
	}else{
		var search_href = '/content/searchgs.htm?' + gStrAppend + 'txtKeyword=' + term + '&' + gStrAppend + 'cmdKeywordSearch=search&' + gStrAppend + 'txtMode=site&' + gStrAppend + 'BranchIds=4';
		window.location.href = search_href ;
	}

        if (window.event) {
	  window.event.cancelBubble = true;
	  window.event.returnValue = false;
	}


	//e.stopPropagation works only in Firefox.
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}



}


function onKeyPressMainGS(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 {
			siteSearchEncy(e);
			//siteSearchMain()
		}
	}
}


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

// alert(event);

 if (keycode == 13) {
   entersiteSearch(e);
 }
}


function onHeaderSearchKeyPress(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

// alert(event);

 if (keycode == 13) {
   entersiteSearch(e);
 }
}



function onSearchKeyPress(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(event) {
	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(e)
		}
	}
}


//--------------------------------------------//
////////// ----- REGULAR SEARCH ----- //////////
////////////////////////////////////////////////


/*

/////----- 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) {
                  siteSearch();
                  return false;
            }
      }
}


function OldonKeyPress(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;
		}
	}
}

function onKeyPress() {
 

  onKeyPress(window.event);


}




*/






////////////////////////////////////////////////
////////// ----- 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 ----- //////////////
////////////////////////////////////////////////













////////////////////////////////////////////////
////////// ----- 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;
}


function hideEmptyNav(id) {
  navid = document.getElementById(id);
  if (navid != null) {
    ihtml = navid.innerHTML;
    if (ihtml == '' || ihtml == '&nbsp;') {
      navid.style.visibility='hidden';
      navid.style.width=0;
      navid.style.height=0;
    }     
  }
}

function hideEmptyDTA(id) {
	dta = document.getElementById(id);
	if (dta != null) {
		ihtml = dta.innerHTML;
		if (ihtml == '' || ihtml == '&nbsp;') {
		dta.style.visibility='hidden';
		dta.style.width=0;
		dta.style.height=0;
		}     
	}
}



//--------------------------------------------//
////////// ----- SITE ----- //////////////
////////////////////////////////////////////////


/** USED IN Find a Physician */

function showMap(address, city, state, zip) {
	var url = 'http://www.google.com/maps?f=d&hl=en&q=' + address + ',' + city + ',' + state + ',' + zip;
	window.open(url);
}


/*******************************************************************************
********************************************************************************
							--------------------------
						Curvy Corners (http://www.curvycorners.net/demos/)
							--------------------------
							added 7/10/09 attempt to style boxes with
							rounded corners using javascript + css	
********************************************************************************
*******************************************************************************/
 function include_js(file) {
	var include_file = document.createElement('script');
	include_file.type = 'text/javascript';
	include_file.src = file;
	document.getElementsByTagName('head')[0].appendChild(include_file);
}
/* include your file */
//include_js('curvycorners.js');




//--------------------------------------------//
///////// ----- FIND A PHYSICIAN ----- /////////
////////////////////////////////////////////////


function onRadiusKeyPress(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

// alert(event);

 if (keycode == 13) {
   srcbtn = document.getElementById('keySearchBtnAdv');
   if (srcbtn != null) srcbtn.click();
 }

}


function FramePath(path) {
  var x = path;
}