$(document).ready(function() {
	
	$("div.news>ul>li:nth-child(2n)").css("margin-right","0");
	$('#qweb').focus();
	// Search choosers
	var currSearchBoxID = '#qweb';
	var schbwidth = Math.floor((728/$('div.search>ul>li').length))-2;
	$('div.search>ul>li').css('width',schbwidth+'px');
	$('div.search>ul>li').first().css('border-left','transparent 1px solid');
	$('div.search>ul>li').last().css('border-right','transparent 1px solid');
	$('div.search>ul>li').last().css('width',schbwidth+2+'px');
	// Onclick
	$('div.search>ul>li').click(function() {
		// Reset background and text color
		$('div.search>ul>li').attr("class","searchbdef");
		// Set background and color on this
		$(this).attr('class','searchbsel');
		// Hide all boxes
		$('div.search div.boxes div.content').hide();
		// Show selected box
		$('#'+$(this).attr("id")+'_box').show();
		// Focus on search fields, and add previous value
		if ($(this).attr("id") == 's_web') {
			$('#qweb').focus();
			$('#qweb').val($(currSearchBoxID).val());
			currSearchBoxID = '#qweb';
		}
		else if ($(this).attr("id") == 's_news') {
			$('#qnews').focus();
			$('#qnews').val($(currSearchBoxID).val());
			currSearchBoxID = '#qnews';
		}
		else if ($(this).attr("id") == 's_img') {
			$('#qimg').focus();
			$('#qimg').val($(currSearchBoxID).val());
			currSearchBoxID = '#qimg';
		}
		else if ($(this).attr("id") == 's_video') {
			$('#qvideo').focus();
			$('#qvideo').val($(currSearchBoxID).val());
			currSearchBoxID = '#qvideo';
		}
		else if ($(this).attr("id") == 's_phone') {
			$('#qphone').focus();
			$('#qphone').val($(currSearchBoxID).val());
			currSearchBoxID = '#qphone';
		}
		
		
	});
	
});
