

$(document).ready(function()
{

// Чемодан внизу

    function  getPageSize()
    {
           var xScroll, yScroll;

           if (window.innerHeight && window.scrollMaxY) {
                   xScroll = document.body.scrollWidth;
                   yScroll = window.innerHeight + window.scrollMaxY;         //    alert('4');
           }
           else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
                   xScroll = document.documentElement.scrollWidth;
                   yScroll = document.documentElement.scrollHeight;                 //     alert('6');
           }
           else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                   xScroll = document.body.scrollWidth;
                   yScroll = document.body.scrollHeight;                             //   alert('5');
           }    else { // Explorer Mac...would also work in Mozilla and Safari
                   xScroll = document.body.offsetWidth;
                   yScroll = document.body.offsetHeight;                                 //      alert('7');
           }

           var windowWidth, windowHeight;
           if (self.innerHeight) { // all except Explorer
                   windowWidth = self.innerWidth;          //   alert('1');
                   windowHeight = self.innerHeight;
           } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                   windowWidth = document.documentElement.clientWidth;
                   windowHeight = document.documentElement.clientHeight;     //  alert('2');
           } else if (document.body) { // other Explorers
                   windowWidth = document.body.clientWidth;
                   windowHeight = document.body.clientHeight;                //  alert('3');
           }

           // for small pages with total height less then height of the viewport
           if(yScroll < windowHeight){
                   pageHeight = windowHeight;
           } else {
                   pageHeight = yScroll;
           }

           // for small pages with total width less then width of the viewport
           if(xScroll < windowWidth){
                   pageWidth = windowWidth;
           } else {
                   pageWidth = xScroll;
           }

           return [pageWidth,pageHeight,windowWidth,windowHeight];
    }

    // инициализация
    doSomething();
    function doSomething()
    {
        //alert($("#new_auto7").css('width'));
        var msize=getPageSize();   // alert (msize[0]+"  "+msize[2]);
        if(msize[0]>1180)
        {
            $("#new_auto7").css('display','block');
            $("#new_auto8").css('display','block');
        }
        else
        {
            $("#new_auto7").css('display','none');
            $("#new_auto8").css('display','none');
        }
    };

/*    var resizeTimer = null;
    $(window).bind('resize', function()
    {
        if (resizeTimer)
            clearTimeout(resizeTimer);
        resizeTimer = setTimeout(doSomething, 0);
    });  */

    // автоселект
     $("#brand").change(function ()
     {
         // если выбран элемент
          if($(this).attr("value")!='')
          {
             //alert($(this).attr("value"))
             $("#model").attr("disabled", false);
             $("#model").empty();
             $.post("/util/ajax_select.php", {brand:$(this).attr("value")} ,function(data)
             {
                   $("#model").append(data);
             });
          }
          else
         {   // иначе очищаем
             $("#model").empty();
             $("#model").append("<option>-Выберите модель-</option>");
             $("#model").attr("disabled", true);
         }

     });

     $(".reviews_brand").change(function ()
     {
		if($("#brand").val()!='')
			location.href="/reviews/"+$("#brand").val();
     });

     $(".photo_brand").change(function ()
     {
		if($("#brand").val()!='')
			location.href="/photo/"+$("#brand").val();
     });

     /*$(".reviews_model").change(function ()
     {
		//alert($("#brand").val()+' --- '+$("#model").val());
		if($("#model").val()!='')
			location.href="/reviews/"+$("#brand").val()+'/'+$("#model").val();
     });*/

});



