// JavaScript Document
function FormPopUp()
{
	this.SF = null;
	this.TA = null; 
	this.durrationAnimation = 1;
	this.popUpForm = null;
	
	this.Show = function()
	{
		if(this.popUpForm == null)alert('this.popUpForm == null');
		if(document.getElementById('SFMENU2_bg') == null)alert('SFMENU2_bg == null');
		this.popUpForm.style.display = '';
		this.centerTheForm();
		this.popUpForm.style.visibility = 'visible';
		document.getElementById('SFMENU2_bg').style.visibility = 'visible';
		
		document.getElementById('SFMENU2_HH_forms_T_S_TF').className = 'flexcroll';
	}
	this.Close = function()
	{
		if(this.popUpForm == null)alert('this.popUpForm == null');
		if(document.getElementById('SFMENU2_bg') == null)alert('SFMENU2_bg == null');
		
		this.popUpForm.style.visibility = 'hidden';
		this.popUpForm.style.display = 'none';
		document.getElementById('SFMENU2_bg').style.visibility = 'hidden';
		
		document.getElementById('SFMENU2_HH_forms_T_S_TF').className = '';
	}
	this.centerTheForm = function()
	{
		if(this.popUpForm == null)alert('this.popUpForm == null');
		var windowW = obj_PositionsAndSizes_in_differentbrowsers.windowGetSizeVariables().width;
		var windowH = obj_PositionsAndSizes_in_differentbrowsers.windowGetSizeVariables().height;
		var windowFormsW = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.popUpForm).width; 
		var windowFormsH = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.popUpForm).height;
		if(windowFormsH == 0)windowFormsH=575;
		if(windowFormsW == 0)windowFormsW=840;
		var pozX = (parseFloat(windowW)-parseFloat(windowFormsW))/2;
		var pozY = (parseFloat(windowH)-parseFloat(windowFormsH))/2;
		//alert(windowW+' '+windowH+' '+windowFormsW+' '+this.popUpForm);
		
		/*
		document.getElementById('holderAllMENUPopUpForms_transparentWhiteBG').style.width = windowW+'px';
		document.getElementById('holderAllMENUPopUpForms_transparentWhiteBG').style.height = windowH+'px';
		*/
		
		this.popUpForm.style.left = pozX+'px';
		this.popUpForm.style.top = pozY+'px';
		document.getElementById('SFMENU2_bg').style.left = '0px';
		document.getElementById('SFMENU2_bg').style.top = '0px';
		document.getElementById('SFMENU2_bg').style.width = windowW+'px';
		document.getElementById('SFMENU2_bg').style.height = windowH+'px';
	}
	this.addEventsToTheForms = function(btnClose)
	{
		btnClose.theForm = this;
		btnClose.onclick = function()
		{
			this.theForm.Close();
		}
		document.getElementById('SFMENU2_bg').theForm = this;
		document.getElementById('SFMENU2_bg').onclick = function()
		{
			this.theForm.Close();
		}
		EVENT_ADD.addEvent(this.windowOnResize, 'onresize', window);
	}
	this.windowOnResize = function(e)
	{
		FPU.centerTheForm();
	}
}
function ScrollerForms(roler_,roler__bg_,scroled_form_,visible_form_)
{
	return;
	this.mouseRolerPosition = 0;
	this.rolerMouseIsDown = false;
	this.ROLER_CURRENT_POSITION = 0;
	this.MOUSE_START_POSITION = 0;
	
	this.VARIABLE_SIZE = 'height';
	this.VARIABLE_ARROW_ANODER = 'left';
	this.VARIABLE_ARROW = 'top';
	this.VARIABLE_OSKA = 'ry';
	
	this.roler = roler_;
	this.roler__bg = roler__bg_;
	this.scroled_form = scroled_form_;
	this.visible_form = visible_form_;
	
	this.ROLER_SIZE = 0;
	this.ROLER__BG_SIZE = 0;
	this.SCROLED_FORM_SIZE = 0;
	this.VISIBLE_FORM_SIZE = 0;
	
	this.REFRESH = function()
	{
		this.ROLER_SIZE = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.roler)[this.VARIABLE_SIZE];
		this.ROLER__BG_SIZE = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.roler__bg)[this.VARIABLE_SIZE];
		this.SCROLED_FORM_SIZE = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.scroled_form)[this.VARIABLE_SIZE];
		this.VISIBLE_FORM_SIZE = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.visible_form)[this.VARIABLE_SIZE];
		
		this.roler.style[this.VARIABLE_ARROW] = '0px';
		this.roler.style[this.VARIABLE_ARROW_ANODER] = '0px';
		
		if(parseInt(this.SCROLED_FORM_SIZE)+400 <= parseInt(this.VISIBLE_FORM_SIZE))this.roler__bg.style.visibility = 'hidden';
	}
	this.setTheFormPosition = function()
	{
		/*
		this.ROLER_SIZE = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.roler)[this.VARIABLE_SIZE];
		this.ROLER__BG_SIZE = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.roler__bg)[this.VARIABLE_SIZE];
		*/
		var maxDistance = parseFloat(this.ROLER__BG_SIZE)-parseFloat(this.ROLER_SIZE);
		var currentPosition = parseFloat(obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.roler)[this.VARIABLE_OSKA]);
		var procent=0;
		if(maxDistance != 0)procent = parseFloat(currentPosition)/parseFloat(maxDistance);
		var SIZEFORM = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.scroled_form)[this.VARIABLE_SIZE];
		var SIZEVISIBLEFORM = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.visible_form)[this.VARIABLE_SIZE];
		var maxDIFFForms = (parseFloat(SIZEVISIBLEFORM)-parseFloat(SIZEFORM) - 300)*procent;
		this.scroled_form.style.top = maxDIFFForms+'px';
	}
	this.roler.SF = this;
	this.roler.onmousedown = function()
	{
		SF_SELECTED = this.SF;
		var objRBG = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this.SF.roler__bg);
		var x=objRBG.x,y=objRBG.y,w=objRBG.width,h=objRBG.height;
		var this_RBG = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(this);
		var xbg=objRBG.x,ybg=objRBG.y,wbg=objRBG.width,hbg=objRBG.height;
		SDSD.startDrag(this, new Rectangle(0,0,0, parseInt(h)-parseInt(hbg)));
		EVENT_ADD.addEvent(this.SF.w_onMouseMove, 'onmousemove', document);
		EVENT_ADD.addEvent(this.SF.w_onMouseUP, 'onmouseup', document);
	}
	this.roler.onmouseup = function()
	{
		EVENT_ADD.removeEvent(this.SF.w_onMouseMove, 'onmousemove', document);
		EVENT_ADD.removeEvent(this.SF.w_onMouseUP, 'onmouseup', document);
		SDSD.stopDrag(this);
	}
	this.w_onMouseMove = function(e)
	{
		SF_SELECTED.setTheFormPosition();
	}
	this.w_onMouseUP = function(e)
	{
		EVENT_ADD.removeEvent(SF_SELECTED.w_onMouseMove, 'onmousemove', document);
		EVENT_ADD.removeEvent(SF_SELECTED.w_onMouseUP, 'onmouseup', document);
	}
	this.REFRESH();
}
function StartDragStopDrag()
{
	this.obj = null;
	this.rectangle = null;
	this.OLD_M_X = null;
	this.OLD_M_Y = null;
	this.START_X = null;
	this.START_Y = null;
	
	this.startDrag = function(obj_, rectangle_)
	{
		this.obj = obj_;
		this.rectangle = rectangle_;
		this.addEventsToWindow();
	}
	this.stopDrag = function()
	{
		this.removeEventsFromWindow();
		this.obj = null;
		this.rectangle = null;
		this.OLD_M_X = null;
		this.OLD_M_Y = null;
		this.START_X = null;
		this.START_Y = null;
	}
	
	this.onmousemove_W = function(e)
	{
		var MOUSEPOZ = obj_PositionsAndSizes_in_differentbrowsers.getobjMousePosition(e);
		var OPID = obj_PositionsAndSizes_in_differentbrowsers.getAbsolutePozSizeOfAnHTMLElement(SDSD.obj);
		if(SDSD.OLD_M_X == null)
		{
			SDSD.OLD_M_X = MOUSEPOZ.x;
			SDSD.OLD_M_Y = MOUSEPOZ.y;
			SDSD.START_X = OPID.rx;
			SDSD.START_Y = OPID.ry;
		}
		var diffX = parseInt(MOUSEPOZ.x)- parseInt(SDSD.OLD_M_X);
		var diffY = parseInt(MOUSEPOZ.y)- parseInt(SDSD.OLD_M_Y);
		OPID.x = SDSD.START_X + parseInt(diffX);
		OPID.y = SDSD.START_Y + parseInt(diffY);
		if(parseInt(OPID.x) > parseInt(SDSD.rectangle.w))
		{
			OPID.x = parseInt(SDSD.rectangle.w);
			//document.getElementById('helpDiv').innerHTML += OPID.x +' parseInt(OPID.x) >  ';
		}
		else if(parseInt(OPID.x) < parseInt(SDSD.rectangle.x))
		{
			OPID.x = parseInt(SDSD.rectangle.x);
		}
		if(parseInt(OPID.y) > parseInt(SDSD.rectangle.h))
		{
			OPID.y = parseInt(SDSD.rectangle.h);
		}
		else if(parseInt(OPID.y) < parseInt(SDSD.rectangle.y))
		{
			OPID.y = parseInt(SDSD.rectangle.y);
		}
		SDSD.obj.style.left = OPID.x+'px';
		SDSD.obj.style.top = OPID.y+'px';
	}
	this.onMouseUp_W = function()
	{
		SDSD.stopDrag();
	}
	this.addEventsToWindow = function()
	{	
		if(document.addEventListener != null)
		{
			// e.g. Firefox, Opera, Safari
			document.addEventListener("mousemove", this.onmousemove_W, true);
			document.addEventListener("mouseup", this.onMouseUp_W, true);
		}
		else
		{
			document.attachEvent("onmousemove", this.onmousemove_W);
			document.attachEvent("onmouseup", this.onMouseUp_W);
		}
	}
	this.removeEventsFromWindow = function()
	{
		if(document.removeEventListener != null)
		{
			document.removeEventListener("mousemove", this.onmousemove_W, true);
			document.removeEventListener("mouseup", this.onMouseUp_W, true);
		}
		else if(document.detachEvent != null)
		{
			document.detachEvent("onmousemove", this.onmousemove_W);
			document.detachEvent("onmouseup", this.onMouseUp_W);
		}
	}
}
function Rectangle(x_,y_,w_,h_)
{
	this.x = x_;
	this.y = y_;
	this.w = w_;
	this.h = h_;
}
var SDSD = new StartDragStopDrag();
var SF_SELECTED = null;
var FPU = new FormPopUp();
