var commentPage = "e12.php?w=";
function addClap(id)
{
	setClap( id, 0, function(){
			if(document.getElementById('clapNum'+clap['id']) ){
				document.getElementById('clapNum'+clap['id']).innerHTML = clap['count'];
				infoClap(Number(clap['valid']));
			}
		}
	);
}

function sendClap(id){
	setClap(id, 1, function(){jump(commentPage+clap['id']);});
}

function setClap(id, flag, nextFunction){
	httpRequest("data/setNewWorkClap.php?id="+id+"&keep="+flag, function( indata ){
			if(typeof(indata) == "object" || typeof(indata) != "string"){indata = "";}
			if(typeof(clap) != "object"){clap = new Array();}
			var csv = indata.split( "\n" );
			if ( csv[0] == "Error" ){alert(csv[0]);return;}
			else { clap={id:csv[0],count:csv[1],valid:csv[2]};}
			nextFunction();
		}
	);
}

function infoClap(mode)
{
	var infoBox = document.getElementById('addClapInfoArea');
	var clapArea = document.getElementById('clapCountArea');
	if( mode ){
		if(infoBox){infoBox.style.display = "block";}
		if(clapArea){clapArea.className = "ouen_push1";}
	}
	else{
		if(infoBox){ infoBox.style.display = "none"; }
		if(clapArea){clapArea.className = "ouen_push";}
	}
}
