$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
		// for ie6, set height since min-height isn't supported
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return this;
};    
    function ntzAccordion(e) {
    	$(e).find('dd').hide();
    	$(e).find('dt').bind('click', function(){
    		if($(e).find('dd').is(':animated') || $(this).next('dd').is(':visible')) {return false;}
    			$(e).find('dt.opened').removeClass('opened');
    			$(e).find('dd:visible').slideUp('fast');
    			$(this).next('dd').slideDown('fast').end().addClass('opened');
    	});
    	$(e).find('.active').trigger('click');
    };//ntzAccordion
    function load_games(plt,sort) {
        $('div.games').html('Loading...');
        $('#pop_games_head span').html(plt.toUpperCase());        
        $('div.games').load("http://www.gamingdeals.co.uk/ajax/games/",{platform: plt, order: sort});
        $('div.games ul li').equalHeights();
        $('div.games ul li img').equalHeights(); 
        //return false;   
    }
    function load_article(post_id) {   
        $.get("http://www.gamingdeals.co.uk/ajax/article/" + post_id, function(data){
            $('#content .post_content').html(data);
            $('#content .post_content').slideDown();
        });
        //$('#content .post_content').show();
    }
    function load_vids(title) {
        $('#descr').hide();
        $('#info').html('Loading...');         
        $('#info').slideDown().load("http://www.gamingdeals.co.uk/ajax/youtube/",{query: title});
        $("a[rel^='prettyPhoto']").prettyPhoto();      
    }
    function load_sim_games(plt,cat) {
        $('#descr').hide();  
        $('#info').html('Loading...');      
        $('#info').slideDown().load("http://www.gamingdeals.co.uk/ajax/similar_games/",{platform: plt, category: cat})        
    }   
    function load_desc() {
        $('#info').hide();
        $('#descr').show();
    } 
$(document).ready(function() {
    $('#info').hide();   
    $('#games ul li').equalHeights();   
    $('#price_track').hide();   
    $('#price_track_form').click(function() {
        $('#price_track').slideToggle();
    });
    $('a.check_discounts').click(function() {
        var call = $(this).attr('href');
        $(this).parent().load(call).wrap('<ul></ul>');
        return false;
    }); 
    $('ul.noclick a').click(function() {
        return false;
    });
   	ntzAccordion($('.home_list')); // we call function with DL selector as parameter
    $('#price_tracker').submit(function() {
        var email = $('#email').val();
        var submit_url = $(this).attr('action');
        var price = $('#price').val();
        //alert(price);
        var current_price = $('#current_price').val();
        $('p.status').show().load(submit_url,{email: email, price: price, cp: current_price});
        return false;
    });
}); 
