// Set Homepage only for IE
if(jQuery.browser.msie == true){
    $('.link-make-homepage').click(function(){
        this.style.behavior='url(#default#homepage)';
        this.setHomePage('http://www.talktalk.co.uk');
        return false;
    });
}


$('#keyword').focus(function(){ 
	if($('#tt-search-types span.search-active a').attr('title') == this.value) this.value = '';
 });

var searchTitles = Array('Search the web here...','Compare product prices...','Search this site','Search video','Search local businesses','Search for TT customer help');

$('#tt-search-types a').click(function() {
	$(this).blur();
    var stypelong = $(this).attr('id');
    var stypeshort = stypelong.replace(/search-/i,'');
    $('#tt-search-types a').parent().removeClass('search-active');
    $(this).parent().addClass('search-active');
    $('#searchform input[name="type"]').val(stypeshort);

    if(stypeshort=='shopping'){
        $("#search-logo").attr({'class':"tt-hd1searchshopbg"});
    }else if(stypeshort=='business'){
        $("#search-logo").attr({'class':"tt-hd1searchlocalbg"});		
	}else if(stypeshort=='internal' || stypeshort=='video' || stypeshort=='help'){
        $("#search-logo").attr({'class':"tt-hd1searchinternalbg"});				
    }else{
        $("#search-logo").attr({'class':"tt-hd1searchgooglebg"});				
    }

    if($('#keyword').val() == ''){
        $('#keyword').val($(this).attr('title'));
    } else {
        var changeVar = false;
        for(i in searchTitles){
            if(searchTitles[i] == $('#keyword').val()) changeVar = true;
        }
        if(changeVar)
            $('#keyword').val($(this).attr('title'));
    }

    // remove the left dotted border on selected tabs
    $('#tt-search-types>span').not(':last').css({'border-right' : '1px dotted #B4B4B4'});
    var selectedtab = $(this).parent().prev();
	
    if($(selectedtab).is('span') || $('#tt-search-types a').index(this)==0) {
        $(this).parent().css({'border-right' : '0px'}).prev().css({'border-right' : '1px #fff solid'});
    }

    return false;
});

try{
	var urlcalled = location.pathname;
	if(urlcalled.match(/search\/internal\.php$/i)){
		$('#search-internal').click();
	} else if(urlcalled.match(/search\/video-results\.html$/i)){
		$('#search-video').click();		
	} else if(urlcalled.match(/search\/local-results\.html$/i)){
		$('#search-business').click();		
	} else if((urlcalled.match(/^\/help\//i) && (!urlcalled.match(/^\/tiscali-product\//i)))){
		$('#search-help').click();		
	}
}catch(e){}