﻿/*
if(cityValue!='')
       document.getElementById('txtFindIn').value=cityValue;
    if(categoryIdValue!='')
        document.getElementById('selCategory').value=categoryIdValue;
        
    if(productValue!='')
    {
        document.getElementById('txtKeywordSearch').value=productValue;
        
     }
    
    if(lookinValue=='Products')
    {   document.getElementById('selLookIn').value='Products';
    }
    else if(lookinValue=='Local')
    {   document.getElementById('selLookIn').value='Local';
    }   
    else if(lookinValue=='Sawaal')
    {   document.getElementById('selLookIn').value='Sawaal';
    }
    else if(lookinValue=='Polls')
    {   document.getElementById('selLookIn').value='Polls';
    }
    else if(lookinValue=='Blogs')
    {   document.getElementById('selLookIn').value='Blogs';
    }
    else if(lookinValue=='People')
    {   document.getElementById('selLookIn').value='People';
    }
     else if(lookinValue=='ibibo')
    {   document.getElementById('selLookIn').value='ibibo';
    }
     else if(lookinValue=='Photos')
    {   document.getElementById('selLookIn').value='Photos';
    }
    function fnChange()
    {
    
       if(document.getElementById('selLookIn').value=='Products')
        {        
              document.getElementById('divInput').style.visibility='hidden';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.visibility='visible';
              document.getElementById('divInput').style.display='none';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.display='block';
              document.getElementById('divLabelKeywords').innerHTML='Find a movie, laptop, camera, TV, mobile...';document.getElementById('divLabelIn').innerHTML='Select category';
              document.getElementById('txtKeywordSearch').style.width='290px';document.getElementById('txtKeywordSearch').value="e.g., Nokia N95, Honda Civic, Sony Bravia";
        }
        else if(document.getElementById('selLookIn').value=='Local')
        {        
              document.getElementById('divInput').style.visibility='visible';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.visibility='hidden';
              document.getElementById('divInput').style.display='block';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.display='none';
              document.getElementById('divLabelKeywords').innerHTML='Find a service, shop, restaurant, local business...';document.getElementById('divLabelIn').innerHTML='in or near';
              document.getElementById('txtKeywordSearch').style.width='280px';document.getElementById('txtKeywordSearch').value="e.g., dentists, Chinese restaurants, fitness centres";
        }       
        else if(document.getElementById('selLookIn').value=='Sawaal')
        {        
              document.getElementById('divInput').style.visibility='hidden';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.visibility='hidden';
              document.getElementById('divInput').style.display='none';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.display='none';
              document.getElementById('divLabelKeywords').innerHTML='  ';document.getElementById('divLabelIn').innerHTML='';
              document.getElementById('txtKeywordSearch').style.width='460px';document.getElementById('txtKeywordSearch').value="e.g., Where can I get the best sushi in Bangalore?";
        }
        else if(document.getElementById('selLookIn').value=='Polls')
        {
              document.getElementById('divInput').style.visibility='hidden';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.visibility='hidden';
              document.getElementById('divInput').style.display='none';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.display='none';
              document.getElementById('divLabelKeywords').innerHTML=' ';document.getElementById('divLabelIn').innerHTML='';
              document.getElementById('txtKeywordSearch').style.width='460px';document.getElementById('txtKeywordSearch').value="e.g., beauty, city, leader, food";
        }
        else if(document.getElementById('selLookIn').value=='Blogs')
        {     var validBlogText = true;
              document.getElementById('divInput').style.visibility='hidden';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.visibility='hidden';
              document.getElementById('divInput').style.display='none';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.display='none';
              document.getElementById('divLabelKeywords').innerHTML=' ';document.getElementById('divLabelIn').innerHTML='';
              document.getElementById('txtKeywordSearch').style.width='460px';
               if(location.href.indexOf('pages') == -1 && location.href.split('/blogsearch/').length > 1)
               {document.getElementById('txtKeywordSearch').value = unescape(location.href.split('/blogsearch/')[1]).replace('_','&'); validBlogText = false;}
               if(location.href.indexOf('pages') >= 0 && location.href.split('/blogsearch/').length > 1 && location.href.split('/blogsearch/')[1].split("/pages/").length>0)
               {document.getElementById('txtKeywordSearch').value = unescape(location.href.split('/blogsearch/')[1]).split("/pages/")[0].replace('_','&');validBlogText = false;}
               if(validBlogText == true){document.getElementById('txtKeywordSearch').value="e.g., Sachin Tendulkar, recipes, Aishwarya";}
        }
        else if(document.getElementById('selLookIn').value=='People')
        {     document.getElementById('divInput').style.visibility='hidden';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.visibility='hidden';
              document.getElementById('divInput').style.display='none';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.display='none';
              document.getElementById('divLabelKeywords').innerHTML=' ';document.getElementById('divLabelIn').innerHTML='';
              document.getElementById('txtKeywordSearch').style.width='460px';document.getElementById('txtKeywordSearch').value="e.g., Priya, Rani, Sonia, Rajat";
        }
         else if(document.getElementById('selLookIn').value=='ibibo')
        {
              document.getElementById('divInput').style.visibility='hidden';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.visibility='hidden';
              document.getElementById('divInput').style.display='none';document.getElementById('ctl00_ctl00_ctl00_header1_SearchCtrl1_divSel').style.display='none';
              document.getElementById('divLabelKeywords').innerHTML=' ';
              document.getElementById('divLabelIn').innerHTML='';document.getElementById('txtKeywordSearch').style.width='460px';
              document.getElementById('txtKeywordSearch').value="e.g., Sachin Tendulkar, Nokia N95, Chinese restaurant";}}
    fnChange();
    function validate()
    {  
  //  alert('aaa');
//    return false;
    if(document.getElementById('selLookIn').value=='Products')
        { if(document.getElementById('txtKeywordSearch').value=='' ||document.getElementById('txtKeywordSearch').value=='e.g., Nokia N95, Honda Civic, Sony Bravia' )
            {document.getElementById('errmsg').innerHTML='Please enter what you want to search';return false;}
            if(document.getElementById('selCategory').value=='-1')
              {document.getElementById('errmsg').innerHTML='Please select a category';return false;}}
        else if(document.getElementById('selLookIn').value=='Local')
        { if(document.getElementById('txtKeywordSearch').value=='' ||document.getElementById('txtKeywordSearch').value=='e.g., dentists, Chinese restaurants, fitness centres' )
            {document.getElementById('errmsg').innerHTML='Please enter what you want to search';return false;}
            if(document.getElementById('txtFindIn').value=='' || document.getElementById('txtFindIn').value=='e.g., GK1, Bandra' )
            {document.getElementById('errmsg').innerHTML='Please type a city';return false;}}
        else if(document.getElementById('selLookIn').value=='Sawaal')
        {if(document.getElementById('txtKeywordSearch').value=='' ||document.getElementById('txtKeywordSearch').value=='e.g., Where can I get the best sushi in Bangalore?' )
            {document.getElementById('errmsg').innerHTML='Please enter what you want to search';return false;}}
        else if(document.getElementById('selLookIn').value=='Polls')
        { if(document.getElementById('txtKeywordSearch').value=='' ||document.getElementById('txtKeywordSearch').value=='e.g., beauty, city, leader, food' )
            {document.getElementById('errmsg').innerHTML='Please enter what you want to search';return false;}}
        else if(document.getElementById('selLookIn').value=='Blogs')
        { if(document.getElementById('txtKeywordSearch').value=='' ||document.getElementById('txtKeywordSearch').value=='e.g., Sachin Tendulkar, recipes, Aishwarya' )
            {document.getElementById('errmsg').innerHTML='Please enter what you want to search';return false;}}       
        else if(document.getElementById('selLookIn').value=='People')
        {  if(document.getElementById('txtKeywordSearch').value=='' ||document.getElementById('txtKeywordSearch').value=='e.g., Priya, Rani, Sonia, Rajat' )
            {document.getElementById('errmsg').innerHTML='Please enter what you want to search';return false;}
        }
        else if(document.getElementById('selLookIn').value=='ibibo')
        { if(document.getElementById('txtKeywordSearch').value=='' ||document.getElementById('txtKeywordSearch').value=='e.g., Sachin Tendulkar, Nokia N95, Chinese restaurant' )
            {document.getElementById('errmsg').innerHTML='Please enter what you want to search';return false;
            }}document.getElementById('errmsg').innerHTML='';
        submitform();return true;}    
    function SetFocus()
    {  document.getElementById("txtKeywordSearch").style.color = '#333';
       var dropDownvalue = document.getElementById('selLookIn')[document.getElementById('selLookIn').selectedIndex].value;
       var validate = false;
       if(document.getElementById("txtKeywordSearch").value == 'e.g., Sachin Tendulkar, Nokia N95, Chinese restaurant' 
       || document.getElementById("txtKeywordSearch").value == 'e.g., Priya, Rani, Sonia, Rajat'
       || document.getElementById("txtKeywordSearch").value == 'e.g., Sachin Tendulkar, recipes, Aishwarya'
       || document.getElementById("txtKeywordSearch").value == 'e.g., beauty, city, leader, food'
       || document.getElementById("txtKeywordSearch").value == 'e.g., Where can I get the best sushi in Bangalore?'
       || document.getElementById("txtKeywordSearch").value == 'e.g., dentists, Chinese restaurants, fitness centres'
       ||document.getElementById("txtKeywordSearch").value == 'e.g., Nokia N95, Honda Civic, Sony Bravia')
       {validate = true;}
       if(validate == true)
       {   if(dropDownvalue=="Products")
            {document.getElementById("txtKeywordSearch").value="";}
            else if(dropDownvalue=="Local")
            {document.getElementById("txtKeywordSearch").value="";}
            else if(dropDownvalue=="Sawaal")
            {document.getElementById("txtKeywordSearch").value="";}
            else if(dropDownvalue=="Polls")
            {document.getElementById("txtKeywordSearch").value="";}
            else if(dropDownvalue=="Blogs")
            {document.getElementById("txtKeywordSearch").value="";}
           else if(dropDownvalue=="People")
            {document.getElementById("txtKeywordSearch").value="";}
            else if(dropDownvalue=="ibibo")
            {document.getElementById("txtKeywordSearch").value="";}
            }
      }   
     */ 
     function CanonSetFocus()
    {  document.getElementById("txtKeywordSearch1").style.color = '#333';
       if(document.getElementById("txtKeywordSearch1").value == 'e.g., Sachin Tendulkar, recipes, Aishwarya' 
       )
       {validate = true;}
       if(validate == true)
       {   
        document.getElementById("txtKeywordSearch1").value="";}
           
      } 
     function CanonSetBlur()
    {   var UserColor =  '#999';    
        
        document.getElementById("txtKeywordSearch1").style.color = UserColor;    
      }
        
    function SetBlur()
    {   var UserColor =  '#999';    
        var dropDownvalue = document.getElementById('selLookIn')[document.getElementById('selLookIn').selectedIndex].value    
        if(dropDownvalue=="Products")
        {
           if(document.getElementById("txtKeywordSearch").value == '') {document.getElementById("txtKeywordSearch").value="e.g., Nokia N95, Honda Civic, Sony Bravia";}
           else{UserColor = '#333';}
        }
        else if(dropDownvalue=="Local")
        {
          if(document.getElementById("txtKeywordSearch").value == '')            
          document.getElementById("txtKeywordSearch").value="e.g., dentists, Chinese restaurants, fitness centres";
           else{UserColor = '#333';}
        }
        else if(dropDownvalue=="Sawaal")
        {
        if(document.getElementById("txtKeywordSearch").value == '') 
          document.getElementById("txtKeywordSearch").value="e.g., Where can I get the best sushi in Bangalore?";
           else{UserColor = '#333';}
        }
        else if(dropDownvalue=="Polls")
        {
        if(document.getElementById("txtKeywordSearch").value == '') 
          document.getElementById("txtKeywordSearch").value="e.g., beauty, city, leader, food";
           else{UserColor = '#333';}
        }
        else if(dropDownvalue=="Blogs")
        {
        if(document.getElementById("txtKeywordSearch").value == '') 
          document.getElementById("txtKeywordSearch").value="e.g., Sachin Tendulkar, recipes, Aishwarya";
           else{UserColor = '#333';}
        }
       else if(dropDownvalue=="People")
        {
        if(document.getElementById("txtKeywordSearch").value == '') 
          document.getElementById("txtKeywordSearch").value="e.g., Priya, Rani, Sonia, Rajat";
           else{UserColor = '#333';}
        }
        else if(dropDownvalue=="ibibo")
        {
            if(document.getElementById("txtKeywordSearch").value == '') 
            {document.getElementById("txtKeywordSearch").value="e.g., dentists, Chinese restaurants, fitness centres";}
            else{UserColor = '#333';}
        }
        document.getElementById("txtKeywordSearch").style.color = UserColor;    
      }
        
        
        function check1(obj, e)
{
//alert('a');
e = e || window.event;
    if(e.keyCode==13)
    {
        validate();
        window.event.cancel = true;
    }
    return false;
    
}
function replaceSpChar(strChar){var temp = new String(strChar); temp = temp.replace(/[^a-zA-Z 0-9 & ]+/g,'');return temp;}
function replaceSpace(strChar){var temp = new String(strChar); temp = temp.replace(/[' ']+/g,'-');return temp;}
function replaceAmpper(strChar){var temp = new String(strChar); temp = temp.replace(/\s*['&']+\s*/g,'_');return temp;}
function replaceUnderScoreWithAmpper(strChar){var temp = new String(strChar); temp = temp.replace(/['_']+/g,' & ');return temp;}
function ConvertSearchToUrl(strChar)
{
    var temp = new String(strChar);
    temp = temp.replace(/[_]+/g,'');
    temp = temp.replace(/[^a-zA-Z 0-9 &]+/g,'');
    temp = temp.replace(/\s*&\s*/g,'_');
    temp = trim(temp);
    temp = temp.replace(/\s+/g,'-');
    temp = temp.replace(/[_]{2,}/g,'_');
    temp = trim(temp, '_');
    return temp;
}
function trim(str)
{
    return str.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
}
    
   function submitform()
    { 
    //alert('aaaaa');
   
    if(navigator.appName=='Microsoft Internet Explorer')
	            window.event.returnValue = false;    
    var URL='';
    var searchTerm = document.getElementById('txtKeywordSearch').value;
        //searchTerm = searchTerm.replace("&","_");
      
      
    if(document.getElementById('selLookIn').value=='Products')
     {  URL=strReviewUrl;
        location.href=URL+ "SearchReviews.aspx?q="+document.getElementById('txtKeywordSearch').value+"&r=" + document.getElementById('txtFindIn').value + "&s=" + document.getElementById('selCategory').value;}
     else if(document.getElementById('selLookIn').value=='Local')
     {  URL=strLocalURL;
        location.href=URL+ "SearchReviews.aspx?q="+document.getElementById('txtKeywordSearch').value+"&r=" + document.getElementById('txtFindIn').value + "&s=" + document.getElementById('selCategory').value;}
     else if(document.getElementById('selLookIn').value=='Sawaal')
     {location.href=strSawaalSearchURl+document.getElementById('txtKeywordSearch').value;}
     else if(document.getElementById('selLookIn').value=='Polls')
     {location.href=strPollsSearchUrl+document.getElementById('txtKeywordSearch').value;}
     else if(document.getElementById('selLookIn').value=='Blogs')
     {
      
      searchTerm = replaceSpChar(searchTerm);     
      searchTerm = replaceAmpper(searchTerm);
      //searchTerm=replaceSpace(searchTerm);
     //location.href='http://my.ibibo.com/Search/Iframe/blogs/%253Fq='+escape(searchTerm);
     location.href='http://cnon.ibibo.com/blogsearch/'+escape(searchTerm);
     }
     else if(document.getElementById('selLookIn').value=='People')
     {location.href=strPeopleSearchUrl+document.getElementById('txtKeywordSearch').value;}
     else if(document.getElementById('selLookIn').value=='ibibo')
     {location.href=stribiboSearchUrl+document.getElementById('txtKeywordSearch').value;}
    }
    


function check(obj, e)
{
e = e || window.event;
    if(e.keyCode==13)
    {
        validateSearch();
        window.event.cancel = true;
    }
    return false;
    
}

var pageURL=varAppPath;

        
function validateSearch()
{
//alert('aaa121211');

if(document.getElementById('txtKeywordSearch1').value=='' ||document.getElementById('txtKeywordSearch1').value=='e.g., Sachin Tendulkar, recipes, Aishwarya' )
            {
            document.getElementById('errmsg1').innerHTML='Please enter what you want to search';return false;
            }
         submitSearchForm();return true;   
} 

            
function submitSearchForm()
    { 
    //alert('aaaaa11');
    if(navigator.appName=='Microsoft Internet Explorer')
    {
	            window.event.returnValue = false;    
	 }
    var URL='';
    URL = varAppPath;
     /*var searchTerm = document.getElementById('txtKeywordSearch1').value;
     //searchTerm = searchTerm.replace("&","_");
     
     searchTerm = replaceSpChar(unescape(searchTerm));
     //searchTerm = searchTerm.repl(" ","-");
     
     searchTerm=replaceSpace(searchTerm);     
     searchTerm = replaceAmpper(searchTerm);*/
     
     
     var searchTerm = ConvertSearchToUrl(document.getElementById('txtKeywordSearch1').value);
        //searchTerm = searchTerm.replace("&","_");
      //searchTerm = replaceSpChar(searchTerm);  
      //searchTerm = replaceAmpper(searchTerm);
      //searchTerm = replaceSpace(searchTerm);
     //pageURL=;
     
      
     //location.href='blogsearch/'+unescape(searchTerm);
     var NewSearchTerm =unescape(searchTerm);
     //window.location.href=URL+'blogsearch/'+NewSearchTerm;
     
     
     //location.href=URL+'blogsearch/'+NewSearchTerm;
     location.href=URL+'blogsearch/'+NewSearchTerm;
     //window.open(URL+'blogsearch/'+NewSearchTerm);
     
    
     }
     
   
