﻿// JScript File

function compare(){
 var y="";
for (i=0;i < document.forms[0].Checkbox1.length;i++) {
          if (document.forms[0].Checkbox1[i].checked) {
          if (y==""){
               y=document.forms[0].Checkbox1[i].value;
                    }
              else
              {
              y= y + ';'+ document.forms[0].Checkbox1[i].value
              }
             
          }
          
       }
  document.getElementById('TempCheckValue').value='S+' + y;
  document.search_hiden.action ="http://www.car2you.com/search/comparecar/comparedetail.aspx";
  document.search_hiden.target ="_blank";
  document.search_hiden.method="post";
  document.search_hiden.submit(); 
}
function CheckValue(x){
//alert(x);
if (document.forms[0].Checkbox[x].checked){
     var min=cal(x);  
     // alert(min); 
        var max=parseInt(min)+parseInt(document.forms[0].Checkbox[x].value)-1;
        
       for(i=parseInt(min);i<=max;i++){
                    
                     document.forms[0].Checkbox1[i].checked=true;
                                                                 }
                                         }
        else
                     {
                      var min=cal(x);  
        var max=parseInt(min)+parseInt(document.forms[0].Checkbox[x].value)-1;
        
       for(i=parseInt(min);i<=max;i++){
                        document.forms[0].Checkbox1[i].checked=false;
                                                             }
                    }
        }
        
 function cal(x){
           
           var J=0;
           if(x==0){
            J=0; }
           else{ 
            for(i=1;i<=x-1;i++){
                    J= parseInt(J) + parseInt(document.forms[0].Checkbox[i].value);
                      }
                      }
                    // alert(J);
                      return J;
             }
