var deta_window;
var note=0;
var delay;
function ira(area)
{
	e = document.getElementsByName(area);
	if (e.length == 1) {
		e[0].focus();
	}
}
function notify()
{
	if (note == 0) {
		alert ('Please Note:\nif you close this window all entries will be lost');
		note = 1;
	}
}
function check(answ)
{
	var obli,o;
	var miss=0;
	var ret = 1;
	var obj_miss;
	// verify all entries
	obli = document.getElementsByTagName("INPUT");
	var OUT = '<table><tr><td width="40%"><hr></td><td width="20%" nowrap>Text fields</td><td width="40%"><hr></td></tr></table>';
	for (var cnt=0;cnt<obli.length;cnt++) {
		o = document.getElementsByTagName("INPUT")[cnt];
		if (printout(o, o.value) > 0) {
			miss++;
			if (miss == 1) {obj_miss=o;}
		}
	}
	OUT += '<table><tr><td width="40%"><hr></td><td width="20%" nowrap>select boxes</td><td width="40%"><hr></td></tr></table>';
	obli = document.getElementsByTagName("SELECT");
	for (var cnt=0;cnt<obli.length;cnt++) {
		o = document.getElementsByTagName("SELECT")[cnt];
		if (o.selectedIndex != 0) {
			t = o[o.selectedIndex].innerText;
			v = o.selectedIndex + " =&gt; " + t;
		} else {
			v="";
		}
		if (printout(o, v) > 0) {
			miss++;
			if (miss == 1) {obj_miss=o;}
		}
	}
	OUT += '<table><tr><td width="40%"><hr></td><td width="20%" nowrap>Text areas</td><td width="40%"><hr></td></tr></table>';
	obli = document.getElementsByTagName("TEXTAREA");
	for (var cnt=0;cnt<obli.length;cnt++) {
		o = document.getElementsByTagName("TEXTAREA")[cnt];
		if (printout(o, o.value) > 0) {
			miss++;
			if (miss == 1) {obj_miss=o;}
		}
	}
	details = 0;
	if (miss > 0) {
		details = confirm(miss + ' Entries marked as obligate not given\nvalues not ready to sent\nsee details?\npopups should be enabled');
		ret = 0;
	} else {
		alert(' check ok - all obligate entries given');
	}
	if (details) {
		if (deta_window == null || deta_window.closed ) {
			deta_window = window.open('about:blank', "_blank","width=310,height=400,left=0,top=0,status=yes,scrollbars=yes,resizable=yes");
		} else {
			deta_window.close();
			deta_window = window.open('about:blank', "deta_window","width=310,height=400,left=0,top=0,status=yes,scrollbars=yes,resizable=yes");
		}
		deta_window.focus();

		//fenster = open("about:blank","deta_window","resizable=yes,status=yes,menubar=yes,locationbar=yes,width=310,height=400,screenX=0,screenY=0,scrollbars=yes");
		deta_window.document.write("<html>");
		deta_window.document.write("<head>");
		deta_window.document.write("</head>");
		deta_window.document.write("<body>");
		deta_window.document.write(OUT);
		deta_window.document.write("</body>");
		deta_window.document.write("</html>");
		deta_window.document.close();
		deta_window.document.focus();
	} else {
		if (obj_miss) {
			obj_miss.focus();
		}
	}
	if (answ) {
		if (! ret) {
			ret = confirm('Should all given values sent tom abalone@ocea.es?');
		}
	}

	if (ret) {
		var Bname;
		o = document.getElementsByName('Boat_name');
		if (o.length == 1) {
			Bname = o[0].value;
		}
		document.mailform.action='http://www.offshoresailsrts.net/sendmail3.php';
	} else {
		document.mailform.action='';
	}
	return ret;
	
	function printout(e,v)
	{
		var nok=0;
		var link;
		var style;
		if (e.name.substr(0,1) != "_") {
			if (e.className == 'o') {
				if (v) {
					//OUT += '<font color="#000000">' + e.name + '=' + v + "</font><br>";
					style = 'style="background-color:#ffffff;"';
					link = '';
				} else {
					//OUT += '<font color="#ff0000">' + e.name + '=' + v + "</font><br>";
					style = 'style="background-color:#ffff00;cursor:pointer;"';
					link = ' onclick="opener.document.forms[0].'+e.name+'.focus()"';
					nok = 1;
				}
			} else {
					//OUT += '<font color="#000088">' + e.name + '=' + v + "</font><br>";
					style = 'style="background-color:#E6FAFA;"';
					link = '';
			}
			OUT += '<span '+style+link+'>' + e.name + '=' + v + '</span><br>';
		}
		return nok;
	}
}
function deco (a)
{
	var erg;
	try {
		erg = decodeURI(a);
		throw "ok";
	}
	catch (eg) {
		//alert('error '+eg);
		if (eg != "ok") {
			erg = a;
		}
	}
	return erg;
}

function showpic(n)
{
	var e = document.getElementById(n);
	e.style.visibility = "visible";
	delay=1;
}
function hidepic(n,t)
{
	if(t > 0) {
		delay=0;
		window.setTimeout("hidepic('"+n+"',0)",t);
	} else {
		if (delay == 0) {
			var e = document.getElementById(n);
			e.style.visibility = "hidden";
		}
	}
}
function if_background() {
	if (screen.colorDepth < 16) {
		document.body.style.background='none';
	}
}