//////////////////////////////////////////////////////////////
//                                                          //
//   Original code written by Reboot Concetps, Inc. for:    //
//   Top Travel Soft                                        //
//                                                          //
//   Contact us for support, upgrades, or assistance.       //
//   support@rebootconcepts.com                             //
//                                                          //
//   Any modifications to the code below not written by     //
//   Reboot Concepts, Inc. will invalidate any and all      //
//   warranty previously agreed upon.  While Reboot         //
//   Concepts, Inc. is not responsible for repairing such   //
//   a modification, you may request an estimate from us.   //
//                                                          //
//////////////////////////////////////////////////////////////

// Initialize TinyMCE WYSIWYG Editor(s)
tinyMCE_GZ.init({
	plugins : "autosave,contextmenu,fullscreen,inlinepopups,nonbreaking,paste,safari,save,searchreplace,style,table,visualchars",
	themes : "simple,advanced", languages : "en", disk_cache : true, debug : false
});
tinyMCE.init({
	content_css : "/css/wysiwyg.css", theme : "advanced", mode : "specific_textareas", editor_selector: "mceEditor", dialog_type : "modal",
	plugins : "autosave,contextmenu,fullscreen,inlinepopups,nonbreaking,paste,safari,save,searchreplace,style,table,visualchars",
	theme_advanced_disable : "styleselect",
	theme_advanced_buttons1_add : "|,pastetext,pasteword,selectall,|,save,cancel",
	theme_advanced_buttons2_add : "fullscreen,|,nonbreaking,search,replace,styleprops",
	theme_advanced_buttons3_add : "visualchars,|,tablecontrols"
});

// Initialize jQuery Datepicker(s)
$(document).ready( function() {
	$('.date').datepicker({ dateFormat: "yy-mm-dd", mandatory: true, closeText: 'Close [X]' });
});

// Validation Functions
function isBlank( e, n, d ) {
	f = $( "#" + e );
	if( f.val() == null || f.val() == "" ) {
		desc = ( d != null ) ? "\nIt must be " + d + '.' : '';
		alert( 'The field: "' + n + '" cannot be blank.' + desc );
		f.focus();
		return true;
	} else {
		return false;
	}
}

function checkRegex( e, n, rx, d ) {
	f = $( "#" + e );
	if( ( f.val() != null ) && ( f.val() != "" ) && ( f.val() != "\u00A0" ) && ( rx.test( f.val() ) != true ) ) {
		desc = ( d != null ) ? "\nIt must be " + d + '.' : '';
		alert( 'The field: "' + n + '" does not appear valid.' + desc );
		f.focus();
		return true;
	}
	return false;
}

function check_pass( f1, f2 ) {
	if( $("#"+f1).val() != $("#"+f2).val() ) {
		alert( "Passwords do not match!" );
		$("#"+f1).val("");
		$("#"+f2).val("");
		$("#"+f1).focus();
		return false;
	} else {
		return true;
	}
}

// Misc. Functions
function check_all( all_field, form ) {
	if( all_field.checked == true ) {
		$('#'+form+'_Mon').attr({ checked: 'checked' });
		$('#'+form+'_Tue').attr({ checked: 'checked' });
		$('#'+form+'_Wed').attr({ checked: 'checked' });
		$('#'+form+'_Thu').attr({ checked: 'checked' });
		$('#'+form+'_Fri').attr({ checked: 'checked' });
		$('#'+form+'_Sat').attr({ checked: 'checked' });
		$('#'+form+'_Sun').attr({ checked: 'checked' });
	} else {
		$('#'+form+'_Mon').removeAttr( 'checked' );
		$('#'+form+'_Tue').removeAttr( 'checked' );
		$('#'+form+'_Wed').removeAttr( 'checked' );
		$('#'+form+'_Thu').removeAttr( 'checked' );
		$('#'+form+'_Fri').removeAttr( 'checked' );
		$('#'+form+'_Sat').removeAttr( 'checked' );
		$('#'+form+'_Sun').removeAttr( 'checked' );
	}
}