//style Sheet Functions========================================================= //============================================================================== function setActiveStyleSheet(title) { var i, a, main; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { a.disabled = true; if(a.getAttribute("title") == title) a.disabled = false; } } } function getActiveStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title"); } return null; } function getPreferredStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title") ) return a.getAttribute("title"); } return null; } 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 expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } //General Functions============================================================= //============================================================================== var backgrounds = new Array(); backgrounds[0] = "http://www.vabio.org/wp-content/themes/VaBio/images/masthead01.jpg"; backgrounds[1] = "http://www.vabio.org/wp-content/themes/VaBio/images/masthead02.jpg"; var delay = 7 var times = 5 function crossFade(c) { var divs = c.getElementsByTagName('div'); bottom = divs[0]; topp = divs[1]; for(var i = 0; i < times; i ++) { fadeOut(topp, bottom); fadeIn(topp, bottom); } } function fadeOut(t, b) { new Effect.Opacity(t.id, { duration: 2.0, transition: Effect.Transitions.linear, from: 1.0, to: 0, delay: delay, queue: 'end', afterFinish: function () {getNewClass(t);} }); } function fadeIn(t, b) { new Effect.Opacity(t.id, { duration: 2.0, transition: Effect.Transitions.linear, from: 0, to: 1.0, delay: delay, queue: 'end', afterFinish: function () {getNewClass(b);} }); } function getNewClass(e) { var rand = Math.round(10*Math.random()) % 2; e.style.backgroundImage = "url(" + backgrounds[rand] + ")"; } function checkform ( form ) { if (form.fEmail.value == "") { alert( "Please enter your email address." ); form.fEmail.focus(); return false ; } return true ; } //Behaviour rules=============================================================== //============================================================================== /* var myrules = { 'a' : function(element){ element.onclick = function(){ console.log('dude'); return false; } }, '.styleDefault' : function(element){ element.onclick = function(){ setActiveStyleSheet('default'); return false; } }, '.styleLarge' : function(element){ element.onclick = function(){ setActiveStyleSheet('Large Type'); return false; } }, '.styleHC' : function(element){ element.onclick = function(){ setActiveStyleSheet('High Contrast'); return false; } } }; Behaviour.register(myrules); Behaviour.addLoadEvent(function() { var cookie = readCookie("style"); var title = cookie ? cookie : getPreferredStyleSheet(); setActiveStyleSheet(title); //crossFade($('mastheadContainer')); }); */ Event.addBehavior({ '.styleDefault:click' : function(e) { setActiveStyleSheet('default'); return false; }, '.styleLarge:click' : function(e) { setActiveStyleSheet('Large Type'); return false; }, '.styleHC:click' : function(e) { setActiveStyleSheet('High Contrast'); return false; } }); //General ====================================================================== //============================================================================== window.onunload = function(e) { var title = getActiveStyleSheet(); createCookie("style", title, 365); } var cookie = readCookie("style"); var title = cookie ? cookie : getPreferredStyleSheet(); setActiveStyleSheet(title);