function gv(id)
{
   var el = $(id);
   if (el) return el.value;
}

function sv(id, value)
{
   var el = $(id);
   if (el) el.value = value;
}

function scon(id, content)
{
   var el = $(id);
   if (el) el.innerHTML = content;
}

function gcon(id)
{
   var el = $(id);
   if (el) return el.innerHTML;
}

function rep(id, content)
{
   var el = $(id);
   if (el)
   {
      var cnt = document.body.innerHTML;
      var pos = cnt.indexOf(el.innerHTML);
      document.body.innerHTML = cnt.substr(0, pos) + content + cnt.substr(pos + el.innerHTML.length);
   }
}

function replaceClass(id, class1, class2)
{
   var el = $(id);
   if (el)
   {
   	  if (el.className == class1) el.className = class2;
   	  else el.className = class1;
   }
}

function display(id, disp)
{
   var el = $(id);
   if (el)
   {
   	  if (disp != undefined) el.style.display = disp;
   	  else
   	  {
   	     if (el.style.display == 'none') el.style.display = '';
   	     else el.style.display = 'none';
   	  }
   }
}

function checkAll(form, checked)
{
   var objForm;
   if (typeof(form) == "string") objForm = $(form);
   else objForm = form;
   var elements = objForm.getElements('input');
   for (var i = 0; i < elements.length; i++)
   {
      if (elements[i].type == 'checkbox') elements[i].checked = checked;
   }
}

function megaFormStart(formid, fadeid, top, zindex, left, opacity)
{
   var fade = $(fadeid);
   if (!fade) return;
   var size = getPageSize(); //(new Element(document.body)).getSize()['size'];
   if (typeof(hideBadElement) == 'function') hideBadElement();
   if (zindex) fade.style.zIndex = zindex; else fade.style.zIndex = '9';
   fade.style.position = 'absolute';
   fade.style.top = 0;
   fade.style.left = 0;
   fade.style.background = 'black';
   fade.style.width = size[0] + 'px';
   fade.style.height = size[1] + 'px';
   fade.style.display = '';
   if (opacity == 1) fade.className = 'fadeoutblackclass';
   var form = $(formid);
   if (!form) return;
   var y = 50;
   if (top) y = (window.getHeight() - top) / 2;
   if (zindex) form.style.zIndex = zindex + 1; else form.style.zIndex = '25';
   form.style.position = 'absolute';
   form.style.top = window.getScrollTop() + y + 'px';
   if (left) form.style.left = left; else form.style.left = 0;
}

function updateFadeHeight(fadeid)
{
   var fade = $(fadeid);
   if (!fade) return;
   var size = getPageSize();
   fade.style.height = size[1] + 'px';
}

function megaFormFinish(formid, fadeid)
{
   var fade = $(fadeid);
   if (!fade) return;
   var form = $(formid);
   if (!form) return;
   display(fadeid);
   form.style.top = -100000 + 'px';
   if (typeof(showBadElement) == 'function') showBadElement();
}

function showMenu(menuid, divid)
{
   var menu = $(menuid);
   var div = $(divid);
   if (menu == undefined || div == undefined) return;
   var size = menu.getSize()['size'];
   var coor = menu.getCoordinates();
   div.style.top = coor.top + size['y'];
   div.style.left = coor.left;
   div.style.visibility = 'visible';
}

function shBlock(menuid, divid)
{
   var menu = $(menuid);
   var el = $(divid);
   if (menu == undefined || el == undefined) return;
   var size = menu.getSize()['size'];
   var coor = menu.getCoordinates();
   el.style.zIndex = '999999999';
   el.style.position = 'absolute';
   el.style.top = coor.top + size['y'] + 'px';
   el.style.left = coor.left + 'px';
   display(divid);
}

function getPageSize()
{
   var xScroll,yScroll;
   if (window.innerHeight&&window.scrollMaxY)
   {
      xScroll=document.body.scrollWidth;
      yScroll=window.innerHeight+window.scrollMaxY;
   }
   else if (document.body.scrollHeight>document.body.offsetHeight)
   {
      xScroll=document.body.scrollWidth;
      yScroll=document.body.scrollHeight;
   }
   else
   {
      xScroll=document.body.offsetWidth;
      yScroll=document.body.offsetHeight;
   }
   var windowWidth,windowHeight;
   if (self.innerHeight)
   {
      windowWidth=self.innerWidth;
      windowHeight=self.innerHeight;
   }
   else if (document.documentElement&&document.documentElement.clientHeight)
   {
      windowWidth=document.documentElement.clientWidth;
      windowHeight=document.documentElement.clientHeight;
   }
   else if(document.body)
   {
      windowWidth=document.body.clientWidth;
      windowHeight=document.body.clientHeight;
   }
   if (yScroll<windowHeight)
   {
      pageHeight=windowHeight;
   }
   else
   {
      pageHeight=yScroll;
   }
   if (xScroll<windowWidth)
   {
      pageWidth=windowWidth;
   }
   else
   {
      pageWidth=xScroll;
   }
   var test1=document.body.scrollHeight;
   var test2=document.body.offsetHeight;
   if (test1>test2)
   {
      x=document.body.scrollWidth;
      y=document.body.scrollHeight;
   }
   else
   {
      x=document.body.offsetWidth;
      y=document.body.offsetHeight;
   }
   arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
   return arrayPageSize;
}

function tabSwitcher(tabID,divID,num) {
	var menuTabs = $(tabID).getElementsByTagName('SPAN');
	var Tabs = getElementsByClassName(divID);

	for (var i=0;i<menuTabs.length;i++) {
		menuTabs[i].className = 'tabMenu';
		Tabs[i].style.display = 'none';
	}

	menuTabs[num].className = 'tabMenu_Mark';
	Tabs[num].style.display = '';
}

/*function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}*/