// JavaScript Document

var d=document;

function warn_user_pass_fail(status) {

	if (status != "9999") {
		alert('Important Information\nBy marking this report as Pass or Fail, once saved, you will not be able to edit your comment again.\n\nSelect In Progress if you wish to return to this report another time for further editing.\n\n');
	}
	
}//end function



function close_search_popup() {
	d.getElementById('search_results').style.display = "none";
	//show_hide_dropdowns('visible');
}//end function

function assess_report_monitor(value) {
	if (value == 'rejected') {

		$.ajax({
		   type: "GET",
		   url: "../ajax_process/assess_report_revision_dropdown.php",
		   data: 'doajax=true&decision='+value,
		   success: function(text){
			 d.getElementById('w_revision_dropdown').innerHTML = text;
		   }
		 });

	} else {
		 d.getElementById('w_revision_dropdown').innerHTML= "";
	}//end if
	
}//end function

function search_for_author(value) {

	if (value != '') {

		$.ajax({
		   type: "GET",
		   url: "../ajax_process/author_search.php",
		   data: 'doajax=true&keyvalue='+value,
		   success: function(text){
			 d.getElementById('search_results_content').innerHTML = text;
			 
			 if (text != "") {
			  d.getElementById('search_results').style.display = "block";
			 } else {
			  d.getElementById('search_results').style.display = "none";
			 }//end if
		   }
		 });

	} else {
		d.getElementById('search_results').style.display = "none";
	}//end if
	
}//end function


function populate_lead_author_list() {
	var selobj = document.getElementById('f_author_id');
	var vals = Array();

	$('option:selected',selobj).each( function() { vals.push( this.value ) } );

	$.ajax({
	   type: "GET",
	   url: "../ajax_process/update_lead_author_dropdown.php",
	   data: 'doajax=true&author_id='+vals,
	   success: function(text){
		  d.getElementById('w_lead_author').innerHTML = text;
	   }
	 });
 
}//end function



function filter_reports(category_id) {

		$.ajax({
		   type: "GET",
		   url: "../ajax_process/filter_projects.php",
		   data: 'doajax=true&category_id='+category_id,
		   error: function (XMLHttpRequest, textStatus, errorThrown) {
				  // typically only one of textStatus or errorThrown 
				  // will have info
				  this; // the options for this ajax request
				},
		   success: function(text){
			 d.getElementById('w_project').innerHTML = text;
			 update_full_project_name(d.getElementById('f_project_id').value);
		   }
		 });

	
}//end function



function filter_users(role_id) {
		$.ajax({
		   type: "GET",
		   url: "../ajax_process/filter_users.php",
		   data: 'doajax=true&role_id='+role_id,
		   error: function (XMLHttpRequest, textStatus, errorThrown) {
				  // typically only one of textStatus or errorThrown 
				  // will have info
				  this; // the options for this ajax request
				},
		   success: function(text){
			 d.getElementById('w_users').innerHTML = text;
		   }
		 });

	
}//end function



function update_full_project_name(project_id) {

		$.ajax({
		   type: "GET",
		   url: "../ajax_process/update_project_name.php",
		   data: 'doajax=true&project_id='+project_id,
		   error: function (XMLHttpRequest, textStatus, errorThrown) {
				  // typically only one of textStatus or errorThrown 
				  // will have info
				  this; // the options for this ajax request
				},
		   success: function(text){
			 d.getElementById('project_full_name').innerHTML = text;
		   }
		 });

	
}//end function



function add_upload() {
	var upload_count = d.getElementById('upload_count').value;
	upload_count++;
	d.getElementById('upload_count').value = upload_count;
	d.getElementById('upload_section').innerHTML += '<div class="padding"><strong>'+upload_count+'.</strong> Select File: <input type="file" name="f_report_document[]" id="report_document'+upload_count+'" /class="marginright_small" />Label: <input type="text" name="f_report_label[]" value=""  class="marginright_small"  />Display order <input type="text" name="f_report_order[]" value="'+upload_count+'" size="3" maxlength="3"  /></div>';
}//end function



function delete_warning(checked) {
	if (checked==true) {
		alert('Warning: you have opted to delete this file. When you click Update Files, this action cannot be undone.');
		
	} //end if
}//end function

/* OLD FUNCTIONS BELOW - WITH 'x' ADDED */
/*
function populate_lead_author_listx() {

	var selobj = document.getElementById('f_author_id');
	var vals = Array();

	$('option:selected',selobj).each( function() { vals.push( this.value ) } );

	 var getxml = 0;
	 var reqtype = "get";
	 var callback = 'return_lead_author_list';
	 var url = 'ajax_process/update_lead_author_dropdown.php';
	 var query = 'doajax=true&author_id='+vals;
	 
	 
	doAjax(url, query, callback, reqtype, getxml);

}//end function


function return_lead_author_listx(html) {
	 d.getElementById('w_lead_author').innerHTML = text;
}//end function


function search_for_subscriberx(value) {
 var getxml = 0;
 var reqtype = "get";
 var callback = 'return_subscriber_results';
 var url = 'author_search.php';
 var query = 'dosearch=true&keyvalue='+value;
 
 if (value != '') {
  doAjax(url, query, callback, reqtype, getxml);
 } else {
  d.getElementById('search_results').style.display = "none";
 }//end if
 
}//end function
 
function return_subscriber_resultsx(text) {
 d.getElementById('search_results_content').innerHTML = text;
 
 if (text != "") {
  d.getElementById('search_results').style.display = "block";
 } else {
  d.getElementById('search_results').style.display = "none";
 }//end if
 
}//end function

*/

