//function init
function ttlOver() {}
function ttlOut() {}
function infobar_update() {}
function infobar_loading() {}
function log() {}

//Last call function
var lfn = ''; var lfn_count = 1;
function lf(fname) {
	if (lfn!=fname){
//  	  try{ log(' FC: Function call '+lfn+' ('+lfn_count+')'); } catch(e){}
		lfn=fname;
		lfn_count = 1;
	}
	else { lfn_count++; }
}

// Read registry
function RegRead(key) {
	lf('RegRead');
	var ret = "";
	try { ret = WshShell.RegRead(key); }
	catch(e) { ret = ""; }
	return ret;
}

// Get registry Value
function loadValue(key,default_val) {
	lf('loadValue');
	ret = RegRead(Reg+key) ? Boolean(parseInt(RegRead(Reg+key))) : default_val;
	return ret;
}

// Open url
function goToUrl(url){
	lf('goToUrl');
	try {
		defBrowser = RegRead("HKCU\\SOFTWARE\\Clients\\StartMenuInternet\\");
		if (!defBrowser) defBrowser = RegRead("HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\");
		runComm = RegRead("HKLM\\SOFTWARE\\Clients\\StartMenuInternet\\" + defBrowser + "\\shell\\open\\command\\");
		runComm = runComm.replace(/"/ig,'');
		if (runComm)
			WshShell.Run('"' + runComm + '" ' + '"' + url + '"',1,false);
		else
			window.open(url);
	}
	catch(e) {
		log("Failed to open "+url);
		window.open(url);
	}
	return false;
}

// htmlspecialchars
function htmlspecialchars(html) {
	lf('htmlspecialchars');
	html = html.replace(/&/g, "&amp;");
	html = html.replace(/</g, "&lt;");
	html = html.replace(/>/g, "&gt;");
	html = html.replace(/"/g, "&quot;");
	html = html.replace(/'/g, "&quot;");
	return html;
}
