
var VoteInterface = {
    positive: new I4.Ajax.SyncMessage('/excelentni-nevesta/votepositive/').withPostParams('profile')
,
    negative: new I4.Ajax.SyncMessage('/excelentni-nevesta/votenegative/').withPostParams('profile')
}

function showLoginForm()
{
        document.getElementById('login-form').style.display = 'block';
}
function hideLoginForm()
{
        document.getElementById('login-form').style.display = 'none';
}

function addPoint(type)
{
	try      {with(document.getElementById(type).firstChild) data = parseInt(data) + 1;}
	catch(e) {/* Hlasovani se nezobrazuje */}
}

function showResponse(request, movie, pointCounter)
{
    try {
        var response = I4.Ajax.JSONResponse(request);
        var txt = document.createTextNode(response.MESSAGE);
        with(document.getElementById('promo-ajax-response')) 
        	try {
                style.display = 'block';
                replaceChild(txt, firstChild);
        	} catch(e) {
                appendChild(txt);
        	}
        	if(response.STATUS == 1) showLoginForm();
        	if(response.STATUS == 0) {
				addPoint(pointCounter);
				//PlayFlashMovie(movie);
			}
    } catch(e) {
                alert('Chyba pri komunikaci se serverem');
    }
}

function votePositive(profile)
{
        showResponse(VoteInterface.positive(profile), 'jes', 'positivePoints');
}


function voteNegative(profile)
{
        showResponse(VoteInterface.negative(profile), 'nou', 'negativePoints');
}

