var d = window.document; function getE( v ) { e = false; if ( d.getElementById ) { e = d.getElementById( v ); } else if ( d.all ) { e = d.all[ v ]; } return e; } function countdown(instance,target) { var Today = new Date(); var Todays_Date = new Date(Today.toGMTString()); var Target_Date = new Date(target); //Find their difference, and convert that into seconds. var Time_Left = Math.round((Target_Date - Todays_Date) / 1000); if(Time_Left < 0) Time_Left = 0; var thisCountDown = getE('countdown' + instance); // alert(instance+' '+target+' '+thisCountDown); thisCountDown.innerHTML = Math.floor(Time_Left / 60) + ":" + (Time_Left % 60).toFixed().pad(2, "0"); //Recursive call, keeps the clock ticking. if(Time_Left > 0) setTimeout('countdown('+instance+',\''+target+'\');',1000); else checkOnProduct(instance); //call AJAX } function individualCountdown(target) { Today = new Date(); Todays_Date = new Date(Today.toGMTString()); Target_Date = target; //Find their difference, and convert that into seconds. var Time_Left = Math.round((Target_Date - Todays_Date) / 1000); if(Time_Left < 0) Time_Left = 0; var thisCountDown = getE('countdown'); thisCountDown.innerHTML = Math.floor(Time_Left / 60) + ":" + (Time_Left % 60).toFixed().pad(2, "0") ; //Recursive call, keeps the clock ticking. if(Time_Left > 0) setTimeout('individualCountdown(Target_Date);',1000); else window.location='/timeout.php'; } function nextProductCountdown(target) { DisplayDays = "%%D%%:"; DisplayHours = "%%H%%:"; DisplayMinutes = "%%M%%:"; DisplaySeconds = "%%S%%"; DisplayStr = ''; Today = new Date(); Todays_Date = new Date(Today.toGMTString()); Target_Date = target; //Find their difference, and convert that into seconds. var Time_Left = Math.round((Target_Date - Todays_Date) / 1000); if(Time_Left < 0) Time_Left = 0; var thisCountDown = getE('nextProductCountdown'); days = calcage(Time_Left,86400,100000); hours = calcage(Time_Left,3600,24); minutes = calcage(Time_Left,60,60) + ''; seconds = calcage(Time_Left,1,60) + ''; if(days.length == 1) days = '0'+days; if(hours.length == 1) hours = '0'+hours; if(minutes.length == 1) minutes = '0'+minutes; if(seconds.length == 1) seconds = '0'+seconds; if(days > 0) DisplayStr += DisplayDays.replace(/%%D%%/g, days); if(days > 0 || hours > 0) DisplayStr += DisplayHours.replace(/%%H%%/g, hours); if(days > 0 || hours > 0 || minutes > 0) DisplayStr += DisplayMinutes.replace(/%%M%%/g, minutes); DisplayStr += DisplaySeconds.replace(/%%S%%/g, seconds); getE('nextProductCountdown').innerHTML = DisplayStr; //Recursive call, keeps the clock ticking. if(Time_Left > 0) setTimeout('nextProductCountdown(Target_Date);',1000); } function calcage(secs, num1, num2) { s = ((Math.floor(secs/num1))%num2).toString(); return s; } function getHTTPObject() { //http://www.webpasties.com/xmlHttpRequest/xmlHttpRequest_tutorial_1.html var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } function handleHttpResponse() { if (http.readyState == 4) { var incoming_json = http.responseText; //http://www.json.org/js.html var productData = eval('('+incoming_json+')'); right_this_instant = new Date(); var money_time = getE('countdown'+productData.series_number); var a_link = getE('a'+productData.series_number); var li_class = getE('li_class'+productData.series_number); if(productData.hold_end > productData.now) { right_now = new Date(); counted_ahead = parseInt(right_now.getTime()) + parseInt(productData.hold_end) - parseInt(productData.now); soon = new Date(); soon.setTime(counted_ahead); countdown(productData.series_number,soon); } else if(productData.purchase_complete == "1") { money_time.innerHTML = 'SOLD!'; li_class.className = 'sold_button'; } else { money_time.innerHTML = '$' + productData.series_number; a_link.addEventListener("click",eval('enableProduct'+productData.series_number),true); li_class.className = 'purchase_button'; } isWorking = false; } } var http = getHTTPObject(); // We create the HTTP Object var isWorking = false; function checkOnProduct(instance) { if(!isWorking) { isWorking = true; var url="_svc/product_status.php?product_id=" + product_id + "&series_number=" + instance; http.open("GET", url , true); http.onreadystatechange = handleHttpResponse; http.send(null); var detailsDiv=document.getElementById('detailsDiv'); } else { setTimeout("checkOnProduct()",500); } } String.prototype.pad = function(l, s) { return (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length) : this; }; function swapTabs(tabStr) { if(tabStr == "1") { getE("tab1").style.display = "block"; getE("tab2").style.display = "none"; getE("tab3").style.display = "inline"; getE("tab4").style.display = "none"; } if(tabStr == "2") { getE("tab1").style.display = "none"; getE("tab2").style.display = "block"; getE("tab3").style.display = "none"; getE("tab4").style.display = "inline"; } } function girlNoXXX() { curSize = getCheckedValue(document.forms['optionsForm'].elements['size']); if(curSize == 'xxx') { setCheckedValue( document.forms['optionsForm'].elements['size'], 'xx'); } } function setCheckedValue(radioObj, newValue) { if(!radioObj) return; var radioLength = radioObj.length; if(radioLength == undefined) { radioObj.checked = (radioObj.value == newValue.toString()); return; } for(var i = 0; i < radioLength; i++) { radioObj[i].checked = false; if(radioObj[i].value == newValue.toString()) { radioObj[i].checked = true; } } } function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; }