/* AV Arcade Pro front-end javascript functions Author: Andy Venus Rating stars rollover by Addam M. Driver */ var sMax; // Isthe maximum number of stars var holder; // Is the holding pattern for clicked state var preSet; // Is the PreSet value onces a selection has been made var rated; // AJAX for all browsers 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; } // AJAX POST FUNCTION function AjaxPost(url, param, success_function) { xmlHttp = GetXmlHttpObject(); if (xmlHttp == null) { alert("Your browser doesn't support AJAX. You should upgrade it!") return } xmlHttp.onreadystatechange = success_function; xmlHttp.open("POST", url, true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.send(param); } function div(d) { return document.getElementById(d); } // Rollover for image Stars // function rating(num){ sMax = 0; // Isthe maximum number of stars for(n=0; n'+unfav+''; } else { div('favbutton').innerHTML = ''+fav+''; } } // ADD COMMENT function AddComment(id, site_url) { div('comment_submit').disabled=true; div('comment_submit').value="Adding comment..."; thecomment = div('the_comment').value; AjaxPost(site_url+"/includes/view_game/ajax/add_comment.php", "comment="+thecomment+"&id="+id, function () { if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") { if (xmlHttp.responseText == '') { alert("An error occured in sending your message"); } else { var container = document.getElementById('comment_list'); var new_element = document.createElement('li'); new_element.innerHTML = xmlHttp.responseText; container.insertBefore(new_element, container.firstChild); window.location.hash="1"; div('comment_submit').value="Comment added!"; setTimeout("EnableButton()",30000); } } } ) } // Re-enable add-comment button function EnableButton () { div('comment_submit').value="Add comment"; div('comment_submit').disabled=false; } function clickclear(thisfield, defaulttext) { if (thisfield.value == defaulttext) { thisfield.value = ""; } } function clickrecall(thisfield, defaulttext) { if (thisfield.value == "") { thisfield.value = defaulttext; } } // Ajax delete comment function DeleteComment(id, site_url) { AjaxPost(site_url+"/admin/includes/delete_comment.php", "id=" + id, function () { div('comment-' + id).style.display = 'none'; } ) }