function infobar(title,text,color,button,img){
	var infobar_color = document.getElementById('infobar_color');
	var infobar_img = document.getElementById('infobar_img');

	if (color == 'green') {
		infobar_color.style.backgroundImage = "url(./tools/ico/infobar/green.png)";
		infobar_img.src = "./tools/ico/infobar/greenImg.png";
		infobar_color.style.backgroundColor = "#c4fb9c";
	}
	else if (color == 'yelow') {
		infobar_color.style.backgroundImage = "url(./tools/ico/infobar/yelow.png)";
		infobar_img.src = "./tools/ico/infobar/yelowImg.png";
		infobar_color.style.backgroundColor = "#ffda75";
	}
	else if (color == 'red') {
		infobar_color.style.backgroundImage = "url(./tools/ico/infobar/red.png)";
		infobar_img.src = "./tools/ico/infobar/redImg.png";
		infobar_color.style.backgroundColor = "#ff7575";
	}

//    text += '<br><LABEL style="float:left; margin:5px; margin-left:0px; font-size:11px;"><input type="checkbox" name="hideDetail" id="hideDetail" value="a2" onclick="hideDetails(this.checked)"' + (document.getElementById('drv_lists').style.display=='none'?' checked':'') + '> '+infobar_hideDetails+'</LABEL>';

	if (button == 'InstAll')
		text += "<button class='infobar_button' onclick='chkManual(\"driver_available\"); facebox_dialog();'>"+infobar_buttonInstAll+"</button>";
	if (button == 'UpdAll')
		text += "<button class='infobar_button' onclick='chkManual(\"driver_new\"); facebox_dialog();'>"+infobar_buttonUpdAll+"</button>";
	if (img)
		infobar_img.src = "./tools/ico/infobar/"+img+".png";

	document.getElementById('infobar_title').innerHTML = title;
	document.getElementById('infobar_info').innerHTML = text;
}

function chkManual(div){
	ClearChk();
	for (var i = 0; i < buttonCount; i++) {
		var checkbox = document.getElementById('chk'+i);
		var divname = document.getElementById('type'+i).value;

		if (divname == div) { checkbox.checked="true"; ChangeChkCount(1); }
		else { checkbox.checked=""; }
	}
}

function infobar_update(){
/*    doc_num['no_driver']  	 =10;
	doc_num['driver_available']=0;
	doc_num['driver_new']      =0;*/
	if (doc_num['driver_available'] > 0) {
		infobar_drvAvailable();
	}
	else if (doc_num['no_driver'] > 0) {
		infobar_drvNone();
	}
	else if (doc_num['driver_new'] > 0) {
		infobar_drvNew();
	}
	else {
		infobar_drvAllOk();
	}
}

function infobar_drvAvailable(){
	infobar(
			infobar_titleDriverAvailable,
			'<b>'+doc_num['driver_available']+'</b> - '+morfolog('infobar_infoDriverAvailable',doc_num['driver_available']),
			'red',
			'InstAll'
		);
	if (doc_num['driver_available']==0) infobar_drvAllOk();
	setTab('tab-install');
	set_lists
		(doc_num["driver_available"]?"block":"none",
		 doc_num["no_driver"]?"block":"none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",

		 "block",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none"
		);
}
function infobar_drvNew(){
	infobar(
			infobar_titleDriverNew,
			'<b>'+doc_num['driver_new']+'</b> - '+morfolog('infobar_infoDriverNew',doc_num['driver_new']),
			'yelow',
			'UpdAll'
		);
	if (doc_num['driver_new']==0) {
		infobar(
			infobar_titleAllUpd,
			infobar_infoAllUpd,
			'green'
		);
		setTimeout("document.getElementById('infobar_img').src = './tools/ico/infobar/update.png';",0);
	}
	setTab('tab-update');
	set_lists
		("none",
		 "none",
		 doc_num["driver_new"]?"block":"none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",

		 "none",
		 "none",
		 "block",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none"
		);
}
function infobar_drvAdvanced(){
/*    infobar(
			infobar_titleDriverNew,
			'<b>'+doc_num['driver_new']+'</b> - '+morfolog('infobar_infoDriverNew',doc_num['driver_new']),
			'yelow',
			'UpdAll'
		);
	if (doc_num['driver_new']==0) {*/
		infobar(
			infobar_titleAllAdv,
			infobar_infoAllAdv,
			'green'
		);
		setTimeout("document.getElementById('infobar_img').src = './tools/ico/infobar/misc.png';",0);
//    }
	setTab('tab-advanced');
	set_lists
		("none",
		 "none",
		 "none",
		 "none",
		 "none",
		 doc_num["driver_unknown"]?"block":"none",
		 "none",
		 "none",

		 "none",
		 "none",
		 "none",
		 "block",
		 "block",
		 "block",
		 "block",
		 "block"
		);
}

function infobar_drvNone(){
	infobar(
			infobar_titleNoDriver,
			'<b>'+doc_num['no_driver']+'</b> - '+morfolog('infobar_infoNoDriver',doc_num['no_driver'])+infobar_urls,
			'red'
		);
	if (doc_num['no_driver']==0) infobar_drvAllOk();
	setTab('tab-search');
	hideOrShow('tab-search');
	set_lists
		("none",
		 "block",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",

		 "none",
		 "block",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none"
		);
}
function infobar_drvAllOk(){
	infobar(
			infobar_titleAllInst,
			infobar_infoAllInst,
			'green'
		);
	setTab('tab-install');
	set_lists
		(doc_num["driver_available"]?"block":"none",
		 doc_num["no_driver"]?"block":"none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",

		 "block",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none",
		 "none"
		);
}



function infobar_loading(){
	infobar(
		infobar_titleLoading,
		infobar_infoLoading,
		'yelow',
		'',
		'loading'
	);
}

infobar_update();


function setTab(tab){
	document.getElementById('tab-install').setAttribute('className','');
	document.getElementById('tab-update').setAttribute('className','');
	document.getElementById('tab-advanced').setAttribute('className','');
	document.getElementById('tab-search').setAttribute('className','');

	if (tab) document.getElementById(tab).setAttribute('className','active');
}
