var inactiveColor = '#fbedbb';
      function selects(id,obj){
               var objTr = document.getElementById(id);
               var objTrd = document.getElementById(id+'_n');
               if(obj.checked){
                 objTr.style.backgroundColor = '#F0F0F0';
                 objTrd.style.backgroundColor = '#F0F0F0';
               }else{
                 if(objTr.bgColor==inactiveColor){
                   objTr.style.backgroundColor = inactiveColor;
                   objTrd.style.backgroundColor = inactiveColor;
                 }else{
                   objTr.style.backgroundColor = '#FFFFFF';
                   objTrd.style.backgroundColor = '#FFFFFF';
                 }
               }
        }
        function go(){
          window.document.catalog.submit();
        }


        function Select_All(field){
          var id = 0;
          if(window.document.catalog.selectAll.checked) id=1;
                if (field.length)
                        {
                        for (i = 0; i < field.length; i++)
                                {
                                if (id) field[i].checked = true
                                else field[i].checked = false;
                                };
                        }
                else
                        {
                        if (id) field.checked = true
                        else field.checked = false;
                        };
                //catalog.submit();
                check(field);
        };
        function info(id, bag)
        {
        window.open('info?id='+id+'&bag='+bag);
        };
        function infonet(id, bag, networkId)
        {
        window.open('info?networkId='+networkId+'&id='+id+'&bag='+bag);
        };
        function type(num, vid)
        {
          newObj=window.open('http://www.newsoutdoor.ru/images/sales_street signs/'+num+'_'+vid+'.gif', '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=880, height=720');
        };
        function rules(){
          newObj=window.open('/office/BookingRules.jsp', '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=880, height=720');
        }
        function check(field){
          if (field.length && field[field.length-1].value){
            for (i = 0; i < field.length; i++){
              if(field[i].checked){
                    if(typeof(field[i].value)!="undefined"){
                          eval("window.document.all.col"+field[i].value+".style.backgroundColor = '#F0F0F0'");
			  eval("window.document.all.col"+field[i].value+"_n.style.backgroundColor = '#F0F0F0'");
                    }
              }else{
                    if(typeof(field[i].value)!="undefined"){
						x= eval("window.document.all.col"+field[i].value+".bgColor");
						if (x!=inactiveColor) {
			  				eval("window.document.all.col"+field[i].value+".style.backgroundColor = '#FFFFFF'");
			  				eval("window.document.all.col"+field[i].value+"_n.style.backgroundColor = '#FFFFFF'");
						}
						 else {
							eval("window.document.all.col"+field[i].value+".style.backgroundColor = "+inactiveColor);
							eval("window.document.all.col"+field[i].value+"_n.style.backgroundColor = "+inactiveColor);
						  }
                    }
              }
            };
          }else{
            if(field.checked){
                    if(typeof(field.value)!="undefined"){
                        eval("window.document.all.col"+field.value+".style.backgroundColor = '#F0F0F0'");
			eval("window.document.all.col"+field.value+"_n.style.backgroundColor = '#F0F0F0'");
                    }
            }else {
              if(typeof(field.value)!="undefined"){
				  x= eval("window.document.all.col"+field.value+".bgColor");
				  if (x!=inactiveColor) {
                eval("window.document.all.col"+field.value+".style.backgroundColor = '#FFFFFF'");
                eval("window.document.all.col"+field.value+"_n.style.backgroundColor = '#FFFFFF'"); }
			  } else {
				eval("window.document.all.col"+field.value+".style.backgroundColor = "+inactiveColor);
                eval("window.document.all.col"+field.value+"_n.style.backgroundColor = "+inactiveColor);
			  }

              }
          };
        }

function saveSelection(){
  var isSave = false;
  var selId = new Array();
  var src = document.getElementsByName("id");
  var element;
  var j = 0;
  for(i=0;i<src.length; i++){
    element = src[i];
    if(element.checked){
      isSave = true;
      selId[j] = element;
      j++;
    }
  }
  if(isSave){
    if(confirm("У Вас есть отмеченные поверхности: "+j+" шт.\r\nХотите добавить в Ваши Отобранные поверхности?")){
      //go();
      return true;
    }else{
      for(i=0; i<j; i++){
        selId[i].checked = false;
      }
      return false;
    }
  }
}

function linkGo(id){
showFilter(1);
 // closeFilter();
  if(!saveSelection()){
    var pageId = document.getElementById("pageId");
    //alert(pageId.name + " : " + pageId.value + " => " + id);
    pageId.value = id;
  }
  go();
}

function bagGo2(url){
  window.document.location = url;
}

function bagGo(){
  //closeFilter();
  if(!saveSelection()){
    var catalog = document.getElementById("catalog");
    catalog.action="bag";
  }
  go();
}

function goSup() {
newObj=window.open('http://www.newsoutdoor.ru/help/support.php', '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=755, height=600');
}


        function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  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=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function order(){
    var flag = true;
    if(window.document.regdata.product.value=="" || window.document.regdata.product.value=="null"){
      //eval("document.getElementById('prodSel').className='err'");
      //eval("document.getElementById('prodTd').className='error'");
      alert("Пожалуйста, укажите рекламируемый продукт.");
      flag = false;
    }else{
      //eval("document.getElementById('prodSel').className='norm'");
      //eval("document.getElementById('prodTd').className='norm'");
    }
    if(window.document.regdata.advert.value=="" && flag){
      //eval("document.getElementById('advertInp').className='err'");
      //eval("document.getElementById('advertTd').className='error'");
      alert("Пожалуйста, укажите рекламодателя.");
      flag = false;
    }else{
      //eval("document.getElementById('prodSel').className='norm'");
      //eval("document.getElementById('prodTd').className='norm'");
    }
    if(window.document.regdata.brend.value=="" && flag){
      //eval("document.getElementById('advertInp').className='err'");
      //eval("document.getElementById('advertTd').className='error'");
      alert("Пожалуйста, укажите бренд.");
      flag = false;
    }else{
      //eval("document.getElementById('prodSel').className='norm'");
      //eval("document.getElementById('prodTd').className='norm'");
    }
    if(window.document.regdata.salePoint.value=="" && flag){
      //eval("document.getElementById('salePointSel').className='err'");
      //eval("document.getElementById('salePointTd').className='error'");
      alert("Пожалуйста, выберите офис продаж.");
      flag = false;
    }else{
      //eval("document.getElementById('salePointSel').className='norm'");
      //eval("document.getElementById('salePointTd').className='norm'");
    }

    if(window.document.regdata.name.value=="" && flag){
      //eval("document.getElementById('nameInp').className='err'");
      //eval("document.getElementById('nameTd').className='error'");
      alert("Пожалуйста, укажите всю требуемую контактную информацию.");
      flag = false;
    }else{
      //eval("document.getElementById('nameInp').className='norm'");
      //eval("document.getElementById('nameTd').className='norm'");
    }
    if(window.document.regdata.fom.value=="" && flag){
      //eval("document.getElementById('fomInp').className='err'");
      //eval("document.getElementById('fomTd').className='error'");
      alert("Пожалуйста, укажите всю требуемую контактную информацию.");
      flag = false;
    }else{
      //eval("document.getElementById('fomInp').className='norm'");
      //eval("document.getElementById('fomTd').className='norm'");
    }
    if(window.document.regdata.fname.value=="" && flag){
      //eval("document.getElementById('fnameInp').className='err'");
      //eval("document.getElementById('fnameTd').className='error'");
      alert("Пожалуйста, укажите всю требуемую контактную информацию.");
      flag = false;
    }else{
      //eval("document.getElementById('fnameInp').className='norm'");
      //eval("document.getElementById('fnameTd').className='norm'");
    }
    if(window.document.regdata.org.value=="" && flag){
      //eval("document.getElementById('orgInp').className='err'");
      //eval("document.getElementById('orgTd').className='error'");
      alert("Пожалуйста, укажите всю требуемую контактную информацию.");
      flag = false;
    }else{
      //eval("document.getElementById('orgInp').className='norm'");
      //eval("document.getElementById('orgTd').className='norm'");
    }
    if(window.document.regdata.phone.value=="" && flag){
      //eval("document.getElementById('phoneInp').className='err'");
      //eval("document.getElementById('phoneTd').className='error'");
      alert("Пожалуйста, укажите всю требуемую контактную информацию.");
      flag = false;
    }else{
      //eval("document.getElementById('phoneInp').className='norm'");
      //eval("document.getElementById('phoneTd').className='norm'");
    }
    if(window.document.regdata.mail.value=="" && flag){
      //eval("document.getElementById('mailInp').className='err'");
      //eval("document.getElementById('mailTd').className='error'");
      alert("Пожалуйста, укажите всю требуемую контактную информацию.");
      flag = false;
    }else{
      //eval("document.getElementById('mailInp').className='norm'");
      //eval("document.getElementById('mailTd').className='norm'");
    }
    if(window.document.regdata.license.checked!=true && flag){
      //eval("document.getElementById('licenseTd').className='error'");
      alert("Вы должны принять условия размещения и условия online продаж!");
      flag = false;
    }else{
      //eval("document.getElementById('licenseTd').className='norm'");
    }
    if(flag){
      window.document.regdata.action.value="correct";
      document.forms["regdata"].submit();
      //alert("Оформляем!");
    }
  }

  function book(){
    var flag = true;
    if(window.document.regdata.salePoint.value=="" && flag){
      //eval("document.getElementById('salePointSel').className='err'");
      //eval("document.getElementById('salePointTd').className='error'");
      alert("Пожалуйста, выберите офис продаж.");
      flag = false;
    }else{
      //eval("document.getElementById('salePointSel').className='norm'");
      //eval("document.getElementById('salePointTd').className='norm'");
    }
    if(window.document.regdata.license.checked!=true && flag){
      //eval("document.getElementById('licenseTd').className='error'");
      alert("Вы должны принять условия размещения и условия online продаж!");
      flag = false;
    }else{
      //eval("document.getElementById('licenseTd').className='norm'");
    }
    if(flag){
      window.document.regdata.action.value="correct";
      document.forms["regdata"].submit();
      //alert("Оформляем!");
    }
  }

  onReady = (function(ie){
   var d = document;
   return ie ? function(c){
     var n = d.firstChild,
      f = function(){
       try{
        c(n.doScroll('left'))
       }catch(e){
        setTimeout(f, 10)
       }
      }; f()
    } :
    /webkit|safari|khtml/i.test(navigator.userAgent) ? function(c){
     var f = function(){
       /loaded|complete/.test(d.readyState) ? c() : setTimeout(f, 10)
      }; f()
    } :
    function(c){
     d.addEventListener("DOMContentLoaded", c, false);
    }
})();


