function log() {
	// safe log, avoid javascript breaks if firebug isn't installed
	try {
		console.log.apply(this, arguments);
	} catch (e) {}
}

function getWindowWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;
	if (document.body) return document.body.clientWidth;
	return window.undefined;
}

function getWindowHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight;
	return window.undefined;
}

function clean_attr(str) {
	return str.replace(/[\\\n"]/g, "");
}

function trim (s) {
	s = s.replace(/^\s+/, "");
	s = s.replace(/\s*$/, "");
	return s;
}

var create_pat = /(\w+)(?:\.(\w+))?(?:#(\w+))?/i;
function create (n) {
	// allows create with name of form: eltName[.className][#id]
	var results = create_pat.exec(n);
	var elt = results[1];
	var class = results[2];
	var id = results[3];
	var ret = Element.extend(document.createElement(elt));
	if (class) ret.className = class;
	if (id) ret.id = id;
	return ret;
}

/////////////////////////////////////////
// Cookie fns from quirksmode / ppk
// http://www.quirksmode.org/js/cookies.html

function createCookie(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 readCookie(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 eraseCookie(name) {
	createCookie(name,"",-1);
}

/////////////////////////////////////////

