// to run the login from a static context the web4url must be set to
// a URL with the correct application path 
// http://web4biz.ic4b.net/web4system/web4.sh/WService=web4biz/content/index_main.html
var web4url = window.document.URL;

//formats the CompanyID to the preceding 0s Bsp. 525 --> 000525
function web4formatCompany(CompanyID) {
	var comp;
	comp = CompanyID.toString();
	for(var i=comp.length;i<6;++i){
		comp = + "0" + comp;
	}
	return comp;
}

// get the domain  + Script web4.sh + WService=
// adds the service web4biz + the index_main path
function web4getdomain() {
	var i = web4url.indexOf(":");
	var dom = web4url.substring(i+3);
	i = dom.indexOf("=");
	var ser = web4getservice(dom.substring(i+1));
	return dom.substring(0, i + 1) + ser;
}

// get the service + the index_main path 
function web4getservice(dom) {
	var i = dom.indexOf("/");
	return dom.substring(0, i) + "/content/index_main.html";
}

// get the Protocol HTTP....
function web4getprotocol() {
	var i = web4url.indexOf(":");
	return web4url.substring(0, i);
}

// gets the correct Window Name it needs CompanyID
// the Name = web4bizmain + CompanyID + First entry . of the domain
function web4getwindowname(Comp) {
	var dom = web4getdomain();
	var i = dom.indexOf("."); 
	var web4compname = dom.substring(0, i);
	alert(dom.substring(0, i));
	var web4bizmain = 'web4bizmain' + Comp + web4compname;
	return web4bizmain;
}

