
var gKey = 48;
var gLang = "";
var gItem = 0;

var gCommon_request = null;

var gSiteURL = "http://mounteverest.ch/";		// mit / at end
var gSiteURLPrefix = "";						// empty or me-test/


// expects div named "menu"

function loadMenuBar(item)
{	
	gItem = item;
	
	// check language
	if (gLang == "")
		var lang = getLanguageCookie();
	else
		var lang = gLang;
	
	var mapStr = "<map name='MenuMap_" + lang + "' id='MenuMap'>";

	// add map, depending on laguage
	switch (lang) {
		case "fr":
			switch (item) {
				case 0: mapStr += "<area shape='rect' coords='96,1,180,12' href='indexInstructionsFr.html' /><area shape='rect' coords='183,1,240,12' href='indexTracks.html' /><area shape='rect' coords='241,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,352,12' href='indexPrizesFr.html' /><area shape='rect' coords='353,1,410,12' href='indexImagesFr.html' />";
	  				break;
				case 1: mapStr += "<area shape='rect' coords='1,1,95,12' href='index.html' /><area shape='rect' coords='183,1,240,12' href='indexTracks.html' /><area shape='rect' coords='241,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,352,12' href='indexPrizesFr.html' /><area shape='rect' coords='353,1,410,12' href='indexImagesFr.html' />";
					break;
	  			case 2: mapStr += "<area shape='rect' coords='1,1,95,12' href='index.html' /><area shape='rect' coords='96,1,180,12' href='indexInstructionsFr.html' /><area shape='rect' coords='241,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,352,12' href='indexPrizesFr.html' /><area shape='rect' coords='353,1,410,12' href='indexImagesFr.html' />";
	  				break;
	  			case 3: mapStr += "<area shape='rect' coords='1,1,95,12' href='index.html' /><area shape='rect' coords='96,1,180,12' href='indexInstructionsFr.html' /><area shape='rect' coords='183,1,240,12' href='indexTracks.html' /><area shape='rect' coords='312,1,352,12' href='indexPrizesFr.html' /><area shape='rect' coords='353,1,410,12' href='indexImagesFr.html' />";
					break;
				case 4: mapStr += "<area shape='rect' coords='1,1,95,12' href='index.html' /><area shape='rect' coords='96,1,180,12' href='indexInstructionsFr.html' /><area shape='rect' coords='183,1,240,12' href='indexTracks.html' /><area shape='rect' coords='241,1,310,12' href='indexResults.html' /><area shape='rect' coords='353,1,410,12' href='indexImagesFr.html' />";
					break;
				case 5: mapStr += "<area shape='rect' coords='1,1,95,12' href='index.html' /><area shape='rect' coords='96,1,180,12' href='indexInstructionsFr.html' /><area shape='rect' coords='183,1,240,12' href='indexTracks.html' /><area shape='rect' coords='241,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,352,12' href='indexPrizesFr.html' />";
					break;
				case 6: mapStr += "<area shape='rect' coords='1,1,95,12' href='index.html' /><area shape='rect' coords='96,1,180,12' href='indexInstructionsFr.html' /><area shape='rect' coords='183,1,240,12' href='indexTracks.html' /><area shape='rect' coords='241,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,352,12' href='indexPrizesFr.html' /><area shape='rect' coords='353,1,410,12' href='indexImagesFr.html' />";
					break;
				case 10: mapStr += "<area shape='rect' coords='1,1,95,12' href='index.html' /><area shape='rect' coords='96,1,180,12' href='indexInstructionsFr.html' /><area shape='rect' coords='183,1,240,12' href='indexTracks.html' /><area shape='rect' coords='241,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,352,12' href='indexPrizesFr.html' /><area shape='rect' coords='353,1,410,12' href='indexImagesFr.html' />";
					break;
				default:
			}
			break;
		case "it":
			switch (item) {
				case 0: mapStr += "<area shape='rect' coords='42,1,175,12' href='indexInstructionsIt.html' /><area shape='rect' coords='176,1,245,12' href='indexTracks.html' /><area shape='rect' coords='246,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,365,12' href='indexPrizesIt.html' /><area shape='rect' coords='367,1,428,12' href='indexImagesIt.html' />";
	  				break;
				case 1: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='176,1,245,12' href='indexTracks.html' /><area shape='rect' coords='246,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,365,12' href='indexPrizesIt.html' /><area shape='rect' coords='367,1,428,12' href='indexImagesIt.html' />";
					break;
	  			case 2: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,175,12' href='indexInstructionsIt.html' /><area shape='rect' coords='246,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,365,12' href='indexPrizesIt.html' /><area shape='rect' coords='367,1,428,12' href='indexImagesIt.html' />";
	  				break;
	  			case 3: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,175,12' href='indexInstructionsIt.html' /><area shape='rect' coords='176,1,245,12' href='indexTracks.html' /><area shape='rect' coords='312,1,365,12' href='indexPrizesIt.html' /><area shape='rect' coords='367,1,428,12' href='indexImagesIt.html' />";
					break;
				case 4: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,175,12' href='indexInstructionsIt.html' /><area shape='rect' coords='176,1,245,12' href='indexTracks.html' /><area shape='rect' coords='246,1,310,12' href='indexResults.html' /><area shape='rect' coords='367,1,428,12' href='indexImagesIt.html' />";
					break;
				case 5: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,175,12' href='indexInstructionsIt.html' /><area shape='rect' coords='176,1,245,12' href='indexTracks.html' /><area shape='rect' coords='246,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,365,12' href='indexPrizesIt.html' />";
					break;
				case 6: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,175,12' href='indexInstructionsIt.html' /><area shape='rect' coords='176,1,245,12' href='indexTracks.html' /><area shape='rect' coords='246,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,365,12' href='indexPrizesIt.html' /><area shape='rect' coords='367,1,428,12' href='indexImagesIt.html' />";
					break;
				case 10: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,175,12' href='indexInstructionsIt.html' /><area shape='rect' coords='176,1,245,12' href='indexTracks.html' /><area shape='rect' coords='246,1,310,12' href='indexResults.html' /><area shape='rect' coords='312,1,365,12' href='indexPrizesIt.html' /><area shape='rect' coords='367,1,428,12' href='indexImagesIt.html' />";
					break;
				default:
			}
			break;
			
			
		case "en":
			switch (item) {
				case 0: mapStr += "<area shape='rect' coords='42,1,130,12' href='indexInstructionsEn.html' /><area shape='rect' coords='133,1,190,12' href='indexTracks.html' /><area shape='rect' coords='191,1,250,12' href='indexResults.html' /><area shape='rect' coords='251,1,300,12' href='indexPrizesEn.html' /><area shape='rect' coords='305,1,355,12' href='indexImagesEn.html' />";
	  				break;
				case 1: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='133,1,190,12' href='indexTracks.html' /><area shape='rect' coords='191,1,250,12' href='indexResults.html' /><area shape='rect' coords='251,1,300,12' href='indexPrizesEn.html' /><area shape='rect' coords='305,1,355,12' href='indexImagesEn.html' />";
					break;
	  			case 2: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,130,12' href='indexInstructionsEn.html' /><area shape='rect' coords='191,1,250,12' href='indexResults.html' /><area shape='rect' coords='251,1,300,12' href='indexPrizesEn.html' /><area shape='rect' coords='305,1,355,12' href='indexImagesEn.html' />";
	  				break;
	  			case 3: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,130,12' href='indexInstructionsEn.html' /><area shape='rect' coords='133,1,190,12' href='indexTracks.html' /><area shape='rect' coords='251,1,300,12' href='indexPrizesEn.html' /><area shape='rect' coords='305,1,355,12' href='indexImagesEn.html' />";
					break;
				case 4: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,130,12' href='indexInstructionsEn.html' /><area shape='rect' coords='133,1,190,12' href='indexTracks.html' /><area shape='rect' coords='191,1,250,12' href='indexResults.html' /><area shape='rect' coords='305,1,355,12' href='indexImagesEn.html' />";
					break;
				case 5: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,130,12' href='indexInstructionsEn.html' /><area shape='rect' coords='133,1,190,12' href='indexTracks.html' /><area shape='rect' coords='191,1,250,12' href='indexResults.html' /><area shape='rect' coords='251,1,300,12' href='indexPrizesEn.html' />";
					break;
				case 6: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,130,12' href='indexInstructionsEn.html' /><area shape='rect' coords='133,1,190,12' href='indexTracks.html' /><area shape='rect' coords='191,1,250,12' href='indexResults.html' /><area shape='rect' coords='251,1,300,12' href='indexPrizesEn.html' /><area shape='rect' coords='305,1,355,12' href='indexImagesEn.html' />";
					break;
				case 10: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,130,12' href='indexInstructionsEn.html' /><area shape='rect' coords='133,1,190,12' href='indexTracks.html' /><area shape='rect' coords='191,1,250,12' href='indexResults.html' /><area shape='rect' coords='251,1,300,12' href='indexPrizesEn.html' /><area shape='rect' coords='305,1,355,12' href='indexImagesEn.html' />";
					break;
				default:
			}		
			break;
			
		default:
			switch (item) {
				case 0: mapStr += "<area shape='rect' coords='42,1,157,12' href='indexInstructionsDe.html' /><area shape='rect' coords='164,1,230,12' href='indexTracks.html' /><area shape='rect' coords='237,1,304,12' href='indexResults.html' /><area shape='rect' coords='312,1,361,12' href='indexPrizesDe.html' /><area shape='rect' coords='367,1,417,12' href='indexImagesDe.html' />";
	  				break;
				case 1: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='164,1,230,12' href='indexTracks.html' /><area shape='rect' coords='237,1,304,12' href='indexResults.html' /><area shape='rect' coords='312,1,361,12' href='indexPrizesDe.html' /><area shape='rect' coords='367,1,417,12' href='indexImagesDe.html' />";
					break;
	  			case 2: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,157,12' href='indexInstructionsDe.html' /><area shape='rect' coords='237,1,304,12' href='indexResults.html' /><area shape='rect' coords='312,1,361,12' href='indexPrizesDe.html' /><area shape='rect' coords='367,1,417,12' href='indexImagesDe.html' />";
	  				break;
	  			case 3: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,157,12' href='indexInstructionsDe.html' /><area shape='rect' coords='164,1,230,12' href='indexTracks.html' /><area shape='rect' coords='312,1,361,12' href='indexPrizesDe.html' /><area shape='rect' coords='367,1,417,12' href='indexImagesDe.html' />";
					break;
				case 4: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,157,12' href='indexInstructionsDe.html' /><area shape='rect' coords='164,1,230,12' href='indexTracks.html' /><area shape='rect' coords='237,1,304,12' href='indexResults.html' /><area shape='rect' coords='367,1,417,12' href='indexImagesDe.html' />";
					break;
				case 5: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,157,12' href='indexInstructionsDe.html' /><area shape='rect' coords='164,1,230,12' href='indexTracks.html' /><area shape='rect' coords='237,1,304,12' href='indexResults.html' /><area shape='rect' coords='312,1,361,12' href='indexPrizesDe.html' />";
					break;
				case 6: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,157,12' href='indexInstructionsDe.html' /><area shape='rect' coords='164,1,230,12' href='indexTracks.html' /><area shape='rect' coords='237,1,304,12' href='indexResults.html' /><area shape='rect' coords='312,1,361,12' href='indexPrizesDe.html' /><area shape='rect' coords='367,1,417,12' href='indexImagesDe.html' />";
					break;
				case 10: mapStr += "<area shape='rect' coords='1,1,36,12' href='index.html' /><area shape='rect' coords='42,1,157,12' href='indexInstructionsDe.html' /><area shape='rect' coords='164,1,230,12' href='indexTracks.html' /><area shape='rect' coords='237,1,304,12' href='indexResults.html' /><area shape='rect' coords='312,1,361,12' href='indexPrizesDe.html' /><area shape='rect' coords='367,1,417,12' href='indexImagesDe.html' />";
					break;
				default:
			}
	}
	

	// check for session
	if (isSIDSet()) {
		switch (lang) {
			case "fr": mapStr += "<area shape='rect' coords='412,1,463,12' href='indexMyPage.html' /><area shape='rect' coords='470,1,541,12' href='javascript:doLogout();' />";
				break;
			case "it": mapStr += "<area shape='rect' coords='429,1,488,12' href='indexMyPage.html' /><area shape='rect' coords='490,1,588,12' href='javascript:doLogout();' />";
				break;
			case "en": mapStr += "<area shape='rect' coords='367,1,417,12' href='indexMyPage.html' /><area shape='rect' coords='422,1,472,12' href='javascript:doLogout();' />";
				break;
			default: mapStr += "<area shape='rect' coords='422,1,472,12' href='indexMyPage.html' /><area shape='rect' coords='480,1,541,12' href='javascript:doLogout();' />";
		}
		
		document.getElementById("menu").innerHTML = "<img src='img/nav/" + lang + "_menu" + item + "_plus.png' border='0' usemap='#MenuMap_" + lang + "' />" + mapStr + "</map>";
	}
	else {	
		document.getElementById("menu").innerHTML = "<img src='img/nav/" + lang + "_menu" + item + ".png' border='0' usemap='#MenuMap_" + lang + "' />" + mapStr + "</map>";
	}
}



function isSIDSet()
{
	if (document.cookie) {
		var a = document.cookie;
		var b = a.indexOf("sid=") + 4;
		if (b >= 4) {
			var c = a.indexOf(";",b-1);
			if (c > 0)
				var cookie_sid = a.substring(b,c);
			else
				var cookie_sid = a.substring(b,a.length);
			
			if (cookie_sid.length <= 1)
				return false;
			else
				return true;
	
		}
		else
			return false;
	}
	else
		return false;
}


function getSIDCookie()
{
	if (document.cookie) {
		var a = document.cookie;
		var b = a.indexOf("sid=") + 4;
		if (b >= 4) {
			var c = a.indexOf(";",b-1);
			if (c > 0)
				var cookie_sid = a.substring(b,c);
			else
				var cookie_sid = a.substring(b,a.length);
			
			if (cookie_sid.length <= 1)
				return 0;
			else
				return cookie_sid;
	
		}
		else
			return 0;
	}
	else
		return 0;
}



function getUIDCookie()
{
	if (document.cookie) {
		var a = document.cookie;
		var b = a.indexOf("uid=") + 4;
		if (b >= 4) {
			var c = a.indexOf(";",b-1);
			if (c > 0)
				var cookie_uid = a.substring(b,c);
			else
				var cookie_uid = a.substring(b,a.length);
			
			if (cookie_uid.length < 1)
				return 0;
			else
				return cookie_uid;
	
		}
		else
			return 0;
	}
	else
		return 0;
}




function getLanguageCookie()
{
	var lang = "de";
	if (document.cookie) {
		var a = document.cookie;
		if (a.indexOf("lng=de") >= 0)
			lang = "de";
		if (a.indexOf("lng=fr") >= 0)
			lang = "fr";
		if (a.indexOf("lng=en") >= 0)
			lang = "en";
		if (a.indexOf("lng=it") >= 0)
			lang = "it";
	}

	gLang = lang;
	return lang;
}



function setCookie(name, value, expires, path, domain, secure)
{
	var today = new Date();
	today.setTime(today.getTime());


	if (expires) {			/* expiration in minutes, if 0, keep for one year */
		if (expires == 0)
			expires = 1000 * 60 * 60 * 24 * 365;
		else
			expires = expires * 1000 * 60;
	}
	var expires_date = new Date(today.getTime() + (expires));

	document.cookie = name + "=" +escape(value) +
	((expires) ? ";expires=" + expires_date.toGMTString() : "") +
	((path) ? ";path=" + path : "") +
	((domain) ? ";domain=" + domain : "") +
	((secure) ? ";secure" : "");
}


function deleteCookie(name, path, domain)
{
	document.cookie = name + "=" +
	((path) ? ";path=" + path : "") +
	((domain) ? ";domain=" + domain : "") +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}





function switchLanguage(lang,page) 
{
	if (gLang != lang) {
		setCookie("lng",lang,0);
		gLang = lang;
		loadMenuBar(gItem);
		if (page != null)
			switch (parseInt(page,10)) {
				case 0:		switchLoginRegister(0);
							loadTopTen();
							switchLanguageTexts(lang);
//							loadRandomUserImage();
							displayActivityOnHomepage(document.getElementById("communityBox"),isSIDSet()); //disbaled during winter
							break;
				case 1:		switch (lang) {
								case "fr":	window.location = 'indexInstructionsFr.html';	break;
								case "en":	window.location = 'indexInstructionsEn.html';	break;
								case "it":	window.location = 'indexInstructionsIt.html';	break;
								default:	window.location = 'indexInstructionsDe.html';	break;
								
							}
							break;
				case 2:		displayTracksMain();
							break;
				case 3:		displayResultsMain();
							break;
				case 4:		switch (lang) {
								case "fr":	window.location = 'indexPrizesFr.html';	break;
								case "en":	window.location = 'indexPrizesEn.html';	break;
								case "it":	window.location = 'indexPrizesIt.html';	break;
								default:	window.location = 'indexPrizesDe.html';	break;
								
							}
							break;
				case 5:		switch (lang) {
								case "fr":	window.location = 'indexImagesFr.html';	break;
								case "en":	window.location = 'indexImagesEn.html';	break;
								case "it":	window.location = 'indexImagesIt.html';	break;
								default:	window.location = 'indexImagesDe.html';	break;
								
							}
							break;
				case 6:		loadMyPage();
							break;
							
				case 10:	displayCupMain();
							break;
				
			
				default: ;	
			}
	}
}




function doLogout(msg)
{	
//	document.getElementById("loginRegisterBox").style.visibility = "visible";
	deleteCookie("uid");
	deleteCookie("sid");
/*	
	userQuery("log",gUID,"");
	initUser();
	gCacheResUser = "";	
	
	
	
	clearTimer();*/
	if (msg)
		alert(msg);
		
//	loadMenuBar(0);
	window.location = 'index.html';
}




function getUserStatusIcon(alt)
{
	var anzahl_me = Math.floor(alt / kAlt_ME);
	
	if (anzahl_me == 1)
		return "<img src='img/icon/usr_bronze.gif' alt='Bronze' border=0>";
	else
		if (anzahl_me == 2)
			return "<img src='img/icon/usr_silber.gif' alt='Silber'  border=0>";
		else
			if (anzahl_me >= 3 && alt < 100000)
				return "<img src='img/icon/usr_gold.gif' alt='Gold'  border=0>";
			else
				if (alt >= 100000)
					return "<img src='img/icon/usr_diamond.png' alt='Diamant'  border=0>";
				else
					return "";

}


function getUserStatusIconFromLevel(lvl)
{	
	if (isNaN(lvl))
		return "";
		
	if (lvl == 1)
		return "<img src='img/icon/usr_bronze.gif' alt='Bronze' border=0>";
	else
		if (lvl == 2)
			return "<img src='img/icon/usr_silber.gif' alt='Silber'  border=0>";
		else
			if (lvl == 3)
				return "<img src='img/icon/usr_gold.gif' alt='Gold'  border=0>";
			else
				if (lvl >= 4)
					return "<img src='img/icon/usr_diamond.png' alt='Diamant'  border=0>";
				else
					return "";
}




function getClubStatusIcon(alt)
{
	var anzahl_me = Math.floor(alt / kAlt_ME);
	
	if (anzahl_me >= 10 && anzahl_me <= 19)
		return "<img src='img/icon/usr_bronze.gif' alt='Bronze' border=0>";
	else
		if (anzahl_me >= 20 && anzahl_me <= 29)
			return "<img src='img/icon/usr_silber.gif' alt='Silber' border=0>";
		else
			if (anzahl_me >= 30)
				return "<img src='img/icon/usr_gold.gif' alt='Gold' border=0>";
			else
				return "";
}


// -----------------------------------------------------------
// Random User Images
// -----------------------------------------------------------


function loadRandomUserImage()
{
		var cmd = "Image.pl?cmd=GetRandomImages";
	commonAjax(cmd,processImageReqGetRandomImages);
}


// used in results (rechte spalte) in promo box
function processImageReqGetRandomImages()	
{
	var err = 0;
	
    if (gCommon_request.readyState == 4) {
        // only if "OK"
        if (gCommon_request.status == 200) {
			if (gCommon_request.responseText.length > 0) {
				var items = gCommon_request.responseXML.getElementsByTagName("image");
				var txt = "<table width='100%' border='0'>";
				var tiid, fname, caption, author, datum, tid, trackName, full_fname;
				for (var i = 0; i < 1; i++) {
					tiid = parseInt(getElementTextNS("", "tiid", items[i], 0),10);
					fname = getElementTextNS("", "fname", items[i], 0);
					caption = decodeURIComponent(getElementTextNS("", "caption", items[i], 0));
					author = getElementTextNS("", "nickname", items[i], 0);
					datum = getElementTextNS("", "datum", items[i], 0);
					tid = parseInt(getElementTextNS("", "tid", items[i], 0),10);
					trackName =  getElementTextNS("", "name", items[i], 0);
					
					txt += "<tr><span class='boxTitle'>"+trackName+"</span><br />";
					full_fname = gSiteURL+"usr-img/l272/l272_" + fname;
					txt += "<img src='" + full_fname + "' class='imgBorder' /><br><span class='imagelist2-font'>" + formatDateFromDB(datum);
					if (caption.length > 1)
						txt += ": " + caption;
					txt += " ("+getLocStr('Autor')+": "+author+")";
					txt += "<br><br><br></span>";
					txt += "</td></tr>";
				}
				txt += "</table>";

				document.getElementById("promoImageBox").innerHTML = txt;
			}
		}
		else {
			alert("Failed to retrieve data (" + gCommon_request.status + "/" + err + ")");
		}
	}
	else {
	}
}




// -----------------------------------------------------------
// USER AJAX
// -----------------------------------------------------------

function commonAjax(cmdStr,callBack)
{	
	gCommon_request = false;
    if (typeof XMLHttpRequest != 'undefined') {
    	try {
			gCommon_request = new XMLHttpRequest();
        } catch(e) {
			gCommon_request = false;
        }
    } else if(window.ActiveXObject) {
       	try {
        	gCommon_request = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		gCommon_request = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		gCommon_request = false;
        	}
		}
    }
	
	
	if (gCommon_request) {
		var localfile = document.URL.indexOf("file:",0);
		if (localfile < 0)
			var url = document.URL.substring(0,(document.URL.indexOf(".ch/") + 4)) + gSiteURLPrefix + "cgi-local/";
		else
			var url = gSiteURL + "cgi-local/";
						
				
		gCommon_request.onreadystatechange = callBack;
		url += cmdStr + "&sid=" + gSID;
		

		gCommon_request.open("GET",url,true);
		gCommon_request.send(null);
	}
	
//	alert(url);

}


