/**
 * Electrocon Jquery Object
 *
 * @author  Ryan Sexton (ryan@floatingbytes.com)
 *
 * @date    December 6, 2007
 * @version	1.0
 *		Working order
 * @version 1.1
 *		Removed the config variable config.childindicator.
 *		Changed the way children are located, they're now located
 *			through the use of class checking (config.childclass).
 *	
 *
 	<script src="scripts/jquery.js" type="text/javascript" language="javascript"></script>
	<script src="scripts/jquery.electrocon.js" type="text/javascript" language="javascript"></script>
	
	OR
	
	rollover.js
	function _import(src){
	  var scriptElem = document.createElement('script');
	  scriptElem.setAttribute('src',src);
	  scriptElem.setAttribute('type','text/javascript');
	  document.getElementsByTagName('head')[0].appendChild(scriptElem);
	  
	}
	
	_import('scripts/jquery.js');
	_import('scripts/jquery.electrocon.js');
 */

$(document).ready(function(){

	config = {
		parentclass:'sub1',
		childclass:'sub2'
	};
	
	var _foundParent = false;
	var _lookingForSub = false;
	var _mypage = 'index.html';
    var _tmp = String(window.location).split('/');
	if (_tmp[_tmp.length-1].length != 0) {
		_mypage = _tmp[_tmp.length-1];
	}
	
	$('#local p').each(function (i) {
		$(this).removeClass(config.parentclass);
		var atag = $(this).children('a').get(0);
		if ($(atag).length) {
			if ($(atag).attr('href') != undefined) {
				if ($(this).hasClass(config.childclass)) {
					$(this).css('display', 'none');
				}
				var _tmp = $(atag).attr('href').split('/');
				var _url = _tmp[_tmp.length-1];
				if (_foundParent && _lookingForSub) {
					if ($(this).hasClass(config.childclass)) {
						$(this).css('display', 'block');
						$(this).addClass(config.childclass);
					} else {
						_lookingForSub = false;
					}
				}
				if (_url == _mypage) {
					_foundParent = true;
					_lookingForSub = true;
					$(this).css('display', 'block');
					$(this).addClass(config.parentclass);
				}
			}
		}
	});
});