function restore(e) {
    if (e.options[e.selectedIndex].disabled) {
        e.selectedIndex = window.select_current[e.id];
    }
}

function emulate(e) {
    for (var i=0, option; option = e.options[i]; i++) {
        if (option.disabled) {
            option.style.color = "graytext";
        }
        else {
            option.style.color = "menutext";
        }
    }
}

function url(loc) {
    window.location.href = loc;
}

//Rising element
function blend(id) 
{
      if(!el) var el = document.getElementById(id);
      if (el.filters.alpha.opacity < 100) 
      {
      el.filters.alpha.opacity += 5;
      Timer = window.setTimeout('blend("'+ el.id +'")',1);
      } else {
       el.filters.alpha.opacity = 100;
       window.clearTimeout(Timer);
      }
}

function toggle(id) {
    
    var togel = document.getElementById(id);
    
    //togel.style.display = "block" ;    return;
    if (!togel.style.display || togel.style.display=="none") {
        togel.style.display = "block";
        extel.style.display = "block";   
    } else  togel.style.display = "none";
}



function setaction(id,value) {
    var el = document.getElementById(id);
    el.value = value;
}

function chngState(chbox,trg) {
    var tfield = document.getElementById(trg);
    if (chbox.checked) tfield.value="1";
    else tfield.value="0";
}

// TRANSPORT -------------------- 


function togglesketch(obj) {
	var next_cel = false;
	var prev_cel = document.getElementById('c'+parseInt(parseInt(obj.id)-1));
	
	var cel = document.getElementById('c'+obj.id);
	var next = document.getElementById(parseInt(obj.id)+1);
	var next_cel = document.getElementById('c'+parseInt(parseInt(obj.id)+1));
	if (cel.style.height =='0px')  
	{
		cel.style.height = '124px';
		obj.style.background = "url(/images/center_3_bg.jpg)";
		
		if (next_cel && next_cel.style.height=='0px') {
			next.height = '30';
			next.style.background = "url(/images/center_0all_bg.jpg)";
		}
	} 
	else 
	{
		cel.style.height = '0px';
		
		if (next_cel && next_cel.style.height=='0px') {
			next.height = '32';
			next.style.background = "url(/images/center_alll_bg.jpg)";
		}
		
		if (obj.id=='3' || prev_cel.style.height!='0px') {
			//alert(obj.id);
			obj.style.background = "url(/images/center_0all_bg.jpg)";
			obj.height = '30';
		} else {
			obj.style.background = "url(/images/center_alll_bg.jpg)";
			obj.height = '32';
		}
		
	}
}

function chkreg() {
		var frm = document.forms['regcard'];
		var mess = '';
		if (frm.elements['card[sname]'].value.length<3) {frm.elements['card[sname]'].focus(); return;}
		if (frm.elements['card[smail]'].value.length<3) {frm.elements['card[smail]'].focus(); return;}
		if (frm.elements['card[rmail]'].value.length<3) {frm.elements['card[rmail]'].focus(); return;}
		frm.sbutton.disabled = true;
		frm.sbutton.value = "ئلوْم...";
		frm.submit();
}

var ffnum = 1;

function addfield() {
	if (ffnum==4) return;
	//if (ffnum==1) {document.getElementById('fbox').innerHTML = '<input type="radio" name="ta" onclick="setAvt(1)">';}
	var cont = document.getElementById('ffcont');
	var div = document.createElement("div");
	div.setAttribute("id", "ff"+parseInt(ffnum+1));
	div.innerHTML = '<input class="field" size="35" type="file" name="userfile'+parseInt(ffnum+1)+'" value=""> <input type="checkbox" name="card[avt]" value="'+parseInt(ffnum+1)+'" onClick="setAvt(this)"> <input type="button" value="-" onclick="delfield('+parseInt(ffnum+1)+')">';
	cont.appendChild(div);
	ffnum++;
}

function addBox(o) {
	
	
}

function delfield(id) {
	var cont = document.getElementById('ffcont');
	var del = document.getElementById('ff'+id);
	cont.removeChild(del);
	//ffnum--;
}

function setAvt(sender) {
	
	var boxs  = document.getElementsByName("card[avt]");
	for(i=0;i<boxs.length;i++) {
		if(sender.value==boxs[i].value) continue;
		boxs[i].checked = false;
	}
}


function ShowItemDesc(alias)
{window.open("http://www.ericsonlab.ru/item.php?alias="+alias,"Window1","width=500,height=400,menubar=no,toolbar=no,scrollbars=yes,location=no,status=no");}



function HideDesc()
{
  document.getElementById("ol").style.display = "none";
  document.getElementById("img").style.display = "none";
  window.document.body.scroll = 'auto';
}

function keyPressHandler(e) 
{
var kC  = (window.event) ?  // MSIE or Firefox?
  event.keyCode : e.keyCode;
var Esc = (window.event) ?   
  27 : e.DOM_VK_ESCAPE // MSIE : Firefox
if(kC==Esc) {HideDesc();}
}


function getPageSizeWithScroll()
{
  if (window.innerHeight && window.scrollMaxY) 
  {
    // Firefox
    yWithScroll = window.innerHeight + window.scrollMaxY;
    xWithScroll = window.width;
  } 
  else if (document.body.scrollHeight > document.body.offsetHeight)
  { 
    // all but Explorer Mac
    yWithScroll = document.body.scrollHeight;
    xWithScroll = document.body.scrollWidth;
  } 
  else 
  { 
    // works in Explorer 6 Strict, Mozilla (not FF) and Safari
     yWithScroll = document.body.offsetHeight;
     xWithScroll = document.body.offsetWidth;
  }
  arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
  //alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
  return arrayPageSizeWithScroll;
}

