﻿
//*********************************Div层*********************************//
Global = new Object();
Global.__UniqueID = 0;
Global.GetUniqueID = function(){ return "__MT_UID_" + Global.__UniqueID ++;};
function Dialog(title,icon,body){
 this.Icon = icon || "";
 this.Title = title || "易招网";
 this.Body = body || "Blank Document";
 this.UniqueID = Global.GetUniqueID();
 //////////////////////////////////////
 this.Width = 350;
 this._mousedown = false;
 this._offsetX = 0;
 this._offsetY = 0;
 this._x = 0;
 this._y = 0;
 var i,l;
 //////////////////////////////////////
 this.SetRect = function(_width,_top,_left){
  var obj;
  if(_width > 200) this.Width = _width;
  this._x = _left;
  this._y = _top;
  obj = document.getElementById(this.UniqueID);
  if(obj){
   obj.style.width = this.Width;
   obj.style.top = _top;
   obj.style.left = _left;
  }
 }
 this.SetIndex = function(index){
  if(isNaN(index)) return;
  var obj = document.getElementById(this.UniqueID);
  if(obj) obj.style.zIndex = index;
 }
 this.BindEvent = function(){
  var self = this,obj = null;
  var table = document.getElementById(this.UniqueID);
  if((null == table)||(table.tagName != "TABLE")) return;
  if(table.rows&&table.rows[0].cells&&table.rows[0].cells[0]&&table.rows[0].cells[0].firstChild){
   obj = table.rows[0].cells[0].firstChild;
   obj.rows[0].cells[2].lastChild.onclick = function(e){
    var obj = document.getElementById(self.UniqueID);
    if(obj) obj.parentNode.removeChild(obj);
    parent.document.getElementById("mydiv").parentNode.removeChild(parent.document.getElementById("mydiv"));
   }
   obj.rows[0].cells[2].firstChild.onclick = function(e){
    e = window.event || e;
    var obj = document.getElementById(self.UniqueID);
    if(obj&&obj.rows&&obj.rows.length){
     with(obj.rows[1].style){
      display = display == "" ? "none" : "black";
     }
    }
    obj = (e.target || e.srcElement);
    if(obj.on == "true"){
     obj.on = "false";
     obj.src = "";
    }
    else{
     obj.on = "true";
     obj.src = "images/bt_close.gif";
    }
   }
   if(obj.rows&&obj.rows[0].cells&&obj.rows[0].cells[0].firstChild) obj = obj.rows[0].cells[0].firstChild;
   obj.onmousedown = function(e){
    e = window.event || e;
    if(e.cancelBubble) e.cancelBubble();
    //Firefox....
   };
   obj.ondblclick = function(){self.Close();};
   table.onmousedown = function(){
    var obj;
    if(Dialog.ObjectRef&&(this != Dialog.ObjectRef)){
     obj = document.getElementById(Dialog.ObjectRef.UniqueID);
     if(obj){
      obj.style.borderColor = "#cccccc";
      obj.style.zIndex = 90;
      obj.rows[0].cells[0].firstChild.rows[0].cells[0].firstChild.src = "images/window_blur.gif";
     }
    }
    obj = document.getElementById(self.UniqueID);
    if(obj){
     obj.style.borderColor = "lightblue";
     obj.style.zIndex = 99;
     obj.rows[0].cells[0].firstChild.rows[0].cells[0].firstChild.src = "images/window.gif";
    }
    Dialog.ObjectRef = self;
   }
  }
  if(table.rows){
   table.rows[0].cells[0].firstChild.rows[0].cells[1].onmousedown = function(e){
    var obj;
    e = window.event || e;
    self._dragable = true;
    obj = document.getElementById(self.UniqueID);
    if(null == obj) return;
    self._x = e.clientX;
    self._y = e.clientY;
    self._offsetX = parseInt(obj.style.left);
    self._offsetY = parseInt(obj.style.top);
   }
   table.onmouseover = function(e){
    e = window.event || e;
    var obj = document.getElementById(self.UniqueID);
    if(obj) obj.style.cursor = "default";
    
   };
   table.onmouseup = function(e){
    var obj;
    e = window.event || e;
    self._dragable = false;
    obj = document.getElementById(self.UniqueID);
    if(obj) obj.style.cursor = "default";
   }
   table.rows[0].ondblclick = function(e){
    obj = document.getElementById(self.UniqueID);
    if(null == obj) return;
    if(obj.rows&&(obj.rows.length > 1)){
     with(obj.rows[1].style){
      display = display == "" ? "none" : "block";
      obj = obj.rows[0].cells[0].firstChild.rows[0].cells[2].firstChild;
      obj.src = obj.on == "true" ? "" : "images/bt_close.gif";
      obj.on = obj.on == "true" ? "false" : "true";
     };
    }
   }
  }
 }
 this.Close = function(){
  var table = document.getElementById(this.UniqueID);
  if(table)
  { 

	 table.parentNode.removeChild(table); 
	
	
  }
  
 }
 this.toString = function(){
  var shtml = '';
  shtml += '<table title="鼠标按住标题栏,可以随意拖动哦" cellpadding="0" cellspacing="0" border="1" onselectstart="return false;" oncontextmenu="return false;" ondragstart="return false;" bgcolor="#ffffff" id="' + this.UniqueID + '" style="border:solid 1px #cccccc;cursor:default;width:' + (this.Width) + 'px;position:absolute;top:' + this._y + 'px;left:' + this._x + 'px;">';
  shtml += '<tr><td style="border:0px;"><table cellpadding="0" cellspacing="0" border="0"  height="33" width="100%" background="images/tittle_msg.gif"><tr><td width="20"><img src="'+ this.Icon + '" width="0" height="0"/></td><td align="left" style="height:32px;margin-top:1px">'+ this.Title+'</td><td width="32"><img src="" height="0" width="0" title="最小化" on="false" hspace="1" onmouseover="style.borderColor=\'lightblue\'" style="border:solid 1px #ffffff;display:none" onmouseout="style.borderColor=\'#ffffff\'"/><img src="images/bt_close.gif"  width="16" height="16" title="关闭" style="border:solid 1px #ffffff;cursor:pointer" onmouseover="style.borderColor=\'lightblue\'" onmouseout="style.borderColor=\'#ffffff\'"/></td></tr>';
  shtml += '</table></td></tr>';
  shtml += '<tr style="display:block;"><td valign="top">' + this.Body + '</td></tr>';
  shtml += '</table>';
  return shtml;
 }
}
document.onmousemove = function(e){
 var _x,_y,obj;
 e = window.event || e;
 if(null == Dialog.ObjectRef) return;
 obj = document.getElementById(Dialog.ObjectRef.UniqueID);
 if(null == obj) return;
 if(Dialog.ObjectRef._dragable){
  obj.style.top = Dialog.ObjectRef._offsetY + e.clientY - Dialog.ObjectRef._y;
  obj.style.left = Dialog.ObjectRef._offsetX + e.clientX - Dialog.ObjectRef._x;
  obj.style.cursor = "move";
 }
}

Dialog.ObjectRef = null;

//*********************************反馈层*********************************//

function openFeedback()
{
	var url = "FeedbackAjax.aspx?action=1";
	new Ajax.Request(url,{method:'post',onComplete:GetAction});
}

function GetAction(originalRequest)
{
	var type = originalRequest.responseText;
	if(type == "a")
	{
	
		createDiv1("Feedback_2.htm");
	}
	else
	{
		createDiv1("Feedback_3.htm");
	}
   
}


function createDiv1(freamurl)
{

	var div = null;
	var divmsg = null;
	var doc = document; //遮罩层iframe页面地址

	/**************************/
	//遮罩层
	div = doc.createElement("DIV");
	div.id = "mydiv";
	div.style.zIndex = "1000";
	div.style.left = "0px";
	div.style.top = "0px";
	var height = doc.documentElement.scrollHeight;
	var width = doc.body.clientWidth;
	div.style.width = width;
	div.style.height = height;
	div.style.position = "absolute";
	div.style.backgroundColor = "#ccc";
	div.style.filter = "alpha(opacity=70)";
	div.innerHTML = "<iframe width=\""+width+"\" frameborder=\"0\"  scrolling=\"no\" src=\""+"zhezhao.htm"+"\" height=\""+height+"\"></iframe>";
	$("div01").appendChild(div);
	/**************************/
	divMsg = doc.createElement("DIV");
	divMsg.style.zIndex = "1001";
	divMsg.style.left =  ((document.body.clientWidth-350) / 2)+ "px"; 
	divMsg.style.top = ((screen.height-400)/2 )+ document.documentElement.scrollTop + "px";	
	divMsg.style.position = "absolute";	
	var dialog5 = new Dialog("<div class=\"txt f_black_14b txt_l\">易招网 意见反馈</div>",null,"<iframe width=\"350\" scrolling=\"no\" height=\"157\" frameborder=\"0\" src=\""+freamurl+"\"></iframe>");
	
	divMsg.innerHTML = dialog5;
	$("div01").appendChild(divMsg); 
	dialog5.BindEvent();
	dialog5.SetIndex(2);
	dialog5.SetRect(350,100,250);
}