﻿function showTab(facet)
    {      
        var elementId = 'tab-' + facet;
    	
        if(!Element.hasClassName(elementId, 'active'))
        {	
	        if(Element.hasClassName('tab-features', 'active') 
		        && elementId != 'tab-features')
	        {
		        Element.removeClassName('tab-features', 'active');
		        Element.hide('phone-features');
	        }
	        else if(Element.hasClassName('tab-prices', 'active') 
		        && elementId != 'tab-prices')
	        {
		        Element.removeClassName('tab-prices', 'active');			
		        Element.hide('phone-prices');
	        }	        
    				
	        Element.addClassName(elementId, 'active');
	        Element.show('phone-' + facet);    		
        }
    }

function enableTabs() 
{   
  separator = ',';    
  query = '' + this.location;
  qu = query
  query = query.substring((query.indexOf('?')) + 1);    
  if (query.length < 1) { return false; } 
  keypairs = new Object();
  numKP = 1;    
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;      
  }
  keypairs[numKP] = query;  
  var found = '0';
  var prepaid = '0';
   
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));      
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
    while (keyValue.indexOf('+') > -1) 
    {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
    }
    keyValue = unescape(keyValue);              

    if (keyName == 'p')
    {
         if (keyValue == '1')        
            prepaid = '1';
         else if(keyValue == '2')
            prepaid = '2';
         else
            prepaid = '3';
    }
    if (keyName == 't')
    {        
         if (keyValue == '1')        
            found = '1';
         else if(keyValue == '2')
            found = '2';
         else if(keyValue == '3' || keyValue == null)
            found = '3';         
    }
  } 
 
  if (prepaid == '1')
  {
    Element.hide('tab-prices');            
  }
  else if (prepaid == '2')
  {
    if(found == '1')
        Element.show('tab-prices');    
  }
  else if(prepaid == '3')
  {    
    if (found == '2' || found == '3')
        Element.hide('tab-prices');
    else            
        Element.show('tab-prices');   
  }
    
}
