var deta_window;
var note=0;
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;
	var OUT = 'jump to input field by click text here';
	// verify all entries
	obli = document.getElementsByTagName("INPUT");
	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?');
		ret = 0;
	}
	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 send to info@intersailsupply.com?');
		}
	}

	if (ret) {
		var Bname;
		o = document.getElementsByName('Boat_name');
		if (o.length == 1) {
			Bname = o[0].value;
		}
		document.mailform.action='http://www.intersailsupply.com/sendmail3.php';
	} else {
		document.mailform.action='';
	}
	return ret;
	
	function printout(e,v)
	{
		var nok=0;
		link = '';
		if (e.name.substr(0,1) != "_") {
		  var nn = e.name;
			if (e.className == 'o') {
			  link = 'style="cursor:pointer;" onclick="opener.jump(\''+nn+'\');"';
				if (v) {
					//OUT += '<font color="#000000">' + e.name + '=' + v + "</font><br>";
					bgc = '#ffffff';
				} else {
					//OUT += '<font color="#ff0000">' + e.name + '=' + v + "</font><br>";
					bgc = '#ffff00';
					nok = 1;
				}
			} else if (e.className == 'i') {
			  link = 'style="cursor:pointer;" onclick="opener.jump(\''+nn+'\');"';
				//OUT += '<font color="#000088">' + e.name + '=' + v + "</font><br>";
				bgc = '#E6FAFA';
			} else {
			  bgc = '#FFFFFF'
			  link = '';
      }
			OUT += '<span '+link+' style="background-color: '+bgc+'">' + 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 jump(nn)
{
  var e = document.getElementsByName(nn);
  if (e.length == 1) {
    e[0].focus();
  }
}
