function confirmSubmit(langEntries, context)
{
	var message = langKeyPrint(langEntries, 'delete_record_from_db') + '\n';
	
	if (context)
	{
		message += '\n ' + langKeyPrint(langEntries, 'warning') + ':  ' + context;
	}
	  
	var agree=confirm(message);
	
	if (agree)
	{
		return true;
	}
	else{
		return false;
	}
}

function submitLangForm(langEntries, theForm)
{
	var why = "";
	why += isEmpty(langEntries, theForm.name.value, langKeyPrint(langEntries, 'lang_name'));
	why += isEmpty(langEntries, theForm.code.value, langKeyPrint(langEntries, 'lang_code'));

	if (why != "") {
	   alert(why);
	}
	else{
		theForm.submit();
	}
}

function submitLangKeysForm(langEntries, theForm)
{
	var why = "";
	why += isEmpty(langEntries, theForm.lang_key.value, langKeyPrint(langEntries, 'lang_key'));
	why += checkDropdown(langEntries, theForm.cat_flag.selectedIndex,  langKeyPrint(langEntries, 'cat_flag'));
    var myReg = new RegExp("type_id", "i");
	var count = 0;
    
	for (i=0;i<theForm.elements.length; i++)
	{
	  results = theForm.elements[i].name.search(myReg);
	  
	  if (results > -1 && theForm.elements[i].type == 'checkbox')
	  {
	    if (theForm.elements[i].checked)
	    {
	      count++;
	    }
	  }
	}
	
	if (count < 1)
	{
	  why += langKeyPrint(langEntries, 'script_type_not_filled_in');
	}
	
	if (why != "") {
	   alert(why);
	}
	else{
		theForm.submit();
	}
}

function submitLangEntriesForm(langEntries, theForm)
{
	var why = "";
	why += isEmpty(langEntries, theForm.lg_entry.value, langKeyPrint(langEntries, 'lang_entry'));
	why += checkDropdown(langEntries, theForm.fk_lang_keys_id.selectedIndex,  langKeyPrint(langEntries, 'lang_key'));
	why += checkDropdown(langEntries, theForm.fk_langs_id.selectedIndex,  langKeyPrint(langEntries, 'languages'));

	if (why != "") {
	   alert(why);
	}
	else{
		theForm.submit();
	}
}

function submitTextsForm(langEntries, theForm)
{
	tinyMCE.triggerSave();
	
	var why = "";
	why += isEmpty(langEntries, theForm.title.value, langKeyPrint(langEntries, 'texts_title'));
	why += isEmpty(langEntries, theForm.keywords.value, langKeyPrint(langEntries, 'texts_keywords'));
	why += isEmpty(langEntries, theForm.description.value, langKeyPrint(langEntries, 'texts_description'));
	why += isEmpty(langEntries, theForm.text_entry.value, langKeyPrint(langEntries, 'texts_entry'));
	why += checkDropdown(langEntries, theForm.fk_langs_id.selectedIndex,  langKeyPrint(langEntries, 'languages'));
	
	sels = document.getElementsByTagName('select');
	values = '';
	for (i=0; i < sels.length; i++)
	{
		if (sels[i] != undefined)
		{
			if (sels[i].name.search('cats_sel_arr') > -1)
			{
				for (x=0; x < sels[i].length; x++)
				{
					if (sels[i][x].selected) { values += sels[i][x].value; }
				}
			}
		}
	}
	
	if (values == '') { why += langKeyPrint(langEntries, 'categories') + ' ' + langKeyPrint(langEntries, 'multi_no_sel') + '\n'; }
	why += checkDropdown(langEntries, theForm.hidden_id.selectedIndex,  langKeyPrint(langEntries, 'status'));
	
	if (why != "") {
	   alert(why);
	}
	else{
		theForm.submit();
	}
}

function submitEventsForm(langEntries, theForm)
{
	tinyMCE.triggerSave();
	
	var form_time = theForm.events_date_y.value + theForm.events_date_mo.value;
	var form_time_range = theForm.events_end_date_y.value + theForm.events_end_date_mo.value;
	var why = "";

	why += isEmpty(langEntries, theForm.title.value, langKeyPrint(langEntries, 'events_title'));
	why += isEmpty(langEntries, theForm.nav_title.value, langKeyPrint(langEntries, 'events_short_title'));
	
	form_time += (theForm.events_date_d.value.length < 2) ? "0" + theForm.events_date_d.value : theForm.events_date_d.value;
	
	if (theForm.date_range_flag.checked == true)
	{
		form_time_range += (theForm.events_end_date_d.value.length < 2) ? "0" + theForm.events_end_date_d.value : theForm.events_end_date_d.value;
		  
		if (form_time_range <= form_time)
		{
			why += "Please select an End Date that is after the Start Date\n";
		}
	}

	why += isEmpty(langEntries, theForm.keywords.value, langKeyPrint(langEntries, 'events_keywords'));
	why += isEmpty(langEntries, theForm.description.value, langKeyPrint(langEntries, 'events_description'));
	why += checkDropdown(langEntries, theForm.fk_langs_id.selectedIndex,  langKeyPrint(langEntries, 'languages'));
	
	sels = document.getElementsByTagName('select');
	values = '';
	for (i=0; i < sels.length; i++)
	{
		if (sels[i] != undefined)
		{
			if (sels[i].name.search('cats_sel_arr') > -1)
			{
				for (x=0; x < sels[i].length; x++)
				{
					if (sels[i][x].selected) { values += sels[i][x].value; }
				}
			}
		}
	}
	
	if (values == '') { why += langKeyPrint(langEntries, 'categories') + ' ' + langKeyPrint(langEntries, 'multi_no_sel') + '\n'; }
	why += checkDropdown(langEntries, theForm.hidden_id.selectedIndex,  langKeyPrint(langEntries, 'status'));
	
	if (why != "") {
	   alert(why);
	}
	else{
		theForm.submit();
	}
}

