/* Debug */
function Dump(obj) {
	var s = '';
	switch (typeof obj) {
		case 'number':
			s = 'number: '+ obj;
			break;
		case 'string':
			s = 'string('+ obj.length +'): "'+ obj +'"';
			break;
		case 'boolean':
			s = 'boolean: '+ obj;//(obj ? 'true' : 'false');
			break;
		case 'object':
			s = 'object:\n';
			for (p in obj) {
				s += p+ ' = '+ obj[p] +'\n';
			}
		case 'function':
			s = 'function: '+ obj.toString();
			break;
		case 'undefined':
			s = 'undefined';
			break;
		default :
			s = 'unknown';
	}
	alert(s);
	//return s;
	//document.getElementById('txtDebug').value = s;
}

/* Generic Cookie functies */

function GetCookie(name) {
	var cookies = document.cookie.split('; ');
	var crumb;
	var i = cookies.length;
	while (i--)	{
 		crumb = cookies[i].split('=');
		if (name == crumb[0]) {
			if (typeof crumb[1] != 'undefined') {
				return unescape(crumb[1]);
			} else {
				return null;
			}
		}
	}
	return null;
}

function SetCookie(name, value) {
	document.cookie = name + '=' + escape(value) + '; expires=Fri, 31 Dec 2099 23:59:59 GMT; path=/';
}

/* Settings */

/* Links */
function OpenLink(linkEl) {
	var chk = document.getElementById('chkOpenInNewWindow');
	if (chk.checked) {
		window.open(linkEl.href, '_blank');
	} else {
		window.open(linkEl.href, '_content');
		//window.location = linkEl.href;
	}
	return false;
}

/* Uploads */
function CopyFilename(source, targetId) {
	var txt = document.getElementById(targetId);
	if (txt.value=='') {
		// strip path and extension
		txt.value = source.value.replace(/^(.*\\)*(.*?)([.].*)$/, '$2');
	}
}


