









var vhm_jenc = function(o) {
	// regex from YUI
	var i,b,spc=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
	switch (typeof o) {
	case 'string':
		return '"' + o.replace(spc, function(c) {
			return '\\u'+('0000'+(+(c.charCodeAt(0))).toString(16)).slice(-4);
		}) + '"';
	case 'number':
	case 'boolean':
		return o;
	case 'array':
		b = [];
		for (i=0;i<o.length;i++)
			b.push(vhm_jenc(o[i]));
		return '[' + b.join(',') + ']';
	case 'object':
		b = [];
		for (i in o)
			b.push(i + ':' + vhm_jenc(o[i]));
		return '{' + b.join(',') + '}';
	default:
		return 'null';
	}
};

(function(t) {

	var
	ws = vhm_widget_settings,
	args = document.location.search.substring(1).replace(/\+/g, ' ').split('&'),
	dec = decodeURIComponent,
	i,p,n,v;

	ws.baseUrl = 'http://vhmengine.com/';
	ws.secureUrl = 'https://vhmengine.com/';
	ws.widgetsUrl = 'http://s3.vhmengine.com/widgets/1964/';
  ws.mediaUrl = 'http://vhmengine.com/media/';
	ws.gigyaAPIKey = '2_KKaHN0mFm5QNmv2jIFH7Rnw7xtQJbTC1sLrJ6uJAxSuLbx0hm0zN5e1i3uYpbEeB';
	ws.referrer = document.domain;

	ws.admin = false;
	if (ws.height < 250)
		ws.height = 250;

	// Pass vhm_ parameters to widgetSettings
	for (i = 0; i < args.length; i++) {
		p = args[i].split('=');
		n = dec(p[0]);
		if (n.indexOf('vhm_') == 0) {
			n = n.substring(4);
			v = (p.length==2) ? dec(p[1]) : n;
			ws[n] = v;
		}
		else {
			// TODO: Don't even handle adminMode, just make admin-pages use widget_skel directly!
			ws.admin = (n=='admin');
		}
	}

	document.write(
			'<iframe id="vhm_qaframe0" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" ' +
			'width="' + ws.width + '"  scrolling="no"  height="' + ws.height + '" src="' + ws.widgetsUrl +
			'qawidget/skel.html?s=' + encodeURIComponent(vhm_jenc(ws)) + '" ></iframe>');
})(this);
