

function newWin(url,img,title,w,h) {

	   if (! (url) && ! (img)) { return; }
	   var day= new Date();
	   var id = day.getTime();
	   var ww = w+75;
	   var wh = h+125;
	   if ((screen.height) && (wh > screen.height-100)) { wh = screen.height-100; }
	   var params = 'width='+ww+',height='+wh+',scrollbars,resizable';
	   var t = (title != '')?title:img;
	   if (url=='') {
	      var msg='<!DOCTYPE HTML PUBLIC "-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN" "http:\/\/www.w3.org/TR\/html4\/loose.dtd">\n'+
		          '<meta http-equiv="Content-Type" content="text\/html; charset=iso-8859-1">\n'+
		          '<html><head><title>'+t+'<\/title><\/head>'+
		          '<style type="text\/css">\n'+
				  'html,body { font-family: Arial,Helvetica,Sans-Serif; }\n'+
				  'h3 { text-align: center; }\n'+
				  'td { text-align: center; }\n'+
				  '<\/style><body>\n'+
				  '<h3>'+t+'<\/h3>\n <table align="center" border="0"><tr><td><img src="'+img+'" width="'+w+'" height="'+h+'" border="0" alt="'+title+'"></td></tr>\n'+
				  '<tr><td><hr width="100%" size="1"><form><input type="button" onClick="javascript:window.close();" value="Close Window">\n'+
				  '<hr width="100%" size="1"><\/form><\/td><\/tr><\/table><\/body><\/html>\n';
	      var win = open('',id,params);
		  win.document.write(msg);
		  win.document.close();
	   }
	   else { var win = open(url,id,params); } 
	   return false;
}

// Otherwise generated within scripts, this is just for the main page.

function checkMainForm(form) {

		var requireds  = new Array("email","userpass","password_confirm");
		var plainNames = new Array("email","userpass","password confirm");
		var checkThis=itemName=msg='';

		for (i=0; i<requireds.length; i++) {
			var obj = document.getElementById(requireds[i]);
			if (obj.type == 'select-one') { checkThis = obj[obj.selectedIndex].value; }
			else { checkThis = obj.value; }
			itemName =  plainNames[i];

			if ((checkThis == '') || (checkThis == 'none')) {
				msg += '\n  Please provide your ' + itemName + ' before submitting this form.';
			}
		}

		if (document.getElementById('userpass')) {
			var pwd = document.getElementById('userpass').value;
			if (pwd.length < 6) {
				msg += '\n  For your security, Please enter a password' +
				'\n  that is 6 characters or more with no spaces or' +
				'\n  special characters.';
			}
			else if (pwd.indexOf(" ",1) != -1) {  msg += '\n  Your password cannot contain spaces.';  }
			if ((form.password_confirm) && (form.password_confirm.value != pwd)) {
				msg = '\n  The password and password confirmation do not match.';
			}
		}

		if (msg != '') {
			msg = 'Your form contains the following errors:\n'+msg+'\n Please make the necessary corrections and try again.';
			alert(msg);
		}
		else  { 
			form.submitButton.disabled = true; 
			form.submit();
		}
		return false;
}

	
function closeRefresh(pid,state,func) {
    if ((! pid) || (! state)) { alert('Source ID and display required to close and refresh.'); return; } 
    if (window.opener && !window.opener.closed) {
	   window.opener.document.location='/Customer-Login?'+func+'='+state+'&id='+pid; 
       window.close();
    }
}

function upload_win(cid) {
   var day = new Date();
   var id  = day.getTime();
   var url = '/cgi-bin/sf-upload.cgi?display=account_upload&pop_window=1&id='+cid;
   var win = open(url,id,'width=500,height=500,resizable,scrollbars');
}
