document.write('<script type="text/javascript" src="http://broadbandninja.co.uk/media/js/jquery.js"></script>');
document.write('<script type="text/javascript" src="http://broadbandninja.co.uk/media/js/jquery-dom.js"></script>');
document.write('<link rel="stylesheet" type="text/css" media="all" href="http://broadbandninja.co.uk/media/css/widget.css?v=1" />');

w_width = typeof w_width == 'string' ? w_width : '200px';
w_height  = typeof w_height  == 'string' ? w_height  : '150px';
w_border  = typeof w_border  == 'number' ? w_border  : 1;
w_target  = typeof w_target  == 'number' ? '_blank' : '';
w_count = typeof w_count  == 'number' ? 'no-count'  : '';
w_description = typeof w_description  == 'number' ? ''  : 'no-description';
w_theme = typeof w_theme  == 'string' ? w_theme  != 'awidget-unstyled' ? 'awidget '+w_theme : w_theme  : 'mywidget TopProducts';
w_title = typeof w_title  == 'string' ? w_title  : 'Compare';
w_custom_header = typeof w_custom_header  == 'string' ? 'background: '+w_custom_header+';'  : '';
w_custom_border = typeof w_custom_border  == 'string' ? 'border-color: '+w_custom_border+';'  : '';
w_custom_link = typeof w_custom_link  == 'string' ? w_custom_link  : '';
w_custom_hoverlink = typeof w_custom_hoverlink  == 'string' ? w_custom_hoverlink  : '';
w_custom_footer = typeof w_custom_footer  == 'string' ? ' style="color: '+w_custom_footer+'"'  : '';
w_id = typeof w_id  == 'string' ? ''+w_id+''  : 'awidget-container';

aff_buy_at = typeof aff_buy_at  == 'string' ? aff_buy_at  : '__';

keyword = typeof keyword  == 'string' ? keyword  : '__';

document.write('<div id="'+w_id+'" class="'+w_theme+'" style="width: '+w_width+';">');
document.write('<br class="clear"></div>');

function widget_go(obj) {
    $j('#'+w_id).html(' ');
    var tpl = function() {
    	
    	var url = this.href;
    	var aff = "__";
    	if (this.an == "buy-at") {
    		aff = aff_buy_at;
    	}
    	url = url + aff + '/' + keyword + '/';
        return [
        	'dl', {}, [
        		'dt',{},[
        			'a', {'href':url}, [
        				'img',{ 'src':this.logo, 'alt':'' },[]
        			]
        		],
        		'dd',{},[
	        		'div', {'class':'TopPro01'}, this.title,
	        		'div', {'class':'TopPro02'}, [
	        			'a',{},this.desc
	        		],
	        		'div', {'class':'TopPro03'}, [
	        			'img',{'src':'http://broadbandninja.co.uk/media/img/0_price_icon.gif', 'align':'absmiddle'},[], 
	        			'a',{'href':url},this.price
	        		]
	        	]
        	]
        ];
    };
    if(!obj) {
        $j('#'+w_id).html('Widget Error please try later.');
    }
    if(!obj.objects || obj.objects.length == 0) {
        $j('#'+w_id).html('Some other widget error');
    }
    for (var i = 0 ; i < obj.objects.length ; i++) {
            $j('#'+w_id).tplAppend(obj.objects[i], tpl);
    }
    if(w_custom_hoverlink != '') {
        $j('#'+w_id+' table a').hover(function(){$j(this).css('color',  w_custom_hoverlink)}, function() {$j(this).css('color',  w_custom_link)});
    }
}

