function change(id, bTest, lang) {
	if (bTest)
		var imgSrc = "images/"+lang+"_"+id+"h.gif";
	else
		var imgSrc = "images/"+lang+"_"+id+".gif";
	document.images[id].src = imgSrc;
	return false;
}
function changeRFinfo(sType, lang) {
	self.location = "index.php?page="+sType+"&tpointCC="+lang;
}
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("It's about time to upgrade don't you think?");
	}
}
var oTPoint = getXmlHttpRequestObject();
function vote(type, companyid, tpoint, name) {
	text = 'Finance Tpoints';
	if (type == 'stp')
		text = 'Supplier Tpoints';
	if (tpoint > 0)
		blnConfirm = confirm('Potwierdź jeśli chcesz dać '+text+': '+tpoint+' firmie '+name+'?');
	else
		blnConfirm = confirm('Potwierdź jeśli chcesz usunąć ocenę '+text+' dla firmy '+name+'?');
	if (blnConfirm)
	{
		id = type+'_avg'+companyid;
		var ss = document.getElementById(id);
		ss.innerHTML = '<img src="http://forad.pl/images/new_layout/loading.gif"/>';
		if (oTPoint.readyState == 4 || oTPoint.readyState == 0) {
			oTPoint.open("GET", 'vote.php?type='+type+'&cid='+companyid+'&tp='+tpoint, true);
			oTPoint.onreadystatechange = showAvg; 
			oTPoint.send(null);
		}
	}
}
function showAvg() {
	if (oTPoint.readyState == 4) {
		var str = oTPoint.responseText.split('|');
	 	td = document.getElementById(str[0]);
		td.innerHTML = str[1];
		td.onmouseover = new Function(str[2]);
	}
}

function checkAll(check, iName) 
{
	var checkBoxes = document.getElementsByName(iName);
	for (var n = checkBoxes.length-1; n>=0; n--) 
	{
		if (check) { checkBoxes[n].checked=true; }
     	else { checkBoxes[n].checked=false; }
	}
}
function calc() {
	var sum = 0;
	var checkBoxes = document.getElementsByName("modul");
	for (var n = checkBoxes.length-1; n>=0; n--) {
		if (checkBoxes[n].checked==true)
			sum += parseInt(checkBoxes[n].value);
	}
	document.getElementById('suma').innerHTML = sum+" PLN";
}

function sForm(pg) {
	document.getElementById('pg').value = pg;
	document.search.submit();
}