document.getElementBySector = function(sector)
{
	return document.getElementsBySelector(sector)[0];
}

function getElementByTagName(parent, tagname)
{
	return parent.getElementsByTagName(tagname)[0];
}
// get Elements By given attribute value
function getElementsByAttributeValue(node, tag, att, val) 
{
	node = node || document;
	
	var indexes  = node.getElementsByTagName(tag);
	var elements =[];
	
	for (i=0; i<indexes.length; i++) 
	{
		if ((!val && indexes[i][att]) || (val && indexes[i][att] == val))
		{
			elements.push(indexes[i]);
		}
	}
	
	return elements;
}

// jump to url
function jump(href, sel)
{
	if (sel)
	{
		sel   = $(sel);
		href += sel.options[sel.selectedIndex].value;
	}
	
	window.location.href = href;
	
	return true;
}

Object.extend(String.prototype,
{
	// htmlspecialchars
	htmlChars: function()
	{
		text = arguments[0] || this;
		text = text.replace(/(<)/gi, '&lt;');
		text = text.replace(/(>)/gi, '&gt;');
		text = text.replace(/([\n])/gi, "\n <br />");
		
		return text;
	}
});

Object.extend(Class, 
{
	E: function () {}
});

// include file (can be js and css)
function include(src)
{
	if (src.match(/\.(js)$/i))
	{
		var elem = document.createElement('script');
		elem.setAttribute('type', 'text/javascript');
		elem.setAttribute('src', src);
	}
	else if (src.match(/\.(css)$/i))
	{
		var elem = document.createElement('link');
		elem.setAttribute('href', src);
		elem.setAttribute('rel', 'stylesheet');
		elem.setAttribute('type', 'text/css');
	}
	else
	{
		return;
	}
	
	document.getElementsByTagName('head')[0].appendChild(elem);
}

//////////////////////////////////////////////////////////////////////////////////////
// check if one element is parent of other element
// @credits: digg.com
function containsDOM (container, containee)
{
	if (document.all)
	{
		return container.contains(containee);
	}
	
	var isParent = false;
	do
	{
		if ((isParent = container == containee)) break;

		containee = containee.parentNode;
	} 
	while (containee != null);
	
	return isParent;
}

// check mouse have left some element
// @credits: digg.com
function checkMouseLeave (element, evt)
{
	evt = (evt) ? evt : ((window.event) ? window.event : "");
  
	if (evt.relatedTarget)
	{
    	return !containsDOM(element, evt.relatedTarget);
  	}
  	else
  	{
  		return !containsDOM(element, evt.toElement);
  	}
}

function editorInit()
{
}

// empty function

/// !!!!!!!!!!!!!!!!!!!!!!!
function addLoadEvent(func)
{
	if (typeof window.onload == 'function')
	{
		var oldonload = window.onload;
		
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
	else
	{
		window.onload = func;
	}
}


function d(msg)
{
	if (typeof(window) != "undefined" && window.console&& window.console.log)
	{
		// Safari
		window.console.log(msg);
	}
	else if (typeof(opera) != "undefined" && opera.postError)
	{
		// Opera
		opera.postError(msg);
	}
	else if (typeof(printfire) == "function")
	{
		// FireBug
		printfire(msg);
	}
	else
	{
		alert(msg);
	}
}
