// JavaScript Document

function starOver(which) {

	img = document.getElementById('star' +  which);
	img.src = 'images/star_green_small.png';
}

function starOut(which, clr) {

	img = document.getElementById('star' +  which);
	img.src = 'images/star_' + clr + '_small.png';
}

function starOver_big(which) {

	img = document.getElementById('star' +  which);
	img.src = 'images/star_green.png';
}

function starOut_big(which, clr) {

	img = document.getElementById('star' +  which);
	img.src = 'images/star_' + clr + '.png';
}

function updateRating(id, a, b, c, d){

	url = 'updaterating.php?id_buck_item=' + id + '&votea=' + a + '&voteb=' + b + '&votec=' + c + '&voted=' + d;

	var ajaxIndex = dynamicContent_ajaxObjects.length;
	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent('stars'+id,ajaxIndex,url); setTimeout("refreshBucks(" + id + "," + a + "," + b + "," + c + "," + d + ")", 1500); };
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();	
}

function refreshBucks(id, a, b, c, d) {

	if (a != 0 && document.getElementById('stars'+id+'-1')) ajax_loadContent( 'stars'+id+'-1', 'refresh.php?param=a&id='+id );
	if (b != 0 && document.getElementById('stars'+id+'-2')) ajax_loadContent( 'stars'+id+'-2', 'refresh.php?param=b&id='+id );
	if (c != 0 && document.getElementById('stars'+id+'-3')) ajax_loadContent( 'stars'+id+'-3', 'refresh.php?param=c&id='+id );
	if (d != 0 && document.getElementById('stars'+id+'-4')) ajax_loadContent( 'stars'+id+'-4', 'refresh.php?param=d&id='+id );
	ajax_loadContent( 'stars'+id, 'refresh.php?param=all&id='+id );
}

function showErrorWin(app) {

	document.getElementById('leftSide').style.filter = 'gray alpha(opacity=20)';
	document.getElementById('rightSide').style.filter = 'gray alpha(opacity=20)';
	document.getElementById('leftSide').style.opacity = '0.1'; 
	document.getElementById('leftSide').style.MozOpacity = '0.1';
	document.getElementById('rightSide').style.opacity = '0.1'; 
	document.getElementById('rightSide').style.MozOpacity = '0.1';
	document.getElementById('errorHolder').style.visibility = 'visible';
	ajax_loadContent('errorWin',app);
}

function hideErrorWin() {

	document.getElementById('leftSide').style.filter = 'alpha(opacity=100)';
	document.getElementById('rightSide').style.filter = 'alpha(opacity=100)';
	document.getElementById('leftSide').style.opacity = '1'; 
	document.getElementById('leftSide').style.MozOpacity = '1';
	document.getElementById('rightSide').style.opacity = '1'; 
	document.getElementById('rightSide').style.MozOpacity = '1';
	document.getElementById('errorHolder').style.visibility = 'hidden';
	document.getElementById('errorWin').innerHTML = '';
}

function hideF(which) {

	nextF = which + 1;
	
	document.getElementById('hide_' + which).style.display = 'none';
	document.getElementById('hide_' + nextF).style.display = 'block';
	document.getElementById('buck_' + nextF).style.display = 'block';
}

function showD(which, layer) {

	document.getElementById('itemHelp' + layer).style.display = 'block';
	document.getElementById('itemHelp' + layer).innerHTML = helpItems[which];
}

function hideD(layer) {

	document.getElementById('itemHelp' + layer).style.display = 'none';
}