/******************************************************************************
 * EVENTX: CASCADING EVENT EXTENSIONS (ADD RULES TO ruleSets LIST)
 *****************************************************************************/
var ruleSets=[

//'A.supplimental { oninit: var foo=this.innerHTML; this.innerHTML=null; this.innerHTML=foo+"<img src=\'new_window_cue.gif\' class=\'new_win_cue\' />" }',
//'A.supplimental { oninit: if (this.title) this.title+=" - "; this.title+="Opens in New Window" }',
'A.supplimental { onclick: this.blur(); window.open(this.href); return false }',
'A.supplimental > IMG { oninit: removeClass(this.parentNode, "supplimental") }',
'A.supplimental { oninit: if(this.title)this.title+=" - "; this.title+="Opens New Window" }',
'A.supplimental { oninit: addImg(this, "cue_new_win.gif") !important }',

//'* { onclick: this.parentNode.removeChild(this); return false !important }',

//'A.supplimental > IMG + IMG.new_win_cue { onmouseover: this.parentNode.removeChild(this) }',


//'#menu A { onclick: top.location.href = this.href; return false }', // menu links bust out of frames
'DIV.menu A { onclick: top.location.href = this.href; return false }', // menu links bust out of frames
'A.frameset { onclick: top.location.href = this.href; return false }', // prevent frame nesting
'A.demo { onclick: this.blur(); window.open(this.href, "demo"); return false }',

//'A.external { onclick: return confirm("You are leaving this site. Do you want to continue?") }',
//'A.external { oninit: this.appendChild(document.createTextNode(" (external)")); }',
//'A.external { oninit: this.innerHTML += " (external)" }',
'A.external { oninit: if (this.title) this.title += " - "; this.title += "External Link" }',
'A.external { oninit: addImg(this, "cue_external.gif") }',
 
/* for eventx2_basic.html */
'#eg_this H4 { onclick: this.style.color = "blue" }',
'#eg_separate H4 { onclick: this.className = "selected" }',
'#eg_custom_function H4 { onclick: customFunction(this) }'
// note: last rule not followed by comma


];

/******************************************************************************
 * ADD CUSTOM FUNCTIONS BELOW (FOR USE IN ABOVE RULES)
 *****************************************************************************/
function customFunction(node) {
	if (node.className == "selected") {
		node.className = "";
	} else {
		node.className = "selected";
	}
}
function addClass(node, value) {
	node.className = node.className + ' ' + value;
}
function removeClass(node, value) {
	value = new RegExp('\\s*\\b' + value + '\\b', 'g');
	node.className = node.className.replace(value, '');
}
function offSite(node) {
	followLink = confirm('You are leaving this site. Do you want to continue?');
	if (followLink == true)
		window.location = node.href;
}

function addNewWinCue(node) {
	if (node.title) { node.title += ' - '; }
	node.title += 'Opens in New Window';

	var foo = node.innerHTML;
	node.innerHTML = null;
	node.innerHTML = foo + '<img src="new_win_cue.gif" />';
}
// function appendImg(src, optClass) {}
function addImg(node, filename) {
	var foo = node.innerHTML;
	foo += '<img src="' + filename + '" />';
	node.innerHTML = null;
	node.innerHTML = foo;
}

function insertMenu(node) {
	var markup = '<p>'
		+ 'EventX &#187; '
		+ '<a href="eventx1.html">Home</a> | '
		+ '<a href="eventx2.html">Principles</a> | '
		+ '<a href="eventx3.html">Examples</a> | '
		+ '<a href="eventx4.html">Reference</a>'
		+ '</p>';
	node.innerHTML = ''; // prevents IE for Mac from freaking
	node.innerHTML = markup;
	var anchors = node.getElementsByTagName('A');
	for (var i=0, iMax=anchors.length; i<iMax; i++) {
		
	}
	// anchors = node.getElementsByTagName('A');
	// mark current
}




/* function to load other scripts, usage: include('anotherScript.js'); */
function include(src) {
	document.write('<script type="text/javascript" src="' + src + '"></script>');
}
//include('myCustomScript.js');

function toggleClass(node, value1, value2) {
	var pattern = new RegExp('\\s*\\b' + value1 + '\\b', 'g');
	if (value1 && node.className.match(pattern)) {
		node.className = node.className.replace(pattern, ' ' + value2);
	} else {
		pattern = new RegExp('\\s*\\b' + value2 + '\\b', 'g');
		if (value2 && node.className.match(pattern)) {
			node.className = node.className.replace(pattern, ' ' + value1);
		}
	}
}
/* popup (height & width optional) - not used in demo */
function pop(link, height, width) {
	if (isNaN(height) || isNaN(width)) { width = false; height = false; }
	var optns = 'resizable=yes,'
	          + 'scrollbars=yes,'
	          + 'toolbar=no,'
	          + 'status=no';
	if (height && width) {
		optns = optns + ','
		        + 'top=' + ((screen.height - height)/2) + ','
		        + 'left=' + ((screen.width - width)/2) + ','
		        + 'height=' + height + ','
		        + 'width=' + width;
	}
	window.open(link, '', optns);
	return false;
}

/******************************************************************************
 * BEGIN EventX v0.9 (build 1) - TO EDIT, SEE EVENTX_FULL_COMMENT.TXT
 * Copyright 2005 Shawn Brown - http://shawnbrown.com/contact
 * License - http://creativecommons.org/licenses/by/2.5/
 * Manner of Attribution - don't remove the copyright notice or contact info
 *****************************************************************************/
var autoRun = true; // if true, eventxMain() runs at onload
var syntaxAlert = false; // if true, alert box displays rule with error

function eventxMain(){if(!document.getElementsByTagName)return null;for(
var i=0,aq=ruleSets.length;i<aq;i++){var al=ruleSets[i].match(av);if(al)af(
al[1],al[2],'function(){'+al[4]+'}',document);else if(syntaxAlert)alert(
'Syntax error in following EventX rule:\n\n'+ruleSets[i])}if(
navigator.userAgent.toLowerCase().indexOf('msie')>-1){if(typeof
window.onunload!='function'){window.onunload=ah}else{var as=window.onunload;
window.onunload=function(){as();ah()}}}}function ah(){for(var i=
ruleSets.length;i;i--){var al=ruleSets[i-1].match(av);if(al)af(al[1],al[2],
'null',document)}}try{var av=new RegExp().compile('^[ ]*([\\w\\d*#+>. ]+)[ ]'
+'*\\{[ ]*([\\w]+)[ ]*:[ ]*(["\']?)(.*)[ ]*\\3[ ]*\\}[ ]*$')}catch(e){var av
=/^[ ]*([\w\d*#+>. ]+)[ ]*\{[ ]*([\w]+)[ ]*:[ ]*(["\']?)(.*)[ ]*\3[ ]*\}[ ]*$/
}function af(an,ap,ab,ak){if(an.lastIndexOf('#')>-1){an=an.substring(
an.lastIndexOf('#'),an.length)}var ac,au;if(an.indexOf(' ')>-1){ac=
an.substring(0,an.indexOf(' '));au=an.substring(an.indexOf(' ')+1,an.length)}
else{ac=an;au=''}if(ac.indexOf('.')>-1){var ad=ac.substring(ac.indexOf('.')
+1,ac.length);ac=ac.substring(0,ac.indexOf('.'))}var aw=[];switch(
ac.substring(0,1)){case'#':ac=ac.substring(1,ac.length);aw[0]=
ak.getElementById(ac);if(!aw[0])return null;break;case'>':ac=ac.substring(
1,ac.length);aw=ak.childNodes;var ax=[];for(var i=0,aq=aw.length;i<aq;i++){
if(aw[i].tagName==ac||ac=='*'){ax[ax.length]=aw[i]}}aw=ax;break;case'+':ac=
ac.substring(1,ac.length);while(ak.nextSibling&&ak.nextSibling.nodeType!=1){
ak=ak.nextSibling}if(ak.nextSibling&&(ak.nextSibling.tagName==ac||ac=='*')){
aw[0]=ak.nextSibling}break;default:if(ac=='*'||(ad&&!ac)){aw=ak.all?ak.all:
ak.getElementsByTagName('*')}else{aw=ak.getElementsByTagName(ac)}}if(ad){var
ax=[];var at=new RegExp('\\b'+ad+'\\b');for(var i=0,aq=aw.length;i<aq;i++){
if(at.test(aw[i].className)){ax[ax.length]=aw[i]}}aw=ax}if(au){for(var i=0,
aq=aw.length;i<aq;i++){af(au,ap,ab,aw[i])}}else{if(ap!='oninit'){for(var i
=0,aq=aw.length;i<aq;i++){eval('aw[i].'+ap+'='+ab)}}
// IF ERROR ON THIS LINE, CHECK YOUR RULE BEHAVIOUR CODE (IN ruleSets[] ARRAY)
else{for(var i=0,aq=aw.length;i<aq;i++){eval('aw[i].aa='+ab);aw[i].aa()}}}}
ag:{try{var ao=new RegExp().compile('[ ][ ]+','g');var aj=new
RegExp().compile('[ ]?>[ ]?','g');var am=new RegExp().compile('[ ]?\\+[ ]?',
'g');var bc=new RegExp().compile('#','g');var az=new RegExp().compile('[.]',
'g');var ba=new RegExp().compile('(^|[ ])[\\w+>*]','g');var bb=new
RegExp().compile('[ ]*[!][ ]*(important|first)[ ]*}$')}catch(e){var ao
=/[ ][ ]+/g;var aj=/[ ]?>[ ]?/g;var am=/[ ]?\+[ ]?/g;var bc=/#/g;var az
=/[.]/g;var ba=/(^|[ ])[\w+>*]/g;var bb=/[ ]*[!][ ]*(important|first)[ ]*}$/
}for(var i=0,aq=ruleSets.length;i<aq;i++){var al=ruleSets[i];var an=
al.substring(0,al.indexOf('{'));var ae=al.substring(al.indexOf('{'),
al.length);an=an.replace(ao,' ');an=an.replace(aj,' >');an=an.replace(am,
' +');function ar(ay){return ay?(ay.length<9?ay.length.toString():'9'):'0'};
var ai=ar(an.match(bc));ai+=ar(an.match(az));ai+=ar(an.match(ba));ai+='-'+
'00000'.substring(0,5-i.toString().length)+i.toString()+'~';var at=ae.match(
bb);if(at){ai=((at[1]=='important')?'X':'%')+ai;ae=ae.substring(0,
ae.lastIndexOf('!'))+'}'}ruleSets[i]=ai+an+ae}ruleSets.sort();for(var i
=ruleSets.length;i;i--){var al=ruleSets[i-1];ruleSets[i-1]=al.substring(
al.indexOf('~')+1,al.length)}}
/******************************************************************************
 * If autorun is true, add eventxMain() to onload.
 * The following code adapted from Simon Willison's addLoadEvent() function -
 * http://simon.incutio.com/archive/2004/05/26/addLoadEvent
 *****************************************************************************/
if (autoRun === true) {
	if (typeof window.onload != 'function') {
		window.onload = eventxMain
	} else {
		var oldonload = window.onload;
		window.onload = function() { oldonload(); eventxMain() }
	}
}
