function starsChange(myVal, startString) { if (startString) { var myStars = new Array(document.getElementById(startString + '1'), document.getElementById(startString + '2'), document.getElementById(startString + '3'), document.getElementById(startString + '4'), document.getElementById(startString + '5')); for (i=0; i < myVal; i++) { if (myVal - i == 0.5) { if (myStars[i] != null) myStars[i].src = 'http://www.sextoys.com/images/star_rate_orange_half.png'; } else { if (myStars[i] != null) myStars[i].src = 'http://www.sextoys.com/images/star_rate_orange.png'; } } var myLeftOvers = 5 - myVal; if (myLeftOvers > 0) { for (i=0; i < myLeftOvers; i++) { if (myStars[eval(myVal + i)]) myStars[eval(myVal + i)].src = 'http://www.sextoys.com/images/star_rate_grey.png'; } } if (window.StarsTimeoutObj) clearTimeout(window.StarsTimeoutObj); if (!window.StarsTimeout && !window.StarsMouseOver) { window.StarsTimeout = 1; window.StarsTimeoutObj = setTimeout("starsChange(" + myVal + ")", 100); } } } function starsRestore(theOriginalValue, startString) { window.StarsTimeout = 0; starsChange(theOriginalValue, startString); } function starsSet(myVal, startString) { document.getElementById('ratingValue').value = myVal; starsChange(myVal, startString); } function showCommentTools(idValue,locationValue,returnType, theStars) { if (!theStars) theStars = 0; myInnerString = '
'; var myCommentTools = document.getElementById('commentTools'); if (myCommentTools.innerHTML != "") { myCommentTools.style.display = "block"; document.getElementById("ratingValue").value = theStars; starsRestore(theStars, "myStars"); } else { RequestThreadedDynamicDataFromMySQL("http://www.sextoys.com/review_write.php?id=" + idValue + "&loc=" + locationValue + "&ret=" + returnType + "&stars=" + theStars, ProcessPageUpdateJustTheElement, 'commentTools'); setTimeout("starsRestore(document.getElementById('ratingValue').value, 'myStars')", 500); } } function reviewsSubmit(theId, theLoc, theRet) { if (document.getElementById("commentArea").value != "") { if (escape(document.getElementById("ratingValue").value) < 1) { alert("You must enter a rating to leave a review."); } else { document.getElementById('saveButton').disabled = true; document.getElementById('saveButton').innerHTML = 'Please Wait...'; newComment(theId, theLoc, theRet); } } else { alert("You must enter a comment in order to leave a review."); } } function newComment(idValue,locationValue,returnType) { var myDate = new Date(); var mill = myDate.getTime(); myReviewTitle=escape(document.getElementById("reviewTitle").value); myName=escape(document.getElementById("reviewerName").value); myLocation=escape(document.getElementById("reviewerLocation").value); myEditTextValue=escape(document.getElementById("commentArea").value); myRatingValue=escape(document.getElementById("ratingValue").value); myURL="http://www.sextoys.com/new_review.php?noCache=" + mill + "&action=saveComment&id=" + idValue + "&location=" + locationValue + "&returnType=" + returnType + "&rating=" + myRatingValue + "&review=" + myEditTextValue + "&myLocation=" + myLocation + "&myName=" + myName + "&reviewTitle=" + myReviewTitle; $.post(myURL, function(data){ document.getElementById('reviewsDiv').innerHTML = data; }); //RequestThreadedDynamicDataFromMySQL(myURL, ProcessPageUpdateJustTheElement, 'reviewsDiv'); document.getElementById('reviewerName').value = myName; document.getElementById('reviewerLocation').value = myLocation; setTimeout('document.getElementById("reviewStatus").style.display = "block"; document.getElementById("reviewStatus").innerHTML = "Thank you for submitting your review!
Reviews typically appear live within 24 hours.
";', 1000); } function compareProducts(productNumber) { var myDate = new Date(); var mill = myDate.getTime(); var action = ""; productNumber=escape(productNumber); if(document.getElementById("check_"+productNumber).checked) { action = "add"; } else { action = "sub"; } myURL="http://www.sextoys.com/compare_session_manager.php?noCache=" + mill + "&action=" + action + "&productNumber=" + productNumber; RequestThreadedDynamicDataFromMySQL(myURL,'doNothing',''); } function ProcessPageUpdateJustTheElement(myHTMLString,myElementToUpdate) { document.getElementById(myElementToUpdate).innerHTML=myHTMLString; } function doNothing() {} function RequestThreadedDynamicDataFromMySQL(url, myBlank, target) { if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = function() { if (req.readyState == 4) { if (document.getElementById(target)) { if (req.status == 200) { document.getElementById(target).innerHTML = req.responseText; } else { document.getElementById(target).innerHTML = "Error: " + req.statusText; } } } }; req.open("GET", url, true); req.send(null); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { if (document.getElementById(target)) { if (req.status == 200) { document.getElementById(target).innerHTML = req.responseText; } else { document.getElementById(target).innerHTML = "Error: " + req.statusText; } } } }; req.open("GET", url, true); req.send(); } } } // these are the functions for highlighting products that are going to be compaired function highlight(id){ var check_box = 'check_'+id; var current_state = document.getElementById(check_box).checked; var rand = Math.random(); if(current_state == true){ document.getElementById(id).style.background='#fff url(/images/check_highlight_ani.gif?id='+rand+') top right no-repeat'; }else{ document.getElementById(id).style.backgroundImage=''; } } function highlight_session(){ } function image_change(imageElement, newImageUrl) { if (document.getElementById(imageElement)) { document.getElementById(imageElement).src = newImageUrl; } }