// JavaScript Document
// rxportfolio.js

function toggleForm(id, mode) {
	if(mode == 'show') {
		Effect.BlindUp("htmlContainer-"+id);
		Effect.BlindDown("formContainer-"+id);
	}
	if(mode == 'hide') {
		Effect.BlindUp("formContainer-"+id);
		Effect.BlindDown("htmlContainer-"+id);
	}
}

function deleteRecord(id, title, extra_params) {
	// Set default for params if they are not passed to function
	var extra_params = ( extra_params === null ) ? "" : extra_params;
	
	confirmed = confirm("Do you want to delete: "+title+"?");
	if(confirmed == true) {
		document.location = "?action=delete&id="+id+"&"+extra_params;
	}
}

function showHide(show,hide)
{
	if (!document.getElementById) return null;
	var showWhat = document.getElementById(show);
	var hideWhat = document.getElementById(hide);
	showWhat.style.display = "block";
	hideWhat.style.display = "none";
}

function hide(hide)
{
	if (!document.getElementById) return null;
	var hideWhat = document.getElementById(hide);
	hideWhat.style.display = "none";
}

function show(show)
{
	if (!document.getElementById) return null;
	var showWhat = document.getElementById(show);
	showWhat.style.display = "block";
}

function showfield(name){
    if(name=='9999')document.getElementById('other_school').style.display="block";
    else document.getElementById('other_school').style.display="none";
  }


function demo() {
	alert("This feature is not available in Demo Mode");
}

function confirmEditClose( formName, formContainerId )
{
	// Requires the unique name of the form to submit 
	// if the user clicks 'OK' in the confirmation dialog window.
	
	var agree = confirm("Your changes have not been saved yet. Do you want to save these changes before closing this panel?");
	if (agree) {
		// Must process variable formName using eval() to work properly.
		eval( "document." + formName + ".submit();" )

	} else {	
		toggleForm(formContainerId,'hide');
	}		
}

function confirmJQueryEditClose( formName, formContainerId )
{
	// Requires the unique name of the form to submit 
	// if the user clicks 'OK' in the confirmation dialog window.
	
	var agree = confirm("Your changes have not been saved yet. Do you want to save these changes before closing this panel?");
	if (agree) {
		
		// Must process variable formName using eval() to work properly.
		eval( "document." + formName + ".submit();" )
		//document.updateForm.submit();
	} else {		
			jQuery('.record_update').hide('slow', function() {
			jQuery('.record_content').show('slow');
			jQuery('.record_buttons').show('slow');
		});			
	}		
}

function displayProgressBar(id)
{
	//DISPLAYS THE PROGRESS BAR WHEN THE SUBMIT BUTTON IS CLICKED.
	var ele = $("progressbar_"+id);
	ele.style.display = "block";
}

function updateSwatch(color,swatch)
{
	
	// SETS THE SWATCH COLOR BASED ON FIELD INPUT WITHIN RXADMIN FORMS
	var ele = $(swatch);
	ele.style.background = color;
}


// This function is used to check and uncheck all items in a list
var checkflag = "false";
function check(field) {
	if (checkflag == "false") {
		for (i = 0; i < field.length; i++) {
			field[i].checked = true;
		}
		checkflag = "true";
		return "Uncheck All"; 
	}
	else 
	{
		for (i = 0; i < field.length; i++) {
			field[i].checked = false; 
		}
		checkflag = "false";
		return "Check All"; 
	}
}
// end check and uncheck functions

var checkedflag = false;
function confirmChecked(field) {
	for (i = 0; i < field.length; i++) {
		if(field[i].checked == true) {
		checkedflag = true;
		} 
	}
	if(checkedflag == false) {
		alert("No items were checked off. Check at least one item.");	
	}
	return checkedflag;
}

