ieHover = function() {
  var ieEls = document.getElementById("page").getElementsByTagName("LI");
  for (var i=0; i<ieEls.length; i++) {
    ieEls[i].onmouseover=function() {
      this.className+=" hover";
    }
    ieEls[i].onmouseout=function() {
      this.className=this.className.replace(new RegExp(" hover\\b"), "");
    }
  }
}

if (window.attachEvent) window.attachEvent("onload", ieHover);


try{document.execCommand("BackgroundImageCache",false,true);}catch(err){}
jQuery(document).ready(function() {
  jQuery('input[value]').each(function(){
    if(this.type == 'text') {
      jQuery(this).focus(function(){
        if (this.value == this.defaultValue) {
          this.value = '';
        }
      }).blur(function(){
        if (!this.value.length) {
          this.value = this.defaultValue;
        }
      });
    }
  });



  //jQuery('.mainCols').wrapInner('<div class="colInner"><div class="colInner"></div></div>');
  jQuery('.mainCols').wrapInner('<div class="colInner"></div>');

  jQuery('#commentBox .reply').click(function(event){
    event.preventDefault();
    var string = '<a class="replyTo" href="#' + jQuery(this).parents('li').attr('id') + '">@' + jQuery(this).siblings('#commentBox .info').find('.author').text() + ':</a>';
    var currentValue = jQuery('#comment').val();
    jQuery('#comment').val(currentValue + string + '\n').focus();
  });
  var exp = /^@/;
  var exphref = /^#comment-/;
  jQuery('#commentBox .content p a').each(function(){
      if (jQuery(this).text().match(exp) && jQuery(this).attr('href').match(exphref)) {
        jQuery(this).addClass('replyTo');
      }
  });
  var offset = jQuery('#commentBox').offset();
  jQuery('.replyTo').hover(
    function(){
      jQuery(jQuery(this).attr('href')).clone().hide().attr('id','').insertAfter(jQuery(this).parents('li')).addClass('commentTip').fadeIn('medium');
    },
    function(){
      jQuery('.commentTip').fadeOut('fast',function(){
        jQuery(this).remove();
      });
    }
  ).mousemove(function(e){
    jQuery('.commentTip').css({'left' : (e.pageX - offset.left + 10) , 'top' : (e.pageY - offset.top + 5)});
  });
});






jQuery('.product-12, .product-13, .product-14').ready(function() {
	//	TODO: see about finding a way to make this work without using setTimeout
	setTimeout( function(){

		var heights = new Array();
		
		jQuery('.product-12, .product-13, .product-14').each(function(i) {
			var height = jQuery(this).outerHeight(0);
			heights[i] = height;
		});
		
		//console.log(heights)
		
		heights.sort(function(a,b){return b - a});
		var largestHeight = heights[0] - 20;

		jQuery('.product-12, .product-13, .product-14').each(function(i) {
			jQuery(this).css('height', largestHeight);
		});

	}, 400);

	

})

