function new_win(img, name,width,height) {
      w1=window.open('','new_window','resizable=no,menubar=no,status=no,scrollbars=no,width='+width+',height='+height+',top=70,left=100');
      w1.document.open();
      w1.document.write("<html><head><title>"+name+"</title></head><body leftmargin=0 topmargin=0>");
      w1.document.write("<center><a style='font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight : bold; font-size: 10px; text-decoration : none; color : #336699;' href='javascript:window.close()'><img src="+img+" width="+width+" height="+(height-20)+" border=0 alt='"+name+"'><br>Закрыть окно</a>");
      w1.document.write("</body></html>");
      w1.document.close();
    w1.focus();
}
function new_win_href (name,title,width,height) {
      w1=window.open('','new_window','resizable=no,menubar=no,status=no,scrollbars=no,width='+width+',height='+height+',top=70,left=100');
      w1.document.open();
      w1.document.write("<html><head><title>"+title+"</title></head><body leftmargin=0 topmargin=0>");
      w1.document.write("<center><textarea rows=4 cols=40 wrap=on>"+name+"</textarea><br><a style='font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight : bold; font-size: 10px; text-decoration : none; color : #336699;' href='javascript:window.close()'>Закрыть окно</a>");
      w1.document.write("</body></html>");
      w1.document.close();
    w1.focus();
}

//#############################
function winaclose(tek)
        {
		  $('#wina').replaceWith('<div id="wina" onclick="winaclose();"  style="position: absolute;  width: 0px; height: 0px; visibility: hidden; filter:alpha(opacity=50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.5; background: #000000;"></div>');
          $('#wina').css('visibility','hidden');
          var str='<div id="form_reg"  style="position: absolute; width: 0px; height: 0px; visibility: hidden; background: #ffffff url(/images/form_t_w.png) no-repeat top left;"><div  style="height: 15px; background: url(/images/form_b_w.png) no-repeat top left;">&nbsp;</div></div>';
          $('#form_reg').replaceWith(str);
          $('#quote1').css('visibility','hidden');
          $('#quote1').css('display','none');
          $('#ajax_ico').css('visibility','hidden');
        }
//#############################
function com_add(cat)
  {
  $('#wina').css('visibility','visible');
  $('#wina').css('width',$(document).width());
  $('#wina').css('height',$(document).height());
  $('#wina').css('left',0);
  $('#wina').css('z-index','59');
	                    $('#form_reg').css('left',$(window).width()/2-$('#form_reg').width()/2);
	                    $('#form_reg').css('top',$(window).height()/2-$('#form_reg').height()/2);
	                    if($('#form_reg').offset().top<20)$('#form_reg').css('top',20);
	                    $('#form_reg').css('visibility','visible');
	                    $('#form_reg').css('position','fixed');
                        $('#form_reg').css('z-index','60');
  var str="idcat="+cat;
        $.post("/ajax_company.php",str, function (data)
                    {
//                   alert(data);
                        $('#form_reg').replaceWith(data);
	                    $('#form_reg').css('left',$(window).width()/2-$('#form_reg').width()/2);
	                    $('#form_reg').css('top',$(window).height()/2-$('#form_reg').height()/2);
	                    if($('#form_reg').offset().top<20)$('#form_reg').css('top',20);
	                    $('#form_reg').css('visibility','visible');
		              		if ($.browser.msie)
								   {
									$('#form_reg').css('position','absolute');
								   }
							else
								{
								$('#form_reg').css('position','fixed');
								}
//	                    $('#form_reg').css('position','fixed');
                        $('#form_reg').css('z-index','60');
                    }
                );
 }
//#############################

function com_save()
        {
        $('#quote1').slideUp(300);
        var str = $("#form_companu").serialize();
        str=encodeURI(str);
//        alert(str);
        $.post("/ajax_company.php",str, function (data)
                    {
//                    alert(data);
                        var idt='#f_sub';
                        var tmp_left=0;
                        var key='';
            if(data!='ok')
                    {
                         if(data.substr(0,3)=='ok#')
                                 	{

                                 		url=data.substr(3);
	                                    location = '/catalog/'+url;
                                 	}
                          else
                          			{
		                    		data=data.substr(4);
			                        $('#quote_text1').replaceWith('<div class="quote_text1" id="quote_text1">'+data+'</div>');
            			            $('#quote1').slideDown(600);
		                            }
                    }
                    else
                    		{
                                  $('#form_reg').css('visibility','hidden');
                                  if(data.substr(0,3)=='ok#'){url=data.substr(3);}
                                  location = '/';
                            }
                    }
                );
        }

//#############################
