/*
Module	: PAM
Functie	: Javascript functies
Datum	: 03-05-2006
*/

function getTopMenuItem(url, id){
 mainFrame = document.getElementById('mainFrame');
 if (url.indexOf('?') > 0) 
  seperator = '&';
 else seperator = '?';
 mainFrame.location.href = url + seperator + 'menuid=' + id;
 return;
}

function changeClass(id, klasse){
 document.getElementById(id).className = klasse;
}

function accessDenied(){
 alert('Access denied');
}

function showSub(id){
 
 theRows=document.getElementById("dataTable").rows
 reg=new RegExp("^"+id)
 for (i=0;i<theRows.length;i++)
  if (reg.test(theRows[i].id))
     if  (theRows[i].style.display=="none") {
       theRows[i].style.display="";
	   src = 'min';
	 }else{
       theRows[i].style.display="none";
	   src = 'plus';
	 }

 document.getElementById('icon_' + id).src = 'images/icons/icon_' + src + '.gif';
}

function loadMainPage(page){
 if (page != '') parent.MAIN.location.href = page;
 return;
}

/*
============================================================================================
	Module specifieke functies
============================================================================================
*/

function dateonly(){
 if ((event.keyCode<48&&event.keyCode!=45)||event.keyCode>57)
  return false
}

function deleteNews(id, parent, message){
 if (confirm(message)){
  document.location.href = 'delete.asp?id=' + id + '&open_node=' + parent;
 }
 return;
}

function insertNews(parent, id2, id3){
 document.location.href = 'edit.asp?parent=' + parent;
 return;
}

function deleteUser(id, parent, message){
 if (confirm(message)){
  document.location.href = 'delete_user.asp?id=' + id + '&open_node=' + parent;
 }
 return;
}

function insertGroup(parent, id2, id3){
 document.location.href = 'edit.asp?parent=' + parent;
 return;
}

function changeRowColorItem(id, color){
 document.getElementById(id).bgColor = color;
}

function editNews(id, id2, id3){
 document.location.href = 'edit.asp?id=' + id;
 return;
}

function editMenuItem(id, id2, id3){
 document.location.href = 'edit_menuopties.asp?id=' + id;
 return;
}

function uploaden(field, newdir, stayindir, add){
  winstyle = "width=800, height=550, screenX=300, screenY=300, resizable=yes";
  window.open('../jscripts/filebrowser/index.asp?field=' + field + '&newdir=' + newdir + '&stayindir=' + stayindir + '&add=' + add,null,winstyle);
}

function detailsGroupLink(id){
   winstyle = "width=650, height=550";
   window.open('itemselect.asp?id=' + id,'Details',winstyle);
}

function deleteGroup(url, extrastr){
  if (confirm('Weet u zeker dat u dit item wilt verwijderen? / Are you sure you want to delete this item?') == true)
  location.href = url + extrastr;
  return;
}

function editUser(id, id2, id3){
 document.location.href = 'edit_user.asp?id=' + id;
 return;
}

function showDiv(id){
 elm = document.getElementById('div_' + id);
 if (elm.style.display == 'none'){
  elm.style.display = '';}
 else{
  elm.style.display = 'none';}
}

function getLanguage(id){
 divs = document.getElementsByTagName('div');
 for (i = 0; i <= divs.length-1; i++){
  indexof = divs[i].id.indexOf('page_');
  if (indexof != -1){
	divs[i].style.display = 'none';
  }
 }
 divs = document.getElementsByTagName('div');
 for (i = 0; i <= divs.length-1; i++){
  indexof = divs[i].id.indexOf('selection_');
  if (indexof != -1){
	divs[i].className = 'language_selection';
  }
 }
 document.getElementById('selection_' + id).className = 'language_selection_active';
 document.getElementById('page_' + id).style.display = '';
 return;
}

function submitForm(id1, id2, id3){
 document[id2].submit();
}