/* NAVIGATION SCRIPT */
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
					this.style.zIndex = 100;
  				}
  				node.onmouseout=function() {
  					this.className=this.className.replace(" over", "");
  					this.style.zIndex = 1;
				}
			}
		}
 	}
}
window.onload=startList;




//functions

//check if empty
function notEmpty(obj,msg){   
   var mystr = ""
   len = obj.value.length
   if (len > 0)
   {  for (i=0;i<len; i++) 
		{ if(obj.value.substring(i,i+1)!=" ")
			{ mystr = mystr + obj.value.substring(i,i+1)}}	
	}
	if(mystr=="")
	{alert(msg);if(obj.name !='rte1')
	{
		if(obj.name!='txt_total')
			{obj.focus();}
		}
		return false;}
 return true;	
}



function confirm_delete_news(news_id){
	var answer = confirm ("Are you sure you want to delete this entry?");
	if (answer){
		window.open("index.php?action=delete_news&news_id="+news_id,"_self");
	}
}

function confirm_delete_events(news_id){
	var answer = confirm ("Are you sure you want to delete this entry?");
	if (answer){
		window.open("index.php?action=delete_events&news_id="+news_id,"_self");
	}
}



function check_form_add_news(frm){
	if(notEmpty(document[frm].title,"Please enter the title.") == false ||
		//notEmpty(document[frm].author,"Please enter the author.") == false ||
		notEmpty(document[frm].date_added,"Please enter the date.") == false/* ||
		notEmpty(document[frm].content,"Please enter the content.") == false*/){
		return false;
	}else{
		return true;
	}	
}



function delete_photo(news_id, filename, column){
	var answer = confirm ("Are you sure you want to delete this photo?");
	if (answer){
		window.open("index.php?action=edit_news&action2=delete_photo&news_id="+news_id+"&filename="+filename+"&column="+column,"_self");
	}
}


function delete_events_photo(news_id, filename, column){
	var answer = confirm ("Are you sure you want to delete this photo?");
	if (answer){
		window.open("index.php?action=edit_events&action2=delete_photo&news_id="+news_id+"&filename="+filename+"&column="+column,"_self");
	}
}