﻿function ShowDiv(divid)
{
    if(document.getElementById("CourseCollection"+divid))
	{
	    var obj = document.getElementById("CourseCollection"+divid);
		obj.style.display = "block";
		//alert(obj.offsetLeft+'-'+obj.offsetTop);
	}
	else
	{
	    var object = document.getElementById("href"+divid);
	    
		var ttop  = object.offsetTop;     //TT控件的定位点高
		var thei  = object.clientHeight;  //TT控件本身的高
		var tleft = object.offsetLeft;    //TT控件的定位点宽
		var ttyp  = object.type;          //TT控件的类型
		while (object = object.offsetParent){ttop+=object.offsetTop; tleft+=object.offsetLeft;}
	
	  var s = window.document.createElement("DIV"); 
	  s.id = "CourseCollection"+divid;
	  s.name = "CourseCollection"+divid;
	  s.align = "center";      
	  s.style.position="absolute";
	  s.style.width = 250 +"px";
	  //alert(parseInt(tleft) + parseInt(s.style.width));
	  if((parseInt(tleft) + parseInt(s.style.width)) > document.body.clientWidth)
	  {
	    var w = (parseInt(window.screen.width) - parseInt(document.body.clientWidth))/2;
	    w = parseInt(document.body.clientWidth) - w - parseInt(s.style.width);
	    //alert(w);
	     s.style.left = w;
	  }
	  else
	  {
	     s.style.left = tleft;	
	  }
	 
	 
	  //alert(document.body.clientWidth+"-"+document.body.offsetWidth +"-"+window.screen.width+"-"+window.screen.availWidth );
	  s.style.top = (ttyp=="image")? ttop+thei : ttop+thei+13;  
	 
	 
      s.style.backgroundColor = "#f6f6f6";
	  s.style.border = "black 0px solid";
	  s.style.zIndex=1000;  
	  s.style.display="block";  
	  s.onmouseover = Function("this.style.display = 'block';");
	  s.onmouseout = Function("HiddeDiv("+divid+")");
	  s.innerHTML= "正在加载...";
	  document.body.appendChild(s);
	  GetCourseInfo(divid);
	}
	
}
function GetCourseInfo(divid)
{
	 $.ajax({
            type: "GET",//使用get方法访问后台
            url: "/common/GetCourseInfoByMenuID.aspx",//要访问的后台地址
            data: "mid="+divid,
            success: function(response)
                    {
                        document.getElementById("CourseCollection"+divid).innerHTML=response;
                    } 
           });

}
function HiddeDiv(divid)
{
    if(document.getElementById("CourseCollection"+divid))
	{
		document.getElementById("CourseCollection"+divid).style.display = "none";
	}
}