//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
/// version: 0.0.0.19
/// Verified in: IE7, IE8, FF3, Chrome
/////////////////////
/*
	POP UP MANAGER
*/

var Popup = {}

///////////////////////////////////////
/**************************************
LOADING NAMESPACES
**************************************/
///////////////////////////////////////
if (typeof(General) === 'undefined')
{
	var _scriptObj = document.createElement('script');
    _scriptObj.src = 'http://www.girlsense.com/premium/tools/clientScripts/general.js';
    _scriptObj.type = 'text/javascript';
    document.getElementsByTagName('head')[0].appendChild(_scriptObj);
}

if (typeof(EVENTS) === 'undefined')
{
	var _scriptObj = document.createElement('script');
    _scriptObj.src = 'http://www.girlsense.com/premium/tools/clientScripts/events.js';
    _scriptObj.type = 'text/javascript';
    document.getElementsByTagName('head')[0].appendChild(_scriptObj);
}


///////////////////////////////////////
/**************************************
ENUMS
**************************************/
///////////////////////////////////////
Popup.PositionType = 
{
	SELF : 'self',
	RELATIVE : 'relative',
	
	SCREEN_CENTER_TOP : 'sct',	
	SCREEN_CENTER_MIDDLE : 'scm',
	SCREEN_CENTER_BOTTOM : 'scb',
	PAGE_CENTER_TOP : 'pct',	
	PAGE_CENTER_MIDDLE : 'pcm',
	PAGE_CENTER_BOTTOM : 'pcb',
	
	SCREEN_LEFT_TOP : 'slt',
	SCREEN_LEFT_MIDDLE : 'slm',
	SCREEN_LEFT_BOTTOM : 'slb',
	PAGE_LEFT_TOP : 'plt',	
	PAGE_LEFT_MIDDLE : 'plm',
	PAGE_LEFT_BOTTOM : 'plb',
	
	
	SCREEN_RIGHT_TOP : 'srt',	
	SCREEN_RIGHT_MIDDLE : 'srm',
	SCREEN_RIGHT_BOTTOM : 'srb',
	PAGE_RIGHT_TOP : 'prt',	
	PAGE_RIGHT_MIDDLE : 'prm',
	PAGE_RIGHT_BOTTOM : 'prb'
};



///////////////////////////////////////
/**************************************
POPUP CLASS
**************************************/
///////////////////////////////////////
Popup.Popup = function(element, dragElement, positionObject, toShowAlone)
{
	/////////// checking the element and the dragElement parameter ////////////////
	if (typeof(element) === 'string')
		this.popupElement = document.getElementById(element);
	else if (typeof(element) === 'object')
		this.popupElement = element;
	if (typeof(dragElement) === 'string')
		this.dragElement = document.getElementById(dragElement);
	else if (typeof(dragElement) === 'object')
		this.dragElement = dragElement;
		
	/////////// if there is no element, returning ////////////////
	if (this.popupElement === null)
		return null;
		
	this.id = this.popupElement.id;
	this.num = Popup.array.length;
		
	/////////// verifying that the div isn't already a floating div ////////////////
	if(Popup.idArray[this.id] != null)	
		return null;
		
	/////////// checking if there is drag element ////////////////
	if (this.dragElement === null)
	{
		/////////// creating drag element ////////////////
		if (typeof(dragElement) === 'boolean' && dragElement === true)
		{
			/////////// creating the div's drag zone ////////////////
			this.dragElement = document.createElement('div');
			this.dragElement.setAttribute('id',this.id + "_dragDiv");	
			this.dragElement.style.width = "100%";
			this.dragElement.style.height = "20px";
			this.dragElement.style.background = "#eeeeee";
			
			/////////// appending the drag element as the first child of the "floating" div ////////////////
			var childs = new Array();
			var child = this.popupElement.childNodes[0];
			while (typeof(child) !== 'undefined')
			{
				childs.push(child);
				this.popupElement.removeChild(child);
				child = this.popupElement.childNodes[0];
			}
			this.popupElement.appendChild(this.dragElement);
			for (var i=0;i<childs.length;i++)
			{
				this.popupElement.appendChild(childs[i]);
			}
		}
	}
	
	/////////// to show the popup alone? with no other popups? ////////////////
	this.toShowAlone = toShowAlone === true ? true : false;
	
	/////////// if drag element exists ////////////////
	if (this.dragElement !== null)
	{
		/// setting drag to true ///		
		this.isDragged = true;
		
		/// adding a mouse move style to the drag element ///
		this.dragElement.style.cursor = "move";	
		
		/// creating a pointer to the drag element inside the popup element ///
		this.popupElement.dragElement = this.dragElement;
		
		/// Dragging event handlers ///
		this.eventListeners();
	}
	
	/////////// creating a pointer to the object within the popup element ////////////////
	this.popupElement.floatObject = this;
	
	/////////// setting div starting position & style ////////////////
	if (typeof(positionObject) === 'object')
		this.updatePositionType(positionObject);
	else
		return null;
	
	this.popupElement.style.display = "none";
	this.popupElement.style.visibility = "hidden";
	
	/////////// insertting the object to arrays ////////////////
	Popup.array.push(this);
	Popup.idArray[this.id] = 1;
	
	/////////// starting events ////////////////
	this.onBeforeShowEvent = new EVENTS.Event("PopupOnBeforeShow" + this.num);
	this.onAfterShowEvent = new EVENTS.Event("PopupAfterShow" + this.num);
	this.onBeforeHideEvent = new EVENTS.Event("PopupOnBeforeHide" + this.num);
	this.onAfterHideEvent = new EVENTS.Event("PopupOnAfterHide" + this.num);
	
	return this;
}

///////// VARIABLES 
Popup.Popup.prototype.popupElement = null;
Popup.Popup.prototype.dragElement = null;
Popup.Popup.prototype.isDragged = false;
Popup.Popup.prototype.positionType = Popup.PositionType.PAGE_CENTER_MIDDLE;
Popup.Popup.prototype.positionToElement = null;
Popup.Popup.prototype.positionToElementLeft = 0;
Popup.Popup.prototype.positionToElementTop = 0;
Popup.Popup.prototype.toShowAlone = false;
Popup.Popup.prototype.isMouseDown = false;
Popup.Popup.prototype.hasMoved = false;
Popup.Popup.prototype.visible = false;
Popup.Popup.prototype.blockerDivColor = null;
Popup.Popup.prototype.blockerDivOpacity = null;
Popup.Popup.prototype.id = -1;
Popup.Popup.prototype.num = -1;
Popup.Popup.prototype.needBlocker = true;
Popup.Popup.prototype.toAnchorPosition = true;
Popup.Popup.prototype.onBeforeShowEvent = null;
Popup.Popup.prototype.onAfterShowEvent = null;
Popup.Popup.prototype.onBeforeHideEvent = null;
Popup.Popup.prototype.onAfterHideEvent = null;

///////// METHODS
Popup.Popup.prototype.updatePositionType = function(positionObject)
{
	if (typeof(positionObject) === 'object')
	{
		this.positionType = positionObject.type || this.positionType;
		this.positionToElement = positionObject.positionToElement || this.positionToElement;
		this.positionToElementLeft = positionObject.left || 0;
		this.positionToElementTop = positionObject.top || 0;
	}
	
	if (Popup.PositionType !== Popup.PositionType.SELF)
		this.popupElement.style.position = "absolute";
}

Popup.Popup.prototype.eventListeners = function()
{
	//// [drag element onmouedown] ////
	if (this.popupElement.dragElement.addEventListener)
		this.popupElement.dragElement.addEventListener('mousedown', this.onmouseDownHandler, true);
	else if (this.popupElement.dragElement.attachEvent)
		this.popupElement.dragElement.attachEvent('onmousedown', this.onmouseDownHandler);
		
	//// [Element onmouedown] ////
	if (this.popupElement.addEventListener)
		this.popupElement.addEventListener('mousedown', this.onElementMouseDown, true);
	else if (this.popupElement.attachEvent)
		this.popupElement.attachEvent('onmousedown', this.onElementMouseDown);
		
	//// [document onmouseup] ////
	document.onmouseup = function(event4FF)
	{
		var e = event4FF || event; 	// FF/IE
		/////////// removing the document onmousemove event listener  ////////////////
		if (document.removeEventListener)
			document.removeEventListener('mousemove', Popup.Drag.mouseMoveHandler,true);
		else if (document.detachEvent)
			document.detachEvent('onmousemove', Popup.Drag.mouseMoveHandler);
			
		/////////// Clearing focus from dragElement in order to cancel drang * drop issue in Firefox ///////////
		var eventTarget = null;
		if (General.browser === 'ie6' || General.browser === 'ie7' || General.browser === 'ie8')
			eventTarget = e.srcElement;
		else
			eventTarget = e.target;
		
		var popElement = null;
		if (eventTarget !== null)
			popElement = eventTarget.parentNode || null;
		if (popElement !== null && Popup.idArray[popElement.id] === 1)
			popElement.focus();	
	}
}


Popup.Popup.prototype.onElementMouseDown = function(event4FF)
{
	/////////// checking the event object ////////////////
	var e = event4FF || event; 	// FF/IE
	var eventTarget = null;
	var isIE = false;
	if (General.browser === 'ie6' || General.browser === 'ie7' || General.browser === 'ie8')
	{
		eventTarget = e.srcElement;
		isIE = true;
	}
	else
	{
		eventTarget = e.target;
	}
	
	/////////// Setting z-index ////////////////
	var popElement = eventTarget || null;
	if (popElement !== null)
	{
		var isFound = false;
		while (popElement !== null && popElement !== document.body && !isFound)
		{
			popElement = popElement.parentNode || null;
			if (typeof(Popup.idArray[popElement.id]) !== 'undefined')
			{
				if (eventTarget !== popElement.floatObject.popupElement.dragElement)
					isFound = true;
				else
					return;
			}
			
		}
	}
	if (popElement !== null && Popup.idArray[popElement.id] === 1)
	{
		/////////// Setting Z-index ////////////////
		setTimeout(function(){
		Popup.Manager.managePopups(popElement.floatObject);
		},50);
	}
	
}

Popup.Popup.prototype.onmouseDownHandler = function(event4FF)
{
	/////////// checking the event object ////////////////
	var e = event4FF || event; 	// FF/IE
	var eventTarget = null;
	var isIE = false;
	if (General.browser === 'ie6' || General.browser === 'ie7' || General.browser === 'ie8')
	{
		eventTarget = e.srcElement;
		isIE = true;
	}
	else
	{
		eventTarget = e.target;
	}
	
	/////////// Starting the drag only if the click is on the drag div ////////////////
	var popElement = eventTarget || null;
	if (popElement !== null)
	{
		var isFound = false;
		while (popElement !== null && popElement !== document.body && !isFound)
		{
			popElement = popElement.parentNode || null;
			if (typeof(Popup.idArray[popElement.id]) !== 'undefined')
				isFound = true;
		}	
	}
	if (popElement !== null && Popup.idArray[popElement.id] === 1)
	{
		/////////// Saving the current div ////////////////
		Popup.Drag.currentElement = popElement;
		
		/////////// Setting Z-index ////////////////
		setTimeout(function(){
		Popup.Manager.managePopups(popElement.floatObject);
		},50);
		
		/////////// Saving mouse current position ////////////////
		Popup.Drag.cursorX = e.clientX;
		Popup.Drag.cursorY = e.clientY;
		
		/////////// Creating mouse move event listener ////////////////
		if (document.addEventListener)
			document.addEventListener('mousemove', Popup.Drag.mouseMoveHandler, true);
		else if (document.attachEvent)
			document.attachEvent('onmousemove', Popup.Drag.mouseMoveHandler);
			
		/////////// Canceling event bubbling ////////////////
		if (isIE)
			e.cancelBubble = true;
		else
			e.stopPropagation();
	}
	
	/////////// Canceling the selection ////////////////
	if (!isIE)
		return false;
	else
		document.selection.empty();
}

Popup.Popup.prototype.show = function(positionObject)
{
	if (!this.visible)
	{	
		/// updating position type ///
		this.updatePositionType(positionObject);
		
		/// dispatching event ///
		this.onBeforeShowEvent.dispatch();
		
		/// showing popup ///
		this.hasMoved = false;
		if (Popup.idArray[this.id] === 1)
			Popup.Manager.show(this);
			
		/// dispatching event ///
		this.onAfterShowEvent.dispatch();
	}
}

Popup.Popup.prototype.hide = function()
{
	if (this.visible)
	{
		/// dispatching event ///
		this.onBeforeHideEvent.dispatch();
		
		/// showing popup ///
		if (Popup.idArray[this.id] === 1)
			Popup.Manager.hide(this);
			
		/// dispatching event ///
		this.onAfterHideEvent.dispatch();
	}
}

Popup.Popup.prototype.dispose = function()
{
	/////////// removing from popups array ///////////
	var l = Popup.array.length;
	var popedUpArray = new Array();
	for (var i=(l-1);i>this.num;--i)
	{
		popedUpArray.push(Popup.array.pop());
	}
	/////////// pulling out the popup ///////////
	Popup.array.pop();
	
	/////////// inserting in the poped popups ///////////
	var l2 = popedUpArray.length;
	for (var i=0;i<l2;++i)
	{
		Popup.array.push(popedUpArray.pop());	
	}
	
	/////////// disposing events ///////////
	this.onBeforeShowEvent.dispose();
	this.onAfterShowEvent.dispose();
	this.onBeforeHideEvent.dispose();
	this.onAfterHideEvent.dispose();
	
	/////////// removing from id array ///////////
	Popup.idArray[this.id] === null;
}

///////////////////////////////////////
/**************************************
STATIC 
**************************************/
///////////////////////////////////////
Popup.array = new Array();
Popup.idArray = new Array();

///////////////////////////////////////
/**************************************
MANAGER
**************************************/
///////////////////////////////////////
Popup.Manager = {}
Popup.Manager.openedPopups = new Array();
Popup.Manager.show = function(popup)
{
	// showing blocker //
	if (popup.needBlocker)
		Popup.BlockerDiv.show();
	
	// calculating position //
	if (popup.positionType !== Popup.PositionType.SELF)
	{
		var position = Popup.Manager.calcPosition(popup);
		popup.popupElement.style.top = position.top + "px";
		popup.popupElement.style.left = position.left + "px";
	}
	
	// setting open popups //
	Popup.Manager.managePopups(popup);
	
	// showing popup //
	popup.popupElement.style.display = "block";
	popup.popupElement.style.visibility = "visible";
	
	// changing visibility attribute //
	popup.visible = true;
}

Popup.Manager.hide = function(popup)
{
	var l = Popup.Manager.openedPopups.length;
	
	// popping popup out of the opened popups array //
	popup = Popup.Manager._pop(popup);
	
	// hiding popup //
	popup.popupElement.style.display = "none";
	popup.popupElement.style.visibility = "hidden";
	
	// setting the next popup to open //
	Popup.Manager.managePopups();
	
	// changing visibility attribute //
	popup.visible = false;
	
	// hiding screen blocker div //
	if (l == 1)
		Popup.BlockerDiv.hide();
}

Popup.Manager.calcPosition = function(popup)
{
	var position = {left:0, top:0};
	
	// adjusting style //
	popup.popupElement.style.visibility = "hidden";
	popup.popupElement.style.display = "block";
	
	
	// calculating position //
	if (popup.positionType === Popup.PositionType.RELATIVE)
	{
		var _position = General.ObjectPosition.get(popup.positionToElement);
		position.left = _position.x + popup.positionToElementLeft;
		position.top = _position.y + popup.positionToElementTop;
	}
	else
	{
		var positionTypeArr = popup.positionType.split("");
		var sheet = positionTypeArr[0];
		var hor = positionTypeArr[1];
		var ver = positionTypeArr[2];
		
		/////// SHEET ///////
		var sheetX = 0;
		var sheetY = 0;
		if (sheet === 'p') // page
		{
			General.calcPageSize();
			General.calcScreenSize();
			if (General.screenX > General.pageX)
				sheetX = General.screenX;
			else
				sheetX = General.pageX;
			
			if (General.screenY > General.pageY)
				sheetY = General.screenY;
			else
				sheetY = General.pageY;
			
			// updating blocker div's atribute //
			Popup.BlockerDiv.show(sheetX,sheetY);
		}
		else if (sheet === 's') // screen
		{
			General.calcScreenSize();
			sheetX = General.screenX;
			sheetY = General.screenY;	
		}
		
		/////// Horizontal ///////
		var _left = 0;
		if (hor === 'l')
		{
			_left = 0;
		}
		else if (hor === 'c')
		{
			_left = (sheetX/2) - (popup.popupElement.offsetWidth/2);
			if (sheet === 's')
				_left += General.getScrollLeft();
		}
		else if (hor === 'r')
		{
			_left = sheetX - (popup.popupElement.offsetWidth);
			if (sheet === 's')
				_left += General.getScrollLeft();
				
			var isIE = false;
			if (General.browser === 'ie6' || General.browser === 'ie7' || General.browser === 'ie8')
				isIE = true;
				
			// in SCREEN mode the X size doesn't count the scroll bars //
			if (!isIE && sheet === 's')
			{
				General.calcPageSize();
				
				// if there's a scroll
				if (General.pageY > sheetY)
					_left -= 16; // removing scroll width
			}
		}
		
		/////// Vertical ///////
		var _top = 0;
		if (ver === 't')
		{
			_top = 0;
		}
		else if (ver === 'm')
		{
			_top = (sheetY/2) - (popup.popupElement.offsetHeight/2);
			if (sheet === 's')
				_top += General.getScrollTop();
		}
		else if (ver === 'b')
		{
			_top = sheetY - (popup.popupElement.offsetHeight);
			if (sheet === 's')
				_top += General.getScrollTop();
		}
		
		position.left = _left;
		position.top = _top;
	}
	
	if (position.top < 0)
		position.top = 0;
		
	if (position.left < 0)
		position.left = 0;
	
	
	// adjusting style //
	popup.popupElement.style.display = "none";
	popup.popupElement.style.visibility = "visible";
	
	return position;
}

Popup.Manager.managePopups = function(popupParam)
{
	popupParam = popupParam || null; 
	var l = Popup.Manager.openedPopups.length;
	var popup = null;
	
	// hiding the last popup // 
	if (popupParam === null && l === 0)
		return;
	// hiding a popup and there are more popups around //
	else if (popupParam === null)
	{
		// popping last popup //
		popup = Popup.Manager.openedPopups.pop();
		Popup.Manager.openedPopups.push(popup);
	}
	// this a new popup //
	else if ((popup = Popup.Manager._pop(popupParam)) === null )
	{
		popup = popupParam;
		
		// inserting the popup 
		Popup.Manager.openedPopups.push(popup);
		
		// updating length //
		l = Popup.Manager.openedPopups.length; 
	}
	// changing existing popup's z-index //
	else
	{
		// inserting the popup 
		Popup.Manager.openedPopups.push(popup);
	}
	
	// calculating zIndex //
	var totalZIndex = Popup.BlockerDiv.zIndex + l;
	
	// showing current popup //
	popup.popupElement.style.display = "block";
	popup.popupElement.style.visibility = "visible";
	popup.visible = true;
	
	// showing blocker div //
	if (popup.needBlocker)
	{
		Popup.BlockerDiv.show();
		
		// setting blocker div style //
		var blockerColor = popup.blockerDivColor;
		var blockerOpacity = popup.blockerDivOpacity;
		Popup.BlockerDiv.setStyle(blockerColor, blockerOpacity);
	}
	else
		Popup.BlockerDiv.hide();
		
	// setting current popup on top //
	popup.popupElement.style.zIndex = totalZIndex--;
	
	// setting z-indexes //
	var tempPop = null;
	for (var i=(l-2);i>=0;--i)
	{
		tempPop = Popup.Manager.openedPopups[i];
		if (tempPop.num !== popup.num)
		{
			tempPop.popupElement.style.zIndex = totalZIndex--;
			if (popup.toShowAlone || tempPop.toShowAlone)
			{
				tempPop.popupElement.style.visibility = "hidden";
				
				tempPop.visible = false;
			}
		}
	}
}

Popup.Manager._pop = function(popup)
{
	popup = popup || null;
	if (popup === null) return;
	
	var foundPopup = null;
	
	// pulling out current popup //
	var popedUp = null;
	var popedUps = new Array();
	var l = Popup.Manager.openedPopups.length;
	for (var i=0;(i<l && foundPopup === null);i++)
	{
		popedUp = Popup.Manager.openedPopups.pop();
		if (popedUp.num !== popup.num)
			popedUps.push(popedUp)
		else
			foundPopup = popedUp;
	}
	
	// returning all irrelevant poped ups // 
	var l2 = popedUps.length;
	for (var i=0;i<l2;i++)
	{
		popedUp = popedUps.pop();
		Popup.Manager.openedPopups.push(popedUp);
	}
	
	return foundPopup;
}

///////////////////////////////////////
/**************************************
MANAGER - RESIZE
**************************************/
///////////////////////////////////////
Popup.Manager.Resize = {}

Popup.Manager.Resize.set = function()
{
	/////////// Creating mouse move event listener ////////////////
	if (window.addEventListener)
		window.addEventListener('resize', Popup.Manager.Resize.hanlder, true);
	else if (window.attachEvent)
		window.attachEvent('onresize', Popup.Manager.Resize.hanlder);
}

Popup.Manager.Resize.unset = function()
{
	/////////// Creating mouse move event listener ////////////////
	if (window.addEventListener)
		window.removeEventListener('resize', Popup.Manager.Resize.hanlder, true);
	else if (window.attachEvent)
		window.detachEvent('onresize', Popup.Manager.Resize.hanlder);	
}

Popup.Manager.Resize.hanlder = function(event4FF)
{
	////// setting blocker div new position //////
	Popup.BlockerDiv.setSize();
	
	////// setting popups new position //////
	var l = Popup.Manager.openedPopups.length;
	var popup = null;
	for (var i=0;i<l;i++)
	{
		popup = Popup.Manager.openedPopups[i];
		// calculating position //
		if (popup.toAnchorPosition && !popup.hasMoved && popup.positionType !== Popup.PositionType.SELF)
		{
			var position = Popup.Manager.calcPosition(popup);
			popup.popupElement.style.top = position.top + "px";
			popup.popupElement.style.left = position.left + "px";
		}
		if (popup.visible)
			popup.popupElement.style.display = "block";
	}
}

Popup.Manager.Resize.set();

///////////////////////////////////////
/**************************************
BLOCKER
**************************************/
///////////////////////////////////////
Popup.BlockerDiv = {}
Popup.BlockerDiv.divBg = '#000000';
Popup.BlockerDiv.opacity = 40; 
Popup.BlockerDiv.element = null;
Popup.BlockerDiv.zIndex = 5000;
Popup.BlockerDiv.show = function(w,h)
{
	// if the blocker div doesn't exists, creating it //
	if (Popup.BlockerDiv.element === null)
		Popup.BlockerDiv.create();
	
	// setting blocker div size //
	Popup.BlockerDiv.setSize(w,h);
	
	// showing the blocker div //
	Popup.BlockerDiv.element.style.display = "block";
}

Popup.BlockerDiv.setStyle = function(bg, opacity)
{
	bg = bg || Popup.BlockerDiv.divBg;
	opacity = opacity || Popup.BlockerDiv.opacity;
	
	// setting background //
	Popup.BlockerDiv.element.style.backgroundColor = bg;
	
	// setting opacity //
	if (General.browser === 'ie6' || General.browser === 'ie7' || General.browser === 'ie8')
		Popup.BlockerDiv.element.style.filter = "alpha(opacity="+opacity+")";	
	else
		Popup.BlockerDiv.element.style.opacity = (opacity/100);	
	
}

Popup.BlockerDiv.setSize = function(w,h)
{
	if (Popup.BlockerDiv.element == null)
		return;
	
	// resetting the size to 1*1 //
	Popup.BlockerDiv.element.style.width = "1px";
	Popup.BlockerDiv.element.style.height = "1px";
	
	// setting width + height //
	var _w = 0;
	var _h = 0;
	if (w == null || h == null)
	{
		General.calcPageSize();
		General.calcScreenSize();
		if (General.screenX > General.pageX)
			_w = General.screenX;
		else
			_w = General.pageX;
		
		if (General.screenY > General.pageY)
			_h = General.screenY;
		else
			_h = General.pageY;
			
		// if there's a scroll and NOT IE (removing the scroll)
		if (General.browser !== 'ie6' && General.browser !== 'ie7' && General.browser !== 'ie8' && General.pageY > General.screenY)
			_w -= 16; // removing scroll width
	}
	else
	{
		_w = w;
		_h = h;
	}
	Popup.BlockerDiv.element.style.width = _w + "px";
	Popup.BlockerDiv.element.style.height = _h + "px";
}


Popup.BlockerDiv.hide = function()
{
	Popup.BlockerDiv.element.style.display = "none";
}

Popup.BlockerDiv.create = function()
{
	var _div = document.createElement('div');
	_div.setAttribute('id','PopupManagerBlock');
	
	// setting some style //
	_div.style.display = "none";
	_div.style.position = "absolute";	
	_div.style.top = 0;	
	_div.style.left = 0;
	_div.style.backgroundImage = 'none';
	_div.style.zIndex = Popup.BlockerDiv.zIndex;
		
	// appending //
	document.body.appendChild(_div);
	
	// saving pointer //
	Popup.BlockerDiv.element = _div;
	
	// setting opacity and bg style //
	Popup.BlockerDiv.setStyle();
	
}


///////////////////////////////////////
/**************************************
DRAG HANLDER
**************************************/
///////////////////////////////////////
Popup.Drag = {}

Popup.Drag.currentElement = null;
Popup.Drag.cursorX = 0;
Popup.Drag.cursorY = 0;

Popup.Drag.mouseMoveHandler = function(event4FF)
{
	var e = event4FF || event; 	// FF/IE
	
	General.calcPageSize();
	General.calcScreenSize();
	var maxW, maxH;
	if (General.screenX > General.pageX)
		maxW = General.screenX;
	else
		maxW = General.pageX;
	
	if (General.screenY > General.pageY)
		maxH = General.screenY;
	else
		maxH = General.pageY;
	
	var moveByX = e.clientX - Popup.Drag.cursorX;
	var moveByY = e.clientY - Popup.Drag.cursorY;

	/////////// setting hasMoved flag to true ///////////
	Popup.Drag.currentElement.floatObject.hasMoved = true;
		
	/////////// Calculating next element position in the page ////////////////
	var futureLeftXPos = Popup.Drag.currentElement.offsetLeft + moveByX;
	var futureRightXPos = Popup.Drag.currentElement.offsetLeft + Popup.Drag.currentElement.offsetWidth + moveByX;
	var futureTopYPos = Popup.Drag.currentElement.offsetTop + moveByY;
	var futureBottomYPos = Popup.Drag.currentElement.offsetTop + Popup.Drag.currentElement.offsetHeight + moveByY;
	
	if ((futureRightXPos <= maxW && futureLeftXPos >= 0) && (futureBottomYPos <= maxH && futureTopYPos >= 0))
	{
		Popup.Drag.cursorX = e.clientX;
		Popup.Drag.cursorY = e.clientY;
		Popup.Drag.currentElement.style.left = (Popup.Drag.currentElement.offsetLeft + moveByX) + "px";
		Popup.Drag.currentElement.style.top = (Popup.Drag.currentElement.offsetTop + moveByY) + "px";
	}
	
	
	/////////// Is Internet Explorer? ////////////////
	var isIE = false;
	if (General.browser === 'ie6' || General.browser === 'ie7' || General.browser === 'ie8')
	{
		isIE = true;
	}
	
	/////////// Canceling event bubbling ////////////////
	if (isIE)
		e.cancelBubble = true;
	else
		e.stopPropagation();
		
	/////////// Canceling the selection ////////////////
	if (!isIE)
		return false;
	else
		document.selection.empty();
}





