/** 
 * @author Kenneth.priisholm
 * requires
 * YAHOO.util.Dom;
 * YAHOO.util.Event;
 * YAHOO.util.Anim;
 * YAHOO.util.Motion;
 * YAHOO.util.DD;
*/
//shortcutting YAHOO libs
var $D = $D || YAHOO.util.Dom;
var $E = $E || YAHOO.util.Event;
var $A = $A || YAHOO.util.Anim;
var $M = $M || YAHOO.util.Motion;
var $DD = $DD || YAHOO.util.DD;
var $ = $D.get;
var $$ = YAHOO.util.Selector ? YAHOO.util.Selector.query : null;

var Valtech = Valtech || {};
Valtech.util = Valtech.util || {};
var $VU = Valtech.util;

String.prototype.trim = function(){
    return this.replace(/^\s*(\S+(\s+\S+)*)\s*$/, "$1");
}

String.prototype.supplant = function(o){
	return this.replace(/{([^{}]*)}/g,
		function(a, b){
			var r = o[b];
			return typeof r === "string" ? r : a;
		}
	);
};

Function.prototype.curry = function() {
	if (!arguments.length) return this;
	var __method = this, args = Array.prototype.slice.apply(arguments);
	return function() {
		return __method.apply(this, args.concat(Array.prototype.slice.apply(arguments)));
	}
}

function object(o){
	function F(){};
	F.prototype = o; 
	return new F();
}
//credit: Dustin Diaz, http://www.dustindiaz.com/
YAHOO.util.Dom.getElementsByAttribute = function(atr, val, tag, root, callBack) {
	
	var method = function(el) { 
		var re = new RegExp('(?:^|\\s+)' + val + '(?:\\s+|$)');
		/* UGLY IE bug!*/
		if(atr == "for"){
			atr = el.getAttribute(atr)? atr : "htmlFor";
		}
		if ( el.getAttribute(atr) && re.test(el.getAttribute(atr)) ) {
		    if(callBack){
		        callBack(el);
		    }
			return true;
		}
		return false;
	};
	return this.getElementsBy(method, tag, root);
};

Valtech.util.clone = function(objIn) {
	if(objIn == null || typeof(objIn) != 'object') { 
	    return objIn;
	}	
	var objOut = {};
	for(var prop in objIn){
		objOut[prop] = Valtech.util.clone(objIn[prop]);
	}
	return objOut;
};


YAHOO.util.Dom.show = function(el) {
	$D.setStyle(el, "display", "");
};
YAHOO.util.Dom.hide = function(el) {
	$D.setStyle(el, "display", "none");
};