jquery window size

$(document).ready(function(){
	var _ww = $(window).width();
	var device;
	
	init();
	function init(){resize();};
	function resize(){
		var _ww = $(window).width();
		if ( _ww > 940 ) {
			device = "p";
		}else{
			device = "s";
		}
	}
	$(window).on('resize',function() {resize();});
});