function addToCart(sunid, pid) { if(getACookie('crystalcart') == 'blank') { var timestring = new Date().getTime().toString(); var random = (Math.random()*100001).toString(); //alert(timestring + ', ' + random); var cookieVal = timestring + random; //alert(cookieVal); document.cookie = 'crystalcart=' + cookieVal+ ';path=/'; } //alert(sunid); //alert(document.getElementById('qfield' + pid).value); document.forms[1].quantity.value = document.getElementById('qfield' + pid).value; document.forms[1].item.value = sunid; document.forms[1].submit(); } function changeFormTag() { document.cartform.action = '../CartAdd?OpenForm&Seq=1'; } function getACookie(cookieName) { if (document.cookie.length > 0) { if (document.cookie.indexOf(cookieName) != -1) { var sStartCookie = document.cookie.indexOf('=', document.cookie.indexOf(cookieName)); var sEndCookie = document.cookie.indexOf(';', sStartCookie); if (sEndCookie == -1) { sEndCookie = document.cookie.length } var PlaceToGo = document.cookie.substring(sStartCookie + 1, sEndCookie); return unescape(PlaceToGo); } else { return 'blank'; } } else { return 'blank'; } }