
jq(document).ready(function() {
	
	jq("[alt|=webbradio]").live("hover", function(e) {
		jq(this).css("cursor", "pointer");
	});

	jq("[alt|=webbradio]").live("click", function(e) {
		//var url = jq(this).attr("url");
		var url = "http://player.emunityedge.net/player/index.php?playerkey=stadium_se";
		window.open(url,"popup","menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=310,height=386");
	});
	
	jq("#testgimlet").live("click", function(e) {
		e.preventDefault();
		var url = jq("#gimleturl").val();
		//var senddata = 
		jq.post(url, { 'products': ["101045","102525", "097466"], locale : "se" }, function(data) {
			alert(data["097466"].price_normal);
		},"json");
	});
	
	jq("#bonuspaymentslink").live("click", function(e) {
		e.preventDefault();
		new LITBox(jq(this).attr("href"), {type:'window', overlay:true, height:480, width:800, resizable:true, opacity:1, header: "Bonusutbetalningar", top:276});
		var height = jq('#table_payment_history').innerHeight()+75;
		if(height > jq('#LitBox2').innerHeight()) {
			jq('#LitBox2').css('height', height + 'px');
			jq('#LB_content_id').css('height', height + 'px');
		}
	});
	
	jq("#pointshistorylink").live("click", function(e) {
		e.preventDefault();
		new LITBox(jq(this).attr("href"), {type:'window', overlay:true, height:480, width:800, resizable:true, opacity:1, header: "Poänghistorik", top:276});
		var height = jq('#table_payment_history').innerHeight()+75;
		if(height > jq('#LitBox2').innerHeight()) {
			jq('#LitBox2').css('height', height + 'px');
			jq('#LB_content_id').css('height', height + 'px');
		}
	});
	
	jq("#submit_member_card").live("click", function(e) {
			jq("#become_member").append('<input type="hidden" name="RegForm_SendStadiumCard" id="RegForm_SendStadiumCard" value="1" />');
			sumbmitMembership();
	});
	
	jq("#printOffers").live("click", function(e) {
		jq("#middle_container").printElement({printMode:'popup',pageTitle:'Medlemserbjudanden'});
	});
	
	jq("#printPurchases").live("click", function(e) {
		jq("#middle_container").printElement({printMode:'popup',pageTitle:'Mina köp på Stadium'});
	});
	
	jq("input:checkbox[name^='RegForm_Com']").live("click", function(e) {
			if(jq(this).attr("checked")) {
				jq(this).val("1");
			}
			else {
				jq("#become_member").append('<input type="hidden" name="'+jq(this).attr("name")+'" id="'+jq(this).attr("name")+'" value="0" />');
			}
	});
	
	jq("#select_payment_year").live('change', function(e) {
		jq.post(jq(this).val(), function(data) {
			jq('tr[attr="tr_payment_history_data"]').remove();
			jq("#tr_payment_history").after(data);
		});
	});
	

});

function changeyear(el) {
	//IE jquery onchange problem
	var url = el.options(el.selectedIndex).value;
	
	jq.post(url, function(data) {
		jq('tr[attr="tr_payment_history_data"]').remove();
		jq("#tr_payment_history").after(data);
	});
}
