
function pageSetup() {
	window.focus();
	var f, e;
	if (f = document.mainForm) {
		// hilight first empty text field
		for (var i = 0;  (e = f.elements[i]);  i++) {
			if ((e.type == 'text' || e.type == 'password' || e.type == 'textarea') && e.value == '') {
				e.focus();
				break;
			}
		}
	}	
	if (!document.getElementsByTagName) return;
	
	// alternative to 'target="_blank"' for external links,
	//  because "target" has been removed from strict doctype spec
	var a, anchors = document.getElementsByTagName('a');
	for (var i = 0;  i < anchors.length;  i++) {
		a = anchors[i];
		if (a.getAttribute('href') && a.getAttribute('rel') == 'ext') 
			a.target = '_blank';
	}
}

function formSubmit() {
	document.mainForm.submit();
}
function formSubmitVal() {
	if (validate()) 
		document.mainForm.submit();
	else return false;
}

function formSubmitVal1p(step) {
	if (validateExtra(step)) {
		if (step == 1 || step == 3) 
			openWait();
		formSubmit('mainForm');
	}
	else return false;
}


function openWait() {
	ref = window.open('_wait.html?lead_id='+leadID, 'wait', popupTypes[2]);
	if (ref.opener == null) ref.opener = window;
	ref.opener.name = "opener";
	ref.focus();
	//waitWindow = ref;
	//document.onunload = waitWindow.close();
}


function popup(name, specs) {
	var ref = window.open('', name, specs);
	return ref;
}


function val(selName) {
	var sel = document.mainForm[selName];
	if (sel.options) {
		return sel.options[sel.selectedIndex].value;
	} else return '';
}


function opennewwindow(url){
	l=(screen.availWidth-620)/2;
	sFeature="height=400,width=620,location=0,status=0,resizeable=0,scrollbars=1,titlebar=0,toolbar=0,menubar=0,top=0,left="+l;
	window.open(url,null,sFeature);
}

function getupdated(){
	myDate = new Date();
	d = myDate.getDay();
	date = myDate.getDate();
	m = myDate.getMonth();
	y = myDate.getFullYear();
	switch (d){
		case 0: day="SUNDAY";break;
		case 1: day="MONDAY";break;
		case 2: day="TUESDAY";break;
		case 3: day="WEDNESDAY";break;
		case 4: day="THURSDAY";break;
		case 5: day="FRIDAY";break;
		case 6: day="SATURDAY";break;
	}
	switch (m){
		case 0: {month="JANUARY";break;};
		case 1: {month="FEBRUARY";break;};
		case 2: {month="MARCH";break;};
		case 3: {month="APRIL";break;};
		case 4: {month="MAY";break;};
		case 5: {month="JUNE";break;};
		case 6: {month="JULY";break;};
		case 7: {month="AUGUST";break;};
		case 8: {month="SEPTEMBER";break;};
		case 9: {month="OCTOBER";break;};
		case 10: {month="NOVEMBER";break;};
		case 11: {month="DECEMBER";break;};
	}	
	updated =day + ", " + month +" "+ date + ", " + y;
	obj=document.createTextNode(updated);
	document.getElementById("topleftbelow").appendChild(obj);
}






