jQuery(window).load(function(){
    function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
    }
    equalHeight(jQuery("#mainDown .col"));
    if (!$(".frontpage").length) {
    equalHeight(jQuery("#main .sameHeight"));
    }
	if ($("#tipsForm").length) {
		$("#tipsForm").submit(function() {   
		  var $this = $(this),
			  $senderEmail = $this.find("#senderEmail").removeClass("error"),
			  $recipientEmail = $this.find("#recipientEmail").removeClass("error");
		  if (!emailpattern.test($senderEmail.val())) {
			  $senderEmail.addClass("error").focus();
			  return false;
		  } else if(!emailpattern.test($recipientEmail.val())){
			  $recipientEmail.addClass("error").focus();
			  return false;
		  }
		  $.ajax({
		  method: 'post',
		  url: ips.system.urlroot,
		  data: $(this).serialize(),
		  error: function(msg){
			 $("#objectResponse").html(ips.strings.tipafrienderror); 
		  },
		  success: function(data){
			 $("#objectResponse").html(ips.strings.tipafriendsuccess);
			 $("#tipsForm").reset();
		  }
		  }); 
		return false;
		});
	}

});

function submitWebshop(){
  var myCount = 0;
  var formAmount = $('#webshop').find('form').size();

  $('#webshop').find('form').each( 
    function(){

var thisAmount = $(this).children('.amount').val();
if (thisAmount > 0) {
      $.ajax({
        method : 'post',
        url : $(this).attr("action"),
        data : $(this).serialize(),
        error : function(msg){},
        success : function(data){}
      }); 
}
      myCount=myCount+1;
      if (myCount == formAmount) {
        setTimeout("window.location=ips.system.urlroot + '?module=Webshop&action=ShoppingBasketView.displayShoppingBasket&template=basket_' + ips.system.lang",300);
      }
    }
  ); 
}

function changeOption(a){
  if(a != ''){
    $('#webshop').load(a);
  }
}

function facebook_click() {
  u=location.href;
  t=document.title;
  window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
  return false;
}

function twitter_click() {
  u=location.href;
  t=document.title;
  window.open('http://twitter.com/home?status='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=810,height=436');
  return false;
}
