function getAbsolutePos(el)
{
   var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent)
   {
       var tmp = getAbsolutePos(el.offsetParent);
       r.x += tmp.x;
       r.y += tmp.y;
   }
   return r;
}


function show_menu(m){
	c=document.getElementById('menu'+m);
	a=document.getElementById('mnu'+m);
	b=document.getElementById('logotbl');
	pos = getAbsolutePos(b);
	c.style.display="block";
	a.style.display="block";
	a.style.left=pos.x;
	p=document.getElementById('poser'+m);
	posc = getAbsolutePos(p);
	c.style.left=posc.x;
	a.style.top=posc.y-10;
	c.style.width="50px";
	c.style.height="40px";
}

function hide_menu(m){
	a=document.getElementById('menu'+m);
	a.style.display="none";
	a=document.getElementById('mnu'+m);
	a.style.display="none";
}

function ShoworHide(b){
	if (document.getElementById('menu'+b).style.display=='block'){
		document.getElementById('menu'+b).style.display='none';
	}
	else{
		for (x=1; x<=10; x++){
			if (a=document.getElementById('menu'+x)){
				a.style.display='none';
			}
		}
		document.getElementById('menu'+b).style.display='block';
	}
}

function screenSize() {
      var w, h;
      w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
      h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
      return {w:w, h:h};
}

/* Array.shuffle( deep ) - перемешать элементы массива случайным образом

deep - необязательный аргумент логического типа, указывающий на то, 
       нужно ли рекурсивно обрабатывать вложенные массивы;
       по умолчанию false (не обрабатывать)
*/
Array.prototype.shuffle = function( b )
{
 var i = this.length, j, t;
 while( i ) 
 {
  j = Math.floor( ( i-- ) * Math.random() );
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }

 return this;
};

function deltextfromsubmit(inp){
	if(inp.value=='Submit email for gallery updates'){
		inp.value='';
	}
}
function instexttosubmit(inp){
	if(inp.value==''){
		inp.value='Submit email for gallery updates';
	}
}