/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * Für die Kontaktgruppen seite
 */
function selectAll(selectBox,selectAll) {
	checkBox = document.getElementById('checkGroups');

    if( checkBox.getAttribute('value') == 1 ) {
        selectAll = true;
        checkBox.setAttribute('value', 0 );
    } else {
        selectAll = false;
        checkBox.setAttribute('value', 1 );
    }
	// have we been passed an ID
	if (typeof selectBox == "string") {
		selectBox = document.getElementById(selectBox);
	}
	// is the select box a multiple select box?
	if (selectBox.type == "select-multiple") {
		for (var i = 0; i < selectBox.options.length; i++) {
			selectBox.options[i].selected = selectAll;
		}
	}
}

function selectAllAlphabundContacts(enable, id) {
//  var list = document.getElementById('alphabund-contact-list');
  var list = document.getElementById(id);
  for (var i=0; i<list.childNodes.length;i++){
    list.childNodes[i].firstChild.checked = enable;
  }
}

function selectAllSavedAlphabundContacts(enable, id){
  //var liste = document.getElementById('alphabund-saved-contacts');
  var liste = document.getElementById(id);
  console.debug(liste);
  for (var i=0; i<liste.childNodes.length;i++){
    liste.childNodes[i].firstChild.checked = enable;
  }
}

/*F�r die Kontakt bearbeiten Seite*/
function deleteContact(){
	if(confirm("Wollen Sie diesen Kontakt wirklich l"+unescape('%F6')+"schen?")){
		return true;
	}else{
		return false;
	}

}

/*Dokumentendatenbank*/

function deleteDocument(){
	if(confirm("Wollen Sie diese Version wirklich l"+unescape('%F6')+"schen?")){
		return true;
	} else {
		return false;
	}

}


function clickOnOpenAccess(id){
	dojo.require("dojo.fx");
	if(dojo.style(id,"display")=="none"){
		wipeInOne(id);
	}else{
		wipeOutOne(id);
	}
}

function wipeInOne(id){
  	dojo.fx.wipeIn({
	    node: id,
	    duration: 300
  	}).play();
}

function wipeOutOne(id){
	dojo.fx.wipeOut({
	    node: id,
	    duration: 300
  	}).play();
  	dojo.query("#"+id+" input").forEach("item.checked = false;");
}

function checkAccess(){
	if(dojo.byId("openaccess") != null && !(dojo.byId("openaccess").checked)){
		if(dojo.byId("access") != null)
			dojo.style("access","display","block");
	} else {
		if(dojo.byId("access") != null)
			dojo.style("access","display","none");
	}
}

function manageDiv(t, id){
	if(t.checked){
		wipeInOne(id);
	} else {
		wipeOutOne(id);
	}
}

if(dojo != null){
	dojo.addOnLoad(function(){checkAccess();});
}

