﻿var req = null;

function $get(e) {
    return document.getElementById(e);
}

function $create(e) {
    return document.createElement(e);
}

function $attrValue(node, key) {
    if (node != null)
        return (node.getAttributeNode(key) == null ? null : node.getAttributeNode(key).nodeValue);
    
    return null;
}

function $format() {

	if (arguments.length > 0) {
		var params = arguments;
		var target = params[0];
		
		for (var i=1; i < params.length; i++) {
			target = replaceAll(target, '{' + (i-1) + '}', params[i]);			
		}
		return target;
	}
	
	function replaceAll(str, from, to) {
		var index = str.indexOf(from);
		
		while (index > -1) {
			str = str.replace(from, to);
			index = str.indexOf(from);
		}
		
		return str;
	}
}