/* 
# Author: Lee Driscoll
# Function: secureEmail
# Desc: Inserts a functional email link with a 'title' for screen readers
# Args: 
#	a = username
#	b = hostname (default:keyonline.ie)
*/

function secureEmail(a,b){
	b = typeof(b) != 'undefined' ? b : 'keyonline.ie';

	var eAddress = a + '@' + b;
	document.write('<a href="mailto:' + eAddress + '" title="send email to ' + eAddress + '" />' + eAddress + '</a>');
}

dojo.addOnLoad(function(){
	if((dojo.byId("categoryOnlyResultsFilterDisplay_Grid_Top") != null)){ //run script only if this id is on the page
		MI.toggleView('List');//set view to list
	
		dojo.connect(dojo.byId('categoryOnlyResultsFilterDisplay_Grid_Top'), 'onclick', function(event) {
		dojo.cookie("key_default_list_view","grid");
		});//if the grid button is clicked then leave a cookie
		dojo.connect(dojo.byId('categoryOnlyResultsFilterDisplay_Grid_Bottom'), 'onclick', function(event) {
		dojo.cookie("key_default_list_view","grid");
		});//Same again for the bottom button
		
		if(dojo.cookie("key_default_list_view") && dojo.cookie("key_default_list_view") == "grid"){
		MI.toggleView('Grid');
		}//is grid cookie is found then set the view to grid
		
		
		dojo.connect(dojo.byId('categoryOnlyResultsFilterDisplay_List_Top'), 'onclick', function(event) {
		dojo.cookie("key_default_list_view","grid",{expires : -1});
		});//if list button is clicked then delete the the 'Grid' cookie 
		dojo.connect(dojo.byId('categoryOnlyResultsFilterDisplay_List_Bottom'), 'onclick', function(event) {
		dojo.cookie("key_default_list_view","grid",{expires : -1});
		});//same again for bottom button
	}
});






/* 
# Author: Previous Webmaster
# Function: validate name and email address before subscribing
*/


/*
function isEmail(emailAddress){
emailAddressValue=emailAddress.value.toLowerCase();
var countryTLDs=/^(ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$/;
var gTLDs=/^(aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org)$/;
var basicAddress=/^(.+)@(.+)$/;
var specialChars='\\(\\)&gt;&lt;@,;:\\\\\\\"\\.\\[\\]';
var validChars='\[^\\s'+specialChars+'\]';
var validCharset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\'-_.';
var quotedUser='(\"[^\"]*\")';
var atom=validChars+'+';
var word='('+atom+'|'+quotedUser+')';
var validUser=new RegExp('^'+word+'(\.'+word+')*$');
var symDomain=new RegExp('^'+atom+'(\.'+atom+')*$');
var matchArray=emailAddressValue.match(basicAddress);
if(emailAddress.value==''||emailAddress==null){
return true;
}
if(matchArray==null){
alert('The Email address doesn\'t seem to be correct,\nplease check syntax.');
emailAddress.focus();
return false;
}else{
var user=matchArray[1];
var domain=matchArray[2];
for(i=0;i&lt;user.length;i++){
if(validCharset.indexOf(user.charAt(i))==-1){
alert('The Email address contains invalid characters,\nplease check the username.');
emailAddress.focus();
return false;
}
}
for(i=0;i&lt;domain.length;i++){
if(validCharset.indexOf(domain.charAt(i))==-1){
alert('The Email address contains invalid characters,\nplease check the domain.');
emailAddress.focus();
return false;
}
}
if(user.match(validUser)==null){
alert('The Email address doesn\'t seem to be correct,\nplease check the username.');
emailAddress.focus();
return false;
}
var atomPat=new RegExp('^'+atom+'$');
var domArr=domain.split('.');
var len=domArr.length;
for(i=0;i&lt;len;i++){
if(domArr[i].search(atomPat)==-1){
alert('The Email address doesn\'t seem to be correct,\nplease check the domain name.');
emailAddress.focus();
return false;
}
}
if((domArr[domArr.length-1].length==2)&amp;&amp;(domArr[domArr.length-1].search(countryTLDs)==-1)){
alert('The Email address doesn\'t seem to be correct,\nplease check domain suffix.');
emailAddress.focus();
return false;
}
if((domArr[domArr.length-1].length&gt;2)&amp;&amp;(domArr[domArr.length-1].search(gTLDs)==-1)){
alert('The Email address doesn\'t seem to be correct,\nplease check domain suffix.');
emailAddress.focus();
return false;
}
if((domArr[domArr.length-1].length&lt;2)||(domArr[domArr.length-1].length&gt;6)){
alert('The Email address doesn\'t seem to be correct,\nplease check domain suffix.');
emailAddress.focus();
return false;
}
if(len&lt;2){
alert('The Email address doesn\'t seem to be correct,\nplease check missing hostname.');
emailAddress.focus();
return false;
}
}
return true;
}
String.prototype.trim = function() { return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");	}
function mandatoryText(input,fieldName){
if(input.value.trim()==''||input==null){
alert('Please enter your '+fieldName+'.');
input.focus();
return false;
} else {
return true;
}
}
function validForm(){
if(!mandatoryText(document.getElementById('EMAIL_FIELD'), 'Email address')) return;
if(!isEmail(document.getElementById('EMAIL_FIELD'))) return;
if(!mandatoryText(document.getElementById('FULLNAME_FIELD'), 'Name')) return;
document.getElementById('subForm').submit();
}*/

/*
# Author: David Walsh
# Function: add scrolling effect to 'back to top' link


(function(d,$) {
	d.addOnLoad(function() {
		var topLink = $('gototop');
		d.style(topLink,{
			opacity: 0,
			visibility: 'visible'
		});
		d.connect(window,'onscroll',function(e) {
			var scrollY = -dojo.position(dojo.body()).y, thresh = 100;
			  d['fade' + (scrollY > thresh ? 'In' : 'Out')]({ node: topLink }).play(); 
			dojo.anim(topLink, { opacity: (scrollY > thresh ? 1 : 0 ) }); /* more concise, @phiggins 
		});
	});
})(dojo,dojo.byId);
*/
