// JavaScript Document

var Browser = {
	isIE     : window.attachEvent && !window.opera,
	isOpera  : !!window.opera,
	isWebKit : navigator.userAgent.indexOf('AppleWebKit/') > -1,
	isGecko  : navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
}

function findParentByTagName (object, tag_name, limit){
	var limit = parseInt(limit);
	limit = limit ? limit : 0 ;

	if ( object && object.nodeType && object.nodeType == 1 ) {
		var count = 0;

		while ( ++count ) {
			var object = object.parentNode;

			if ( object == null || count >= limit ) {
				break;
			} else if ( object.tagName.toLowerCase() == tag_name ) {
				return object;
			}
		}
	}

	return null;
}

function addFavorite (object, name, site) {
	var name = name ? name : document.title;
	var site = site ? site : location.protocol + '//' + location.host + '/' ;

	if ( object.is_action_set ) return;

	if ( Browser.isIE ) {
		object.onclick = function () {
			window.external.AddFavorite(site, name);
		}
		object.is_action_set = true;
	} else if ( window.sidebar ) {
		object.onclick = function () {
			window.sidebar.addPanel(name, site, true)
		}
		object.is_action_set = true;
	} else if ( Browser.isOpera ) {
		object.title = name;
		object.rel   = "sidebar";
		object.href  = site
		object.is_action_set = true;
	}

	return false;
}