// Show/hide form elements in select drop downs
if(document.getElementById) { // for modern browsers
        var upLevel = true;
        }

function showHide (id) { 
 var style = document.getElementById(id).style
 if (style.display == "none")
  style.display = "block";
 else  
  style.display = "block";
}


// show form elements
function showForm() {

	var allElems = document.getElementsByTagName('*');
	for (var i = 0; i < allElems.length; i++) {
		var thisElem = allElems[i];
		if (thisElem.className && thisElem.className == 'show') {
			thisElem.style.display = 'block';
		}
	}

}


//another show hide for other elements

function checkMe(el, div){
id = document.getElementById(div).style;

   if(el.checked == true){
      id.display = 'block';
   }
   else {
      id.display = 'none';
   }
} 



// Eoin Landy showing hiding divs 16 June 2006 easier to have separate functions for showing and hiding - removes need to ask whether radio is checked or not
function showMe(el, div){
	id = document.getElementById(div).style;
	id.display = 'block';
}
function hideMe(el, div){
	id = document.getElementById(div).style;
	id.display = 'none';
}


//these 2 are used on select boxes - it shows or hides based on whether the selected index is the passed cValue
function conditionalShowMe(el, div, cValue){
	var id = document.getElementById(div).style;
  var divDisplay = "none";
  cValue = cValue + ",";
  var i=cValue.indexOf(",");
  var currentStr = "";
  do {
    currentStr = cValue.substr(0,i);
  	if(el.selectedIndex == currentStr)
      divDisplay = "block";
    cValue = cValue.replace(currentStr+",","");
    i = cValue.indexOf(",");
  }
  while (i > -1)
	id.display = divDisplay;

}
function conditionalHideMe(el, div, cValue){
	id = document.getElementById(div).style;
	if(el.selectedIndex == cValue){
		id.display = 'none';
	}else{
		id.display = 'block';
	}
}
function CreateBookmarkLink(url, title) { 
  if (window.sidebar) { 
    // Mozilla Firefox Bookmark		
    window.sidebar.addPanel(title, url,"");	
  } 
  else if( window.external ) { 
    // IE Favorite		
    window.external.AddFavorite( url, title); 
  }	
  else if(window.opera && window.print) { 
    // Opera Hotlist		
    return true; 
  } 
} 

function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=0,width=750,height=550,left = 465,top = 250');");
}

function popUpHCC(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=989,height=590,left = 345.5,top = 230');");
}

// generic open window function
// this takes a url and a list of arguments
function popUp(url, args) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(url, '" + id + "', args) ;");
}



function showbuttons() {   

    var agt       = navigator.userAgent.toLowerCase();
    var IEMAC     = ((agt.indexOf("msie") != -1) && agt.indexOf("mac")!=-1);
    var N6        = (agt.indexOf("netscape6") != -1 || (agt.indexOf("netscape/6") !=-1 ));

    if ( N6 ) {
      return "Netscape 6 is unable to support our detailed reports.  Please upgrade to Nescape 7.<P>";
    }
    if ( IEMAC ) {
      return "<P>";
    }

    return "<P><FORM><INPUT TYPE='button' value='Calculate' Name='btnCallCalc' onClick='document.calculator.calculate()'><INPUT TYPE='button' value='View Report' Name='btnOpenNote' onClick='openNote()'></FORM>";
}

function openNote()
 { 
 
 var agt=navigator.userAgent.toLowerCase(); 
 var is_aol   = (agt.indexOf("aol") != -1);

 leftpos=0;
 if (screen) {
   leftpos=screen.width/2 - 300;
 } 

 if (is_aol) {
   var s = " ";
   s=document.calculator.sJavaScriptReport('HTML');
    document.write(s);
 }
 else {
   var OpenWindow=window.open("","newwin","toolbar=yes,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=380,left="+leftpos+",top=20");
   var s = " ";
   s=document.calculator.sJavaScriptReport('HTML');
   OpenWindow.document.write(s);
   OpenWindow.document.close(); 
   OpenWindow.focus();
 }
 }

function showDatePicker() 
{
window.open("/DatePicker/DatePicker.aspx", "Date_Picker", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=220,height=200');
}


function storeValue()
{
    window.opener.document.dateSelection.fromDate.value = document.form1.fromDate.value 
    window.opener.document.dateSelection.toDate.value = document.form1.toDate.value 
    window.opener.document.dateSelection.submit()
    window.close()

}

