var paging = '';

function selectTradeMark(){        
    $("body").addClass("opacity");
    var selects = $("select").serialize();
    $("#model_target").load("/includes/getmodel.php?action=mark&"+selects,
    function(){
           $("body").removeClass("opacity"); 
    });  
}

function LoadTable(){  
    $("body").addClass("opacity");
    setCookie('home',  '1',              '/', ''+window.location.host); 
    setCookie('mark',  $('#mark').val(), '/', ''+window.location.host); 
    setCookie('model', $('#model').val(), '/', ''+window.location.host); 
    setCookie('type',  $('#type').val(), '/', ''+window.location.host);
    setCookie('only',  $('#only').attr("checked"), '/', ''+window.location.host);
    
    var selects = $("select").serialize();
    var check   = $('#only').attr("checked"); 
    $("#searchtabletarget").load("/includes/getmodel.php?action=table&"+selects+"&only="+check,
    function(){
      $("body").removeClass("opacity"); 
    });  
}

function changeTable(road, element, url){      
    setCookie('home',  '1',              '/', ''+window.location.host);  
    setCookie('mark',  $('#mark').val(), '/', ''+window.location.host); 
    setCookie('model', $('#model').val(), '/', ''+window.location.host); 
    setCookie('type',  $('#type').val(), '/', ''+window.location.host);
    setCookie('only',  $('#only').attr("checked"), '/', ''+window.location.host);
     
    setCookie('road', road, '/', ''+window.location.host); 
    setCookie('element', element, '/', ''+window.location.host); 
    if ( url != '' ){
        window.location.href = "http://" + url;
    }else{    
        $("body").addClass("opacity");
        var selects = $("select").serialize();
        var check   = $('#only').attr("checked"); 
        $("#searchtabletarget").load("/includes/getmodel.php?action=table&view=search&"+selects+"&only="+check+"&road="+road+"&element="+element,
        function(){
           $("body").removeClass("opacity"); 
        }); 
    }
}

function changeCatalogTable(road, element, url){  
   //alert(road + ' ' +  element + ' ' + window.location.host); 
   setCookie('road', road, '/', ''+window.location.host); 
   setCookie('element', element, '/', ''+window.location.host); 
   window.location.href = "http://" + url;
   //var selects = $("#type").val();
   // $("#searchtabletarget").load("/includes/getmodel.php?action=table&view=catalog&type="+selects+"&only=&road="+road+"&element="+element);  
}

function clearHome(){
    setCookie('home',  '', '/', ''+window.location.host);   
    setCookie('mark',  '', '/', ''+window.location.host); 
    setCookie('model', '', '/', ''+window.location.host); 
    setCookie('type',  '', '/', ''+window.location.host);
    setCookie('only',  '', '/', ''+window.location.host);
    setCookie('road', '', '/', ''+window.location.host); 
    setCookie('element', '', '/', ''+window.location.host); 
    window.location.href = "http://" + window.location.host;
}

function setCookie (name, value, path, domain, secure) {
      var today = new Date();
      var expires = new Date();
      expires.setTime(today.getTime() + 3600000);
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


/*$(document).ready(function(){  
   paging = $("#paging").html();
   alert(paging);
});*/