// ADDING JAVASCRIPT CSS

function FindPath(filename) {
	var path = false; 
	var scripts = document.getElementsByTagName('script');
	for (var i=0; i<scripts .length; i++) {
		if (scripts[i].getAttribute('src') && scripts[i].getAttribute('src').indexOf(filename) != -1) {
			path = scripts[i].getAttribute('src').replace(new RegExp(filename), '');
			break;
		}
	}
	return path;
}

var jsCSS = { 
	_jsFile: 'core.js',
	_cssFile: 'js_core.css',
	_basePath: false, 
	initialize: function() { 
		// determine the path 
		this._basePath = FindPath( this._jsFile ); 
		// add the CSS file 
		var css = document.createElement( 'link' );
		css.setAttribute( 'rel', 'stylesheet' );
		css.setAttribute( 'type', 'text/css' );
		css.setAttribute( 'media', 'screen' );
		css.setAttribute( 'href', this._basePath + this._cssFile );
		document.getElementsByTagName( 'head' )[0].appendChild( css );
	}
};

jsCSS.initialize();

// POPUPS

/*
isUndefined(v)
    returns true if [v] is not defined, false otherwise

    IE 5.0 does not support the undefined keyword, so we cannot do a direct
    comparison such as v===undefined.
*/

function isUndefined(v) {
    var undef;
    return v===undef;
}

// These defaults should be changed the way it best fits your site
var _POPUP_FEATURES = 'width=600,height=400,toolbar=0,location=0,statusbar=0,menubar=0,scrollbars=1,resizable=1,directories=0,left=50px,top=50px';

function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

// SWITCHER - Simple Dislocated Tabbing

function switcher(groupID,itemID) {
	var hiddenItem;
	for(n=0; hiddenItem = document.getElementById(groupID + n); n++) {
		hiddenItem.className = 'nihilo';
	}
	var shownItem = document.getElementById(groupID + itemID);
	shownItem.className = 'exNihilo';
}


/* Year Generator */

function fetchYear()
	{
		 var now = new Date();
		 document.write(now.getUTCFullYear());
		 return;
	}