var red = "#990000"; // home
var blue = "#65809A"; // machine
var green = "#5C9D5C"; // try & buy
var yellow = "#FECE02"; // about us
var lightblue = "#BED0E2"; // support
var grey = "#CCCCCC"; // default

var alertStatus = false;
//var win = null;

function changeFocus(input,color) {
	input.style.border = "1px solid";
  	input.style.borderColor = color;
}

function changeBlur(input,color) {
	input.style.border = "1px solid";
	input.style.borderColor = color;
}

function checkBrowser() {
	var x = navigator.userAgent.toLowerCase();

	if(x.match("msie") && x.match("win")) {
		document.write("<link rel=\"stylesheet\" href=..//%22/site/include/Style_ie.css/%22 type=\"text/css\">")
	}
	else if(x.match("netscape") && x.match("win")) {
		document.write("<link rel=\"stylesheet\" href=..//%22/site/include/Style_nn.css/%22 type=\"text/css\">")
	}
}

function fixUglyIE() {
	for(a in document.links) {
		document.links[a].onfocus = document.links[a].blur;
	}
}

function writeGearWText(d, text) {
	d.innerHTML = "<div id=\"gearBox\"><img src=\"/site/images/Gear_Animated_Transparent.gif\"><br>" + text + "</div>";
}

function showGearWText(id, text) {
	if(document.getElementById) {
		var myGear = document.getElementById(id);
		writeGearWText(myGear, text);
		myGear.style.position = 'absolute';
		myGear.style.display = 'block';
		myGear.style.left = 0;
		myGear.style.top = 0;
		//		myGear.style.left = 387;
		//		myGear.style.top = 222;
		return false;
	}
	else if(document.all) {
		var myGear = document.all[id];
		writeGear(myGear);
		myGear.style.position = 'absolute';
		myGear.style.display = 'block';
		myGear.style.left = 0;
		myGear.style.top = 0;
		//		myGear.style.left = 387;
		//		myGear.style.top = 222;
		return false;
	}
	return false;
}


function writeGear(d) {
	d.innerHTML = "<img src='/site/images/Gear_Animated_Transparent.gif' width='160' height='206' border='0'>";
}

function showGear(id) {
	if(document.getElementById) {
		var myGear = document.getElementById(id);
		writeGear(myGear);
		myGear.style.position = 'absolute';
		myGear.style.display = 'block';
		myGear.style.left = 0;
		myGear.style.top = 0;
//		myGear.style.left = 387;
//		myGear.style.top = 222;
		return false;
	}
	else if(document.all) {
		var myGear = document.all[id];
		writeGear(myGear);
		myGear.style.position = 'absolute';
		myGear.style.display = 'block';
		myGear.style.left = 0;
		myGear.style.top = 0;
//		myGear.style.left = 387;
//		myGear.style.top = 222;
		return false;
	}
	return false;
}

function hideGear(id) {
	if(document.getElementById) {
		var myGear = document.getElementById(id);
		myGear.style.display = 'none';
		myGear.innerHTML = "";
	}
	if(document.all) {
		var myGear = document.all[id];
		myGear.style.display = 'none';
		myGear.innerHTML = "";
	}
}


function writeAlert(d,text,button) {
		d.innerHTML = "<div id=\"alertBox\"><table width='243' border='0' cellspacing='0' cellpadding='0'>" +
			"<tr>" +
				"<td><img src='/site/images/Dot_Black.gif' width='241' height='1'></td>" +
			"</tr>" +
			"<tr>" +
				"<td background='/site/images/Alert_Middle.gif'>" +
					"<table width='243' border='0' cellspacing='0' cellpadding='0'>" +
						"<tr>" +
							"<td colspan='6'><img src='/site/images/Dot_Transparent.gif' width='1' height='10'></td>" +
						"</tr>" +
						"<tr>" +
							"<td width='10'><img src='/site/images/Dot_Transparent.gif' width='10' height='1'></td>" +
							"<td width='32' valign='top'><img src='/site/images/Icons/Alert.gif' width='32' height='32'></td>" +
							"<td width='10'><img src='/site/images/Dot_Transparent.gif' width='10' height='1'></td>" +
							"<td width='178' class='bread' valign='top'>" + text + "</td>" +
							"<td width='10'><img src='/site/images/Dot_Transparent.gif' width='10' height='1'></td>" +
							"<td width='3'><img src='/site/images/Dot_Transparent.gif' width='3' height='1'></td>" +
						"</tr>" +
						"<tr>" +
							"<td colspan='6' align='center'><input id='alertbutton' type='button' name='' value='" + button + "' class='button' onClick=" + '"hideAlert(' + "'divAlert'" + ');"' + "></td>" +
						"</tr>" +
						"<tr>" +
							"<td colspan='6'><img src='/site/images/Dot_Transparent.gif' width='1' height='10'></td>" +
						"</tr>" +
					"</table>" +
				"</td>" +
			"</tr>" +
			"<tr>" +
				"<td><img src='/site/images/Alert_Bottom.gif' width='243' height='4'></td>" +
			"</tr>" +
		"</table></div>";
}


function showAlert(text,button) {
	if(document.getElementById) {
		var myAlert = document.getElementById("divAlert");
		writeAlert(myAlert,text,button);
		//myAlert.style.left = 346;
		//myAlert.style.top = 222;
		myAlert.style.top = 0;
		myAlert.style.left = 0;
		myAlert.className = 'showAlert';
		alertStatus = true;
		return false;
	}
	if(document.all) {
		var myAlert = document.all["divAlert"];
		writeAlert(myAlert,text,button);
		//myAlert.style.left = 346;
		//myAlert.style.top = 222;
		myAlert.style.top = 0;
		myAlert.style.left = 0;
		myAlert.className = 'showAlert';
		alertStatus = true;
		return false;
	}
	return false;
}

function hideAlert(id) {
	if(document.getElementById) {
		var myAlert = document.getElementById(id);
		myAlert.className = 'hideAlert';
		alertStatus = false;
		myAlert.innerHTML = "";
	}
	if(document.all) {
		var myAlert = document.all[id];
		myAlert.className = 'hideAlert';
		alertStatus = false;
		myAlert.innerHTML = "";
	}
}

function checkEvent() {
	if(alertStatus) {
		if(document.getElementById) {
			document.getElementById('divAlert').focus();
		}
		else if(document.all) {
			document.all['divAlert'].focus();
		}
	return false;
	}
}


function expandDiv(id,img,str) {
	if(document.getElementById) {
		var myDiv = document.getElementById(id);
	}
	else if(document.all) {
		var myDiv = document.all[id];
	}
	else if(document.layers){
		var myDiv = document.layers[id];
	}

	if(myDiv.className == 'hideDiv') {
		myDiv.className = 'showDiv';
		document.images[img].src = "/site/images/Nav_Left/Arrow_Blue_" + str + "Down.gif";
	}
	else {
		myDiv.className = 'hideDiv';
		document.images[img].src = "/site/images/Nav_Left/Arrow_Blue_" + str + "Right.gif";
	}
}

function popUp(url,w,h,r) {
	var sx = (screen.width - w) / 2;
	var sy = (screen.height - h) / 2;
	var props = 'toolbar=no,scrollbars=no,location=no,directories=no,menubar=no,resizable='+r+',status=no,width='+w+',height='+h+',top='+sy+',left='+sx+'';
	var win = window.open(url, 'popUp', props); 
	win.window.focus();
	//if(win != undefined) win.window.focus();
	return win;
}
function popUp_new(url,w,h,r) {
	var sx = (screen.width - w) / 2;
	var sy = (screen.height - h) / 2;
	var props = 'toolbar=no,scrollbars=yes,location=no,directories=no,menubar=no,resizable='+r+',status=no,width='+w+',height='+h+',top='+sy+',left='+sx+'';
	var win = window.open(url, 'popUp', props);
	win.window.focus(); 
	//if(win != undefined) win.window.focus();
	return win;
}

function showOnlyDiv(which){
	var alfa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	for(var i = alfa.length; i ; i--) {	
		let = alfa.charAt(i-1);
		if(document.getElementById("let_" + let)) {
			div = document.getElementById("let_" + let);
			div.className = (which != let ? "hideDiv" : "showDiv");
		}
	}
}

function ChangeFrame(top,bottom) {
	parent.topFrame.location.href=top;
	parent.bottomFrame.location.href=bottom;
}

function goHist(a) {
	history.go(a);
}

function goToUrl(a) {
	document.location.href = a;
}

function errorHandler() {
	return false;
}


document.onclick = checkEvent;
// window.onerror = errorHandler; Skall aktiveras vid lansering!
// ShowAlert med extra parameter lista för x,y
function showAlert2(text,button,X,Y) {
	if(X==0)X=346;if(Y==0)Y=222;
	if(document.getElementById) {
		var myAlert = document.getElementById("divAlert");
		writeAlert(myAlert,text,button);
		myAlert.style.left = X;
		myAlert.style.top = Y;
		myAlert.className = 'showAlert';
		alertStatus = true;
		return false;
	}
	if(document.all) {
		var myAlert = document.all["divAlert"];
		writeAlert(myAlert,text,button);
		myAlert.style.left = X;
		myAlert.style.top = Y;
		myAlert.className = 'showAlert';
		alertStatus = true;
		return false;
	}
	return false;
}

function progressbar(percent, imgprc) {
	var d = document.getElementById("inbetweenprogimg");
	if(d) {
		d.src = '/site/images/progressbar/pgbar_' + imgprc + '.gif';
	}
	var d = document.getElementById("inbetweenprogtext");
	if(d) {
		d.innerHTML = percent + "%";
	}
}

