/**** Creat by TrungNQ *******/
function Close(CloseBanner) {
    //document.getElementById(CloseBanner).className = "hide";
    $("#" + CloseBanner).hide();
}
var cursor = { x: 0, y: 0 };
var dragobj = null, elm = null, h1, i1, oLeft, oTop;
var cl1 = 2;
function rel(ob) { if (ob) { return document.getElementById(ob) } else { return null } }
function gTxt(ob, txt) { rel(ob).innerHTML = txt; }

function makeObjectToDrag(obj) {
    if (obj != null) {
        dragobj = rel(obj.id);
        document.onmousedown = startMove;
        document.onmouseup = drop;
        document.onmousemove = moving;
    }
}
function startMove(e) {
    if (dragobj != null) {
        getCursorPos(e);
        i1 = cursor.x - dragobj.offsetLeft;
        h1 = cursor.y - dragobj.offsetTop;
        shadow = new Shadow(dragobj.offsetLeft, dragobj.offsetTop, 270, 310);
    }
}
function drop() {
    if (dragobj) {
        elm.className = 'hide';
        elm = null;
        dragobj.style.left = oLeft + 'px';
        dragobj.style.top = oTop + 'px';
        dragobj = null;
    }
}
function getCursorPos(e) {
    e = e || window.event;
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    }
    else {
        var de = document.documentElement;
        var db = document.body;
        cursor.x = e.clientX +
            (de.scrollLeft || db.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY +
            (de.scrollTop || db.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}
function moving(e) {
    getCursorPos(e);
    if (dragobj && elm) {
        oLeft = cursor.x - i1;
        oTop = cursor.y - h1;
        elm.style.left = oLeft + 'px';
        elm.style.top = oTop + 'px';
    }
}
function Shadow(sLeft, sTop, sWidth, sHeight) {
    elm = document.createElement('FavouritePopup');
    document.body.appendChild(elm);
    elm.className = "moving";
    elm.style.left = sLeft + 'px';
    elm.style.top = sTop + 'px';
    elm.style.width = sWidth + 'px';
    elm.style.height = sHeight + 'px';
    elm.focus();
    this.onmousedown = makeObjectToDrag(this.name);
}

/*
* jqDnR-Minimalistic Drag'n'Resize for jQuery.
*
* Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* $Version: 2007.08.19+r2
*/
(function($){
$.fn.jqDrag=function(h){return i(this,h,'d');};
$.fn.jqResize=function(h){return i(this,h,'r');};
$.jqDnR={dnr:{},e:0,
drag:function(v){
if(M.k == 'd')E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});
else E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)});
return false;},
stop:function(){E.css('opacity',M.o);$().unbind('mousemove',J.drag).unbind('mouseup',J.stop);}
};
var J=$.jqDnR,M=J.dnr,E=J.e,
i=function(e,h,k){return e.each(function(){h=(h)?$(h,e):e;
h.bind('mousedown',{e:e,k:k},function(v){var d=v.data,p={};E=d.e;
if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}}
M={X:p.left||f('left')||0,Y:p.top||f('top')||0,W:f('width')||E[0].scrollWidth||0,H:f('height')||E[0].scrollHeight||0,pX:v.pageX,pY:v.pageY,k:d.k,o:E.css('opacity')};
E.css({opacity:0.8});$().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
return false;
});
});},
f=function(k){return parseInt(E.css(k))||false;};
})(jQuery);/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)*/

