// JavaScript Document

function openWindow(url){
		popup = window.open(url, "uusi", "width=1026, height=655, menubar=1");
	}

var T_Yritys = T_Lahiosoite = T_Postinumero = T_Postitoimipaikka = null;

function InitSaveVariables(form) {
		T_Yritys 			= form.T_Yritys.value;
		T_Lahiosoite 		= form.T_Lahiosoite.value;
		T_Postinumero 		= form.T_Postinumero.value;
		T_Postitoimipaikka 	= form.T_Postitoimipaikka.value;
		
}

function useShipAddress(form) {
		if (form.copy.checked) {
			InitSaveVariables(form);
			form.T_Yritys .value = form.Yritys.value;
			form.T_Lahiosoite.value = form.Lahiosoite.value;
			form.T_Postinumero.value = form.Postinumero.value;
			form.T_Postitoimipaikka.value = form.Postitoimipaikka.value;
			
		} else {
			form.T_Yritys .value = T_Yritys;
			form.T_Lahiosoite.value = T_Lahiosoite ;
			form.T_Postinumero.value = T_Postinumero;
			form.T_Postitoimipaikka.value = T_Postitoimipaikka;
		}
} 


function fieldNotEmpty(type, formName, htmlElement){
	
	var form = document.forms[formName];
	
	if(type == 'sendID'){
		if(form.elements[0].value == ""){
			document.getElementById(htmlElement).innerHTML = 'Teksikenttä on tyhjä';
			// form.elements[0].style.border = '1px solid red';
			return false;	
		}
	}
	
	else if(type == 'login'){
		if(form.elements[0].value == "" || form.elements[1].value == ""){
			document.getElementById(htmlElement).innerHTML = 'Kirjoita tekstikenttiin käyttätunnus ja salasana';
			return false;	
		}	
	}
	
	return true;
}
