function chFoto(img) {
    str = img.src;
    if ( img.src.match("_on") == null ) img.src = str.replace("mapa","mapa_on");
        else img.src = str.replace("_on","");    
}

function submitSelector() {
   var selector = document.getElementById("selector");
   window.location = "index.php?page_list=" + selector.value;
}

function formSubmit() {
    document["pagesForm"].submit();
}

function checkData(data) {
   return ( /^(((?:19|20)\d\d)[-](0*[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01]))|[\b]$/.test(data) );
}      

function checkNews(){
    if (checkData(document.getElementById('date').value))
    {
        document.getElementById('new_news').submit();
    }
    else
    {
       window.alert('Wrong date format! Try YYYY-MM-DD');
    }
}     

function drop_news(id) {
    if(confirm('Delete the element?')) {
        document.location = "index.php?page_list=news&action=delete&id="+id;
    }
}  

function drop_file(id) {
    if(confirm('Delete the element?')) {
        document.location = "index.php?page_list=downloads&action=delete&file_name="+id;
    }
}

function onlyDate(e,decReq) {
    var isIE = document.all?true:false;
    var isNS = document.layers?true:false;
    var key = (isIE) ? window.event.keyCode : e.which;
    var obj = (isIE) ? event.srcElement : e.target;
    var isNum = ((key > 47 && key < 58) || key==45) ? true:false;
    var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
    if(key < 32)
       return true;
    return (isNum || dotOK);
} 

function initTinyMCE() {
tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		file_browser_callback : "tinyBrowser",
		editor_deselector : "mceNoEditor",
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});


			

}
