function coswidget(options) {
        var host = 'www.communityofsweden.com';
        //var host = 'cosdev.dev-2.getupdated.com';
        //var host = 'localhost';
		var frame = document.createElement('iframe');
		//frame.setAttribute("src","widget.html?width=" + options.width +"&photos=" + options.photos +"&stories=" + options.stories +"&className=" + options.class +"&userid=" + options.userid);
		frame.setAttribute('frameborder','0');
		frame.setAttribute('border','0');
		frame.setAttribute('scrolling','no');
		frame.setAttribute('style', 'background:#DFDFDF;border-bottom:1px solid #dfdfdf;');

        var contentBlock;
        if (options.widgetWidthPx) {
            contentBlock = Math.floor((options.widgetWidthPx - 11) / options.width);
            frame.setAttribute('width', options.widgetWidthPx + 'px');
        } else {
            contentBlock = (options.blockWidth) || 172;
            frame.setAttribute('width', ((options.width * contentBlock) + 11) + 'px');
        }

        options.blockWidth = contentBlock;

        frame.setAttribute("src", "http://" + host + "/Widget/Widget-wrapper/?referral=" + window.location.href + "&width=" + options.width + "&height=" + contentHeight + "&photos=" + options.photos + "&stories=" + options.stories + "&className=" + options.className + "&userid=" + options.userid + "&winter=" + options.winter + "&spring=" + options.spring + "&summer=" + options.summer + "&autumn=" + options.autumn + "&geoFilter=" + options.geoFilter + "&tagCombo=" + options.tagCombo + "&partnerRegion=" + options.partnerRegion + "&place=" + options.place + "&regionTheme=" + options.regionTheme + "&blockWidth=" + options.blockWidth + "&blockHeight=" + options.blockHeight + "&widgetWidthPx=" + options.widgetWidthPx);	 
		
		
		var contentBlockHeight = (options.blockHeight) || 172;

		var contentAmount = parseInt(options.stories) + parseInt(options.photos);

		var contentHeight;

		var footerHeight = 168;
		if (options.widgetWidthPx) {
		    if (options.widgetWidthPx < 344) {
		        footerHeight = 236;
		    }
		} else if (options.width < 2) {
		    footerHeight = 236;
		}


		switch (parseInt(options.width)) {
		    case 1:
		        switch (contentAmount) {
		            case 1: contentHeight = contentBlockHeight; break;
		            case 2: contentHeight = 2 * contentBlockHeight; break;
		            case 3: contentHeight = 3 * contentBlockHeight; break;
		            case 4: contentHeight = 4 * contentBlockHeight; break;
		            case 5: contentHeight = 5 * contentBlockHeight; break;
		            case 6: contentHeight = 6 * contentBlockHeight; break;
		            case 7: contentHeight = 7 * contentBlockHeight; break;
		            case 8: contentHeight = 8 * contentBlockHeight; break;
		            case 9: contentHeight = 9 * contentBlockHeight; break;
		            case 10: contentHeight = 10 * contentBlockHeight; break;
		            case 11: contentHeight = 11 * contentBlockHeight; break;
		            case 12: contentHeight = 12 * contentBlockHeight; break;
		        };
		        frame.setAttribute('height', contentHeight + footerHeight + 'px');
		        break;
		    case 2:
		        switch (contentAmount) {
		            case 1:
		            case 2: contentHeight = contentBlockHeight; break;
		            case 3:
		            case 4: contentHeight = 2 * contentBlockHeight; break;
		            case 5:
		            case 6: contentHeight = 3 * contentBlockHeight; break;
		            case 7:
		            case 8: contentHeight = 4 * contentBlockHeight; break;
		            case 9:
		            case 10: contentHeight = 5 * contentBlockHeight; break;
		            case 11:
		            case 12: contentHeight = 6 * contentBlockHeight; break;
		        };
		        frame.setAttribute('height', contentHeight + footerHeight + 'px');
		        break;
		    case 3:
		        switch (contentAmount) {
		            case 1:
		            case 2:
		            case 3: contentHeight = contentBlockHeight; break;
		            case 4:
		            case 5:
		            case 6: contentHeight = 2 * contentBlockHeight; break;
		            case 7:
		            case 8:
		            case 9: contentHeight = 3 * contentBlockHeight; break;
		            case 10:
		            case 11:
		            case 12: contentHeight = 4 * contentBlockHeight; break;
		        };
		        frame.setAttribute('height', contentHeight + footerHeight + 'px');
		        break;
		    default:
		        contentHeight = contentBlock;
		        break;
		};

		var scr = document.getElementById('coswidget'); 
		scr.parentNode.insertBefore(frame, scr);
};	
