﻿
// Check that the page has loaded
$(document).ready(function() {

    // BigTarget for featured phones homepage
    $("#main.home #featuredPhones .featuredPhone .title A").bigTarget({
	    clickZone : 'div.featuredPhone' // jQuery parent selector
  	});
  	$('#main.home #featuredPhones .featuredPhone').css({'cursor': 'pointer'});
  	
  	// BigTarget for featured phones left column
    $("#main .leftCol .featuredPhone .title A").bigTarget({
	    clickZone : '.featuredPhoneMiddle' // jQuery parent selector
  	});
  	$('.leftCol .featuredPhoneMiddle').css({'cursor': 'pointer'});
  	
  	// BigTarget for related phones
    $("#main .relatedProducts .relatedProduct .title A").bigTarget({
	    clickZone : '.relatedProduct' // jQuery parent selector
  	});
  	$('#main .relatedProducts .relatedProduct').css({'cursor': 'pointer'});
  	
  	// Equal column height
  //	var heightRight = $('#main .rightCol .middle').height();
  	//var heightLeft = $('#main .leftCol .middle').height();
  	
  //	if (heightRight > heightLeft) {  	
   //     $('#main .leftCol .middle').height(heightRight+32);
   //     $('#main .leftCol.large .middle').height(heightRight-37);
   // }
   // else
   // {
   //     $('#main .rightCol .middle').height(heightLeft-32);
   //     $('#main .rightCol.large .middle').height(heightLeft+37);

   // }
    // Lightbox
    $('.selectedPhone .contentBoxLeftCol A').lightBox();
    
    //Bind the search button and textbox 
    $('#searchButton').click(function() {
    if ( $('.searchTextbox').val() != "Search for...")
    {
        window.location="/search.aspx?keywords=" + $('.searchTextbox').val();   
        }
        return false;
    });
    
    $('.searchTextbox').keypress(function(e){
        if (e.which == 13 && e.target.type != "") {
            window.location="/search.aspx?keywords=" + $('.searchTextbox').val();
         
            return false;
        }
    });
    
    
    //Fix google toobar autocomplete
      var timer;
    
    for (var count = 0; count < 20; count++)
    {
        setTimeout("resetInputs()", 50 * count);
    }
    timer = setInterval("resetInputs()", 250);
    
});

function resetInputs(){

    $('.form').find('select').css("background-color", "#FDFAF2");
    $('.form').find('input').css("background-color", "#FDFAF2");
}

function clear_checkboxes(myID){
    var frm = document.forms[0];
    for (i = 0; i < frm.length; i++) {
        if (frm.elements[i].id != myID) {
                frm.elements[i].checked = false;
               $('input').next().removeClass('selected');
        }
    }
}