jQuery.noConflict();

jQuery(document).ready(function() {
	// clear search field
    swapValues = [];
    jQuery(".swap_value").each(function(i){
        swapValues[i] = jQuery(this).val();
        jQuery(this).focus(function(){
            if (jQuery(this).val() == swapValues[i]) {
                jQuery(this).val("");
            }
        }).blur(function(){
            if (jQuery.trim(jQuery(this).val()) == "") {
                jQuery(this).val(swapValues[i]);
            }
        });
    });

	// validate ratings form
	jQuery("form.reviewform").submit(function() {
		var overall = jQuery('[name="0_rating"]').val();
		var features = jQuery('[name="1_rating"]').val();
		var value = jQuery('[name="2_rating"]').val();
		if(overall === '0') {
			alert('Please give an Overall rating');
			return false;
		}
		if(features === '0') {
			alert('Please give a Features rating');
			return false;
		}
		if(value === '0') {
			alert('Please give a Value rating');
			return false;
		}
	});

	// hide all hidden inputs 
	jQuery("input[@type='hidden']").addClass("hidden");
	jQuery("#content input[@type='submit']").addClass("submit-btn");
	
	// create onclick effect	
	jQuery("input[@type='submit']").focus(function() {  
		jQuery(this).addClass("onclick");  
	});
	
	// equal heights on archive page
	equalHeight(jQuery(".post-wrap.archives"));
	
	// guide contents box
	equalHeight(jQuery(".column"));
	
	jQuery("a.new-topic").click(function () {	
		elementClick = jQuery(this).attr("href")
		destination = jQuery(elementClick).offset().top;
		jQuery("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100 );
	  	return false;
	})
	jQuery("a.anchorLink").click(function () {
		elementClick = jQuery(this).attr("href")
		destination = jQuery(elementClick).offset().top;
		jQuery("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100 );
	  	return false;
	})
	
	// toggle attachment box
	jQuery("#attachments-box").css("display","none");
	jQuery("a#toggle-attachments").click(function () {
		jQuery("#attachments-box").slideToggle();
	})
	
	// toggle specs box
	jQuery("#specs-list").css("display","none");
	jQuery("#specs-toggle").click(function () {
		jQuery("#specs-list").slideToggle();
	})
	
	jQuery("#specs-toggle").toggle(function(){
		jQuery(this).addClass("active");
	}, function () {
		jQuery(this).removeClass("active");
	});
	
	// hover for IE6
	jQuery("#specs-toggle").hover(function() {
		jQuery(this).addClass('hover');
	}, function() {
		jQuery(this).removeClass('hover');
	});
   
});

function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = jQuery(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}
