﻿function NeatDialog(sHTML, sTitle, bCancel)
{
  if(typeof(window.neatDialog)=="object" && window.neatDialog != null)
  {
     window.neatDialog.close();
  }
  window.neatDialog = null;
  this.elt = null;
  if (document.createElement  &&  document.getElementById)
  {
    var dg = document.createElement("div");
    dg.className = "neat-dialog";
    if (sTitle)
      sHTML = '<div class="neat-dialog-title">'+sTitle+
              ((bCancel)?
                '<img src="x.gif" alt="Cancel" class="nd-cancel" />':'')+
                '</div>\n' + sHTML;
    dg.innerHTML = sHTML;

    var dbg = document.createElement("div");
    dbg.id = "nd-bdg";
    dbg.className = "neat-dialog-bg";

    var dgc = document.createElement("div");
    dgc.className = "neat-dialog-cont";
    dgc.id = "nd_dgc";
    dgc.appendChild(dbg);
    dgc.appendChild(dg);

    var iHeight = window.screen.availHeight;
 //  dgc.style.marginTop = iHeight/2;

     //alert(parent);
    dgc.style.cssText = "position:absolute;top:"+(iHeight/3+parent.document.documentElement.scrollTop-215)+"px;"; 
//   alert(parent.document.body.scrollTop+'---'+dgc.clientHeight+"--"+parent.document.documentElement.scrollTop+"==="+dgc.top);
//    var sScrollTop = parent.document.body.scrollTop+parent.document.documentElement.scrollTop;
//    var iTop = sScrollTop+dgc.clientHeight;
//    var sTop = iTop > 0 ? iTop : 0;
//    alert(evnt.screenX);
//    dgc.style.top=event.screenY+"px";
//    
//    alert(dgc.style.top);
      
    //alert( (document.body.clientHeight-dgc.clientHeight)/2+document.body.scrollTop);
    //dgc.style.marginLeft=(document.body.clientWidth-dgc.clientWidth)/2+document.body.scrollLeft;
    //dgc.style.marginTop=(document.body.clientHeight-dgc.clientHeight)/2+document.body.scrollTop;
    //var sClientWidth = document.body.clientWidth;
    //var sClientHeight = document.body.clientHeight;


    
    //var sScrollTop = (document.body.clientHeight-dgc.clientHeight)/2+document.body.scrollTop;    
    //var iTop = sScrollTop + 80;
    //var sTop = iTop > 0 ? iTop : 0;

    //dgc.style.marginTop = sTop+"px";
    
   
    

    document.body.appendChild(dgc);
    if (bCancel) document.getElementById("nd-cancel").onclick = function()
    {
      window.neatDialog.close();
    };

    this.elt = dgc;
    window.neatDialog = this;
    
   
    //v/ar divId=document.getElementById('nd_dgc');
    //alert($("#nd_dgc").html());
   // alert(parent.document.body.scrollTop+'---'+divId.clientHeight+"--"+parent.document.documentElement.scrollTop+"==="+divId.top);
    //var sClientHeight = parent.document.body.clientHeight;

  }
}


	function middle(_sId)
	{
		$(_sId)['style']['display'] = '';
		$(_sId)['style']['position'] = "absolute";

		var sClientWidth = parent.document.body.clientWidth;
		var sClientHeight = parent.document.body.clientHeight;
		var sScrollTop = parent.document.body.scrollTop+parent.document.documentElement.scrollTop;

		var sleft = (sClientWidth - $(_sId).offsetWidth) / 2;
		var iTop = sScrollTop + 80;
		var sTop = iTop > 0 ? iTop : 0;

		$(_sId)['style']['left'] = sleft + "px";
		$(_sId)['style']['top'] = sTop + "px";
	}
NeatDialog.prototype.close = function()
{
  if (this.elt)
  {
    this.elt.style.display = "none";
    this.elt.parentNode.removeChild(this.elt);
  }
  window.neatDialog = null;
}

function openDialog1()
  {

var sHTML = '<p>确认删除？</p>'+ '<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';
    new NeatDialog(sHTML, "温馨提示", false);  
}

function openDialog2()
  {

var sHTML = '<p><span>描述：</span><span><textarea name="" cols="20" rows="3">30字以内</textarea></span></p>'+ '<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';
    new NeatDialog(sHTML, "温馨提示", false);
  
}
function openDialog3()
  {
var sHTML = '<p><select name="" size="1"><option>我的同事</option><option>我的同学</option></select></p>'+ 
'<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';

    new NeatDialog(sHTML, "温馨提示", false);
	//alert('12');
}
function openDialog4()
  {

var sHTML = '<p>名称：<input name="" type="text"></p>'+ '<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';
    new NeatDialog(sHTML, "温馨提示", false);
  
}
function openDialog5()
  {

var sHTML = '<p><input id="text" name="" type="text"><select id="select" name="" size="1"><option>我的同事</option><option>我的同学</option></select></p>'+ '<p><button class="btn_enter" value="选择">选择</button></p>'+'<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';
    new NeatDialog(sHTML, "温馨提示", false);
  
}

function openDialog11()
  {

var sHTML = '<p>确认设为头像？'+'<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';
    new NeatDialog(sHTML, "温馨提示", false);
  
}
function openDialog12()
  {

var sHTML = '<p>推荐成功，审核后将在首页显示！'+'<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';
    new NeatDialog(sHTML, "温馨提示", false);
  
}
function agree()
  {

var sHTML = '<p>确认同意！'+'<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';
    new NeatDialog(sHTML, "温馨提示", false);
  
}
function deny()
  {

var sHTML = '<p>确认拒绝！'+'<p><button onclick="window.neatDialog.close()" class="btn_enter" value="确定">确定</button>&nbsp;<button onclick="window.neatDialog.close()" class="btn_enter" value="取消">取消</button></p>'+ '<p></p>';
    new NeatDialog(sHTML, "温馨提示", false);
  
}