var switchlst = ['home', 'soft', 'util', 'wis', 'cur', 'man', 'links', 'lnew', 'prom', 'rec', 'firm', 'oclock'];
var switchdta = [];

function cswitch(name, topen) {
	var tt = document.getElementById('tt' + name);
	var ti = document.getElementById('ti' + name);
	var tc = document.getElementById('tc' + name);
	var save = false;
	
	if (topen == undefined) {
		topen = tt.cclosed;		
		save = true;
	}
	
	/*tc.style.position = 'relative';
	tc.style.borderBottom = '0';
	tc.style.borderTop = '0';*/
	
	if (!topen) {
		tt.cclosed = true;
		ti.src = 'i/_lclosed.gif';
		tc.style.display = 'none';
	} else {
		tt.cclosed = false;
		ti.src = 'i/_lopened.gif';
		tc.style.display = 'block';
	}	
	
	for (k in switchlst) {		
		if (switchlst[k] != name) continue;
		switchdta[k] = topen;
	}
	
	if (save) cswitchsave();
}

function addBookmarks(title, url) {
	if (window.external && document.all) {
		window.external.AddFavorite(url, title);
	} else {
		window.sidebar.addPanel(title, url, '');
	}
}

function cswitchload(save) {
	if (save == undefined) save = true;
	var cfg = cookies.get('cdrcfg');
	
	switchdta.length = switchlst.length;
	
	for (var n = 0; n < switchlst.length; n++) {
		var action = true;
		if (cfg != undefined) {
			var c = cfg.charCodeAt(Math.floor(n / 8));
			action = !((c & (1 << (n % 8))) != 0);
		}
		cswitch(switchlst[n], action);		
	}
	
	if (save) cswitchsave();
}

function cswitchsave() {
	var data = [], cfg = '';
	
	for (var n = 0; n < switchdta.length; n++) {
		var cp = Math.floor(n / 8);
		if (data[cp] == undefined) data[cp] = 0;		
		if (!switchdta[n]) data[cp] |= (1 << (n % 8));
	}
	
	for (var n = 0; n < data.length; n++) cfg += String.fromCharCode(data[n]);
	
	cookies.set('cdrcfg', cfg, 3600 * 24 * 365, undefined, 'www.insertcdr.com');
}

function cdrload() {
	cswitchload();
}

if (window.addEventListener) window.addEventListener('load', function() {  }, false);

function csover(id) {
	if (false) { // No se ejecuta
		var tt = document.getElementById('tt' + id);
		var tc = document.getElementById('tc' + id);
		if (tt.cclosed) {
			tc.style.display = 'block';
			tc.style.position = 'absolute';
			tc.style.borderBottom = '1px solid black;';
			tc.style.borderTop = '1px solid black;';
		}
	}
}

function csout(id) {
	if (false) { // No se ejecuta
		var tt = document.getElementById('tt' + id);
		var tc = document.getElementById('tc' + id);
		if (tt.cclosed) {
			tc.style.display = 'none';
			tc.style.position = 'relative';
			tc.style.zIndex = 1000;		
		}
	}
}