
/************************************************************************
* Remove duplicated item from the list by screening their title.
*/

function RemoveDuplicatedItem( list_id, item_id )
{
    var listobj = document.getElementById(list_id);
    var nodupobj = document.getElementById(item_id);
   RemoveDuplicatedTitle(listobj,nodupobj);
}

function RemoveDuplicatedFirst( list_id, item_id )
{
    var listobj = document.getElementById(list_id);
    var nodupobj = document.getElementById(item_id);
    if(!nodupobj || !listobj) {return;}
    RemoveDuplicatedTitle(listobj,nodupobj.firstChild);
}

/************************************************************************
* Remove a list of items from list by screening their title.
* Parameters:
*       list_id:  the target list
*       noduplist_id:   contain a list of item need to be removed from list_id
*/

function RemoveDuplicatedList( list_id, noduplist_id )
{
    var listobj = document.getElementById(list_id);
    var noduplist = document.getElementById(noduplist_id);
    if(!noduplist || !listobj) {return;}
    for (var ix=0; ix < noduplist.childNodes.length; ix++) 
    {
        var cObj = noduplist.childNodes[ix];
        RemoveDuplicatedTitle(listobj,cObj);
    }
}

function RemoveDuplicatedTitle( listobj, obj )
{
        if (!obj || !listobj) { return; }
        for (var ix=0; ix < listobj.childNodes.length; ix++) 
        {
            var cObj = listobj.childNodes[ix];
            if(cObj.title == obj.title)
            {
                cObj.parentNode.removeChild(cObj);
               break;
            } 
        }
}

function ShowDivPic(obj,Urls,xoff,yoff,imglen)
{
    var Url = Urls.replace("\\","/");
    if ( Url.search("/sysImages/") < 0 )
   {  
        var pos = getPosition(obj)
        var objDiv = document.createElement("div");
        objDiv.className="lionrong";//For IE
        objDiv.id="showpic_id";
        objDiv.style.position = "absolute";
	    var tempheight=pos.y;
	    var tempwidth=pos.x+250;
	    var tempwidth1,tempheight1;
	    var windowwidth=document.body.clientWidth;
	    var content;
    	
        if(Url != "")
        {
            content = "<img src='"+Url+"' border='0' width='" + imglen + "px'/>";
        }
        objDiv.innerHTML = content;
	    if (tempwidth>windowwidth)
	    {
		    tempwidth1=tempwidth-windowwidth
		    objDiv.style.left = (pos.x-tempwidth1) + "px";
	    }
	    else
	    {
		    objDiv.style.left = (pos.x+xoff) + "px";
	    }
        objDiv.style.top = (pos.y+yoff) + "px";
        objDiv.style.display = "";
        document.body.appendChild(objDiv);
   } 
}

function hiddDivPic()
{
    var objDiv = document.getElementById("showpic_id");
    if (objDiv!=null&&objDiv!="undefined")
    {
       document.body.removeChild(objDiv);
    }
}

position = function(x,y)
{
    this.x = x;
    this.y = y;
}

getPosition = function(oElement)
{
    var objParent = oElement
    var oPosition = new position(0,0);
    while (objParent.tagName != "BODY")
    {
        oPosition.x += objParent.offsetLeft;
        oPosition.y += objParent.offsetTop;
        objParent = objParent.offsetParent;
    }
    return oPosition;
} 
