
var SigtunaCommon = {};

//events attached after HTML snippet is loaded
SigtunaCommon.init = function () {
	$('.filter').find('th').mouseup(function(){
		var sort = $(this).html();
		sort = sort.toLowerCase();
		
		var currentSearch = $('#sort').val();
		var currentAsc = $('#asc').val();
		var asc = 'true';
		
		if(sort == 'gatuadress'){
			sort = 'address';
		}else if(sort == 'produktnummer'){
			sort = 'produkt_nummer';
		}else if(sort == 'lgh strl'){
			sort = 'rum';
		}else if(sort == 'varav förråd'){
			sort = 'forrad';
		}else if(sort == 'lgh kvm'){
			sort = 'kvm';
		}else if(sort == 'status'){
			sort = 'lagenhet_status';
		}
		
		if(currentSearch == sort && currentAsc == 'true' ){
			asc = 'false';
		}else{
			asc = 'true';
		}
		
		
		$('#sort').val(sort);
		$('#asc').val(asc);
		
		$('.subscribe').submit();
	});

	
	$('.pdf').mousedown(function(){
  		$('.pdfForm').submit();
  	});
}

function email_popup(url) {
	newwindow=window.open(url,'name','height=500,width=400');
	if (window.focus) {newwindow.focus()}
	return false;
}




//DOM-Ready Event Handler _____________________________________________________
$(document).ready(function () {
	SigtunaCommon.init();
});


