
var submittedForms = new Array();

function bhcNavOver(id, isSub) {
	var pf = (isSub ? '' : '_root');
	document.getElementById('nav_container_'+id).className = 'bhc_navigation_item'+pf+'_over';
	document.getElementById('nav_label_'+id).className = 'bhc_navigation_item'+pf+'_over';
}

function bhcNavOut(id, isSub) {
	var pf = (isSub ? '' : '_root');
	document.getElementById('nav_container_'+id).className = 'bhc_navigation_item'+pf;
	document.getElementById('nav_label_'+id).className = 'bhc_navigation_item'+pf;
}

function navOver(id, isSub) {
	var pf = (isSub ? '' : '_root');
	document.getElementById('nav_label_'+id).className = 'navigation_item'+pf+'_over';
}

function navOut(id, isSub) {
	var pf = (isSub ? '' : '_root');
	document.getElementById('nav_label_'+id).className = 'navigation_item'+pf;
}

function openPopup(location, name, width, height, iets) {
	window.open(location,name,'width='+width+',height='+height+',scollbars=no,resizable=no,location=no,menubar=no');
}

function navigate(id) {
	setCookie('navigation', id, false, '/', '.' + g_hostname);
}

function sendMultiForm(basename) {
	
	var frms = document.getElementsByTagName('FORM');
	var idx;
	
	for	(idx = 0; idx < frms.length; ++idx) {
		if (frms[idx].name.substring(0, basename.length) == basename) {
			submittedForms[idx] = true;
			frms[idx].submit();
		}
	}
	
}

function submitLic() {
	
	var chk = document.getElementsByTagName('INPUT');
	var count = 0;
	var i;
	
	for (i = 0; i < chk.length; ++i) {
		if (chk[i].type == 'checkbox') if (chk[i].checked) ++count;
	}

	if (count > 0) submitForm(true);
	
}

function button_mousedown(obj) {

	obj.setAttribute('down', 1);
	button_invalidate(obj);
	
}

function openWizard(page) {
	window.open('/extern/' + page, '_blank' ,'width=530,height=430,status=no,scrollbars=no,resizable=no,menubar=no,locationbar=no');
}

// -- Button stuff -----------------------------------------------------------------------------------------------------------------------------

function button_mouseup(obj) {
	
	obj.setAttribute('down', 0);
	button_invalidate(obj);

}

function button_mouseover(obj) {

	obj.setAttribute('over', 1);
	button_invalidate(obj);

}

function button_mouseout(obj) {

	obj.setAttribute('over', 0);
	button_invalidate(obj);

}

function button_invalidate(obj) {

	var type = obj.getAttribute('type');
	var down = (obj.getAttribute('down') == 1 ? '_d' : '_u');
	var over = (obj.getAttribute('over') == 1 ? '_o' : '');

	obj.className = 'button' + down + over;
	obj.rows[0].cells[0].firstChild.src = '/img/buttons/' + type + '_l' + down + over + '.png';
	obj.rows[0].cells[1].style.backgroundImage = 'url(/img/buttons/' + type + '_m' + down + over + '.png)';
	obj.rows[0].cells[2].firstChild.src = '/img/buttons/' + type + '_r' + down + over + '.png';

}

// -- Cookie Handling --------------------------------------------------------------------------------------------------------------------------

function setCookie(cookieName, cookieValue, expires, path, domain, secure) {

	document.cookie = escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; EXPIRES=' + expires.toGMTString() : '')
		+ (path ? '; PATH=' + path : '')
		+ (domain ? '; DOMAIN=' + domain : '')
		+ (secure ? '; SECURE' : '');
		
}
   
function getCookie(cookieName) {

	var cookieValue = null;
	var posName = document.cookie.indexOf(escape(cookieName) + '=');
	
	if (posName != -1) {

		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);

		if (endPos != -1) {
			cookieValue = unescape(document.cookie.substring(posValue, endPos));
		} else {
			cookieValue = unescape(document.cookie.substring(posValue));
		}

	}
	
	return cookieValue;
	
}

