﻿var lang = 0; 
var myhost = document.location.host;
var full_path_init = document.location.href;
var index = full_path_init.indexOf('#');
var full_path = (index > 0)? full_path_init.substring(0,index) : full_path_init;
var div_path,cv_nonsc_base_path;

function changeVer(lang) {
	chi_path = "/b5_html/";
	eng_path = "/en_html/";
	chs_path = "/gb_html/";
	jp_path = "/jp_html/";

	org_path = full_path;
	org_path_start = org_path.indexOf(div_path) + div_path.length - 1;
	org_path = org_path.substring(org_path_start);

	if (org_path.indexOf(chi_path) != -1) {
		org_lang_path = chi_path;
	} else if (org_path.indexOf(eng_path) != -1){
		org_lang_path = eng_path;
	} else if (org_path.indexOf(chs_path) != -1){
		org_lang_path = chs_path;
	} else if (org_path.indexOf(jp_path) != -1){
		org_lang_path = jp_path;
	}

	if (lang == 'e') {
		des_lang_path = eng_path;
	} else if (lang == 't'){
		des_lang_path = chi_path;
	} else if (lang == 's'){
		des_lang_path = chs_path;
	} else if (lang == 'j'){
		des_lang_path = jp_path;
	}

	base_path = cv_nonsc_base_path;

	tail = org_path.replace(org_lang_path, des_lang_path);

	window.location.href = base_path + tail;
}

div_path = myhost + "/";
cv_nonsc_base_path = "http:" + "//" + myhost;