function showSub(id){
	if (document.getElementById('sub'+id))document.getElementById('sub'+id).style.display = '';
}
function hideSub(id){
	if (document.getElementById('sub'+id))document.getElementById('sub'+id).style.display = 'none';
}
/* Golden Drum Exceptions */
var additional_data = '';
timeout = null;
function lemonConsole(module_data){
	//alert(module_data);
	if(document.getElementById('fuzzyadmin').style.display == 'none')document.getElementById('fuzzyadmin').style.display = '';
	keepAlive();
	new Ajax.Updater('fuzzymanage','/connector/fuzzyConnector.php',
		{
			postBody:(module_data),
			asynchronous:false,
			onSuccess:function(transport){
				//alert(transport.responseText);
				if(additional_data != ''){
					setTimeout(additional_data, 500);
					//additional_data = '';
				}
				
			}
		}
		);
}
function fuzzyAjax(u, el){
	new Ajax.Updater(el,'/connector/ajax/?',
		{
			parameters:$(u).serialize(true),
			asynchronous:false,
			onSuccess:function(transport){
				if(additional_data != ''){
					setTimeout(additional_data, 500);
				}

			}
		}
	);
}
	function showResult(){
		res = 0;
		for(i = 1; i <= 5; i++){
			d = document.getElementsByName("ans_kvz_" + i);
			for(b = 0; b < d.length; b++){
				if(d[b].checked){
					res += d[b].value;
				}
			}
		}
		if(res > 4 && res <= 7){
			document.getElementById("result_1").style.display = "";
			document.getElementById("result_2").style.display = "none";
			document.getElementById("result_3").style.display = "none";
		}else if(res > 7 && res <= 12){
			document.getElementById("result_1").style.display = "none";
			document.getElementById("result_2").style.display = "";
			document.getElementById("result_3").style.display = "none";
		}else if(res > 12){
			document.getElementById("result_1").style.display = "none";
			document.getElementById("result_2").style.display = "none";
			document.getElementById("result_3").style.display = "";
		}
	}
function runRTE(){
	tinyMCE.init({ 
		mode : "textareas", 
		theme: "simple",
		theme_advanced_toolbar_location : "top", 
		theme_advanced_toolbar_align : "left", 
		theme_advanced_resizing : false,
		paste_create_paragraphs : false,
		paste_create_linebreaks : false,
		width: "730",
		height: "500"
	}); 	
}

function printDocument(d) {
	window.print();
}

var hasBeenExecuted = false;
function initRte(){

	
	hasBeenExecuted = true;
	tinyMCE.init({ 
		mode : "textareas", 
		theme : "advanced",
		width : "850",
		height: "220",
//		theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect" 
		
		plugins : "fullscreen,media,table,paste",
		theme_advanced_buttons1 : "cut,copy,paste,|,formatselect,|,cut,copy,paste,pastetext,|,bold,italic,underline,strikethrough,link,unlink,bullist,numlist,|,justifyleft,justifycenter,justifyright,justifyfull,|,fullscreen", 
		theme_advanced_buttons2 : "pastetext,pasteword,|,code,tablecontrols,image,media",
		theme_advanced_buttons3 : "",
		table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",
		table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
		table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
		table_cell_limit : 100,
		table_row_limit : 5,
		table_col_limit : 5,
		theme_advanced_toolbar_location : "top", 
		theme_advanced_toolbar_align : "left", 
		theme_advanced_resizing : false,
		paste_create_paragraphs : false,
		paste_create_linebreaks : false,
		paste_use_dialog : true,
		paste_auto_cleanup_on_paste : true,
		paste_convert_middot_lists : false,
		paste_unindented_list_class : "unindentedList",
		paste_convert_headers_to_strong : true,
		paste_insert_word_content_callback : "convertWord"
	});

}
function closeFuzzyConsole(){
	document.getElementById('fuzzyadmin').style.display = 'none';
}
function classicSave(u, who){
	new Ajax.Updater('fuzzymanage','/connector/fuzzyConnector.php',{parameters:$(who).serialize(true),asynchronous:false});
}
function keepAlive() {
	box = document.getElementById('fuzzyadmin');
	bs = document.getElementById('fuzzyadmin');
	box.style.display = 'block';
	boxw = document.body.scrollWidth;
	boxh = document.body.scrollHeight;
	bsw = 1000;
	bsh = 840;
	if (boxw < bsw)boxw = bsw;
	if (boxh < bsh)boxh = bsh;
	box.style.width = boxw + 'px';
	box.style.height = boxh + 'px';
	bs.style.display = 'block';	
	bs.style.width = bsw + 'px';
	bs.style.height = bsh + 'px';		
	bsl = (document.body.clientWidth / 2) - (bsw / 2);
	bst = (document.body.clientHeight / 2) - (bsh / 2)
	if (bsl < 0)bsl = 0;
	if (bst < 0)bst = 0
	bs.style.left =	bsl;
	bs.style.top = bst;
}
/* NEWS MODULE */
function saveData(u){
	if(timeout != null)clearTimeout(timeout);
	tinyMCE.triggerSave(true,true);
	new Ajax.Updater('fuzzymanage','/connector/fuzzyConnector.php',{parameters:$('news_form').serialize(true),asynchronous:false});
	
}
/* END NEWS MODULE */
/* MODULE FAQ */
function saveFaq(u){
	new Ajax.Updater('fuzzymanage','/connector/fuzzyConnector.php',{parameters:$('faqform').serialize(true),asynchronous:false});
}

/* END MODULE FAQ */
/* CATEGORY MODULE */
function saveCategory(u){
	t = document.getElementById('categorytitle').value;
	
	i = document.getElementById('catid').value;
	a = document.getElementById('categoryactivity').options[document.getElementById('categoryactivity').selectedIndex].value;
	p0 = document.getElementById('categorypublic').options[document.getElementById('categorypublic').selectedIndex].value;
	p1 = document.getElementById('categoryadmin').options[document.getElementById('categoryadmin').selectedIndex].value;
	friendly = document.getElementById('categoryfriendly').value;
	//p2 = document.getElementById('categoryemployer').options[document.getElementById('categoryemployer').selectedIndex].value;
	//p3 = document.getElementById('categoryemployee').options[document.getElementById('categoryemployee').selectedIndex].value;
	
	p = document.getElementById('categorygroup').options[document.getElementById('categorygroup').selectedIndex].value;
	la = document.getElementById('categorylayout').options[document.getElementById('categorylayout').selectedIndex].value;
	lo = document.getElementById('categorylocale').options[document.getElementById('categorylocale').selectedIndex].value;
	u += '&name=' + t + '&active=' + a + '&group=' + p + '&id=' + i + '&locale=' + lo + '&layout=' + la + '&p0=' + p0 + '&p1=' + p1 + '&friendly=' + friendly;
	
	lemonConsole(u);
}
/* END CATEGORY MODULE */
/* JOB MODULE */
function saveJob(u){
	tinyMCE.triggerSave(true,true);
	new Ajax.Updater('fuzzymanage','/connector/fuzzyConnector.php',{parameters:$('job_form').serialize(true),asynchronous:false});
}
/* END JOB MODULE */



function fixPNGS(){
	//<![CDATA[
// If you don't want to put nonstandard properties in your stylesheet, here's yet
 // another means of activating the script. This assumes that you have at least one
 // stylesheet included already in the document above this script.
 // To activate, delete the CSS rules above and uncomment below (remove /* and */ ).
 
 /*
 if (document.all && /MSIE (5\.5|6)/.test(navigator.userAgent) &&
  document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule)
 {
  document.styleSheets[0].addRule('*', 'behavior: url(/resources/iepngfix.htc)');
  // Feel free to add rules for specific elements only, as above.
  // You have to call this once for each selector, like so:
  //document.styleSheets[0].addRule('img', 'behavior: url(/css/resources/iepngfix.htc)');
  //document.styleSheets[0].addRule('div', 'behavior: url(/css/resources/iepngfix.htc)');
 }
 */
 
 // Here's another script that disables all PNGs in IE when the page is printed.
 /*
 if (window.attachEvent  && /MSIE (5\.5|6)/.test(navigator.userAgent))
 {
  function printPNGFix(disable)
  {
   for (var  i = 0; i < document.all.length; i++)
   {
    var e = document.all[i];
    if (e.filters['DXImageTransform.Microsoft.AlphaImageLoader'] || e._png_print)
    {
     if (disable)
     {
      e._png_print = e.style.filter;
      e.style.filter = '';
     }
     else
     {
      e.style.filter = e._png_print;
      e._png_print = '';
     }
    }
   }
  };
  window.attachEvent('onbeforeprint',  function() { printPNGFix(1) });
  window.attachEvent('onafterprint',  function() { printPNGFix(0) });
 }
 */
 
 //]]>
}
