var cpd = new Array();

var out = new Array();

out[1] = "a legjobban utĂĄlom (-5)";
out[2] = "csak Ĺ�t ne, soha (-4)";
out[3] = "majdnem utĂĄlom (-3)";
out[4] = "rosszfej (-2)";
out[5] = "negatĂ­v semleges (-1)";

function omo (sid ,id) {
    //alert(cpd[sid]);
    if (cpd[sid] == 0) {
        for (i=1;i<=5;i++) {
            //alert(sid+' / '+id+' / '+i);
            if (i <= id) {
                document.getElementById(sid+'_vote_'+i).src = '/images/vote/vote_star_active_16.gif';
                //document.getElementById(sid+'_vote_'+i).src = '/images/vote/smile_'+i+'_on.gif';
            } else {
                document.getElementById(sid+'_vote_'+i).src = '/images/vote/vote_star_gray_16.gif';
                //document.getElementById(sid+'_vote_'+i).src = '/images/vote/smile_'+i+'_off.gif';
            }
            //if (i == id) document.getElementById(sid+'_myrating').InnerHTML = "sadsdsa";
            if (i == id) {
                //document.getElementById(sid+'_myrating').innerHTML = out[i];
            }
        }
    };
    //alert (out+' / '+sid+' / '+id);
}

function omout (sid, defrat) {
    if (cpd[sid] == 0) {
        //defrat = (defrat + 6);
        for (i=1;i<=5;i++) {
            if (i <= defrat) {
                //alert(i+' i '+defrat);
                document.getElementById(sid+'_vote_'+i).src = '/images/vote/vote_star_active_16.gif';
                //document.getElementById(sid+'_vote_'+i).src = '/images/vote/color_smile_'+i+'_off.gif';
            } else {
                //alert(i+' x '+defrat);
                document.getElementById(sid+'_vote_'+i).src = '/images/vote/vote_star_gray_16.gif';
                //document.getElementById(sid+'_vote_'+i).src = '/images/vote/smile_'+i+'_off.gif';
            }
        }
        //document.getElementById(sid+'_myrating').innerHTML = '';
    };
}

function omoutreset (sid, defrat) {
    //defrat = (defrat + 6);
    //alert(sid+' / '+defrat);
    for (i=1;i<=5;i++) {
        if (i <= defrat) {
            //alert(i+' i '+defrat);
            document.getElementById(sid+'_vote_'+i).src = '/images/vote/vote_star_active_16.gif';
            //document.getElementById(sid+'_vote_'+i).src = '/images/vote/color_smile_'+i+'_off.gif';
        } else {
            //alert(i+' x '+defrat);
            document.getElementById(sid+'_vote_'+i).src = '/images/vote/vote_star_gray_16.gif';
            //document.getElementById(sid+'_vote_'+i).src = '/images/vote/smile_'+i+'_off.gif';
        }
    }
    cpd[sid] = GetCookie("cpd"+sid);
    //if (out[cpd[sid]]) document.getElementById(sid+'_myrating').innerHTML = 'Szavazatod: ' + out[cpd[sid]];
    if (cpd[sid] != 0) document.getElementById(sid+'_myrating').innerHTML = 'Értékelésed: ' + cpd[sid] + '';
    //if (cpd[sid] != 0) document.getElementById(sid+'_myrating').innerHTML = 'Értékelésed: ' + cpd[sid] + '';
    //alert(cpd[sid]);    
}

function GetXmlHttpObject() {
    var xmlHttp=null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    } catch (e) {
        // Internet Explorer
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}
        
function sendvote(sid, id, user) {
    if (user == "") {
        document.getElementById(sid+'_myrating').innerHTML = 'Ha értékelni akarod, kérlek lépj be!';
    } else {
        if (cpd[sid] == 0) {
            cpd[sid] = id;
            //document.getElementById(sid+'_myrating').innerHTML = 'Értékelésed: ' + cpd[sid] + '';
            document.getElementById(sid+'_myrating').innerHTML = 'Értékelésed: ' + cpd[sid] + '';
            //alert(sid+'_myrating1');
            SetCookie('cpd'+sid, id, 3600);
            xmlHttp=GetXmlHttpObject();
            if (xmlHttp==null) {
                alert ("Your browser does not support AJAX!");
                return;
            }
            var url="http://" + document.domain + "/tarskereso_foto_fotok_bongeszese.php?event=vote&sid="+sid+"&id="+id;
            //alert(url);
            xmlHttp.open("GET",url,true);
            xmlHttp.send(null);
        };
    };
}

function SetCookie(cookieName,cookieValue,nSecs) {
    var today = new Date();
    var expire = new Date();
    if (nSecs==null || nSecs==0) nSecs = 1;
    expire.setTime(today.getTime() + 1000*nSecs);
    document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
    //alert (cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString());
}

function GetCookie( cookieName ) {   
    var start = document.cookie.indexOf( cookieName + "=" );
    var len = start + cookieName.length + 1;
    if ( ( !start ) && ( cookieName != document.cookie.substring( 0, cookieName.length ) ) ) {
        return 0;
    }
    if ( start == -1 ) return 0;
    var end = document.cookie.indexOf( ";", len );
    if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}
