// JavaScript Document
//
// YAAADI - YetAnotherAjaxAndDomInterface
// by Sebastian P. Wolbring
//
//	
// YAAADI v0.1.0
// written by Sebastian Peter Wolbring - except where quoted
//
// DomInterface pseudo class is based on:
// DOMhelp 1.0
// written by Chris Heilmann
// http://www.wait-till-i.com
//
// YAAADI is licensed under The MIT Licence
//
//
// TODO: description of this file
//
//
//
//
// The MIT License
// 
// Copyright (c) 2008 Sebastian Peter Wolbring
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//


// Microtime - Object Literal
Microtime={
    mtStart : function() {
        d = new Date();
        time  = d.getTime();
    },
    mtStop : function() {
        d = new Date();
        return (d.getTime()-time);
    }
}


// var_dump - PHP wannabe
function var_dump(obj) {
	if(typeof obj == "object") {
		return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
	} else {
		return "Type: "+typeof(obj)+"\nValue: "+obj;
	}
}


function firstCharToUpperCase(myString) {
	var stringLength = myString.length;
	firstChar   = myString.slice(0,1);
	otherChars  = myString.slice(1,stringLength);
	firstCharUp = firstChar.toUpperCase();
	return firstCharUp + otherChars;
}


function stripSpaces(str) {
	tempStr = str.replace(/(\s)\s+/g,"$1");
	newStr = "";
	for (i=0; i < tempStr.length; i++) {
		if (tempStr.charAt(i) != '\n' &&
			tempStr.charAt(i) != '\r' &&
			tempStr.charAt(i) != '\t') {
				newStr += tempStr.charAt(i);
			}
	}
	return newStr; 
}





function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function delCookie(name) {
	createCookie(name,"",-1);
}