function formSubmitOnce(f,formCorrect,period) {
  if (formCorrect===false) return false

  if (period<1) period=5
  if (!f.SubmittedFormID) f.SubmittedFormID=Math.round(Math.random()*1000000)
  var a='Submitted'+f.SubmittedFormID

  if (document[a]) {
    alert('Form is already submitted. If you are still on this page, wait about '+period+' sec and try again.')
    return false
    }

  document[a]=1
  setTimeout('document["'+a+'"]=0',period*1000)
  return true
  }

function checkEmail(str) {
  var l=str.length
  if (!l) return false
  var ata=0
  var point=0
  var cch=''
  for (var i=0; i<l; i++) {
    var ch=str.charAt(i)
    if (ch=='@')
      if (ata==1 || i==0 || cch=='.') return false
      else ata=1
    else if (ch=='.')
      if (cch=='.' || cch=='@' || i==l-1 || i==0) return false
      else point=ata
    else if ((ch<'A' || ch>'Z') && (ch<'a' || ch>'z') &&
		(ch<'0' || ch>'9') && (ch!='_') && (ch!='-')) return false
    cch=ch
    }
  return (ata && point)
  }
function tr(obj){
	s=obj.value;
	re=/^\s+/; s=s.replace(re, '');
	re=/\s+$/; s=s.replace(re, '');
	obj.value=s;
	return s;
}
function ve(e){
ind=e.indexOf('\@');return (ind>0 && ind<s.length-1?true:false);
}
function validate(f){
p='Input ';
if (tr(f.email)==''||!ve(f.email.value)) {alert(p+'correct email!'); return false;}
return true;
}

function setdiv(div, HTML) {	
	if(document.all) {document.all(div).innerHTML = HTML}

	else if(document.layers) {
		with(document.layers[div].document) {
			open ("text/html")
			write (HTML)
			close ()
		}
	}
	else if(document.getElementById) {document.getElementById(div).innerHTML = HTML;}

}

function setVisibility(div,show) {
	var disp='';
	var vis='';
	if (!show) {
		disp='none';
		vis='hidden';
	}
	
	if(document.all) {
		if (document.all(div))	{
			document.all(div).style.display = disp;
			document.all(div).style.visibility = vis;
		}
	} else if(document.layers) {}
	else if(document.getElementById)	{
		if (document.getElementById(div)) {
			document.getElementById(div).style.display = disp;
			document.getElementById(div).style.visibility = vis;
		}
	}
}


function pop(url,wd,hg,name)
{

width=wd;height=hg;
if (parseInt (navigator.appVersion) >= 4 )
{
X=(screen.width  - width )/2;
Y=(screen.height - height)/2-40;
}
var extra='width='+width+',height='+height+',top='+Y+',left='+X+',resizable=1,scrollbars=1,location=no,directories=no,status=no,menubar=no,toolbar=no';
window.open(url,name,extra);
} 

function nWin(theURL,winName,width,height,features,br) {
var window_width = width+30;
var window_height = height+20;
var newfeatures= features;
var window_top = (screen.height-window_height)/2;
var window_left = (screen.width-window_width)/2;
str='width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',' + newfeatures + '';
newWindow=window.open('','',str);
newWindow.document.open();

str="<html><head><title>" + winName + "</title></head><body marginwidth=0 margin height=0 topmargin=0 leftmargin=0 rightmargin=0 bgcolor=#fff5e9>"+(br>0?"<br>":"")+'<img src='+theURL+' width='+width+' height='+height+' border=0 hspace=10 vspace=10>'+"</body></html>";
newWindow.document.write(str);
newWindow.document.close();
}

