
function JumpURL2(lang) {
	var currPath = top.location.pathname;
	var newPath = currPath;

	var wPos = newPath.indexOf("?");
	if (wPos >= 0)
		newPath = newPath.substr(0, wPos);

	newPath = newPath + "?locale=" + lang;

	top.location.href = newPath;
}



function JumpURL(lang) {
	var currPath = top.location.pathname;
	var newPath  = stripLanguage(currPath);

	if (lang != "en")
		newPath = "/" + lang + newPath;

	top.location.href = newPath;
}

function stripLanguage(path) {
	var pos = -1;

	if (path.indexOf("/de/") == 0)
		pos = 3;
	else if (path.indexOf("/it/") == 0)
		pos = 3;
	else if (path.indexOf("/fr/") == 0)
		pos = 3;
	else if (path.indexOf("/es/") == 0)
		pos = 3;
	else if (path.indexOf("/en/") == 0)
		pos = 3;
	else if (path.indexOf("/zh/") == 0)
		pos = 3;
	else if (path.indexOf("/hu/") == 0)
		pos = 3;

	if (pos >= 0)
		path = path.substring(pos);

	return path;
}

function languageSelector(sel) {
  var lang_locale=new Array(5);
  var lang_name=new Array(5);
  lang_locale[0]='zh';
  lang_name[0]='Chinese';
  lang_locale[1]='en';
  lang_name[1]='English';
  lang_locale[2]='de';
  lang_name[2]='Deutsch';
  lang_locale[3]='it';
  lang_name[3]='Italiano';
  lang_locale[4]='hu';
  lang_name[4]='Magyar';

  var selector;
  selector='<font face="Verdana,Arial,Helvetica,sans-serif" size=1>';
  selector=selector+'<select name="language" class="input" onChange="JumpURL(document.choose.language.options[document.choose.language.options.selectedIndex].value);">';
  
  for (i=0; i<lang_locale.length; i++) {
    selector=selector+'<option value="'+lang_locale[i]+'" ';
    if (sel==lang_locale[i]) {
      selector=selector+'selected';
    }
    selector=selector+'>'+lang_name[i]+'</option>';
  }
  selector=selector+'</select></font>';
  document.write(selector);
}


