function show_about(){
	about_div = document.getElementById('about_main');
	about_div.style.display = "";
}
function toggle_instructions(instructions_to_be_on){

	var initial = document.getElementById("initial_instructions");
	var fulltext = document.getElementById("fulltext_instructions");
//alert("initial: "+initial.style.display+"\n"+"fulltext: "+fulltext.style.display);
	if(instructions_to_be_on == "fulltext"){
		initial.style.display = "none";
		fulltext.style.display = "";
		//new Effect.Appear(fulltext);
	}else{
		initial.style.display = "";
		fulltext.style.display = "none";
		//new Effect.Squish(fulltext);
		//new Effect.Opacity(fulltext, 0);
	}
	
	
	
}
function reset_dates(){
	datefields = new Array("gd_date1", "gd_date2");

	for(i=0; i<datefields.length; i++){
		el = document.getElementById(datefields[i]);
		el.value = "mm/dd/yyyy";
	}
}
//called when the type of search(full-text, author, title) 
//is changed
//this method hides fields when full text is enabled
//and shows them when any other field is enabled
function change_search(str_search){

	//var elements_to_toggle = new Array("sort_order_table", "opt_divider", "tbl_guided_date");
	var elements_to_toggle = new Array("sort_asc", "sort_desc", "gd_date1", "gd_date2", "has_picture", "reset_dates");
		for(i=0; i<elements_to_toggle.length; i++){
			el = document.getElementById(elements_to_toggle[i]);
			//alert(el)
			//el.style.visibility = str_search == "fulltext" ? "hidden" : "visible";
			if(str_search == "fulltext"){
				//el.setOpacity(0);
				//new Effect.Fade(el);
				el.disabled = true;
				toggle_instructions("fulltext");
			}
			else{
				el.disabled = false;
				toggle_instructions("initial");
				//el.setOpacity(100);
				//new Effect.Appear(el);
			}
		}

	
}

function change_search_type(list){
   subject_select_element = document.getElementById('search_subject');
   input_text_element = document.getElementById('search_text');
   heading = document.getElementById('search_type_heading');
   
   type = list.options[list.selectedIndex].innerHTML

   if(type == "Subject"){
      subject_select_element.style.display = "";
      input_text_element.style.display = "none";
      heading.innerHTML = "Subject";
   }else{
      subject_select_element.style.display = "none";
      input_text_element.style.display = "";    
      heading.innerHTML = "Keywords";     
   }
   
}

function toggle_blind(path, element_name, top_handle_id, bottom_handle_id){
   el = document.getElementById(element_name);
   top_handle = document.getElementById(top_handle_id);
   bottom_handle = document.getElementById(bottom_handle_id);
   
   /* if its hidden */
   if(el.style.display == "none"){
      /* display it */
      new Effect.BlindDown(el, {duration: 0.5});
      /*el.style.display = "";*/
      top_handle.innerHTML = "Collapse Form";
      bottom_handle.innerHTML = "<img src='"+path+"up.png'>";
	  //bottom_handle.innerHTML = "<img src='ticker/img/up.png'>";
      
   /* otherwise, its showing */
   }else{
      /* so hide it */
      new Effect.BlindUp(el, {duration: 0.5});     
      /*el.style.display = "none";*/
      top_handle.innerHTML = "Expand Form";
      bottom_handle.innerHTML = "<img src='"+path+"down.png'>";
   }
   
   
}

//initializes dynarch calendars to any number of input elements
//identified by string id's passed in elements of array
function init_cals(cal_id_array){

   //as long as there are elements to add calendars to
   if(cal_id_array.length > 0){

      //the strftime format 
      strDateFormatForStrfTime = "%m/%d/%Y"; 
      //the initial value of the input element
      strDateFormatInitialValue = "mm/dd/YYYY";
      
      for(i=0; i<cal_id_array.length; i++){
         //set values for input element
         //old way is buggy, see below
         /*Calendar.setup({
            inputField     :    cal_id_array[i],   // id of the input field
            ifFormat       :    "%m/%d/%Y",       // format of the input field
            showsTime      :    false,
            timeFormat     :    "12",
         });   */
         Calendar.setup(new cal_params(cal_id_array[i]));
      }
   }
}
//for some reason the dynarch syntax of pname : value is buggy on ie.
//making custom parameter object
function cal_params(dom_id){
   this.inputField = dom_id;// id of the input field
   this.ifFormat =  "%m/%d/%Y";       // format of the input field
   this.showsTime = false;
   this.timeFormat = "12";
}






function update_article_snapshot(list, id){

	
   img_el = document.getElementById(id);
   snapshot_link = document.getElementById('snapshot_link');
		
/*   utc_date = list.options[list.selectedIndex].value
   article_date = new Date(utc_date*1000);//must be in milliseconds
   
   year = article_date.getFullYear();
   month = article_date.getMonth()+1;
   month = month < 10 ? "0"+month : month;
   day = article_date.getDate();
   day = day < 10 ? "0"+day : day;
*/
	//attempt to load picture
//	str_article_fname = "ticker_"+year+month+day;
	str_article_fname = "ticker_"+list.options[list.selectedIndex].value;
	full_path = "img/article_snapshots/"+str_article_fname+".jpg";//" Page 1 image 1.jpg";

	img_el.src = full_path
  
  	snapshot_link.href = "files/articles/"+str_article_fname+".pdf";
    snapshot_link.target = "_blank";	
}






/*
var is_image_loaded = false;
function update_article_snapshot(list, id){
	if(!/MSIE/.test(navigator.userAgent)){
		snapshot_link = document.getElementById('snapshot_link');
	}
	
    img_el = document.getElementById(id);

	if(img_el == null)
		alert('First snapshot did not load, so cannot update.');
		
   utc_date = list.options[list.selectedIndex].value
   article_date = new Date(utc_date*1000);//must be in milliseconds
   
   year = article_date.getFullYear();
   month = article_date.getMonth()+1;
   month = month < 10 ? "0"+month : month;
   day = article_date.getDate();
   day = day < 10 ? "0"+day : day;

	//attempt to load picture
	str_article_fname = "ticker_"+year+month+day+".pdf";
	is_image_loaded = false;
	img_el.src = "img/article_snapshots/"+str_article_fname+" Page 1 image 1.jpg";
	
	//if successfully loaded
	//set bool
	img_el.onload = function(){is_image_loaded = true;}

	
	//wait x seconds and check if global load var gets set to true
	window.setTimeout("check_image_load(img_el)", 5000);
	
}

function check_image_load(image_el){
	//since this gets run after an amount of time
	//if image is still not loaded as set by onload event
	//display error
	if(!is_image_loaded)
		image_el.src = "img/article_snapshots/notfound.jpg";

	//only link if image loaded
	if(is_image_loaded){
	   snapshot_link.href = "files/articles/"+str_article_fname;
       snapshot_link.target = "_blank";
	}
	else{
		snapshot_link.href = "#browse";
		snapshot_link.target = "_self";
	}
}*/