function showdiv(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function hideinfo(id) {
        if (document.getElementById) { // DOM3 = IE5, NS6
                document.getElementById(id).style.display = 'none';
        }
        else {
                if (document.layers) { // Netscape 4
                        document.id.display = 'none';
                }
                else { // IE 4
                        document.all.id.style.display = 'none';
                }
        }
}

function popUp(URL, WIDTH, HEIGHT) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + WIDTH + ',height=' + HEIGHT + ',left = 390,top = 412');");
}
function popUp_id(URL, WIDTH, HEIGHT, ID) {
	eval("page" + ID + " = window.open(URL, '" + ID + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + WIDTH + ',height=' + HEIGHT + ',left = 390,top = 412');");
	ID.focus();
}


function useragreement(){
	window.opener.document.getElementById('rekisterointi').sopimus.checked = true;
	window.close();
}


function enableForm() {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById('piilotettu').style.display = '';
	}
	else {
		if (document.layers) { // Netscape 4
			document.piilotettu.display = '';
		}
		else { // IE 4
			document.all.piilotettu.style.display = '';
		}
	}
}

function naytaYritys() {
	enableForm();
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById('trcompany_name').style.display = '';
		document.getElementById('trcompany_code').style.display = '';
		document.getElementById('trtyhja').style.display = '';
		document.getElementById('komissio').style.display = '';

		document.getElementById('trsex').style.display = 'none';
		document.getElementById('trdob').style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.trcompany_name.display = '';
			document.trcompany_code.display = '';
			document.trtyhja.display = '';
			document.komissio.display = '';

			document.trsex.display = 'none';
			document.trdob.display = 'none';
		}
		else { // IE 4
			document.all.trcompany_name.style.display = '';
			document.all.trcompany_code.style.display = '';
			document.all.trtyhja.style.display = '';
			document.all.komissio.style.display = '';

			document.all.trsex.style.display = 'none';
			document.all.trdob.style.display = 'none';
		}
	}
}

function naytaYksityis() {
	enableForm();
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById('trcompany_name').style.display = 'none';
		document.getElementById('trcompany_code').style.display = 'none';
		document.getElementById('trtyhja').style.display = 'none';
		document.getElementById('komissio').style.display = 'none';

		document.getElementById('trsex').style.display = '';
		document.getElementById('trdob').style.display = '';
	}
	else {
		if (document.layers) { // Netscape 4
			document.trcompany_name.display = 'none';
			document.trcompany_code.display = 'none';
			document.trtyhja.display = 'none';
			document.komissio.display = 'none';

			document.trsex.display = '';
			document.trdob.display = '';
		}
		else { // IE 4
			document.all.trcompany_name.style.display = 'none';
			document.all.trcompany_code.style.display = 'none';
			document.all.trtyhja.style.display = 'none';
			document.all.komissio.style.display = 'none';

			document.all.trsex.style.display = '';
			document.all.trdob.style.display = '';
		}
	}
}


function DisableEnableForm(xForm,xHow){
  objElems = xForm.elements;
  for(i=0;i<objElems.length;i++){
	if (objElems[i].name == 'invoicing') {
	}
	else if (objElems[i].name == '') {
	}
	else {
	    objElems[i].disabled = xHow;
		if (objElems[i].type != 'button') {
		    if (xHow == false) {
			    objElems[i].style.backgroundColor = '#ffffff';
			    objElems[i].style.color = '#000000';
		    }
		    else if (xHow == true) {
			    objElems[i].style.backgroundColor = '#cccccc';
			    objElems[i].style.color = '#555555';
		    }
		}
	}
  }
}

function addEmailCopies() {
	var tbody = document.getElementById('email').getElementsByTagName("TBODY")[0];
	var row = document.createElement("TR")

	var td1 = document.createElement("TD")
	td1.innerHTML = "<input type='text' class='input' name='emailcopy[]'> ";

	row.appendChild(td1);
	tbody.appendChild(row);
}


function addBanks() {
	var tbody = document.getElementById('invoice').getElementsByTagName("TBODY")[0];
	var row = document.createElement("TR")

	var td1 = document.createElement("TD")
	td1.style.backgroundColor = '#FF9900';
	td1.align = 'right';
	td1.innerHTML = "<input type='text' class='input' style='width: 98px;' name='pankki[]'>";

	var td2 = document.createElement("TD")
	td2.innerHTML = "<input type='text' class='input' style='width: 140px;' name='tili[]'>";

	var td3 = document.createElement("TD")
	td3.innerHTML = "<input type='text' class='input' style='width: 140px;' name='swift[]'>";

	var td4 = document.createElement("TD")
	td4.innerHTML = "<input type='text' class='input' style='width: 140px;' name='iban[]'>";

	row.appendChild(td1);
	row.appendChild(td2);
	row.appendChild(td3);
	row.appendChild(td4);
	tbody.appendChild(row);

}

function paivitaTietoja(valinta) {
	if (valinta == '1') {
		var yksityis = 'none';
		var yritys   = '';
	}
	else {
		var yksityis = '';
		var yritys   = 'none';
	}

	if (document.getElementById) { // DOM3 = IE5, NS6

		document.getElementById('trcompany_name').style.display = yritys;
		document.getElementById('trcompany_code').style.display = yritys;
		document.getElementById('trtyhja').style.display = yritys;
		document.getElementById('komissio').style.display = yritys;

		document.getElementById('trsex').style.display = yksityis;
		document.getElementById('trdob').style.display = yksityis;
	}
	else {
		if (document.layers) { // Netscape 4
			document.trcompany_name.display = yritys;
			document.trcompany_code.display = yritys;
			document.trtyhja.display = yritys;
			document.komissio.display = yritys;

			document.trsex.display = yksityis;
			document.trdob.display = yksityis;
		}
		else { // IE 4
			document.all.trcompany_name.style.display = yritys;
			document.all.trcompany_code.style.display = yritys;
			document.all.trtyhja.style.display = yritys;
			document.all.komissio.style.display = yritys;

			document.all.trsex.style.display = yksityis;
			document.all.trdob.style.display = yksityis;
		}
	}
}

function commissionagreement(){
	window.opener.document.getElementById('rekisterointi').komissio.checked = true;
	window.close();
}

function showInput(Input, Arvo, HaluttuArvo) {
	if (Arvo == HaluttuArvo){ var nayta = ''; }
	else			{ var nayta = 'none'; }

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(Input).style.display = nayta;
	}
	else {
		if (document.layers) { // Netscape 4
			document.Input.display = nayta;
		}
		else { // IE 4
			document.all.Input.style.display = nayta;
		}
	}
}

function clearText(thefield, Out) {
	if (Out == 0) {
		if (thefield.defaultValue==thefield.value) {
			thefield.value = ""; 
		}
	}
	else {
		if (thefield.defaultValue==thefield.value) {
			thefield.value = thefield.defaultValue;
		}
		else if (thefield.value=="") {
			thefield.value = thefield.defaultValue;
		}
	}
} 

function muistuta(userid, itemid, id) {
	var answer = confirm("Olet lähettämässä ostajalle \"" + userid + "\" Huuto.netin muistutusta toteutuneesta kaupasta. Oletko varma?")
	if (answer){
		window.location = "/fi/send_reminder.php?userid=" + userid + "&itemid=" + itemid + "&id=" + id;
	}
}


