function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func;} else { window.onload = function() { oldonload(); func();}
}
}
function hideAll() { if (!document.getElementById) return false; if (!document.getElementsByTagName) return false; var work = (document.getElementById ("home")) ? document.getElementById ("home") : document.getElementById ("ch"); work.className = 'js';}
function showWorks() { if (!document.getElementById) return false; move_wrap = (screen.width / 2) - 293; new Effect.MoveBy('wrapper', 0, -move_wrap, {duration: 0.6}); new Effect.MoveBy('footer', 0, -move_wrap, {duration: 0.6}); works = document.getElementById ("work"); works.style.left = screen.width * 56.5 / 100; works_height = Element.getHeight('work'); new Effect.MoveBy('work', 5000, 0, {duration: 2.6, queue: 'end'});}
function assignShowWorks() { if (!document.getElementById) return false; worklink = document.getElementById ("work-link"); worklink.onclick = function () { showWorks(); this.onclick = function() {return false;}
return false;}
}
function removeForm() { var top = document.getElementById("top"); var contact_form = document.getElementById("home-contact-form"); top.parentNode.removeChild(contact_form); return;}
function sendMail() { if (!document.forms[0]) return; var fo = document.forms[0]; var pname = fo.pname.value; var email = fo.email.value; var message = fo.message.value; var myConn = new XHConn(); if (!myConn) alert("XMLHTTP not available. Try a newer/better browser."); var fnWhenDone = function (oXML) { var ddiv = document.getElementById("home-contact-form"); ddiv.innerHTML = oXML.responseText + "<p><a href='#' id='form-close-link'>Close this window</a></p>"; var close = document.getElementById("form-close-link"); close.onclick = function() { new Effect.Fade(ddiv, { duration: 0.3, afterFinish: function() {removeForm();} });}
return;}; myConn.connect("sendmail.php", "GET", "pname="+ pname +"&email="+ email +"&message=" + message, fnWhenDone); return false;}
function openContactWindow() { if (!document.getElementById) return; var contact_form = document.createElement("div"); contact_form.setAttribute("id", "home-contact-form"); contact_form.style.display = 'none'; contact_form.innerHTML = "<form name='hcf' id='hcf' method='POST' action='sendmail.php'><fieldset><legend>Send me an email</legend><p><label for='pname'>Name: </label><br><input type='text' name='pname' id='pname'></p><p><label for='email'>Email: </label><br><input type='text' name='email' id='email'></p><p><label for='message'>Message: </label><br><textarea name='message' id='message' rows='6' cols='30'></textarea></p><p><input type='submit' id='s-btn' value='Send Message'></p><p><a href='#' id='form-close-link'>Close this window</a></p></fieldset></form>"; var top = document.getElementById("top"); top.parentNode.insertBefore(contact_form, top); new Effect.Appear(contact_form, { duration: 0.3 }); var fo = document.forms[0]; fo.onsubmit = sendMail; var close = document.getElementById("form-close-link"); close.onclick = function() { new Effect.Fade(contact_form, { duration: 0.3, afterFinish: function() {removeForm();} });}
return false;}
function addContactHandler() { if (!document.getElementById || !document.getElementById("contact-link")) return; var contact = document.getElementById("contact-link"); contact.onclick = openContactWindow; return;}
function enablePopups() { if (!document.getElementById) return; var work = document.getElementById("work"); var links = getElementsByClass("popup"); if (!links) return; for (var i=0; i<links.length; i++ ) { links[i].onclick = function() { window.open(this.href, "new_window"); return false;}
}
}
addLoadEvent(hideAll); addLoadEvent(assignShowWorks); addLoadEvent(addContactHandler); addLoadEvent(enablePopups); 
