$(document).ready(function(){
	/* Equal height */
	equalHeight($(".column"));

	/* Tabs */
	$('#tabs ul li#tab-1').addClass('selectedTab');
	$('#screen #tab-content-1').addClass('selected');
	$('#tabs ul li').click(function() {
		var id = $(this).attr('id').replace(/tab-/, '');
		$('#tabs ul li').removeClass('selectedTab');
		$(this).addClass('selectedTab');
		$('#screen div').removeClass('selected');
		$('#screen #tab-content-' + id).addClass('selected');
		return false;
	});

	/* Auto Focus */
	input_text = 'ex: HTC Desire HD';
	$('.input_text').focus().addClass('hint').val(input_text);
	var input = document.getElementById('searchText');
	Select (input);

	$('.input_text').click(function() {
		$(this).removeClass('hint').val('');
	});

	$('.input_text').keydown(function(){
		if($(this).hasClass('hint'))
			$(this).removeClass('hint').val('');
	})

	$('.input_text').blur(function() {
		if($(this).val()=='') {
			$(this).addClass('hint').val(input_text);
		}
	});
});

function equalHeight(group) {
   tallest = 0;
   group.each(function() {
      thisHeight = $(this).height();
      if(thisHeight > tallest) {
         tallest = thisHeight;
      }
   });
   group.height(tallest);
}

function Select (input) {

    if (input.selectionStart === undefined) {
        var inputRange = input.createTextRange();
        inputRange.moveStart ("character", 0);
        inputRange.collapse();
        inputRange.moveEnd("character", 0);
        inputRange.select();
    }
    else {
        input.selectionStart = 0;
        input.selectionEnd = 0;
        input.focus();
    }
}
