/* * Internal timer abstraction to avoid polluting global namespace */ var ContactusClock = { 'timers': [], 'clock': function (ident) { if (!ContactusClock.timers[ident].cancel) { if (!ContactusClock.timers[ident].func(ContactusClock.timers[ident].obj)) ContactusClock.timers[ident].cancel = true; } if (ContactusClock.timers[ident].cancel) { clearInterval(ContactusClock.timers[ident].id); ContactusClock.timers[ident].cancelled = true; } }, 'overwriteTimer': function (ident, ms, func, obj) { ContactusClock.timers[ident] = new Object(); ContactusClock.timers[ident].cancelled = false; ContactusClock.timers[ident].cancel = false; ContactusClock.timers[ident].func = func; ContactusClock.timers[ident].obj = obj; ContactusClock.timers[ident].id = setInterval('ContactusClock.clock('+ident+');', ms); }, 'addTimer': function (ms, func, obj) { for (var i = 0; i < ContactusClock.timers.length; i++) { if (ContactusClock.timers[i].cancelled) { ContactusClock.overwriteTimer(i, ms, func, obj); return; } } ContactusClock.overwriteTimer(ContactusClock.timers.length, ms, func, obj); } }; (function () { var moverHost = new Object(); moverHost.curMover = 0; moverHost.curHeight = 0; moverHost.startPos = 27; moverHost.targetHeight = 398; var hide = function () { } var show = function (moved, hiding, hidden) { var mover = new Object(); mover.thisMover = ++moverHost.curMover; mover.expanding = true; mover.moverHost = moverHost; mover.moved = moved; mover.hiding = hiding; mover.hidden = hidden; mover.speed = 0; mover.accelerations = 2; mover.acceleration = mover.accelerations; mover.retardation = mover.accelerations; mover.targetSpeed = 20; mover.startPos = moverHost.startPos; mover.curPos = mover.startPos; mover.targetPos = moverHost.targetHeight; mover.mover = function (mover) { mover.speed += mover.acceleration; if (mover.speed > mover.targetSpeed && mover.acceleration > 0) { mover.speed = mover.targetSpeed; mover.acceleration = 0; } if (mover.acceleration < 0 && mover.speed < mover.retardation) mover.speed = mover.retardation; if (mover.acceleration >= 0 && ((mover.speed / 2) * (mover.speed / mover.retardation)) >= (mover.targetPos - mover.curPos)) { mover.acceleration = -mover.retardation; } mover.curPos += mover.speed; if (mover.curPos > mover.targetPos) mover.curPos = mover.targetPos; } hide = function () { if (mover.thisMover == mover.moverHost.curMover && mover.expanding) { mover.hiding(); mover.expanding = false; mover.acceleration = mover.accelerations; mover.curPos = (mover.targetPos - mover.curPos); mover.targetPos -= mover.startPos; ContactusClock.addTimer(50, function (mover) { if (mover.thisMover == mover.moverHost.curMover && !mover.expanding) { mover.mover(mover); mover.moverHost.curHeight = Math.floor((mover.targetPos + mover.startPos) - mover.curPos); mover.moved(mover.moverHost.curHeight, mover.moverHost.targetHeight); var cont = (mover.moverHost.curHeight > mover.startPos); if (!cont) mover.hidden(); return cont; } else return false; }, mover); } else return false; } ContactusClock.addTimer(50, function (mover) { if (mover.thisMover == mover.moverHost.curMover && mover.expanding) { mover.mover(mover); mover.moverHost.curHeight = Math.floor(mover.curPos); mover.moved(mover.moverHost.curHeight, mover.moverHost.targetHeight); return (mover.moverHost.curHeight < mover.moverHost.targetHeight); } else return false; }, mover); } var jsBootstrap = function (host_obj) { var contactus_button = document.getElementById('contactus_button'); var contactus_frame = document.getElementById('contactus_frame'); var contactus_form = document.getElementById('contactus_form_element'); var contactus_abort = document.getElementById('contactus_abort'); contactus_button.onclick = function () { /* * Add a mouse-button capture div ontop of body */ var capture = document.createElement('div'); capture.style.width = '100%'; capture.style.height = '100%'; capture.style.position = 'fixed'; capture.style.top = '0px'; capture.style.left = '0px'; capture.onclick = function () { hide(); } var hideParent = document.body.appendChild(capture); contactus_frame.style.top = (-moverHost.targetHeight)+'px'; contactus_frame.style.height = moverHost.targetHeight+'px'; show( /* moving */ function (curHeight, targetHeight) { contactus_frame.style.top = (curHeight - targetHeight)+'px'; }, /* hiding animaition-start */ function () { document.body.removeChild(capture); }, /* hidden */ function () { contactus_frame.style.top = (-moverHost.targetHeight)+'px'; } ); } contactus_form.onsubmit = function () { var obj = new Object(); var val = new Object(); obj.name = document.getElementById('contactus_i_name'); obj.email = document.getElementById('contactus_i_email'); obj.msg = document.getElementById('contactus_i_message'); val.name = obj.name.value; val.email = obj.email.value; val.msg = obj.msg.value; /* * Clear previous validations */ obj.err_name = document.getElementById('contactus_err_name'); obj.err_email = document.getElementById('contactus_err_email'); obj.err_msg = document.getElementById('contactus_err_msg'); if (!obj.err_name) { obj.err_name = document.createElement('p'); obj.err_name.id = 'contactus_err_name'; obj.err_name.setAttribute('class', 'error'); obj.name.parentNode.parentNode.insertBefore(obj.err_name, obj.name.parentNode.nextSibling); } if (!obj.err_email) { obj.err_email = document.createElement('p'); obj.err_email.id = 'contactus_err_email'; obj.err_email.setAttribute('class', 'error'); obj.email.parentNode.parentNode.insertBefore(obj.err_email, obj.email.parentNode.nextSibling); } if (!obj.err_msg) { obj.err_msg = document.createElement('p'); obj.err_msg.id = 'contactus_err_msg'; obj.err_msg.setAttribute('class', 'error'); obj.msg.parentNode.parentNode.appendChild(obj.err_msg); } obj.err_name.style.display = 'none'; obj.err_email.style.display = 'none'; obj.err_msg.style.display = 'none'; /* * Javascript validation, server will only reply OK/Fail */ var error = false; if (!val.name) { obj.err_name.innerHTML = 'Påkrevd.'; obj.err_name.style.display = 'inline'; error = true; } if (!val.email) { obj.err_email.innerHTML = 'Påkrevd.'; obj.err_email.style.display = 'inline'; error = true; } if (!val.msg) { obj.err_msg.innerHTML = 'Påkrevd.'; obj.err_msg.style.display = 'inline'; error = true; } if (!error) { var ajaxServerName = "seria.no"; var siteServerName = location.host; var ajaxCall = { 'url': 'http://seria.no/sites/s/seria.no/designs/default/contactus/ajax.php', 'parameters': { 'name': val.name, 'email': val.email, 'msg': val.msg }, 'onSuccess': function (req) { if (req.responseText != 'OK') { alert('Submit failed (Guru meditation: '+req.responseText+')'); } hide(); obj.name.value = ''; obj.email.value = ''; obj.msg.value = ''; obj.msg.innerHTML = ''; return false; }, 'onError': function (req) { /* * Fallback to post. */ var redirectFlag = document.createElement('input'); redirectFlag.setAttribute('type', 'hidden'); redirectFlag.setAttribute('name', 'redirect'); redirectFlag.setAttribute('value', location.href); contactus_form.appendChild(redirectFlag); contactus_form.onsubmit = function () { return true; /* Disable AJAX posting */ } contactus_form.submit(); } }; if (siteServerName == ajaxServerName) AjaxRequest.post(ajaxCall); else ajaxCall.onError(false); } return false; } contactus_abort.onclick = function () { hide(); } } var adjustToIE6 = function(host_obj) { } var insertTemplate = function(host_obj, template) { host_obj.innerHTML = template; /* * Detect IE, and then IE6 */ if (!window.opera && navigator.userAgent.toLowerCase().indexOf('msie') != -1) { if (typeof(document.addEventListener) != 'function') /* IE6 */ { adjustToIE6(host_obj); } } } /* * Hook transparently onto the dom-ready event */ var domReady = function () { var obj = document.getElementById('contactus_host'); var template = "
Kontakt oss<\/a><\/div>\n
\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t

Kontakt Seria<\/h2>\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t