/*
***************************************************************************
		-TopLevelTabControl Functionality
		-Coded by Harmeet/Aga/Nagesh/Gopal

      Main functionalities:

                        -- Checking Main Cookie functionality 
                        -- Search Cookie Functionality
                        -- CaseRef Functionality
                        -- TagCloud Functionality
***************************************************************************
***************************************************************************
*/

var tabValueG = "";
var tabSelectedVal="";
var isloaded='N';

//To Check the Landing Page Cookie 
function clickanchor()
{
    document.getElementById("launchLandingPage").click();
}
  
function CheckLandingPageCookie(tabVal)
{
  OpenPreferencesWindow(tabVal);
  return false;  
}

function captureenterkey_foo(e)
{
    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
    var keyCode = (isNN) ? e.which : event.keyCode; 
    if(keyCode == 13)
    {
	    TopLevelSearch('Call');
    	return false;
    }
}

// To check the Active Tab for myverizon flow 10/30 MYV
function CheckActiveTabmyv(activeTab,frompop,solncenter)
{
  try
  {
      var url = "" + window.location;
      var queryStringIndex = url.indexOf('=') + 1;
      tabSelectedVal=activeTab;
	  if(activeTab.toLowerCase()=="internet")
      {
        document.getElementById('SuTab2').className='AcRTabM';
        document.getElementById('SuTab1').className='AcGTabM';
        document.getElementById('SuTab3').className='AcGTabM';
        document.getElementById('SuTab4').className='AcGTabM';
        document.getElementById('SuTab5').className='AcGTabM';
        
        document.getElementById('SuTab_L').className='AcGTabL';
        document.getElementById('SuTabSep1').className='AcTabSepR';
        document.getElementById('SuTabSep2').className='AcTabSepR';
                
        if (frompop == 1 || frompop==2)
		{
		    if(solncenter=="HighSpeed")
                window.location.href="/residentialhelp/highspeed";
			else if (solncenter=="FiOSInternet")
			    window.location.href="/residentialhelp/fiosinternet";
			else if (solncenter=="DialUp")
			    window.location.href="/residentialhelp/dialup";
        }
     }
     else if(activeTab.toLowerCase()=="tv")
     {
        document.getElementById('SuTab3').className='AcRTabM';
        document.getElementById('SuTab1').className='AcGTabM';
        document.getElementById('SuTab2').className='AcGTabM';
        document.getElementById('SuTab4').className='AcGTabM';
        document.getElementById('SuTab5').className='AcGTabM';
                
        document.getElementById('SuTab_L').className='AcGTabL';
        document.getElementById('SuTabSep1').className='AcTabSep';
        document.getElementById('SuTabSep2').className='AcTabSep';
        document.getElementById('SuTabSep3').className='AcTabSep';

        if (frompop == 1 || frompop==2)
		{
			if(solncenter=="FiOSTV")
                window.location.href="/residentialhelp/fiostv";
			else if (solncenter.toLowerCase()=="directtv")
		    	window.location.href="/residentialhelp/generic/directv/123626.htm";
		}
    }
    else if(activeTab.toLowerCase()=="phone")
    {
        document.getElementById('SuTab4').className='AcRTabM';
        document.getElementById('SuTab1').className='AcGTabM';
        document.getElementById('SuTab2').className='AcGTabM';
        document.getElementById('SuTab3').className='AcGTabM';
        document.getElementById('SuTab5').className='AcGTabM';
                
        document.getElementById('SuTab_L').className='AcGTabL';
        document.getElementById('SuTabSep1').className='AcTabSep';
        document.getElementById('SuTabSep3').className='AcTabSep';
        document.getElementById('SuTabSep4').className='AcTabSep';
        
        if (frompop == 1 || frompop==2)
        {
          if((getSubTabCookie('vzapps','STATE')!= null && getSubCookie('ECSPCookies','OOFState') != null) && getSubCookie('ECSPCookies','OOFState') != '')
          {
            window.location.href="/residentialHelp/templates/outoffranchise/outoffranchiseState.aspx"; 
            return true;
          }
          else
          {
            window.location.href="/residentialhelp/phone"; 
          }
        }
     }
     /* [Start] - Sarvesh - Wireless to Homecontrol changes */
     //else if(activeTab.toLowerCase()=="wireless")
     else if(activeTab.toLowerCase()=="homecontrol")
     /* [End] - Sarvesh - Wireless to Homecontrol changes */
     {
        document.getElementById('SuTab5').className='AcRTabM';
        document.getElementById('SuTab1').className='AcGTabM';
        document.getElementById('SuTab2').className='AcGTabM';
        document.getElementById('SuTab3').className='AcGTabM';
        document.getElementById('SuTab4').className='AcGTabM';
                
        document.getElementById('SuTab_R').className='AcRTabR';
        document.getElementById('SuTab_L').className='AcGTabL';
        document.getElementById('SuTabSep4').className='AcTabSep';
        document.getElementById('SuTabSep1').className='AcTabSep';
                
        if (frompop == 1 || frompop==2)
		    window.location.href="/ResidentialHelp/HomeControl/129260.htm";
            //CheckWirelessCookie(activeTab);
     }
     //else if (activeTab=="Support Home")
     else  
     {
        document.getElementById('SuTab1').className='AcRTabM';
        document.getElementById('SuTab2').className='AcGTabM';
        document.getElementById('SuTab3').className='AcGTabM';
        document.getElementById('SuTab4').className='AcGTabM';
        document.getElementById('SuTab5').className='AcGTabM';
                
        document.getElementById('SuTab_L').className='AcRTabL';
        document.getElementById('SuTabSep1').className='AcTabSepR';
        
        if (frompop == 1 || frompop==2)
                CheckSupportHomeCookie(activeTab);           
      }
  
    }
    catch(e)
    {}
  }

 function CheckActiveTab(activeTab,frompop,solncenter)
 {
     try
     {
        var url = "" + window.location;
        var queryStringIndex = url.indexOf('=') + 1;
	    tabSelectedVal=activeTab;
        if(activeTab.toLowerCase()=="internet")
        {
          document.getElementById('TopMenu1').className='subnavcurrent launcher';
          document.getElementById('TopMenu0').className='subnav';
          document.getElementById('TopMenu2').className='subnav launcher';
          document.getElementById('TopMenu3').className='subnav launcher';
          /* start Commented on 10/11 to supress the preferences window */
          //document.getElementById('TopMenu4').className='subnav launcher';
          document.getElementById('TopMenu4').className='subnav';
          /* end Commented on 10/11 to supress the preferences window */
		  
		  if (frompop == 1 || frompop==2)
		  {
			 if(solncenter=="HighSpeed")
                    window.location.href="/residentialhelp/highspeed";
			 else if (solncenter=="FiOSInternet")
			        window.location.href="/residentialhelp/fiosinternet";
             else if (solncenter=="DialUp")
			        window.location.href="/residentialhelp/dialup";
          }
        }
        else if(activeTab.toLowerCase()=="tv")
        {
           document.getElementById('TopMenu2').className='subnavcurrent';
           document.getElementById('TopMenu0').className='subnav';
           document.getElementById('TopMenu1').className='subnav launcher';
           document.getElementById('TopMenu3').className='subnav launcher';
           /* start Commented on 10/11 to supress the preferences window */
           //document.getElementById('TopMenu4').className='subnav launcher';
           document.getElementById('TopMenu4').className='subnav';
           /* end Commented on 10/11 to supress the preferences window */
                 
		    if (frompop == 1 || frompop==2)
		    {
			    if(solncenter=="FiOSTV")
                	window.location.href="/residentialhelp/fiostv";
			    else if (solncenter.toLowerCase()=="directtv")
			        window.location.href="/residentialhelp/generic/directv/123626.htm"; 
		    }
         }
         else if(activeTab.toLowerCase()=="phone")
         {
           document.getElementById('TopMenu3').className='subnavcurrent';
           document.getElementById('TopMenu0').className='subnav';
           document.getElementById('TopMenu1').className='subnav launcher';
           document.getElementById('TopMenu2').className='subnav launcher';
           /* start Commented on 10/11 to supress the preferences window */
           //document.getElementById('TopMenu4').className='subnav launcher';
           document.getElementById('TopMenu4').className='subnav';
           /* end Commented on 10/11 to supress the preferences window */
                 
           if (frompop == 1 || frompop==2)
           {
             if((getSubTabCookie('vzapps','STATE')!= null && getSubCookie('ECSPCookies','OOFState') != null) && getSubCookie('ECSPCookies','OOFState') != '')
             {
              window.location.href="/residentialHelp/templates/outoffranchise/outoffranchiseState.aspx"; 
              return true;
             }
             else
             {
               window.location.href="/residentialhelp/phone"; 
             }
            }
         }
         /* [Start] - Sarvesh - Wireless to Homecontrol changes */
         //else if(activeTab.toLowerCase()=="wireless")
         else if(activeTab.toLowerCase()=="homecontrol")
         /* [End] - Sarvesh - Wireless to Homecontrol changes */
         {
            document.getElementById('TopMenu4').className='subnavcurrent';
            document.getElementById('TopMenu0').className='subnav';
            document.getElementById('TopMenu1').className='subnav launcher';
            document.getElementById('TopMenu2').className='subnav launcher';
            document.getElementById('TopMenu3').className='subnav launcher';
            if (frompop == 1 || frompop==2)
            {
                //if((getSubCookie('ECSPCookies','Homecontrol') != null && getSubCookie('ECSPCookies','Homecontrol') != '' && getSubCookie('ECSPCookies','Homecontrol') == 'No'))
                if((getSubCookie('ECSPCookies','Homecontrol') == null || getSubCookie('ECSPCookies','Homecontrol') == ''))
                {
                    CheckSupportHomeCookie(activeTab);
                }
                else
                {
                    window.location.href="/ResidentialHelp/HomeControl";
                }
            }
			    //window.location.href="/ResidentialHelp/HomeControl/129260.htm";
                //CheckWirelessCookie(activeTab);
         }
         //else if (activeTab=="Support Home")
         else  
         {
            document.getElementById('TopMenu0').className='subnavcurrent';
            document.getElementById('TopMenu1').className='subnav launcher';
            document.getElementById('TopMenu2').className='subnav launcher';
            document.getElementById('TopMenu3').className='subnav launcher';
            document.getElementById('TopMenu4').className='subnav';
            if (frompop == 1 || frompop==2)
                CheckSupportHomeCookie(activeTab);           
         }
    }
    catch(e)
    {}
  }
 
// TabLevelCookie Checking Functionality
function getTabValue(tabVal)
 {
    /* [Start] - Sarvesh - Wireless to Homecontrol changes */
    //if(tabVal.toLowerCase()=="wireless")
    if(tabVal.toLowerCase()=="homecontrol")
    /* [End] - Sarvesh - Wireless to Homecontrol changes */
    {	
        //CheckWirelessCookie(tabVal);
        window.location.href="/ResidentialHelp/HomeControl";
    }      
    if(tabVal=="Support Home")
    {
        CheckSupportHomeCookie(tabVal);
    }
    if(tabVal.toLowerCase()=="internet")
    {   
        CheckInterentCookie(tabVal);
    }  
    if(tabVal.toLowerCase()=="tv")
    {      
      CheckTVCookie(tabVal);
    }      
    if(tabVal.toLowerCase()=="phone")
     {       
       CheckPhoneCookie(tabVal);
     }
 }

function CheckInterentCookie(tabvalue)
{
    if (getSubCookie('ECSPCookies',tabvalue) != null)
    {
               var cookieVal = getSubTabCookie('ECSPCookies',tabvalue);
               if(cookieVal!=null && cookieVal!='')
               {
                    if (document.getElementById('layer')) document.getElementById('layer').parentNode.removeChild(document.getElementById('layer'));
                    if (document.getElementById('overlay')) document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));
                    if (document.getElementById('overlay_iframe')) document.getElementById('overlay_iframe').parentNode.removeChild(document.getElementById('overlay_iframe'));
		            if(cookieVal.toLowerCase()=="highspeed")
                	    setTimeout('window.location.href="/residentialhelp/highspeed"',50);
		            else if (cookieVal.toLowerCase()=="fiosinternet")
		                setTimeout('window.location.href="/residentialhelp/fiosinternet"',50);
		            else if (cookieVal.toLowerCase()=="dialup")
		                setTimeout('window.location.href="/residentialhelp/dialup"',50);
                    
                    return true;
               }  
               else
               {
                    if(isloaded != null && isloaded =='Y')
                    {
                        strhref= '/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=Internet';
                        document.getElementById('TopMenu1').href= strhref;
 		                if(document.getElementById('TopMenucontent1')!=null)
                        {
		                    document.getElementById('TopMenucontent1').href= strhref;  	
		                }
                    }
                    else
                    {   
                        return false;
                    }
               }
    }
    else
    {
        if(isloaded != null && isloaded =='Y')
        {
            strhref= '/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=Internet';
            document.getElementById('TopMenu1').href= strhref;
	        if(document.getElementById('TopMenucontent1')!=null)
            {
		         document.getElementById('TopMenucontent1').href= strhref;  	
		    }	
        }
        else
        {   
            return false;
        }
    }
}

function CheckTVCookie(tabvalue)
{
    if (getSubCookie('ECSPCookies',tabvalue) != null)
    {
        var cookieVal = getSubTabCookie('ECSPCookies',tabvalue);
        if(cookieVal!=null && cookieVal!='')
        {
             if (document.getElementById('layer')) document.getElementById('layer').parentNode.removeChild(document.getElementById('layer'));
             if (document.getElementById('overlay')) document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));
             if (document.getElementById('overlay_iframe')) document.getElementById('overlay_iframe').parentNode.removeChild(document.getElementById('overlay_iframe'));
             if(cookieVal.toLowerCase()=="fiostv")
                setTimeout('window.location.href="/residentialhelp/fiostv"',50);
			 else if (cookieVal.toLowerCase()=="directtv")
			    //window.location.href="/residentialhelp/generic/directv/123626.htm";
			    setTimeout('window.location.href="/residentialhelp/generic/directv/123626.htm"',50);

               return true;
           }  
           else
           { 
              if(isloaded != null && isloaded =='Y')
                {
                strhref='/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=TV';
                document.getElementById('TopMenu2').href= strhref;
		        if(document.getElementById('TopMenuContent2')!=null)
                {
		            document.getElementById('TopMenuContent2').href= strhref;  	
		        }
            }
            else
            {   
                return false;
            }
        }
                  
     }
    else
    {
        if(isloaded != null && isloaded =='Y')
        {
            strhref='/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=TV';
            document.getElementById('TopMenu2').href= strhref;
		    if(document.getElementById('TopMenuContent2')!=null)
            {
		         document.getElementById('TopMenuContent2').href= strhref;  	
		    }
         }
         else
         {   
            return false;
         }
    }
 }

function CheckPhoneCookie(tabvalue)
{
    if((getSubTabCookie('vzapps','STATE')!= null && getSubCookie('ECSPCookies','OOFState') != null) && getSubCookie('ECSPCookies','OOFState') != '')
    {
	        if (document.getElementById('layer')) document.getElementById('layer').parentNode.removeChild(document.getElementById('layer'));
            if (document.getElementById('overlay')) document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));
            if (document.getElementById('overlay_iframe')) document.getElementById('overlay_iframe').parentNode.removeChild(document.getElementById('overlay_iframe'));
           //window.location.href="/ResidentialHelp/templates/OutOfFranchise/outoffranchiseState.aspx"; 
    		setTimeout('window.location.href="/ResidentialHelp/templates/OutOfFranchise/outoffranchiseState.aspx"',50);
            return true;
    }
    if (getSubCookie('vzapps','STATE') != null)
    {
            var cookieVal = getSubTabCookie('vzapps','STATE');
            if(cookieVal!=null && cookieVal!='')
            {
                if (document.getElementById('layer')) document.getElementById('layer').parentNode.removeChild(document.getElementById('layer'));
                if (document.getElementById('overlay')) document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));
                if (document.getElementById('overlay_iframe')) document.getElementById('overlay_iframe').parentNode.removeChild(document.getElementById('overlay_iframe'));
                //window.location.href="/residentialhelp/phone"; 
               	setTimeout('window.location.href="/residentialhelp/phone"',50);
                return true;
            }  
            else
            {
                if(isloaded != null && isloaded =='Y')
                {
                    strhref='/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=Phone';	
	                document.getElementById('TopMenu3').href= strhref;
	                if(document.getElementById('TopMenuContent3')!=null)
                    {
		               document.getElementById('TopMenuContent3').href= strhref;  	
		            }
                }
                else
                {   
                     return false;
                }
           }       
    }
    else
    {
         if(isloaded != null && isloaded =='Y')
         {
            strhref='/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=Phone';	
	        document.getElementById('TopMenu3').href= strhref;
	        if(document.getElementById('TopMenuContent3')!=null)
            {
		        document.getElementById('TopMenuContent3').href= strhref;  	
		    }
         }
         else
         {   
            return false;
         }
     }  
 }

function CheckWirelessCookie(tabvalue)
{ 
  if (getSubCookie('ECSPCookies',tabvalue) != null)
    {
           var cookieVal = getSubTabCookie('ECSPCookies',tabvalue);
           //if(cookieVal!=null && cookieVal!='' && cookieVal.toLowerCase() =='yes')
           if(cookieVal!=null && cookieVal!='')
           {
             if (document.getElementById('layer')) document.getElementById('layer').parentNode.removeChild(document.getElementById('layer'));
             if (document.getElementById('overlay')) document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));
             if (document.getElementById('overlay_iframe')) document.getElementById('overlay_iframe').parentNode.removeChild(document.getElementById('overlay_iframe'));
              
    		 if(cookieVal.toLowerCase()=="yes")
		        	setTimeout('window.location.href="/ResidentialHelp/HomeControl/129260.htm"',50);
	
            return true;
           }  
           else
           { 
              if(isloaded != null && isloaded =='Y')
                {
                    strhref='/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=Homecontrol';
                    document.getElementById('TopMenu4').href= strhref;
		            if(document.getElementById('TopMenuContent4')!=null)
                    {
    		            document.getElementById('TopMenuContent4').href= strhref;  	
	    	          }
                }
                 else
                {   
                     return false;
                }
           }
    }
    else
    {
        if(isloaded != null && isloaded =='Y')
        {
                strhref='/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=Homecontrol';
                document.getElementById('TopMenu4').href= strhref;
		        if(document.getElementById('TopMenuContent4')!=null)
                {
		            document.getElementById('TopMenuContent4').href= strhref;  	
		        }
        }
        else
        {   
            return false;
        }
    }
 }

//function CheckWirelessCookie(tabvalue)
//{
//// if (getSubCookie('ECSPCookies',tabvalue) != null)
////    {
////         var cookieVal = getSubCookie('ECSPCookies',tabvalue);
////           if(cookieVal!=null)
////           {
//            /* [Start] - Sarvesh - Wireless to Homecontrol changes */
//           //window.location.href="/residentialhelp/wireless/wireless.htm";
//           window.location.href="/ResidentialHelp/HomeControl/129260.htm";
//            /* [End] - Sarvesh - Wireless to Homecontrol changes */
////           return true;
////           }          
////           else
////           {
////           OpenPreferencesWindow(tabvalue);
////           return false;
////           }
////     }
////   else
////    {
////    OpenPreferencesWindow(tabvalue);
////    return false;
////    }
// }
 
function CheckSupportHomeCookie(tabvalue)
{
    window.location.href="/residentialhelp?Called=Yes";
    return false;
}
 
function getSubTabCookie(c_name, sub_key)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1)
			{ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
			var subCookie = unescape(document.cookie.substring(c_start,c_end))
			s_start = subCookie.indexOf(sub_key + "=")
			if (s_start != -1)
			{
			s_start=s_start + sub_key.length+1 
			s_end=subCookie.indexOf("&",s_start)
			if (s_end==-1) s_end=subCookie.length
				return subCookie.substring(s_start,s_end);				
			}			
		}
		return null
    }
    var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) 
	{
	    begin = dc.indexOf(prefix);
	    if (begin != 0) return null;
	 } 
	 else 
	 {
	    begin += 2;
     }
    var end = document.cookie.indexOf(";", begin);
	if (end == -1) 
	{
	    end = dc.length;    
	}
	var x=unescape(dc.substring(begin + prefix.length, end));    
	return unescape(dc.substring(begin + prefix.length, end));
}
 
function OpenPreferencesWindow_Search(tabVal,ctrl,caseRefID,tags, displayTags)
{
    var sURL ='/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=' +tabVal +'&SelectedCtrl='+ctrl +'&modal=Y' +'&caseRefID='+caseRefID +'&Tags='+tags +'&displayTags='+displayTags
    mywindow=window.showModalDialog(sURL,window,"dialogHeight:400px;dialogWidth:800px;center:yes");
}
 
function OpenPreferencesWindow(tabVal)
{
     var sURL ='/ResidentialHelp/templates/layers/setpreferences_generic.aspx?TabValue=' +tabVal +'&modal=Y';
    mywindow=window.showModalDialog(sURL,window,"dialogHeight:400px;dialogWidth:800px;center:yes");
}

//Search Functionality
function TopLevelSearch(tabValue,e)
 {
      try
      {  
        _hbLink('btnSearchDiv');
      }
      catch(e){}
      var isNN = (navigator.appName.indexOf("Netscape")!=-1);
      try
      {
        var keyCode = (isNN) ? e.which : event.keyCode; 
        if(keyCode == 13)
	    {
            getSearchCookie();
	    } 
	    else if(tabValue!="Call")
	    {
            tabValue='Support Home';
		    var SolutionCenter; 
		    getSearchCookie();				
        }  
      }
      catch(ex)
      {
       getSearchCookie();
      }
 }
 
function CaptureEnterkey_Go(e)
{
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : event.keyCode; 

	if(keyCode == 13)
	{
		//getSearchCookie();
	}          
}
 
 function getSearchCookie()
 {
 
      var ddlValue=document.getElementById('ddlSolutionCenter');
      var varQuestion = document.getElementById('foo');
      var isNN = (navigator.appName.indexOf("Netscape")!=-1);
      var currrecent = getCookie("RecentAllSesarches");
       
      if(currrecent == "null")
            currrecent = "";
      if(ddlValue.selectedIndex==0)
      {
         alert('Please Select a Solution Center');  
         ddlValue.focus();  
         return false;
      }        
	  else if (varQuestion == null || varQuestion.value == null || varQuestion.value == '' || trim(varQuestion.value) == '' || varQuestion.value == 'Please enter phrase or keyword' || varQuestion.value =='Search support')
	  {
           alert('Please enter a Search phrase');  
           document.getElementById('foo').focus();        
           return false;
      }
      else if(ddlValue.selectedIndex==1)
      {
        //Internet --ddlValue.sleectedIndex==1
        ddlValue=document.getElementById('ddlSolutionCenter');
        //set recently searched cookie
        setCookieValue('SearchQuestion',varQuestion.value,null);
        currrecent = currrecent + varQuestion.value +",";
        setCookieValue('RecentAllSesarches',currrecent,null);
        SolutionCenter=InternetSearchCookie(ddlValue.value);  
        if(SolutionCenter == null ||SolutionCenter=='')
        {
          OpenPreferencesWindow_Search_new('internet',2,isNN);
          return false;
        } 
        else
        {
          TempSearch(SolutionCenter);
          return false;
        }     
    }      
    else if(ddlValue.selectedIndex==2)
    {
        //set recently searched cookie
        setCookieValue('SearchQuestion',varQuestion.value,null);
        currrecent = currrecent + varQuestion.value +",";
        setCookieValue('RecentAllSesarches',currrecent,null);
        setblankECSPCookie();
        //for TV we always pass fiostv
        SolutionCenter=TVSearchCookie(ddlValue.value.toUpperCase());
        if(SolutionCenter == null ||SolutionCenter=='')
        {
          OpenPreferencesWindow_Search_new('tv',2,isNN);
          return false;
        }
        else
        {
            TempSearch(SolutionCenter);
        }  
	}
    else if(ddlValue.selectedIndex==3)
    {
        //Phone
        //set recently searched cookie
        setCookieValue('SearchQuestion',varQuestion.value,null);
        currrecent = currrecent + varQuestion.value +",";
        setCookieValue('RecentAllSesarches',currrecent,null);
        //SetRecentSearchCookie(); 
        setblankECSPCookie();
        ddlValue=document.getElementById('ddlSolutionCenter');
        SolutionCenter=PhoneSearchCookie(ddlValue.value);
        if(SolutionCenter==null || SolutionCenter=="")
        {
            OpenPreferencesWindow_Search_new('phone',2,isNN);
            return false;    
        }
        else
        {
            TempSearch("Phone"); 
            return false;
        }              
    }
    else if(ddlValue.selectedIndex==4)
    {
        /* [Start] - Sarvesh - Wireless to Homecontrol changes */
        
        /*wireless   
        SetRecentSearchCookie();   
        setCookieValue('SearchQuestion',varQuestion.value,null);   
        currrecent = currrecent + varQuestion.value +",";
        setCookieValue('RecentAllSesarches',currrecent,null);        
        setblankECSPCookie();
        TempSearch('Homecontrol');
        return false; */ 
        
        ddlValue=document.getElementById('ddlSolutionCenter');
        setCookieValue('SearchQuestion',varQuestion.value,null);
        currrecent = currrecent + varQuestion.value +",";
        setCookieValue('RecentAllSesarches',currrecent,null); 
        SolutionCenter=HomeControlSearchCookie(ddlValue.value); 
        /* [Start] - Sarvesh - 10/11 Commented for Supress the PReferences Window */
        /*if(SolutionCenter == null ||SolutionCenter=='')
        {
          OpenPreferencesWindow_Search_new('homecontrol',2,isNN);
          return false;
        } 
        else
        {
          TempSearch(SolutionCenter);
          return false;
        }*/
          
        TempSearch(SolutionCenter);
        return false;
        /* [End] - Sarvesh - 10/11 Commented for Supress the PReferences Window */
          
        /* [End] - Sarvesh - Wireless to Homecontrol changes */
       
     }  
     // Search All updates  6/23 - start
     else if(ddlValue.selectedIndex==5)
     {
        //wireless   
        //SetRecentSearchCookie();   
        setCookieValue('SearchQuestion',varQuestion.value,null);    
        currrecent = currrecent + varQuestion.value +",";
        setCookieValue('RecentAllSesarches',currrecent,null);
        setblankECSPCookie();
        TempSearch('Searchall');
        return false;         
     }  
     // Search All updates  6/23 - end   
 }
 
function setblankECSPCookie()
{
    if((getCookie('ECSPCookies')== null) || (getCookie('ECSPCookies').length < 0))
      setCookieValue('ECSPCookies','',null);     
}

function TempSearch(SolutionCenter)
{
    
	//alert('slncnter is '+SolutionCenter);
	var ddlValue=document.getElementById('ddlSolutionCenter');
	var HCCookie=HomeControlSearchCookie(ddlValue.value);
	//alert(HCCookie);
	if(SolutionCenter == 'Home Control')  
	{
	        if(HCCookie == null ||HCCookie=='')
        	{
	          window.location.href="/residentialhelp"
	        } 
        	else
	        {
	          search('Homecontrol');
	        }
	}
	else
	{	
		search(SolutionCenter);
	}
}
 
function InternetSearchCookie(tabValue)
{
     var PrefCookie; 
     if (getSubCookie('ECSPCookies',tabValue) != null)
     {
       var cookieVal = getSubCookie('ECSPCookies',tabValue);
       if(cookieVal!=null && cookieVal!='')
       {
            PrefCookie=cookieVal;
       }               
       return PrefCookie      
     }       
 }
 
function HomeControlSearchCookie(tabValue)
{
     var PrefCookie; 
     if (getSubCookie('ECSPCookies',tabValue) != null)
     {
       var cookieVal = getSubCookie('ECSPCookies',tabValue);
       if(cookieVal!=null && cookieVal!='')
       {
            PrefCookie=cookieVal;
       }               
       return PrefCookie      
     }       
}

function TVSearchCookie(tabValue)
{
      var PrefCookie;
      if (getSubCookie('ECSPCookies',tabValue) != null)
      {
        var cookieVal = getSubCookie('ECSPCookies',tabValue);
        if(cookieVal!=null && cookieVal!='')
        {
            PrefCookie=cookieVal;
        }
        return PrefCookie 
      }
}
function PhoneSearchCookie(tabValue)
{
    var PrefCookie;
    if (getSubCookie('vzapps','ZIPCODE') != null)
    {
         var cookieVal = getSubTabCookie('vzapps','ZIPCODE');
         if(cookieVal!=null && cookieVal!='')
         {     
            PrefCookie=cookieVal;
         }
         return PrefCookie 
    }
}
 
function searchTemp(popularSearch)
{
     _hbLink('PopularSearch');
      var SolutionCenter;
      document.getElementById('foo').value = popularSearch;     
      setCookieValue('SearchQuestion',popularSearch,null);
      ddlValue=document.getElementById('ddlSolutionCenter');
      if(ddlValue.selectedIndex==0)
      {
          alert('Please Select a Solution Center');  
          ddlValue.focus(); 
           return;
      }
      else if(ddlValue.selectedIndex==1)
      {                 
          SolutionCenter=InternetSearchCookie(ddlValue.value);  
          if(SolutionCenter != null)           
          {
              search(SolutionCenter);
          }
          else
          {
                OpenPreferencesWindow_Search('internet',2,'');           
                return;
          }             
      }      
      else if(ddlValue.selectedIndex==2)
      {            
          search('FiOSTV');
      }
      else if(ddlValue.selectedIndex==3)
      {
          SolutionCenter=PhoneSearchCookie(ddlValue.value);  
          if(SolutionCenter != null)
          {           
            search("Phone");  
          }
          else
          {
            OpenPreferencesWindow_Search('phone',2,''); 
            return;      
          }     
      }
      else if(ddlValue.selectedIndex==4)
      {
           /* [Start] - Sarvesh - Wireless to Homecontrol changes */        
           //search('Wireless');
           //search('Homecontrol');
           SolutionCenter=HomeControlSearchCookie(ddlValue.value);  
           if(SolutionCenter != null)           
           {
                search(SolutionCenter);
           }
           else
           {
                OpenPreferencesWindow_Search('homecontrol',2,'');           
                return;
           }    
           /* [End] - Sarvesh - Wireless to Homecontrol changes */
      }    
	  //updated 7/29 - recent search issue 
	  else if(ddlValue.selectedIndex==5)
      {
                        
           search('Searchall');
      }    

}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    var domain = document.domain;
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+ ';path=/'+
    ((expiredays==null) ? ";" : ";expires="+exdate.toGMTString());
}

// TO Set default Search Center in drop down
function setDefaultSearchCenter(tabValue) 
 { 
  try{
    if (tabValue.toLowerCase()== "internet") 
     { 
     document.getElementById('ddlSolutionCenter').selectedIndex=1; 
     } 
    else if (tabValue.toLowerCase()== "tv") 
     { 
     document.getElementById('ddlSolutionCenter').selectedIndex=2; 
      } 
    else if (tabValue.toLowerCase()== "phone") 
     { 
     document.getElementById('ddlSolutionCenter').selectedIndex=3; 
     } 
     /* [Start] - Sarvesh - Wireless to Homecontrol changes */
    //else if (tabValue.toLowerCase()== "wireless") 
    else if (tabValue.toLowerCase()== "homecontrol") 
    /* [End] - Sarvesh - Wireless to Homecontrol changes */
     { 
     document.getElementById('ddlSolutionCenter').selectedIndex=4; 
     } 
     else if(tabValue.toLowerCase() =="support home")
     {
      document.getElementById('ddlSolutionCenter').selectedIndex=5; 
     }
    else 
     { 
     document.getElementById('ddlSolutionCenter').selectedIndex=0; 
     }
     }
     
     catch(e){} 
 } 


//Recent Searches.

function UpdateRecentSearch()
{
 var cookieVal = getCookie('SearchQuestion');
 var cookieVal1 = "";

 if(cookieVal==null || cookieVal=='')
 {
      document.getElementById('recentSearch').innerHTML = '';
      return;
 }   
 else
 {  
	//update to fix issue 281 - start
	 html = ' <strong>Recent Searches: </strong>'; 
	if (cookieVal.length >30) 
	{
	 	cookieVal1 = cookieVal.substring(0,27); 	
		cookieVal1 = cookieVal1+"...";
		html += '<a href="javascript:searchTemp(\''+cookieVal+'\')" alt=\''+cookieVal+'\' title=\''+cookieVal+'\'>'+cookieVal1+'</a> ';
	}
	else
	{
	        html += '<a href="javascript:searchTemp(\''+cookieVal+'\')" >'+cookieVal+'</a> ';
	}
	//update to fix issue 281 - end
   document.getElementById('recentSearch').innerHTML = html;
   }
} 
  
 function checkCaseRef(tabValue,caseRef) 
 { 
  var SolutionCenter; 
  
      if(tabValue.toLowerCase()=="internet") 
       { 
          SolutionCenter=InternetSearchCookie(tabValue);   
           if(SolutionCenter == null ||SolutionCenter=='') 
           { 
              OpenPreferencesWindow_Search(tabValue,3,caseRef)   
    		 SolutionCenter=InternetSearchCookie(tabValue);   
         	 if(SolutionCenter == null ||SolutionCenter=='') 
          	 { }
	    	 else 
		     {
		        var sURL='/ResidentialHelp/Templates/Redirect.aspx?TabValue='+SolutionCenter +'&caseRefId='+caseRef 
                window.location.href=sURL; 
    		 }
           } 
           else 
           { 
                //Redirect to Redirect Page with qurerystrings 
               var sURL='/ResidentialHelp/Templates/Redirect.aspx?TabValue='+SolutionCenter +'&caseRefId='+caseRef 
               window.location.href=sURL; 
               return false; 
           } 
         }
       else if(tabValue.toLowerCase()=="tv") 
         { 
            SolutionCenter=TVSearchCookie(tabValue);   
            if(SolutionCenter == null ||SolutionCenter=='') 
            {               
                 SolutionCenter=TVSearchCookie(tabValue);   
	             if(SolutionCenter == null ||SolutionCenter=='') 
	     	     {}
			     else               
			     {
			        var sURL='/ResidentialHelp/Templates/Redirect.aspx?TabValue='+SolutionCenter+'&caseRefId='+caseRef 
                    window.location.href=sURL; 
			     }
            } 
           else 
            { 
                var sURL='/ResidentialHelp/Templates/Redirect.aspx?TabValue='+SolutionCenter+'&caseRefId='+caseRef 
                window.location.href=sURL; 
                return false; 
            } 
         } 
        else if(tabValue.toLowerCase()=="phone") 
         { 
            SolutionCenter=PhoneSearchCookie(tabValue);   
            if(SolutionCenter == null ||SolutionCenter=='') 
              {               
                OpenPreferencesWindow_Search(tabValue,3,caseRef)                                                                  
                SolutionCenter=PhoneSearchCookie(tabValue);   
            	if(SolutionCenter == null ||SolutionCenter=='') 
	            {  
	            }
	            else
	            {             
        	       var sURL= caseRef;
                   window.location.href=sURL; 
                }
              } 
              else 
              { 
                var sURL= caseRef; 
                window.location.href=sURL; 
                return false; 
              } 
          } 
          else if(tabValue.toLowerCase()=="homecontrol") 
         { 
            SolutionCenter=HomeControlSearchCookie(tabValue);   
            if(SolutionCenter == null ||SolutionCenter=='') 
              {               
                OpenPreferencesWindow_Search(tabValue,3,caseRef)                                                                  
                SolutionCenter=HomeControlSearchCookie(tabValue);   
            	if(SolutionCenter == null ||SolutionCenter=='') 
	            {  
	            }
	            else
	            {             
        	       var sURL= caseRef;
                   window.location.href=sURL; 
                }
              } 
              else 
              { 
                var sURL= caseRef; 
                window.location.href=sURL; 
                return false; 
              } 
          } 
 } 
//For tags 

function displayTagClouds(tabValue,tags,display_tags) 
 { 
  var SolutionCenter; 
  var strCltr =4;  
  
 
      if(tabValue.toLowerCase()=="internet") 
       { 
          SolutionCenter=InternetSearchCookie(tabValue);   
           if(SolutionCenter == null ||SolutionCenter=='') 
           { 
              OpenPreferencesWindow_Search(tabValue,strCltr,'',tags,display_tags)   ;
      		  SolutionCenter=InternetSearchCookie(tabValue); 
    	     if(SolutionCenter == null ||SolutionCenter=='') 
               {
		       }
		    else
		       {
	            var sURL='/residentialhelp/TagSearchResults/TagSearchresults.htm?solncenter='+SolutionCenter +'&tag='+tags + '&display_tag=' + display_tags
                window.location.href=sURL; 
		       }
          } 
          else 
          { 
                //Redirect to Redirect Page with qurerystrings 
                var sURL='/residentialhelp/TagSearchResults/TagSearchresults.htm?solncenter='+SolutionCenter +'&tag='+tags + '&display_tag=' + display_tags
                window.location.href=sURL; 
          } 
       }
       else if(tabValue.toLowerCase()=="tv") 
         { 
            SolutionCenter=TVSearchCookie(tabValue);   
            if(SolutionCenter == null ||SolutionCenter=='') 
              {               
               OpenPreferencesWindow_Search(tabValue,strCltr,'',tags,display_tags)   ;
               SolutionCenter=TVSearchCookie(tabValue);   
	           if(SolutionCenter == null ||SolutionCenter=='') 
               {}
               else
               {
		        var sURL='/residentialhelp/TagSearchResults/TagSearchresults.htm?solncenter='+SolutionCenter +'&tag='+tags + '&display_tag=' + display_tags
                window.location.href=sURL; 
		        }
             } 
             else 
              { 
                var sURL='/residentialhelp/TagSearchResults/TagSearchresults.htm?solncenter='+SolutionCenter +'&tag='+tags + '&display_tag=' + display_tags
                window.location.href=sURL; 
              } 
          } 
        else if(tabValue.toLowerCase()=="phone") 
         { 
            SolutionCenter=PhoneSearchCookie(tabValue);   
            if(SolutionCenter == null ||SolutionCenter=='') 
              {               
                OpenPreferencesWindow_Search(tabValue,strCltr,'',tags,display_tags)   ;
          	    SolutionCenter=PhoneSearchCookie(tabValue);   
        	    if(SolutionCenter == null ||SolutionCenter=='') 
                {}
                else
                {
		            var sURL='/residentialhelp/TagSearchResults/TagSearchresults.htm?solncenter=Phone&tag='+tags + '&display_tag=' + display_tags
                    window.location.href=sURL; 
		        }
              } 
              else 
              { 
                var sURL='/residentialhelp/TagSearchResults/TagSearchresults.htm?solncenter=Phone&tag='+tags + '&display_tag=' + display_tags
                window.location.href=sURL; 
              } 
          } 
         else if(tabValue.toLowerCase()=="homecontrol") 
         { 
            SolutionCenter=HomeControlSearchCookie(tabValue);   
            if(SolutionCenter == null ||SolutionCenter=='') 
              {               
                OpenPreferencesWindow_Search(tabValue,strCltr,'',tags,display_tags)   ;
          	    SolutionCenter=HomeControlSearchCookie(tabValue);   
        	    if(SolutionCenter == null ||SolutionCenter=='') 
                {}
                else
                {
		            var sURL='/residentialhelp/TagSearchResults/TagSearchresults.htm?solncenter=Homecontrol&tag='+tags + '&display_tag=' + display_tags
                    window.location.href=sURL; 
		        }
              } 
              else 
              { 
                var sURL='/residentialhelp/TagSearchResults/TagSearchresults.htm?solncenter=Homecontrol&tag='+tags + '&display_tag=' + display_tags
                window.location.href=sURL; 
              } 
          } 
 } 

function open_myVerizonTour(sURL)
{
      try{_hbLink('VzTour_hp');} catch(e) {}
        if(typeof(sURL)!='string')
            window.open(sURL.link,sURL.title,"menubar="+sURL.menubar+",resizable="+sURL.resizeable+",width="+sURL.width+",height="+sURL.height);
        else 
            window.open(sURL,"Popup","width=780,height=480,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}
function fireClick(objID) 
{
	var target=document.getElementById(objID);
	if(document.dispatchEvent) { 
		var oEvent = document.createEvent( "MouseEvents" );
		oEvent.initMouseEvent("click", true, true,window, 1, 1, 1, 1, 1, false, false, false, false, 0, target);
		target.dispatchEvent( oEvent );
	}
	else if(document.fireEvent) 
		target.fireEvent("onclick");
}

function OpenPreferencesWindow_Search_new(tabVal,ctrl,isNN)
{
	document.getElementById('temp').href = '/ResidentialHelp/templates/layers/setpreferences_generic.aspx?tabValue='+tabVal+'&SelectedCtrl='+ctrl;
	if(isNN)
		fireClick('temp');
	else
		document.getElementById('temp').click();
}
