var hide_text = new Array(4);
var show_text = new Array(4);
var dim_temps = new Array(50); // Muista kasvattaa jos tulee lisää mestoja!

function changeimages() {
if (document.images) {
for (var i=0; i<changeimages.arguments.length; i+=2) {
document[changeimages.arguments[i]].src = eval(changeimages.arguments[i+1] + ".src");
}}} 

function toggle(thisId, picId, linkId, textId) {
	var myId = document.getElementById(thisId);
	var myPic = document.images[picId];
	var myLink;
	if (textId != 0) myLink = document.getElementById(linkId);
	var newState;
	
	var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
	// alert(isIE6);

	if (myId.style.display != 'none' && myId.style.display != '') { 
		myId.style.display = 'none'; 
		myPic.src = 'img/plus.png';
		if (myLink) myLink.innerHTML = show_text[textId];
	} else {
		newState = 'block';
		// alert("Huu!");
		if (myId.tagName == 'TR' && !isIE6) { newState = 'table-row'; }
		myId.style.display = newState; 
		myPic.src = 'img/minus.png';
		if (myLink) myLink.innerHTML = hide_text[textId];
	}
}

function setDimTemp(fieldId,selectedValue) {
	var myId = document.getElementById(fieldId);
	// alert("Arvo: " + selectedValue);
	myId.value = dim_temps[selectedValue];
}

function moveRight() {
	// Siirretään hiddeneihin viimeisimmät arvot
	document.inputs_form.project.value = document.print_form.project.value;
	document.inputs_form.user.value = document.print_form.user.value;
}


function goPrint() {
	moveRight();
	// Sit submitataan molemmat formit
	document.inputs_form.submit();
	document.print_form.submit();
}

function openUnitWindow2(theURL,winName,features) {
	window.open(theURL,winName,features);	
}

function change() {
	document.print_form.print_button.disabled = true;
	document.inputs_form.calculate_button.style.textDecoration = 'underline';
	//document.inputs_form.calculate_button.style.backgroundColor = '#ccc';
}

function checkSubmit(formid, alert_terms, alert_common) {
	valid = true;
	var myform = document.getElementById(formid);
	
	if (myform.terms) {
		if (myform.terms.checked == false) {
			alert(alert_terms);
			myform.terms.focus();
			valid = false;
		}
	} 
	
	if (valid && val_fields) {
		for (var intCounter = 0; intCounter < val_fields.length; intCounter++) {
			if (myform.elements[val_fields[intCounter]].value == "") {
				alert(alert_common);
				myform.elements[val_fields[intCounter]].focus();
				valid = false;
				break;
			}
		}
	}
	
	return valid;	 

}


function highlightDiv(divId) {
	var myId = document.getElementById(divId);
	// myId.style.border = "1px solid #996633";
	myId.style.backgroundColor = "#ffffff";
}

