﻿// JScript File
// By: Deepak Bhise.
// All Rights Reserved..

 function IndexAutExt(m)
            {
            m=trim(m);
       if( m.length > 1)
             {      
              WebService.GetAllTypeModelNo(m,0,OnSucceeded1);
             
              } 
            }
            
          function OnSucceeded1(result)
            {
           
            var F=trim(document.getElementById('txtSearch').value);
            var O=F.length;
            var myArray = new Array();
            myArray=result;
            var H="";
            globalCursor=true;
            var N=0;var I=0;var A=null;
            if(myArray.length>6)
                {I=100;A="auto";}
                 else{I="";A="hidden";}
               for (var k=0; k < myArray.length; k++)
                {
                var pf=myArray[k].toUpperCase().indexOf(F.toUpperCase());
               H+="<tr><td width='50%' align='left' onmouseOver=\"this.style.backgroundColor='#F8FBF0';\" onmouseOut=\"this.style.backgroundColor='#ffffff';\" style=\"padding-left:5px;\"><div style='visibility:hidden;display:block;position:absolute;'>"+myArray[k]+"</div><a href=\"javascript:selectedSuggestion1('"+myArray[k]+"');\" onmouseOver=\"this.style.color='#71A115';\" onmouseOut=\"this.style.color='#006699';\" style='cursor:pointer;font-size:11px;font-family:verdana;color:#006699;'><span>"+myArray[k].substring(0,pf)+"</span><span style='font-weight:bold;'\">"+myArray[k].substring(pf,pf + O)+"</span><span>"+myArray[k].substring(pf + O,myArray[k].length)+"</span></a></td>";
               var mk= k+1; 
               if(mk < myArray.length)
                {
                 H+="<td width='50%' align='left' onmouseOver=\"this.style.backgroundColor='#F8FBF0';\" onmouseOut=\"this.style.backgroundColor='#ffffff';\" style=\"padding-left:5px;\"><div style='visibility:hidden;display:block;position:absolute;'>"+myArray[mk]+"</div><a href=\"javascript:selectedSuggestion1('"+myArray[mk]+"');\" onmouseOver=\"this.style.color='#71A115';\" onmouseOut=\"this.style.color='#006699';\" style='cursor:pointer;font-size:11px;font-family:verdana;color:#006699;'><span>"+myArray[k].substring(0,pf)+"</span><span style='font-weight:bold;'\">"+myArray[mk].substring(pf,pf + O)+"</span><span>"+myArray[mk].substring(pf + O,myArray[mk].length)+"</span></a></td></tr>";
                 k=mk;
                 }
               else
                {
                H+="</tr>";
                 }
                }
             
          
              var C= document.getElementById('vv');   
                var D="";var J=true;
          if(myArray.length==0)
            {
               C.style.visibility="hidden";C.style.display="none";J=false
             }
           else{D=H } 
      var D="<table id='tab11' border='0' width='100%' cellspacing='0' cellpadding='0'><tr style='background-color:#6EBD4A'><th width='80%' align='left' style='font-family:verdana;'>Search Models:</th><th width='20%' align='right' ><a href=\"javascript:hideSuggestionBox1('vv');\" style='cursor:pointer;'><img src='images/Div/BtClose.jpg' border='0'></a></th></tr><tr><td valign='top' colspan='2' style='margin: auto;'><div id='test' style='overflow:"+A+";height:"+I+"px;margin-top:0px;'><table id='suggestionTable' width='100%' border='0' cellspacing='0' cellpadding='0'>"+D+"</table></div></td></tr></table>";      
        if(J){
        C.innerHTML=D;C.style.visibility="visible";C.style.display="block";
        }    
     }
            
         function hideSuggestionBox1(A){
         var B=document.getElementById(A);
         B.style.visibility="hidden";
         B.style.display="none"}
//     function showSuggestionBox1(B,A){
//     var D=document.getElementById(B);
//     var E=D.value;
//     var C=document.getElementById(A);
//     if(trim(E).length>0){C.style.visibility="visible";C.style.display="block"}
//     }
     
     function selectedSuggestion1(A)
     {
     document.getElementById("txtSearch").value=A;
     var str1=document.getElementById("txtSearch").value;
    
     var str2=new Array();
     str2= str1.split(":");
     var str3 =str2[0];
     var str4=new Array();
     str4=str2[0].split(" ");
     
    if(str3.match('Laptop'))
     {
       if(str2[1]!=undefined )
        {
         window.location="Laptop-Detail.aspx?ModelNo="+str2[1];
        }
       if(str2[1]==undefined)
        {
          window.location="Laptop-All.aspx?Brand1="+str4[1];
          //window.location="Search.aspx?extnList=" + str4[1];
        }
      }
    if(str3.match('Desktop'))
      {
       if(str2[1]!=undefined )
        {
        window.location="Desktop-Detail.aspx?ModelNo="+str2[1];
        }
       if(str2[1]==undefined)
        {
          window.location="Desktop-All.aspx?Brand1="+str4[1];
          //window.location="Search.aspx?extnList=" + str4[1];
        }
     
      }
  if(str3.match('Projector'))
      {
      if(str2[1]!=undefined )
        {
        window.location="Projector-Detail.aspx?ModelNo="+str2[1];
        }
       if(str2[1]==undefined)
        {
          window.location="Projector-All.aspx?Brand1="+str4[1];
          //window.location="Search.aspx?extnList=" + str4[1];
        }
      
    
       }
      
    }   
    
    
    
function req_fieldDPKB(id)
  {  

   var checkStr=document.getElementById(id);

	if (checkStr.value=="" || checkStr.value==null)
		{
			
			return false;
		}
	var j=checkStr.value.length;
    var allValid = 0;
	
	for (i = 0;  i < j;  i++)
		{
		    	ch = checkStr.value.charAt(i);
		       	if (ch==" " && allValid==0 ) 
		    	{
		    	allValid=0;
		    	}
		    	else
		    	{
		    	allValid=1;
		    	break;
		    	}
			
		}
return allValid;
		
}


// Removes leading whitespaces
     
 function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}
// Removes leading and ending whitespaces

function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

