﻿/* Eitido (c) 2009 - Norman Geiersbach - 10/08/2009 */
function $chk(obj) { return !!(obj || obj === 0); };
function $defined(obj) { return (obj != undefined); };
function $empty(obj) { return !$defined(obj) || (obj == null) || ((typeof obj == 'string') && (obj == '')) || ((obj.constructor) && (obj.constructor.toString().indexOf("Array") != -1) && (obj.length == 0)); }
function $isArray(obj) { return (obj != null) && ($defined(obj)) && (obj.constructor.toString().indexOf("Array") != -1); }
function $lambda(value) { return (typeof value == 'function') ? value : function(){ return value; }; };
function $extend(original, extended) { for(var key in (extended || {})) original[key] = extended[key]; return original; };
function $random(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); };
function $exec(text) { if (!text) return text; if (window.execScript) { window.execScript(text); } else { var script = document.createElement('script'); script.setAttribute('type', 'text/javascript');	script.text = text; document.head.appendChild(script); document.head.removeChild(script); } return text; };
function $(el) { if( typeof el == 'string' ) return document.getElementById(el); return el; }
var $time = Date.now || function() { return new Date().getTime(); };

function $blend(el, duration, url) { el = $(el); if( !$empty(el) ) { if( el.filters && window.createPopup ) { el.style.filter = 'blendTrans(Duration=' + (!$empty(duration) ? duration : '0.25' ) + ')'; if( (el.filters.blendTrans != null) || (el.filters.blendTrans.status != 2) ) { el.filters.blendTrans.apply(); el.filters.blendTrans.play(); } } if( !$empty(url) ) el.src = url; } }
function $display(el, mode) { el = $(el); if( !$empty(el) ) { if( mode == null ) { if( el.style.display == "none" ) el.style.display = "block"; else el.style.display = "none"; } else el.style.display = mode; } return false; }
function $hide(el) { $display(el, 'none'); }
function $show(el) { $display(el, 'block'); }

function $getHtml(el) { el = $(el); return !$empty(el) ? el.innerHTML : null; }
function $setHtml(el, html) { el = $(el); if( !$empty(el) ) { el.innerHTML = html; } }

function $inputHint(el, text) { if( !$empty(text) ) { el = $(el); if( !$empty(el) ) { el.value = text; el.hint = text; el.onfocus = function() { if( (this.hint != null) && (this.hint == this.value) ) this.value = ''; }; el.onblur = function() { if( (this.hint != null) && $empty(this.value) ) this.value = this.hint; }; } } }
