function stdeip_dialog(title,url,w,h) {
  if (!w) w=400;
  if (!h) h=300;
  param=new Array();
  param[0]=window;
  param[1]=title;
  param[2]=url;

//  retval=window.showModalDialog('/site/lms/scheme/dialog.html',param,'dialogwidth:'+w+'px;dialogheight:'+h+'px;status:no;scroll:yes;help:no;');
  retval=window.showModalDialog(url,param,'dialogwidth:'+w+'px;dialogheight:'+h+'px;status:no;scroll:yes;help:no;');
  // refresh the cell
  //if (retval && targetid!=undefined)
  //   cvt_filldiv(targetid,refreshurl,'<br><div class=help align=center>wait...</div><br>');

  // 2003-07-13 joel: refresh entire browser
  if (retval) {
    if (retval=='view_refresh' && window.parent) {
      window.parent.leftFrame.document.location.reload();
      window.parent.mainFrame.document.location.reload();
    }
    else if (retval=='full_refresh' && window.parent) {
      window.parent.document.location.reload();
    }
    else if (retval=='confirm') {
      window.document.location=url+'&confirm=1';
    }
    else document.location.reload();
  }
}

function stdeip_toggle_tip(oimg,otip) {
  if (oimg.state=='open') {
    oimg.state='close';
    oimg.src=oimg.closeSrc;
    otip.style.display='none';
  }
  else {
    oimg.state='open';
    oimg.src=oimg.openSrc;
    otip.style.display='block';
  }
}

function stdeip_show_menu(mname,nudge) {
  var omenu=document.getElementById(mname);
  if (omenu) {
    if (nudge) {
	  if (!omenu.style.origleft) 
		omenu.style.origleft=omenu.style.pixelLeft;
	  omenu.style.pixelLeft=omenu.style.origleft+nudge;
	}
    omenu.style.display='block';
  }
//  else alert('stdeip_show_menu error: menu '+mname+' not found');
}
function stdeip_hide_menu(mname) {
  var omenu=document.getElementById(mname);
  if (omenu) omenu.style.display='none';
//  else alert('stdeip_hide_menu error: menu '+mname+' not found');
}

function stdeip_open_win(linkpath,name,w,h,param){
 if (typeof w =="undefined") w=400;
 if (typeof h =="undefined") h=250;


 var p = "status=no,menubar=no,resizable=no,scrollbars=no";
 if (typeof param != "undefined") p += ","+ param; 

	var left = ( screen.width - w ) / 2 ;
	var top = ( screen.height - h ) / 2;

  p = "width="+w+",height="+h+",top="+top+",left="+left+","+param;

	//adWindow1 = window.open(linkpath, w+"x"+h,"top="+top+",left="+left+",width="+w+",height="+h+param);
	var win = window.open(linkpath, name,p);
	win.focus();
	return win;
}

function stdeip_verify_text(oinput,cond,msg) {
  if (cond=='not empty') {
     if (oinput.value=='') {
	   alert(msg);
	   oinput.focus();
	   return false;
	 }
  }
  return true;
}

function stdeip_verify_date_order(odate1,odate2) {
  dn1=odate1.name;
  dn2=odate2.name;
  if (odate1.value>odate2.value) {
    alert("Please enter a "+dn2+" date which is later than the "+dn1+" date.");
    odate2.focus();
    return false;
  }
  return true;
}

function stdeip_post_popup(form,url,w,h) {
 // post a form to popup win
 if (!w) w=500;
 if (!h) h=500;

 stdeip_open_win("","popupform",w,h);
 form.target="popupform";
 form.action=url;
 form.submit();
}

function stdeip_send_this_page(form,site) {
 var subj=document.getElementById('msg[subject]');
 var body=document.getElementById('msg[body]');

 if (subj.value=="")
 if (document.title) subj.value+=document.title;
 subj.value='Send this page - ' + subj.value;
 
 body.value='Hi,<br><br>Please visit this URL:<br>';
 body.value+='<a target=_blank href='+location.href+'>'+location.href+'</a>';

 url='/cos/o.x?c=/'+site+'/message&func=popup';
 stdeip_post_popup(form,url,550,520);
}


