//COOKIE FUNCTIONS function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else { var expires = ""; } document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var ca = document.cookie.split(';'); var nameEQ = name + "="; for(var i=0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } function eraseCookie(name) { createCookie(name, "", -1); } //SHOW HIDE ELEMENTS function showhide_elm(id) { var element = document.getElementById(id); if (element) { if(element.style.display == "none") { element.style.display = "block"; } else { element.style.display = "none"; } } } function show_elm(id) { var element = document.getElementById(id); if (element) { element.style.display = "block"; } } function hide_elm(id) { var element = document.getElementById(id); if (element) { element.style.display = "none"; } } //MISCELLANEOUS window.onscroll = function scrollfunc() { var js_alert = document.getElementById('js_alert'); if (js_alert) js_alert.style.top = document.documentElement.scrollTop+document.documentElement.offsetHeight/2-js_alert.offsetHeight/2; var js_prompt = document.getElementById('js_prompt'); if (js_prompt) js_prompt.style.top = document.documentElement.scrollTop+document.documentElement.offsetHeight/2-js_prompt.offsetHeight/2; } function js_instant_alert(text) { document.getElementById('js_alert').style.display = 'block'; document.getElementById('js_alert_text').innerHTML = text; } function print_elm(elm,width,height) { printWin = window.open("","printWin","width="+width+",height="+height+",scrollbars=yes,resizeable=no,status=yes"); printWin.document.clear(); printWin.document.open(); printWin.document.write("Kiwi Vending - Vis udskrift"+document.getElementById(elm).innerHTML+""); printWin.focus(); printWin.document.close(); printWin.window.print(); } function confirm_jump(str, url) { js_prompt(str,'Ja',url,'Nej',''); } function js_prompt(question,value1,href1,value2,href2,value3,href3,extra) { document.getElementById('js_prompt').style.display = 'block'; document.getElementById('js_prompt_question').innerHTML = question; anwers = document.getElementById('js_prompt_answers'); anwers.innerHTML = ""; if (value1) { if (href1) anwers.innerHTML = anwers.innerHTML+' '; else if (extra == "form_submit") anwers.innerHTML = anwers.innerHTML+' '; else anwers.innerHTML = anwers.innerHTML+' '; } if (value2) { if (href2) anwers.innerHTML = anwers.innerHTML+' '; else anwers.innerHTML = anwers.innerHTML+' '; } if (value3) { if (href3) anwers.innerHTML = anwers.innerHTML+' '; else anwers.innerHTML = anwers.innerHTML+' '; } }