$(document).ready(function(){
    $('#menu ul li.parent').hover(function(){
        $(this).children('a').addClass('active');
        $(this).children('div').show();
    },function(){
        $(this).children('a').removeClass('active');
        $(this).children('div').hide();
    });

    $('.view a').click(function(){

        $('.tariffs').show();
    });
    
	$('.inside').hover(function(){
		$(this).removeClass('inside');
		$(this).addClass('inside_over');
		},function(){
		$(this).removeClass('inside_over');
		$(this).addClass('inside');
	});
	$('#populer').hover(function(){
		$('.title a').addClass('on');
		},function(){
		$('.title a').removeClass('on');
		});

// Functionality to clear search boxes
    $('#sitesearch').focus(function(){
		if($(this).val()=="Search site"){
			$(this).val('');
		}
	});

    $('#sitesearch').blur(function(){
		if($(this).val()==""){
			$(this).val('Search site');
		}
	});

  if($('div.pay-as-you-go').length) {
    var hidden_text = 0;
    $(".24h_tar").hide();
    $("#readOnlyRowsToggle").click(function() {
      
  	  if ($('.ex_vat').is(':visible')) {
	  	$(this).text('Show ex-VAT tariffs');
	  } else {
	  	$(this).text('Hide ex-VAT tariffs');
	  }

      if($('.notsure-message.extra_tariff').is(':visible')) {
        $(".24h_tar, .ex_vat").fadeToggle();
      }
      else {
        $(".24h_tar").fadeToggle();
      }
      
    });
    
    $(".extra_tariff").hide();
    
    // hide_tariffs

  	$('a#toggle-button').click(function() {
  	  
  	  if($('.topheader .24h_tar').is(':visible')) {
  	    $('.extra_tariff').fadeToggle();
  	  }
  	  else {
  	    $('.extra_tariff').not('.ex_vat').fadeToggle();
  	  }
      // $('.extra_tariff').toggle();
      $(this).text($(this).text() == 'Show all tariffs' ? 'Hide all tariffs' : 'Show all tariffs');
      return false;	
    });
  }
    // hide_tariffs
	if ($('#toggle-vat').length ) {
  		$('a#toggle-vat').click(function() {
  	  		if ($('.ex-vat').is(':visible')) {
  	    		$('.ex-vat').hide();
  	    		$('.in-vat').show();
  	    	}
  	    	else
  	    	{
  	    		$('.ex-vat').show();
  	    		$('.in-vat').hide();
  	    	}
      	// $('.extra_tariff').toggle();
      	$(this).text($(this).text() == 'Show ex-VAT tariffs' ? 'Hide ex-VAT tariffs' : 'Show ex-VAT tariffs');
      	return false;	
    	});  
	}
	if ($('#show-all-tariffs').length ) {
  		$('a#show-all-tariffs').click(function() {  	  
  	    	$('#all-tariffs').slideToggle('slow');
      	$(this).text($(this).text() == 'Show all tariffs' ? 'Hide all tariffs' : 'Show all tariffs');
      	return false;	
    	});  
	}	
});



