function show(ele) {
      var srcElement = document.getElementById(ele);
      if(srcElement) {
          if(srcElement.style.display == "block") {
            srcElement.style.display= 'none';
          }
          else {
            srcElement.style.display='block';
          }
      }
  }
  
function region(regi) {
      var srcElement = document.getElementById(regi);
      if(srcElement) {
          if(srcElement.style.display == "block") {
            srcElement.style.display= 'none';
          }
          else {
            srcElement.style.display='block';
          }
      }
  }
  
function loadpage(url_page){
document.location.href=url_page;
}
function initSMulty(n) {
	var v=$(n+"-value").value;
	if(!v) return;
	v=","+v+",";
	var s=$(n+"-src");
	s.removeChild(s.options[0]);
	for(var i=0;i<s.options.length;i++) s.options[i].selected=(v.indexOf(","+s.options[i].value+",")!=-1);
}

function gop(s) {
	
	for(var i in s) { $(i).value = s[i]; 
	}
	document.forms[0].submit();
	return false;
}

function delPricePos(id) {
	delAnyPos(id, "todelp");
}

function delAnyPos(id, n) {
	if(!confirm("Удалить?")) return;
	var o = $(n);
	if(!o) return;
	o.value=id;
	document.forms[0].submit();
}

function delOffer(id) {
	delAnyPos(id, "todelo");
}


function delFoto(id) {
	delAnyPos(id, "todelfotoid");
}

function delVac(id) {
	delAnyPos(id, "todelv");
}

function delArt(id) {
	delAnyPos(id, "todela");
}

function delPress(id) {
	delAnyPos(id, "todels");
}

function delProduct(id) {
	delAnyPos(id, "todelr");
}


function splinDefault(o,t,e) {
	if(e) {
		if(o.value==t) o.value=""
	} else {
		if(o.value=="") o.value=t;
	}
}

function nullRequest(t, href) {
	var r = getRequest();
	if(!r) return false;
	r.onreadystatechange = function() { 
		if(r.readyState==4) {
			var o = $(t);
			if(r.status==200) { if(r.responseText>0 && o) o.style.display='none'; } else { return false; }

		}
	}
	var _q = href.indexOf("?")==-1?"?":"&";
	if(href.indexOf("?")==-1) {
		href = href+"?"+"mrand="+Math.random()+HREF_PARAMS;
	} else {
		href = href.replace("?","?"+"mrand="+Math.random()+HREF_PARAMS+"&");
	}
	r.open("GET",href, true);
	r.send(null);
	return false;
}

function trClassSwap(o, cl) {
	o.className = cl;
//	for(var i=0;i<o.cells.length;i++) o.cells[i].className = cl;
}


function switchDisplay(a,b) {
	$(a).style.display = "block";
	$(b).style.display = "none";
}
	












function V_add(id) {
	if(!confirm("Добавить запись?")) return false;
	setCookie("adminprevmode",getCookie("adminmode","table"));
	setCookie("adminmode","new");
	if(arguments.length==0) window.location.href=window.location.href;
}

function V_edit(id) {
	setCookie("adminprevmode",getCookie("adminmode","table"));
	setCookie("adminmode","edit");
	if(arguments.length==0) window.location.href=window.location.href;
}

function V_table() {
	setCookie("adminprevmode",getCookie("adminmode","table"));
	setCookie("adminmode","table");
	if(arguments.length==0) window.location.href=window.location.href;
}


function V_cancel() {
	setCookie("adminmode",getCookie("adminprevmode","table"));
	window.location.href=window.location.href;
}


function goSC(c,v) {
	setCookie(c,v);
	window.location.href=""+window.location.href;
}


function doEnvName(s) {
	var o = window.event.srcElement;
	if(o && o.tagName=="A" && !o.target) {
		window.event.cancelBubble = false;
		window.event.returnValue = false;
		setCookie("env"+s,o.href);
		if(o.parentNode.className!="navigator") window.location.href=""+window.location.href;
		return false;
	}
	return true;
}






function goEnvName(s, href, c) {
	if(arguments.length==3) for(var n in c) setCookie(n,c[n]); 
	setCookie("env"+s,href);
	window.location.href=""+window.location.href;
	
}



function saveAndTable() {
	setCookie("adminmode","table");
	document.forms[0].submit();
}






function allPriceDel() {
	if(!confirm("Удалить все прайст листы Вашего предприятия?")) return;
	$("deladdp").value = 1;
	document.forms[0].submit();
}




function JumpToIt(list)
{
    var selection = list.options[list.selectedIndex].value
    if (selection != "None") 
        location.href = selection
}







function Make_Tabsheet(){
	var i, j, k, eDD, iMax_height, iDT_height, aeDL_child, sDD_inner_HTML
	var bFirst_tab = true
	var aeDl = document.getElementsByTagName( "DL" )

	for( i = 0 ; i < aeDl.length ; i++ ){
		if( aeDl[i].className == "tabsheets" ){
			aeDL_child = aeDl[i].childNodes
			iMax_height = 0
			for( j = 0 ; j < aeDL_child.length ; j++ ){
				if( aeDL_child[j].nodeName == "DT" ){
					iDT_height = aeDL_child[j].offsetHeight
					aeDL_child[j].unselectable = true
					aeDL_child[j].onmousedown = Switch_sheet
					eDD = aeDL_child[j]
					while( eDD.nextSibling ){
						eDD = eDD.nextSibling
						if( eDD.nodeName == "DD" ){
							if( eDD.offsetHeight > iMax_height ){
								iMax_height = eDD.offsetHeight
							}
							if( !bFirst_tab ){
								eDD.className = "inactive"
							}else{
								aeDL_child[j].className = "active"
							}
							bFirst_tab = false
							break
						}
					}
				}
			}
			aeDl[i].style.height = (iMax_height + iDT_height) * 1 + "px"
			for( j = 0 ; j < aeDL_child.length ; j++ ){
				if( aeDL_child[j].nodeName == "DD" ){
					aeDL_child[j].style.height = iMax_height + "px"
				}
			}
		}
		return true
	}
}

function Switch_sheet( e ){
	var eTab = e ? e.target : window.event.srcElement
	if( eTab.nodeType == 3){
		eTab = eTab.parentNode
	}
	var eSheet = eTab
	while( eSheet.nextSibling ){
		eSheet = eSheet.nextSibling
		if( eSheet.nodeName == "DD" ){
			break
		}
	}

	if( eSheet.className == "inactive" ){
		eTab.className = "on" 
		var aeDL_child = eTab.parentNode.childNodes
		for( var i = 0 ; i < aeDL_child.length ; i++ ){
			if( aeDL_child[i].nodeName == "DT" && aeDL_child[i].className != "on" ){
				aeDL_child[i].className = ""
			}else if( aeDL_child[i].nodeName == "DD" ){
				aeDL_child[i].className = "inactive"
			}
		}
		eSheet.className = "active"
		eTab.className = "active"
	}
	return false
}



