var BoxHeights = {
	maxh: 0,
	boxes: Array(),
	num: 0,
	equalise: function() {
		this.num = arguments.length;
		for (var i=0;i<this.num;i++) if (!$(arguments[i])) return;
		this.boxes = arguments;
		this.maxheight();
		for (var i=0;i<this.num;i++) $(arguments[i]).css('height', this.maxh + 'px');
	},
	maxheight: function() {
		var heights = new Array();
		for (var i=0;i<this.num;i++) {
			if (navigator.userAgent.toLowerCase().indexOf('opera') == -1) {
				heights.push($(this.boxes[i]).height());
			} else {
				heights.push($(this.boxes[i]).height());
			}
		}
		heights.sort(this.sortNumeric);
		this.maxh = heights[this.num-1];
	},
	sortNumeric: function(f,s) {
		return f-s;
	}
}

$(document).ready(function () {
	$("#smallerText").click(function () {
		decrease(); // found in textsize.js
		this.src = _base_url + '/images/layout/franchisedev/frandev-utility-text-size-sm-active.gif';
		$("#largerText").attr('src', _base_url + '/images/layout/franchisedev/frandev-utility-text-size-lg.gif');
		return false;
	});
	$("#largerText").click(function () {
		$('div.right').css('height', 'auto');
		increase(); // found in textsize.js
		$("#smallerText").attr('src', _base_url + '/images/layout/franchisedev/frandev-utility-text-size-sm.gif');
		this.src = _base_url + '/images/layout/franchisedev/frandev-utility-text-size-lg-active.gif';
		return false;
	});

	if (textsize == 1) {
		$("#smallerText").attr('src', _base_url + '/images/layout/franchisedev/frandev-utility-text-size-sm.gif');
		$("#largerText").attr('src', _base_url + '/images/layout/franchisedev/frandev-utility-text-size-lg-active.gif');
	}
	else {
		$("#smallerText").attr('src', _base_url + '/images/layout/franchisedev/frandev-utility-text-size-sm-active.gif');
		$("#largerText").attr('src', _base_url + '/images/layout/franchisedev/frandev-utility-text-size-lg.gif');
	}

   $('#share').change(function() {
    var pageURL = window.location;
    var pageTitle = document.title;
    var selectedBookmark = this.value;
	var gotoURL = '';

    if (selectedBookmark == 'digg') {
      gotoURL='http://digg.com/submit?url='+pageURL+'&title='+pageTitle;
    } 
    else if (selectedBookmark == 'delicious') {
      gotoURL='http://del.icio.us/post?url='+pageURL+'&title='+pageTitle;
  
    } 
    else if (selectedBookmark == 'facebook') {
      gotoURL='http://www.facebook.com/share.php?u='+pageURL;
  
    }		
    else if (selectedBookmark == 'myspace') {
      gotoURL='http://www.myspace.com/Modules/PostTo/Pages/?c='+pageURL+'&t='+pageTitle;
  
    } 	
    else if (selectedBookmark == 'netscape') {
      gotoURL='http://www.netscape.com/submit/?T='+pageURL+'&U=URL'+pageTitle;
  
    } 
    else if (selectedBookmark == 'reddit') {
      gotoURL='http://reddit.com/submit?url='+pageURL+'&title='+pageTitle
  
    }
    else if (selectedBookmark == 'stumble') {
      gotoURL='http://www.stumbleupon.com/submit?url='+pageURL+'&title='+pageTitle;    
  
    }	
    //else if (selectedBookmark == 'yahoo') {
      //gotoURL='http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+pageTitle+'&u='+pageURL+'&ei=UTF-8';   
    //}	
	
	if (gotoURL != '') {
	  window.open(gotoURL);
	}		   
	
   });

   $('#dspWhy').click(function() {
     $('#email-why').show();  
   });  
   
   $('#closeWhy').click(function() {
     $('#email-why').hide();  
   }); 

	$('div#header_link_home').click(function() {
		window.location = _URL;
	});
 
	$('input#header_search_text').focus(function() {
		$this = $(this);
		if($this.val() == 'Enter Search Term')
		{
			$this.val('').addClass('active');
		}
	});

	$("div#makeMeScrollable").smoothDivScroll({autoScroll: "always", autoScrollDirection: "endlessloopright", autoScrollStep: 1, autoScrollInterval: 15});

  $('#find-city').click(function() {
    $('#dspCity').show();
    $('#dspState').show();
    $('#dspZipCode').hide();
    $('#dspZipCodeText').hide();			

    // Clear the Zip Field
    $('#zipsearch').val('');	
	
	this.className = "tab active";
	$('#find-zip').attr('class',"tab");
	$('#searchLabel').attr('class',"city");
	return false;
  });

  $('#find-zip').click(function() {
    $('#dspCity').hide();
    $('#dspState').hide();
    $('#dspZipCode').show();
    $('#dspZipCodeText').show();			
	
	
    // Clear the City & State Fields
    $('#citysearch').val('');	
	$("#dspState option:eq(0)").attr("selected", "selected");
	
	this.className = "tab active";
	$('#find-city').attr('class',"tab");
	$('#searchLabel').attr('class',"zip");		
	return false;
  });      

});

var jQuery = $;
