﻿var JPos = {};
            (function($)
            {
                $.$getAbsPos = function(p)
                               {
                                   var _x = 0;
                                   var _y = 0;
                                   while(p.offsetParent)
                                   {
                                       _x += p.offsetLeft;
                                       _y += p.offsetTop;
                                       p = p.offsetParent;
                                   }                                  
                                   _x += p.offsetLeft;
                                   _y += p.offsetTop;                                  
                                   return {x:_x,y:_y};
                               };
 
                $.$getMousePos = function(evt)
                                 {
                                     var _x,_y;
                                     evt = evt || window.event;
                                     if(evt.pageX || evt.pageY)
                                     {
                                         _x = evt.pageX;
                                         _y = evt.pageY;
                                     }
                                     else if(evt.clientX || evt.clientY)
                                     {
                                         _x = evt.clientX + document.body.scrollLeft - document.body.clientLeft;
                                         _y = evt.clientY + document.body.scrollTop - document.body.clientTop;
                                     }
                                     else
                                     {
                                         return $.$getAbsPos(evt.target); 
                                     }
                                     return {x:_x,y:_y};
                                }
          })(JPos);
          
function vControl(pChoice,pp,np,obj)
{
    var mPos = JPos.$getMousePos();
    var iPos = JPos.$getAbsPos(arguments[4]);
    if((mPos.x-iPos.x)<(obj.width/2))
    {
        obj.style.cursor="../images/icon/c1.cur";
        if(pChoice=="bclick")
        {
            if(pp != "" && pp !="00000000-0000-0000-0000-0000000000000000")
            {
                window.location.replace("pro.aspx?id=" + pp);
            }
            else
                alert("This is frist!");
        }   
    }
    if((mPos.x-iPos.x)>(obj.width/2))
    {
        obj.style.cursor="../images/icon/c2.cur";
        if(pChoice=="bclick")
        {
            if(np != "" && np != "00000000-0000-0000-0000-0000000000000000")
            {
                window.location.replace("pro.aspx?id=" + np);
            }
            else
                alert("This is last!");
        }
    }
}
