
function jumpPage(protocol, page) {
	location.href = getProtocolChangeURL(protocol, page);
}

function changeLinkProtocolToHttp() {
	if (location.protocol == "https:") {
		if(document.getElementById && document.createTextNode) {
			var i, a;
			for(i=0; (a = document.getElementsByTagName("a")[i]); i++) {
				if(a.getAttribute("href").match(/^https:\/\/[^#]+$/i)) {
					changeProtocol(a, "http");
				}
			}
		}
	}
}

function changeProtocol(obj, protocol) {
	obj.setAttribute("href", getProtocolChangeURL(protocol, obj.getAttribute("href")));
}

function getProtocolChangeURL(protocol, page) {
	if (protocol == "") {
		protocol = "http";	
	}
	var strUrl;
	strUrl = document.URL;
	var pathInfo = new Array();
	pathInfo = strUrl.split('/');
	var domain;
	domain = pathInfo[2];
	pathInfo.shift();
	pathInfo.shift();
	pathInfo.shift();
	
	if (page == "") {
		return 	protocol + "://" + domain + "/" + pathInfo.join("/");
	}else if (page.match(/.+:\/\//i) != null) {
		return page.replace(/.+:\/\//i, protocol + "://");
	}else if (page.match(/^\/.*/i) != null) {
		return 	protocol + "://" + domain + page;
	}
	
	var pageInfo = new Array();
	pageInfo = page.split('/');

	var jumpUrl = "";
	var currentLevel = pathInfo.length;
	var count = 0;
	
	for (i = 0; i < pageInfo.length - 1; i++) {
		if (pageInfo[i] == "") {
			currentLevel = 0;
			break;
		}else if  (pageInfo[i] == ".")  {
			//
		}else if  (pageInfo[i] == "..")  {
			currentLevel--;
		}else {
			break;
		}
		count = i + 1;
	}
	jumpUrl = protocol + "://" + domain + "/";
	for (i = 0; i < currentLevel - 1; i++) {
		jumpUrl += pathInfo[i] + '/';
	}
	for (i = count; i < pageInfo.length - 1; i++) {
		jumpUrl += pageInfo[i] + '/';
	}
	jumpUrl += pageInfo[pageInfo.length - 1];

	return jumpUrl;
}

