<!--
// start jquery
$(document).ready(function() {
	// image rollovers
	$('.mouseover').hover(function(){
		this.src = this.src.replace('_off', '_on');
	}, function(){
		this.src = this.src.replace('_on', '_off');
	});
});

// ------------------------------------------------------------------------- //
// ox_setValue                                                               //
// Function for setting the value of a DOM element                           //
// ------------------------------------------------------------------------- //
// $id (str)			= any jQuery selector                                //
// $val (str)			= any value                                          //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_setValue = function($id, $val) {
	$($id).val($val);
};

// ------------------------------------------------------------------------- //
// ox_setSubmit                                                              //
// Function for setting the value of a DOM element then submitting a form    //
// ------------------------------------------------------------------------- //
// $form (str)			= any jQuery selector, selects the form              //
// $id (str)			= any jQuery selector, selects the element           //
// $val (str)			= any value                                          //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_setSubmit = function($form, $id, $val) {
	$($id).val($val);
	$($form).submit();
};

// ------------------------------------------------------------------------- //
// ox_setPage                                                                //
// Function for setting the page location                                    //
// ------------------------------------------------------------------------- //
// $url (str)			= any url                                            //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_setPage = function($url) {
	document.location = $url;
};

// ------------------------------------------------------------------------- //
// ox_countDown                                                              //
// Function for counting down from a number and displaying it                //
// ------------------------------------------------------------------------- //
// $id (str)			= any jQuery selector                                //
// $num (int)			= any number                                         //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_countDown = function($id, $num) {
	for (i=$num; i>0; i--) {
		window.setTimeout('$(\''+$id+'\').html('+i+');', (1000*$num) - (1000*i));
	}
};

// ------------------------------------------------------------------------- //
// ox_setConfirmPage                                                         //
// Function for setting the page location after confirmation                 //
// ------------------------------------------------------------------------- //
// $url (str)			= the url you want to go to after confirmation       //
// $action (str)		= the action being confirmed                         //
// $type (str)			= the type of item being affected                    //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_setConfirmPage = function($url, $action, $type) {
	if (confirm("Are you sure you want to " + $action + " this " + $type + "?")) {
		document.location = $url;
	}
};

// ------------------------------------------------------------------------- //
// ox_setFormAction                                                          //
// Function for setting the action of a form and submitting it               //
// ------------------------------------------------------------------------- //
// $id (str)			= any jQuery selector, chooses the form              //
// $val (str)			= the url the form is to be submitted to             //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_setFormAction = function($id, $val) {
	$($id).attr('action', $val);
	$($id).submit();
};

// ------------------------------------------------------------------------- //
// ox_checkBoxes                                                             //
// Function for checking a group of checkboxes                               //
// ------------------------------------------------------------------------- //
// $id (str)			= any jQuery selector, chooses the box group         //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_checkBoxes = function($id) {
	$('input[name^="' + $id + '"]:checkbox').attr('checked', 'checked');
};

// ------------------------------------------------------------------------- //
// ox_uncheckBoxes                                                           //
// Function for checking a group of checkboxes                               //
// ------------------------------------------------------------------------- //
// $id (str)			= any jQuery selector, chooses the box group         //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_uncheckBoxes = function($id) {
	$('input[name^="' + $id + '"]:checkbox').removeAttr('checked');
};

// ------------------------------------------------------------------------- //
// ox_setSortingOrder                                                        //
// Function for setting sorting values                                       //
// ------------------------------------------------------------------------- //
// $id (str)			= any jQuery selector, chooses the form              //
// $orderby (str)		= what database column to sort by                    //
// $acdc (str)			= which direction to sort, ascending or descending   //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_setSortingOrder = function($id, $orderby, $acdc) {
	$($id + '_orderby').val($orderby);
	$($id + '_acdc').val($acdc);
	$($id).submit();
};

// ------------------------------------------------------------------------- //
// ox_setSortingOffset                                                       //
// Function for setting the value of a form element then submitting the form //
// ------------------------------------------------------------------------- //
// $form (str)			= any jQuery selector, chooses the form              //
// $id (str)			= any jQuery selector, chooses the element           //
// $val (str)			= the value of the element being set                 //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_setSortingOffset = function($form, $id, $val) {
	$($id).val($($val).val());
	$($id).val($($val).val());
	$($form).submit();
};

// ------------------------------------------------------------------------- //
// ox_setModal                                                               //
// Function for making a confirmation modal                                  //
// ------------------------------------------------------------------------- //
// $id (str)			= any jQuery selector, chooses the modal container   //
// $item (str)			= data to be inserted into the modal                 //
// $url (str)			= the url you want to go to after confirmation       //
// ------------------------------------------------------------------------- //
jQuery.fn.ox_setModal = function($id, $item, $url, $form, $formid) {
	$($id + '_item').html($item);
	$($id).dialog({
		bgiframe: true,
		resizable: true,
		width: 400,
		height: 200,
		modal: true,
		close: function() {
			$(this).dialog('destroy');
		},
		overlay: {
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: {
			'No': function() {
			$(this).dialog('destroy');
		},
			'Yes': function() {
			if ($form && $formid) {
				$(this).dialog('destroy');
				$.fn.ox_setFormAction($formid, $url);
			} else {
				$(this).dialog('destroy');
				document.location = $url;
			}
		}}
	});
};
//-->
