function aj_req(container)
{
	alert(container);
}

function send_email()
{
	if(!checkEmail())
	{
		return;		
	}
	
	ajax.post('/save_email/', aj_req , 'email='+document.subFrom.email.value);
}

function checkEmail() {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.subFrom.email.value)){
	return true;
	}
	alert("Неверный E-mail!");
	return false;
}

function popimg(url, title, width, height)
{
	str="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"><html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">\n<title>«Contact-inprim» - Маркировочное оборудование</title>\n</head>\n<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>\n<img src='"+url+"' alt='"+title+"'>\n</body>\n</html>";
	f_win = window.open(url ,"BigImage" ,'width='+width+',height='+height+',top='+((screen.height/2)-(height/2))+',left='+((screen.width/2)-(width/2))+',toolbar=no,scrollbars=no,resizable=yes,menubar=no,status=no,directories=no,location=no');
	f_win.document.writeln(str);
	f_win.focus();
	f_win.document.close();
}

function popup(url, title, width, height)
{
	f_win = window.open(url ,"" ,'width='+width+',height='+height+',top='+((screen.height/2)-(height/2))+',left='+((screen.width/2)-(width/2))+',toolbar=no,scrollbars=yes,resizable=yes,menubar=no,status=no,directories=no,location=no');
	f_win.focus();
}

function show_ps(id)
{
  var i=0;
  if(document.getElementById(id).style.display == 'none')
  {
    document.getElementById(id).style.display = 'block';
    for(i=1; i<=4; i++)
    {
      if(('p'+i) != id)
        document.getElementById('p'+i).style.display = 'none';
    }
  }
}

function show_content(id) //Каталог -> Описание 
{
  var q;
  if(document.getElementById(id).style.display == 'none')
  {
    document.getElementById(id).style.display = 'block';
    for(q=1;;q++)
    {
      if('layer'+q != id)
	  	var elem=document.getElementById('layer'+q);
		if(elem == null)
			break;
		elem.style.display = 'none';
    }
  }
  else
  {
    document.getElementById(id).style.display = 'none';
  }
}

function IM_swapImgRestore() { //v3.0
  var i,x,a=document.IM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function IM_preloadImages() 
{ //v3.0
  var d=document; 
  if(d.images)
  { 
	if(!d.IM_p) 
	  d.IM_p=new Array();
    var i,j=d.IM_p.length,a=IM_preloadImages.arguments; 
    for(i=0; i<a.length; i++)
    {
      if (a[i].indexOf("#")!=0)
      { 
        d.IM_p[j]=new Image; 
       d.IM_p[j++].src=a[i];
      }
    }
  }
}

function IM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=IM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function IM_swapImage() { //v3.0
  var i,j=0,x,a=IM_swapImage.arguments; document.IM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=IM_findObj(a[i]))!=null){document.IM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



// Menu

var mid='';
var flag;
/*Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};*/
/*var a = [];
var b = ["u2", "u77", "u78", "u79"];*/
/*
a["u2"] = null;
a["u77"] = null;
a["u78"] = "u77";
a["u79"] = "u78";
*/
var col = 0;

function on(it, level) {
		//alert(level);
	col--;
	if(col == 0) return;
	var f = it.getElementsByTagName("ul")[0].id;
	for(var i = 0 ; i < b.length; i++)
	{
		if(document.getElementById(b[i])!=null)
			document.getElementById(b[i]).style.display='none';
	}
	while(f != 'unull')	
	{
		col++;
		document.getElementById(f).style.display='block';
		f = a[f];
	}
}
