// JavaScript Document - universal menu position and visibility engine (no blur and size listener!!)


function letsLogin(){
	getheight($('#FloatMask'),$('#maindiv'));
	showhidediv($('#FloatMask'),$('#logincontainer'));
	focusobj($('#email'));
	
	$('#FloatMask').style.width = '100%';
	$('#logincontainer').style.top = '50%';
	$('#logincontainer').style.left = '50%';

}

function floatmaskkill(){
	$('#FloatMask').style.height = 0;
	$('#FloatMask').style.width = 0;
}


function setback(){
	$('#logincontainer').style.top = '-50%';
	$('#logincontainer').style.left = '-50%';
}



//login form appeare and dissappeare
/*function showhidediv(obj,objTwo) {
	obj.style.visibility = obj.style.visibility=='' || obj.style.visibility=='hidden' ? 'visible' : 'hidden';
	objTwo.style.visibility = objTwo.style.visibility=='' || objTwo.style.visibility=='hidden' ? 'visible' : 'hidden';
}*/
function showhidediv(obj,objTwo) {
	obj.style.display = obj.style.display=='' || obj.style.display=='none' ? 'block' : 'none';
	objTwo.style.display = objTwo.style.display=='' || objTwo.style.display=='none' ? 'block' : 'none';
}


//for language and country dropdowns

function showhide(obj, objct, num)
{
	main.visTogg(objct);
	setLyr(obj,objct,num);
}



function setLyr(obj,lyr, num)
{
	var coors = findPos(obj);
	if (lyr == lyr) {coors[1] += num;}
	lyr.style.top = coors[1] + 'px';
	lyr.style.left = coors[0] + 'px';
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


//function for dissapearing div if clicked elsewhear

function focusobj(o){o.focus()}


// testzone

function getheight(obj,heighter) {
	myHeight = heighter.clientHeight;
	obj.style.height = myHeight+'px';
}

/*function setCont(objc,evt){
		showhide(objc,$('#contrmenucont'),7);
		main.addEvent(document, "mouseup", chekWereClicked);
	}*/

function chekWereClicked(evt){
	if (!checker(main.getTargetElement(evt),$('#contrmenu *,#contrmenu'))) {
		main.removeEvent(document, "mouseup",chekWereClicked);
		main.visTogg($('#contrmenucont'))
		}
	}

function chekWereClicked2(evt){
	if (!checker(main.getTargetElement(evt),$('#langmenu *,#langmenu'))) {
		main.removeEvent(document, "mouseup",chekWereClicked2);
		main.visTogg($('#langmenucont'))
		}
	}


  
function  menuStart(){
	$('#contrselect').onclick = function(){
		showhide(this,$('#contrmenucont'),7);
		main.addEvent(document, "mouseup", chekWereClicked);
		}
	$('#langselect').onclick = function(){
		showhide(this,$('#langmenucont'),1);
		main.addEvent(document, "mouseup", chekWereClicked2);
		}
	}
	
function loginFormInit(){
	$('#blockshadow div.close').onmousedown = function(){showhidediv($('#logincontainer'),$('#FloatMask')); setback();}
	$('#FloatMask').onmousedown = function(){showhidediv($('#logincontainer'),$('#FloatMask')); setback();}
	}

