﻿   
var suggestion=new Array();   
var suggestionLocSearch=new Array();   
var cur=-1;

function setKeywordSearch(value) 
{ 
    value=formatStr(value);   
   	document.getElementById('txtKeywords').value = value;   	 
	document.getElementById('divKeywords').innerHTML  = '';
	document.getElementById('divKeywords').className ="Hide";	
}
var val=-1;
function GetSuggestedKeywords(e)
{    
     var keycode=GetKeycode(e);     
     if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
     {
        return false ;
     }     
    cur=-1;      
    var keyword=document.getElementById('txtKeywords').value;         
    if(keyword.length==0)
    {
       document.getElementById('divKeywords').innerHTML="";        
       document.getElementById('divKeywords').className ="Hide";
       return false;
    }    
    if(suggestion.length == 0)
    {
        Get_keyword();                 
    }        
    else
    {   try
        {               
            if(suggestion.length > 0)
            {                
                SuccessArr(suggestion);        
            }
         }   
        catch(err)
        {
        }
    }
    if(document.getElementById('divKeywords').innerHTML=="")
    {
        document.getElementById('divKeywords').innerHTML="";        
        document.getElementById('divKeywords').className ="Hide";        
    }
}

function SuccessArr(arr)
{  var str=""; 
   var st="" 
   var cntr=0;
   var input=document.getElementById('txtKeywords').value.toLowerCase();
   document.getElementById('divKeywords').innerHTML="";   
   for(i=0;i<arr.length;i++)
   {    
        st=arr[i];  
        var index = st.toLowerCase().indexOf(input.toLowerCase());       
        if(index == 0 || st.charAt(index-1) == " ")
        {             
		    st=arr[i];
			st=st.toLowerCase();
            st=st.replace(input,"<b>"+ input +"</b>");
            str=str +"<div  class='AutoExtenderList' onmouseover='javascript:suggestOver(this);' onmouseout='javascript:suggestOut(this);' onclick='setKeywordSearch(this.innerHTML)' class='AutoExtenderList' >"+ st +"</div>";      
            if(cntr > 13) break;
			cntr++; 	
        }          
   }
   document.getElementById('divKeywords').innerHTML=str;   
   document.getElementById('divKeywords').className  ="AutoExtender";
}
function Fail()
{    
}
function SuggestKeydown(e)
{
    var keycode=GetKeycode(e);     
    switch(keycode)
    {
       case 38: 
           moveUp(document.getElementById('divKeywords'),document.getElementById('txtKeywords'));                     
          break;
       case 40:        
          moveDown(document.getElementById('divKeywords'),document.getElementById('txtKeywords'));          
          break;
       case 13: 
          cleanUp(document.getElementById('divKeywords'));
          break;
       case 9: 
          cleanUp(document.getElementById('divKeywords'));          
          break;   
       case 27: 
          cleanUp(document.getElementById('divKeywords'));          
          break;             
    } 
    if(keycode==13) return false;   
}

function LostkeyFocus()
{
    cur=-1;        
    document.getElementById('divKeywords').className ="Hide"; 
    document.getElementById('divKeywords').innerHTML="";      
    val=0;     
}
function LostLocationFocus()
{
    cur=-1;        
    document.getElementById('divLocation').className ="Hide"; 
    document.getElementById('divLocation').innerHTML="";      
    val=0;     
}
function H_ASearch()
{
    LostkeyFocus();
    LostLocationFocus();
} 
 
 
//location search
var curL=-1;
function setLocationSearch(value) 
{  
    value=formatStr(value);
   	document.getElementById('txtLocation').value = value;
	document.getElementById('divLocation').innerHTML  = '';
	document.getElementById('divLocation').className ="Hide";
}
var suggestionL;
var valL=-1;

function GetLocationSuggestion(e)
{   
     var keycode=GetKeycode(e);
     if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
     {
        return false ;
     }
    curL=-1;          
    var keyword=document.getElementById('txtLocation').value;
    if(keyword.length==0)
    {
       document.getElementById('divLocation').innerHTML="";        
       document.getElementById('divLocation').className ="Hide";
       return false;
    }
    
    if(suggestionLocSearch.length == 0)
    {
        Get_Location();                 
    }        
    else
    {   try
        {               
            if(suggestionLocSearch.length > 0)
            {                
                SuccessArrLoc(suggestionLocSearch);        
            }
         }   
        catch(err)
        {
        }
    }    
    if(document.getElementById('divLocation').innerHTML=="")
    {
        document.getElementById('divLocation').innerHTML="";        
        document.getElementById('divLocation').className ="Hide";        
    }
}
function SuccessArrLoc(arr)
{  var str=""; 
   var st="" 
   var cntr=0;
   document.getElementById('divLocation').innerHTML="";
   var input=document.getElementById('txtLocation').value.toLowerCase();
   for(i=0;i<arr.length;i++)
   {    
        st=arr[i];  
        var index = st.toLowerCase().indexOf(input.toLowerCase());       
         if(index == 0 || st.charAt(index-1) == " ")
        { 
		    st=arr[i];
			st=st.toLowerCase();
            st=st.replace(input,"<b>"+ input +"</b>");
            str=str +"<div  class='AutoExtenderList' onmouseover='javascript:suggestOver(this);' onmouseout='javascript:suggestOut(this);' onclick='javascript:setLocationSearch(this.innerHTML);' class='AutoExtenderList' >"+ st +"</div>";      
            if(cntr > 13) break;
			cntr++; 	
        }          
   }
   document.getElementById('divLocation').innerHTML=str;   
   document.getElementById('divLocation').className  ="AutoExtender";
}

function Locationdown(e)
{
    var keycode=GetKeycode(e);    
    switch(keycode)
    {
       case 38: 
       moveUp(document.getElementById('divLocation'),document.getElementById('txtLocation'));          
          break;
       case 40: 
          moveDown(document.getElementById('divLocation'),document.getElementById('txtLocation'));
          break;
       case 13: 
          cleanUp(document.getElementById('divLocation'));
          break;
       case 9: 
          cleanUp(document.getElementById('divLocation'));          
          break;   
       case 27: 
          cleanUp(document.getElementById('divLocation'));          
          break; 
          case 13:
          cleanUp(document.getElementById('divLocation'));                    
          break;      
    }   
    if(keycode==13) return false;    
}


//Search panel keywords

var curP=-1;
function setKeywordSearchPanel(value) 
{  
    value=formatStr(value);
   	document.getElementById('SearchPanel1_txtKeywords').value = value;
	document.getElementById('divKeywords').innerHTML  = '';
	document.getElementById('divKeywords').className ="Hide";
}
var suggestionPanel=new Array();
var valPanel=-1;
function GetSuggestedKeywordsPanel(e)
{  
     var keycode=GetKeycode(e);     
     if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
     {
        return false ;
     }     
    curPanel=-1;              
    var keyword=document.getElementById('SearchPanel1_txtKeywords').value;            
    if(keyword.length==0)
    {
       document.getElementById('divKeywords').innerHTML="";        
       document.getElementById('divKeywords').className ="Hide";
       return false;
    }    
    if(suggestion.length == 0)
    { 
        Get_keyword();                 
    }        
    else
    {   try
        {              
            if(suggestion.length > 0)
            {                
                SuccessArrKeyPanel(suggestion);        
            }
         }   
        catch(err)
        {
        }
    }
    if(document.getElementById('divKeywords').innerHTML=="")
    {
        document.getElementById('divKeywords').innerHTML="";        
        document.getElementById('divKeywords').className ="Hide";        
    }
}


function SuccessArrKeyPanel(arr)
{  var str=""; 
   var st="" 
   var cntr=0;   
   var input=document.getElementById('SearchPanel1_txtKeywords').value.toLowerCase();   
   var i=0;
   for(i=0;i<arr.length;i++)
   {
        st=arr[i];  
        var index = st.toLowerCase().indexOf(input.toLowerCase());       
        if(index == 0 || st.charAt(index-1) == " ") 
        { 
		    st=arr[i];
			st=st.toLowerCase();
            st=st.replace(input,"<b>"+ input +"</b>");
            str=str +"<div  class='AutoExtenderList' onmouseover='javascript:suggestOver(this);' onmouseout='javascript:suggestOut(this);' onclick='javascript:setKeywordSearchPanel(this.innerHTML);' class='AutoExtenderList' >"+ st +"</div>";      
            if(cntr > 13) break;
			cntr++; 	
        }          
   }
   document.getElementById('divKeywords').innerHTML=str;   
   document.getElementById('divKeywords').className  ="AutoExtender";
}

function SuggestKeydownPanel(e)
{
    var keycode=GetKeycode(e);        
    switch(keycode)
    {
       case 38: 
       moveUp(document.getElementById('divKeywords'),document.getElementById('SearchPanel1_txtKeywords'));          
          break;
       case 40: 
          moveDown(document.getElementById('divKeywords'),document.getElementById('SearchPanel1_txtKeywords'));
          break;
       case 13: 
          cleanUp(document.getElementById('divKeywords'));
          break;
       case 9: 
          cleanUp(document.getElementById('divKeywords'));          
          break;   
       case 27: 
          cleanUp(document.getElementById('divKeywords'));          
          break;          
    }   
    if(keycode==13) return false;      
}

function LostkeyFocusP()
{
    cur=-1;       
    document.getElementById('divKeywords').className ="Hide"; 
    document.getElementById('divKeywords').innerHTML="";      
   valPanelLoc=0;    
}

function LostLocationFocusP()
{
    cur=-1; 
    document.getElementById('divLocation').className ="Hide"; 
    document.getElementById('divLocation').innerHTML="";      
    valPanelLoc=0;     
}

function H_ASearchP()
{
    LostkeyFocusP();
    LostLocationFocusP();
}

//Search panel location
var  curPL=-1;
var suggestionPanelLoc;
var valPanelLoc=-1;
function setLocationSearchPanel(value) 
{  
    value=formatStr(value);
   	document.getElementById('SearchPanel1_txtLocation').value = value;
	document.getElementById('divLocation').innerHTML  = '';
	document.getElementById('divLocation').className ="Hide";
}

function GetSuggestedLocationPanel(e)
{   
    var keycode=GetKeycode(e);
    if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
    {
       return false ;
    }
    curPLanel=-1;          
    var keyword=document.getElementById('SearchPanel1_txtLocation').value;      
    if(keyword.length==0)
    {
       document.getElementById('divLocation').innerHTML="";        
       document.getElementById('divLocation').className ="Hide";
       return false;
    }    
    if(suggestionLocSearch.length == 0)
    {
        Get_Location();                 
    }        
    else
    {   try
        {               
            if(suggestionLocSearch.length > 0)
            {                
                SuccessArrLocPanel(suggestionLocSearch);        
            }
         }   
        catch(err)
        {
        }
    }
    if(document.getElementById('divLocation').innerHTML=="")
    {
        document.getElementById('divLocation').innerHTML="";        
        document.getElementById('divLocation').className ="Hide";        
    }
}


function SuccessArrLocPanel(arr)
{  
   var str=""; 
   var st="" 
   var cntr=0;
   var i=0;
   var input=document.getElementById('SearchPanel1_txtLocation').value.toLowerCase();
   for(i=0;i<arr.length;i++)
   {    
        st=arr[i];  
        var index = st.toLowerCase().indexOf(input.toLowerCase());       
        if(index == 0 || st.charAt(index-1) == " ") 
        { 
		    st=arr[i];
			st=st.toLowerCase();
            st=st.replace(input,"<b>"+ input +"</b>");
            str=str +"<div  class='AutoExtenderList' onmouseover='javascript:suggestOver(this);' onmouseout='javascript:suggestOut(this);' onclick='javascript:setLocationSearchPanel(this.innerHTML);' class='AutoExtenderList' >"+ st +"</div>";      
            if(cntr > 13) break;
			cntr++; 	
        }          
   }
   document.getElementById('divLocation').innerHTML=str;   
   document.getElementById('divLocation').className  ="AutoExtender";
}

function SuggestLocationkeydownPanel(e)
{
    var keycode=GetKeycode(e);    
    switch(keycode)
    {
       case 38: 
       moveUp(document.getElementById('divLocation'),document.getElementById('SearchPanel1_txtLocation'));          
          break;
       case 40: 
          moveDown(document.getElementById('divLocation'),document.getElementById('SearchPanel1_txtLocation'));
          break;
       case 13: 
          cleanUp(document.getElementById('divLocation'));
          break;
       case 9: 
          cleanUp(document.getElementById('divLocation'));          
          break;   
       case 27: 
          cleanUp(document.getElementById('divLocation'));          
          break;      
    case 13:
          cleanUp(document.getElementById('divLocation'));                    
          break;      
    }   
    if(keycode==13) return false;   
}

function PanelLocationLostfocus()
{   
    cur=-1;
    cleanUp(document.getElementById('divLocation'));    
    valPanelLoc=0;     
}



//Resume search

function GetSuggestedResumeKeywords(e)
{  
     var keycode=GetKeycode(e);     
     if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
     {
        return false ;
     }     
    cur=-1;      
    var keyword=document.getElementById('txtKeywords').value;    
    if(keyword.length==0)
    {
       document.getElementById('divKeywords').innerHTML="";        
       document.getElementById('divKeywords').className ="Hide";
       return false;
    }    
    if(suggestion.length == 0)
    {
        Get_Resumekeyword();                 
    }        
    else
    {   try
        {               
            if(suggestion.length > 0)
            {                
                SuccessArr(suggestion);        
            }
         }   
        catch(err)
        {
        }
    }
    if(document.getElementById('divKeywords').innerHTML=="")
    {
        document.getElementById('divKeywords').innerHTML="";        
        document.getElementById('divKeywords').className ="Hide";        
    }
}

//resume search1
function GetSuggestedResumeKeywords2(e)
{  
     var keycode=GetKeycode(e);     
     if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
     {
        return false ;
     }     
    cur=-1;      
    var keyword=document.getElementById('txtKeywords').value;    
    if(keyword.length==0)
    {
       document.getElementById('divKeywords2').innerHTML="";        
       document.getElementById('divKeywords2').className ="Hide";
       return false;
    }
    if(suggestion.length == 0)
    {
        Get_Resumekeyword();                 
    }        
    else
    {   try
        {               
            if(suggestion.length > 0)
            {                
                SuccessArr2(suggestion);        
            }
         }   
        catch(err)
        {
        }
    }
    if(document.getElementById('divKeywords2').innerHTML=="")
    {    
        document.getElementById('divKeywords2').innerHTML="";        
        document.getElementById('divKeywords2').className ="Hide";        
    }
    
}

function SuccessArr2(arr)
{  var str=""; 
   var st="" 
   var cntr=0;
   var input=document.getElementById('txtKeywords').value.toLowerCase();   
   document.getElementById('divKeywords2').innerHTML="";      
   for(i=0;i<arr.length;i++)
   {    
        st=arr[i];  
        var index = st.toLowerCase().indexOf(input.toLowerCase());       
        if(index == 0 || st.charAt(index-1) == " ")
        {                     
		    st=arr[i];
			st=st.toLowerCase();
            st=st.replace(input,"<b>"+ input +"</b>");
            str=str +"<div  class='AutoExtenderList' onmouseover='javascript:suggestOver(this);' onmouseout='javascript:suggestOut(this);' onclick='setKeywordSearch2(this.innerHTML)' class='AutoExtenderList' >"+ st +"</div>";      
            if(cntr > 13) break;
			cntr++; 	
        }          
   }   
   document.getElementById('divKeywords2').innerHTML=str;      
   document.getElementById('divKeywords2').className  ="AutoExtender";   
}
function setKeywordSearch2(value) 
{ 
    value=formatStr(value);   
   	document.getElementById('txtKeywords').value = value;   	 
	document.getElementById('divKeywords2').innerHTML  = '';
	document.getElementById('divKeywords2').className ="Hide";	
}

function SuggestKeydown2(e)
{
    var keycode=GetKeycode(e);     
    switch(keycode)
    {
       case 38: 
           moveUp(document.getElementById('divKeywords2'),document.getElementById('txtKeywords'));                     
          break;
       case 40:        
          moveDown(document.getElementById('divKeywords2'),document.getElementById('txtKeywords'));          
          break;
       case 13: 
          cleanUp(document.getElementById('divKeywords2'));
          break;
       case 9: 
          cleanUp(document.getElementById('divKeywords2'));          
          break;   
       case 27: 
          cleanUp(document.getElementById('divKeywords2'));          
          break;             
    } 
    if(keycode==13) return false;   
}

function LostkeyFocus2()
{
    cur=-1;        
    document.getElementById('divKeywords2').className ="Hide"; 
    document.getElementById('divKeywords2').innerHTML="";      
    val=0;     
}
function LostLocationFocus2()
{
    cur=-1;        
    document.getElementById('divLocation2').className ="Hide"; 
    document.getElementById('divLocation2').innerHTML="";      
    val=0;     
}

function  H_ASearchP2()
{
    LostkeyFocus2();
    LostLocationFocus2();
}



function Get_keyword()
{
    if(suggestion.length == 0)
    {
        Suggestion.SuggestKeyword(Fill_Keywords,Fail); 
    }        
}
function Get_Location()
{
    if(suggestionLocSearch.length == 0)
    {
        Suggestion.SuggestLocation(Fill_Location,Fail); 
    }
}
function Get_Resumekeyword()
{
    if(suggestion.length == 0)
    {
        Suggestion.SuggestResumeKeyword(Fill_Keywords,Fail); 
    } 
}

function Fill_Keywords(results)
{  
   var res=results;   
   if(res !="")
   {    
        suggestion=res;
    }
}
function Fill_Location(results)
{  
   var res=results;   
   if(res !="")
   {    
        suggestionLocSearch=res;
    }
}
function suggestOver(div_value) 
{
	div_value.className ='AutoExtenderHighlight';
}
function suggestOut(div_value) 
{
	div_value.className ='AutoExtenderList';
}

function formatStr(value)
{
    value=value.replace("<B>","");
    value=value.replace("</B>","");
    value=value.replace("<b>","");
    value=value.replace("</b>","");
    value=value.replace("&amp;","&");
    value=value.replace("&AMP;","&");
    value=value.replace("&lt;","<");
    value=value.replace("&gt;",">");
    return value ;    
}
    
function GetKeycode(e) 
{
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;       
    return keycode ;
}


function cleanUp(div)
{
     div.innerHTML="";        
     div.className ="Hide"; 
     val=0;     
}

function moveDown(div,input)
 {
    var oDiv=div;
    var oText= input;
    if(oDiv.childNodes.length>0 && cur<(oDiv.childNodes.length-1))
    {
       ++cur;
       for(var i=0;i<oDiv.childNodes.length;i++)
       { 
          if(i==cur)
          {
             oDiv.childNodes[i].className="AutoExtenderHighlight";
             oText.value=oDiv.childNodes[i].innerHTML;
             oText.value=formatStr(oText.value);
          }
          else
          {
             oDiv.childNodes[i].className="AutoExtenderList";
          }
       }
    }    
 };
 
 function  moveUp(div,input) 
 {
    var oDiv=div; 
    var oText=input;
    if(oDiv.childNodes.length >0 && this.cur>0 ) 
    {        
       --cur;
       for(var i=0;i<oDiv.childNodes.length;i++)
       {
          if(i==cur)
          {            
             oDiv.childNodes[i].className="AutoExtenderHighlight";
             oText.value=oDiv.childNodes[i].innerHTML;
             oText.value=formatStr(oText.value);
          }
          else
          {
             oDiv.childNodes[i].className="AutoExtenderList";
          }
       }
    }
 };
 function D_YN()
 {
    Get_keyword();
    Get_Location();
 }
 function D_YNResume()
 {
    Get_Resumekeyword();
    Get_Location();
 }


//Searchjob page

function setKeywordSearch1(value) 
{ 
    value=formatStr(value);   
   	document.getElementById('txtKeywords').value = value;   	 
	document.getElementById('divKeywords1').innerHTML  = '';
	document.getElementById('divKeywords1').className ="Hide";	
}
var val=-1;
function GetSuggestedKeywords1(e)
{    
     var keycode=GetKeycode(e);     
     if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
     {
        return false ;
     }     
     
    cur=-1;      
    var keyword=document.getElementById('txtKeywords').value;         
    if(keyword.length==0)
    {
       document.getElementById('divKeywords1').innerHTML="";        
       document.getElementById('divKeywords1').className ="Hide";
       return false;
    }    
    if(suggestion.length == 0)
    {        
        Get_keyword();                 
    }        
    else
    {   try
        {               
            if(suggestion.length > 0)
            {                
                SuccessArr1(suggestion);        
            }
         }   
        catch(err)
        {
        }
    }
    if(document.getElementById('divKeywords1').innerHTML=="")
    {
        document.getElementById('divKeywords1').innerHTML="";        
        document.getElementById('divKeywords1').className ="Hide";        
    }
}

function SuccessArr1(arr)
{  var str=""; 
   var st="" 
   var cntr=0;
   var input=document.getElementById('txtKeywords').value.toLowerCase();
   document.getElementById('divKeywords1').innerHTML="";   
   for(i=0;i<arr.length;i++)
   {    
        st=arr[i];  
        var index = st.toLowerCase().indexOf(input.toLowerCase());       
        if(index == 0 || st.charAt(index-1) == " ")
        {             
		    st=arr[i];
			st=st.toLowerCase();
            st=st.replace(input,"<b>"+ input +"</b>");
            str=str +"<div  class='AutoExtenderList' onmouseover='javascript:suggestOver(this);' onmouseout='javascript:suggestOut(this);' onclick='setKeywordSearch1(this.innerHTML)' class='AutoExtenderList' >"+ st +"</div>";      
            if(cntr > 13) break;
			cntr++; 	
        }          
   }
   document.getElementById('divKeywords1').innerHTML=str;   
   document.getElementById('divKeywords1').className  ="AutoExtender";
}

function SuggestKeydown1(e)
{
    var keycode=GetKeycode(e);     
    switch(keycode)
    {
       case 38: 
           moveUp(document.getElementById('divKeywords1'),document.getElementById('txtKeywords'));                     
          break;
       case 40:        
          moveDown(document.getElementById('divKeywords1'),document.getElementById('txtKeywords'));          
          break;
       case 13: 
          cleanUp(document.getElementById('divKeywords1'));
          break;
       case 9: 
          cleanUp(document.getElementById('divKeywords1'));          
          break;   
       case 27: 
          cleanUp(document.getElementById('divKeywords1'));          
          break;             
    } 
    if(keycode==13) return false;   
}

function LostkeyFocus1()
{
    cur=-1;        
    document.getElementById('divKeywords1').className ="Hide"; 
    document.getElementById('divKeywords1').innerHTML="";      
    val=0;     
}
function LostLocationFocus1()
{
    cur=-1;        
    document.getElementById('divLocation1').className ="Hide"; 
    document.getElementById('divLocation1').innerHTML="";      
    val=0;     
}

function H_ASearch2()
{
    LostkeyFocus1();
    LostLocationFocus1();
}
 
 
 //location searchjob.aspx
var curL=-1;
function setLocationSearch1(value) 
{  
    value=formatStr(value);
   	document.getElementById('txtLocation').value = value;
	document.getElementById('divLocation1').innerHTML  = '';
	document.getElementById('divLocation1').className ="Hide";
}
var suggestionL;
var valL=-1;

function GetLocationSuggestion1(e)
{   
     var keycode=GetKeycode(e);
     if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
     {
        return false ;
     }
    curL=-1;          
    var keyword=document.getElementById('txtLocation').value;
    if(keyword.length==0)
    {
       document.getElementById('divLocation1').innerHTML="";        
       document.getElementById('divLocation1').className ="Hide";
       return false;
    }
    
    if(suggestionLocSearch.length == 0)
    {
        Get_Location();                 
    }        
    else
    {   try
        {               
            if(suggestionLocSearch.length > 0)
            {                
                SuccessArrLoc1(suggestionLocSearch);        
            }
         }   
        catch(err)
        {
        }
    }    
    if(document.getElementById('divLocation1').innerHTML=="")
    {
        document.getElementById('divLocation1').innerHTML="";        
        document.getElementById('divLocation1').className ="Hide";        
    }
}
function SuccessArrLoc1(arr)
{  var str=""; 
   var st="" 
   var cntr=0;
   document.getElementById('divLocation1').innerHTML="";
   var input=document.getElementById('txtLocation').value.toLowerCase();
   for(i=0;i<arr.length;i++)
   {    
        st=arr[i];  
        var index = st.toLowerCase().indexOf(input.toLowerCase());       
         if(index == 0 || st.charAt(index-1) == " ")
        { 
		    st=arr[i];
			st=st.toLowerCase();
            st=st.replace(input,"<b>"+ input +"</b>");
            str=str +"<div  class='AutoExtenderList' onmouseover='javascript:suggestOver(this);' onmouseout='javascript:suggestOut(this);' onclick='javascript:setLocationSearch1(this.innerHTML);' class='AutoExtenderList' >"+ st +"</div>";      
            if(cntr > 13) break;
			cntr++; 	
        }          
   }
   document.getElementById('divLocation1').innerHTML=str;   
   document.getElementById('divLocation1').className  ="AutoExtender";
}

function Locationdown1(e)
{
    var keycode=GetKeycode(e);    
    switch(keycode)
    {
       case 38: 
       moveUp(document.getElementById('divLocation1'),document.getElementById('txtLocation'));          
          break;
       case 40: 
          moveDown(document.getElementById('divLocation1'),document.getElementById('txtLocation'));
          break;
       case 13: 
          cleanUp(document.getElementById('divLocation1'));
          break;
       case 9: 
          cleanUp(document.getElementById('divLocation1'));          
          break;   
       case 27: 
          cleanUp(document.getElementById('divLocation1'));          
          break; 
          case 13:
          cleanUp(document.getElementById('divLocation1'));                    
          break;      
    }   
    if(keycode==13) return false;    
}

//resume search location 2
var curL=-1;
function setLocationSearch2(value) 
{  
    value=formatStr(value);
   	document.getElementById('txtLocation').value = value;
	document.getElementById('divLocation2').innerHTML  = '';
	document.getElementById('divLocation2').className ="Hide";
}
var suggestionL;
var valL=-1;

function GetLocationSuggestion2(e)
{   
     var keycode=GetKeycode(e);
     if(keycode==40 || keycode==38 || keycode==37 || keycode==39 ||  keycode==27 || keycode==13)
     {
        return false ;
     }
    curL=-1;          
    var keyword=document.getElementById('txtLocation').value;
    if(keyword.length==0)
    {
       document.getElementById('divLocation2').innerHTML="";        
       document.getElementById('divLocation2').className ="Hide";
       return false;
    }
    
    if(suggestionLocSearch.length == 0)
    {
        Get_Location();                 
    }        
    else
    {   try
        {               
            if(suggestionLocSearch.length > 0)
            {                
                SuccessArrLoc2(suggestionLocSearch);        
            }
         }   
        catch(err)
        {
        }
    }    
    if(document.getElementById('divLocation2').innerHTML=="")
    {
        document.getElementById('divLocation2').innerHTML="";        
        document.getElementById('divLocation2').className ="Hide";        
    }
}
function SuccessArrLoc2(arr)
{  var str=""; 
   var st="" 
   var cntr=0;
   document.getElementById('divLocation2').innerHTML="";
   var input=document.getElementById('txtLocation').value.toLowerCase();
   for(i=0;i<arr.length;i++)
   {    
        st=arr[i];  
        var index = st.toLowerCase().indexOf(input.toLowerCase());       
         if(index == 0 || st.charAt(index-1) == " ")
        { 
		    st=arr[i];
			st=st.toLowerCase();
            st=st.replace(input,"<b>"+ input +"</b>");
            str=str +"<div  class='AutoExtenderList' onmouseover='javascript:suggestOver(this);' onmouseout='javascript:suggestOut(this);' onclick='javascript:setLocationSearch2(this.innerHTML);' class='AutoExtenderList' >"+ st +"</div>";      
            if(cntr > 13) break;
			cntr++; 	
        }          
   }
   document.getElementById('divLocation2').innerHTML=str;   
   document.getElementById('divLocation2').className  ="AutoExtender";
}

function Locationdown2(e)
{
    var keycode=GetKeycode(e);    
    switch(keycode)
    {
       case 38: 
       moveUp(document.getElementById('divLocation2'),document.getElementById('txtLocation'));          
          break;
       case 40: 
          moveDown(document.getElementById('divLocation2'),document.getElementById('txtLocation'));
          break;
       case 13: 
          cleanUp(document.getElementById('divLocation2'));
          break;
       case 9: 
          cleanUp(document.getElementById('divLocation2'));          
          break;   
       case 27: 
          cleanUp(document.getElementById('divLocation2'));          
          break; 
          case 13:
          cleanUp(document.getElementById('divLocation2'));                    
          break;      
    }   
    if(keycode==13) return false;    
}


function OnMinExp_Change(type) {
    var dd_qm = document.getElementById("ddlExpMin");
    var dd_qx = document.getElementById("ddlExpMax");
    var maxval= document.getElementById("ddlExpMax").value;
    if (type == 'off')
        dd_qm.value = dd_qx.value = -1;

    var min_value = parseInt(dd_qm.value);


    removeAllOptions(dd_qx);
    addOption(dd_qx, -1, 'Any');
    if (min_value < 0) return;
    else if (min_value == 12477) {
        addOption(dd_qx, 12477, "< 1");
        min_value = 1;
    }

    var final_value = 50;
    var part = '';
    while (min_value <= final_value) {
        if (min_value == 1) part = '';
        else part = '';
        var str = min_value;
        addOption(dd_qx, min_value, str + " " + part);
        min_value += 1;        
    }
    dd_qx.value=maxval;    
    delete (part);    
    //dd_qx.selectedIndex=0;
    //addOption(dd_qx,51, "50");
}
function removeAllOptions(selectbox) {
    var i;
    for (i = selectbox.options.length - 1; i >= 0; i--) {
        selectbox.remove(i);
    }
}
function addOption(selectbox, value, text) {
    selectbox.options[selectbox.options.length] = new Option(text, value);
}

