﻿function Class(cid,cname)
{
    this.classid = cid;
    this.classname = cname;
}

function Item(iid,iname,cid)
{
    this.itemid=iid;
    this.itemname=iname;
    this.classid=cid;
}

//创建层函数
function getElem(ElemID,ElemType,Parent)
{
    if(!document.getElementById(ElemID))
    { 
        var newNode=document.createElement(ElemType);
        newNode.setAttribute("id",ElemID);
        Parent.appendChild(newNode);  
    }
    return document.getElementById(ElemID);
}

function openWindow(url)
{
    var frmNew;
    frmNew = document.getElementById("frmNew");
    if(!frmNew){ frmNew = getElem("frmNew","form",document.body); }
    
    frmNew.action = url;
    frmNew.method = "post";
    frmNew.target = "_blank";
    frmNew.submit();
}

function getInt(pxNum)
{
    return parseInt(pxNum.replace("px",""));
} 

//取得层offsetTop
function getObjTop(e){
  var t=e.offsetTop;
  while(e=e.offsetParent){
    t+=e.offsetTop;
    }
  return t;
  } 
  
//取得层offsetLeft
function getObjLeft(e){
  var l=e.offsetLeft;
  while(e=e.offsetParent){
    l+=e.offsetLeft;
    }
    return l;
  }
  
var pX,pY;
var curMoveObj=null;
var curMoveIframe=null;

window.onmouseup = function(){
    if(curMoveObj != null)
    {
        curMoveObj.style.opacity=1;
        curMoveObj=null;
        curMoveIframe=null;
    }
}

window.onmousemove = function(evt){
    var curX, curY;
    curX = evt.pageX-pX;
    curY = evt.pageY-pY;
    
    if(curMoveObj != null)
    {
        if(curX<0) curMoveObj.style.left = "0px";
        else if(curX>document.body.clientWidth-curMoveObj.offsetWidth) curMoveObj.style.left = (document.body.clientWidth - curMoveObj.offsetWidth) + "px";
        else curMoveObj.style.left = curX + "px";
        
        if(curY<0) curMoveObj.style.top = "0px";
        else if(curY>document.body.scrollHeight-curMoveObj.offsetHeight) curMoveObj.style.top = (document.body.scrollHeight - curMoveObj.offsetHeight) + "px";
        else curMoveObj.style.top = curY + "px";
        
        curMoveObj.style.opacity=.7;
    }
    
    if(curMoveIframe != null)
    {
        if(curX<0) curMoveIframe.style.left = "0px";
        else if(curX>document.body.clientWidth) curMoveIframe.style.left = document.body.clientWidth + "px";
        else curMoveIframe.style.left = curX + "px";
        
        if(curY<0) curMoveIframe.style.top = "0px";
        else if(curY>document.body.scrollHeight) curMoveIframe.style.top = document.body.scrollHeight + "px";
        else curMoveIframe.style.top = curY + "px";
        
        curMoveIframe.style.opacity=0;
    }
}