	/**
	 * @author: Icarus
	 * @description: Main Functions
	 * @version: 0.2
	**/

	function getEl(element){
		return eval("document.getElementById(element)");
	}

	/**
	 * @access public
	 * @description: submits the form when enter has been pressed.
	 * @params: field : in which field the event has happened in, e : event object
	 * @usage: onKeyPress="return submitEnter(this,event);"
  **/

	function submitEnter(field,e)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		if (keycode == 13)
		   {
			   field.form.submit();
			   return false;
		   }
		else
		   return true;
	}

	/**
	 * @access public
	 * @description: Opens a popup window with given parameters
	 * @params: name,file,width,height
	 *					scrollbar,resizable,modal (true/false)
  **/

	function popup(name,file,width,height,scrollbar,resizable,modal) {
		wLeft=(screen.width)?(screen.width-width)/2:100;
		wTop=(screen.height)?(screen.height-height)/2:100;
		childWindow=window.open(file,name,"modal=yes,width="+width+"px,height="+height+"px,scrollbars="+scrollbar+",resizable="+resizable+",top="+wTop+",left="+wLeft);
		if (childWindow.opener == null) childWindow.opener = self;
			childWindow.focus();
	}

	function submitForm(formId){
		getEl(formId).submit();
	}

	function trim12 (str) {
		var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
		while (ws.test(str.charAt(--i)));
		return str.slice(0, i + 1);
	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function toggleChecked(id){
		element = document.getElementById(id);

		if (element.checked == true) { element.checked = false; }
		else { element.checked = true; }
	}

	function onLoad() {
		for(i=0;i<=document.links.length-1;i++) {document.links[i].hideFocus='true'}
	}

	function applyScroll(){
		if ($('#blog_layout').height() > 0){
			$("#blog_layout").addClass("flexcroll");
		} else {
			setTimeout("applyScroll",500);
		}
	}

	function say_argh(obj){
		var txt = ""
		if (obj){
			for(var i in obj){
				txt += i+" - "+obj[i]+"\n";
			}
		}
		alert(txt);
	}

function array_rand ( input, num_req ) {
    // Return key/keys for random entry/entries in the array  
    // 
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/array_rand    // +   original by: Waldo Malqui Silva
    // *     example 1: array_rand( ['Kevin'], 1 );
    // *     returns 1: 0
    var indexes = [];
    var ticks = num_req || 1;    
	var checkDuplicate = function ( input, value ) {
        var exist = false, index = 0;
        while ( index < input.length ) {
            if ( input [ index ] === value ) {
                exist = true;                
				break;
            }
            index++;
        }
        return exist;    
	};
 
    if ( input instanceof Array && ticks <= input.length ) {
        while ( true ) {
            var rand = Math.floor( ( Math.random( ) * input.length ) );            
			if ( indexes.length === ticks ) { break; }
            if ( !checkDuplicate( indexes, rand ) ) { indexes.push( rand ); }
        }
    } else {
        indexes = null;    
	}
 
    return ( ( ticks == 1 ) ? indexes.join( ) : indexes );
}

