function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

// add to window.onload
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function insertAfter(node, referenceNode) {
	referenceNode.parentNode.insertBefore(node, referenceNode.nextSibling);
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if (node == null)	node = document;
	if (tag == null)	tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^| )"+searchClass+"( |$)");
	//var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	// mirko
	if (classElements.length == 1) classElements = classElements[0];
	if (classElements.length == 0) classElements = false;
	return classElements;
}

// sifr inicijalizacija
addLoadEvent(function() { if (typeof sIFR == "function") {
		var template = named({sFlashSrc:"inc/js/sifr/trebuchetMS.swf", sColor:"#000", sBgColor:"#ffffff", sWmode:"transparent"});
		sIFR.replaceElement("h1", template);
		sIFR.replaceElement("h2", template);
		sIFR();
	}
});


// getHttpObject
function getHttpObject() {
	var xhr = false;
	if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
	else if (window.ActiveXObject) {
		try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(e) {
			try { xhr = new ActiveXObject("Microsoft.XMLHTTP");	}
			catch(e) { xhr = false;	}
		}
	}
	return xhr;
}
