var waitingQ=0;

var idspot = 24577;

var JSONFile ='';var bgcolor = 'e6edf7';
var widgwidth = '200';

var textcolor = '3467a7';

var type = 0

 
var jsoncontent = {"RC":{"CODE":0,"MSG":""},"STATS":{"TIME":52},"VAL":{"idSpot":"24577","title":"Choose the Best Roulette System in the World","baseline":"Roulette System Money Maker Machine - Online Roulette - Play Roulette Online using free roulette system and strategy, or beat roulette using roulette systems tool software.","user":{"0":{"IdUser":"16998","Pseudo":"williamdeluca","Jimage":{"Type":"user","Original":{"Filename":"d9\/e7\/16998\/1252921309.jpeg"},"Data":[{"Url":"d9\/e7\/16998\/1252921309.jpeg","Width":"190","Height":"300"}],"Thumb":{"square_26":{"Url":"d9\/e7\/16998\/square_26_1252921309.png","Height":"26","Width":"26"},"square_48":{"Url":"d9\/e7\/16998\/square_48_1252921309.png","Height":"48","Width":"48"},"square_60":{"Url":"d9\/e7\/16998\/square_60_1252921309.png","Height":"60","Width":"60"},"max_75":{"Url":"d9\/e7\/16998\/max_75_1252921309.png","Height":"75","Width":47.5},"max_128":{"Url":"d9\/e7\/16998\/max_128_1252921309.png","Height":"128","Width":81.0666666667},"max_160":{"Url":"d9\/e7\/16998\/max_160_1252921309.png","Height":"160","Width":101.333333333},"max_192":{"Url":"d9\/e7\/16998\/max_192_1252921309.png","Height":"192","Width":121.6},"max_256":{"Url":"d9\/e7\/16998\/max_256_1252921309.png","Height":"256","Width":162.133333333}}},"KarmaComputed":"4"},"Reader":null,"Writer":[{"Pseudo":"williamdeluca","KarmaComputed":"4","ImageUrl":"nemo","ImageV2":"{\"Type\":\"user\",\"Original\":{\"Filename\":\"d9\/e7\/16998\/1252921309.jpeg\"},\"Data\":[{\"Url\":\"d9\/e7\/16998\/1252921309.jpeg\",\"Width\":\"190\",\"Height\":\"300\"}],\"Thumb\":{\"square_26\":{\"Url\":\"d9\/e7\/16998\/square_26_1252921309.png\",\"Height\":\"26\",\"Width\":\"26\"},\"square_48\":{\"Url\":\"d9\/e7\/16998\/square_48_1252921309.png\",\"Height\":\"48\",\"Width\":\"48\"},\"square_60\":{\"Url\":\"d9\/e7\/16998\/square_60_1252921309.png\",\"Height\":\"60\",\"Width\":\"60\"},\"max_75\":{\"Url\":\"d9\/e7\/16998\/max_75_1252921309.png\",\"Height\":\"75\",\"Width\":47.5},\"max_128\":{\"Url\":\"d9\/e7\/16998\/max_128_1252921309.png\",\"Height\":\"128\",\"Width\":81.0666666667},\"max_160\":{\"Url\":\"d9\/e7\/16998\/max_160_1252921309.png\",\"Height\":\"160\",\"Width\":101.333333333},\"max_192\":{\"Url\":\"d9\/e7\/16998\/max_192_1252921309.png\",\"Height\":\"192\",\"Width\":121.6},\"max_256\":{\"Url\":\"d9\/e7\/16998\/max_256_1252921309.png\",\"Height\":\"256\",\"Width\":162.133333333}}}","IdUser":"16998","timestamp":"1265368009","Description":"","TimeStamp":"1265368009","RF_level":"0","RF_levelName":"Creator","Jimage":{"Type":"user","Original":{"Filename":"d9\/e7\/16998\/1252921309.jpeg"},"Data":[{"Url":"d9\/e7\/16998\/1252921309.jpeg","Width":"190","Height":"300"}],"Thumb":{"square_26":{"Url":"d9\/e7\/16998\/square_26_1252921309.png","Height":"26","Width":"26"},"square_48":{"Url":"d9\/e7\/16998\/square_48_1252921309.png","Height":"48","Width":"48"},"square_60":{"Url":"d9\/e7\/16998\/square_60_1252921309.png","Height":"60","Width":"60"},"max_75":{"Url":"d9\/e7\/16998\/max_75_1252921309.png","Height":"75","Width":47.5},"max_128":{"Url":"d9\/e7\/16998\/max_128_1252921309.png","Height":"128","Width":81.0666666667},"max_160":{"Url":"d9\/e7\/16998\/max_160_1252921309.png","Height":"160","Width":101.333333333},"max_192":{"Url":"d9\/e7\/16998\/max_192_1252921309.png","Height":"192","Width":121.6},"max_256":{"Url":"d9\/e7\/16998\/max_256_1252921309.png","Height":"256","Width":162.133333333}}},"Logged":0}]},"rank":"12689","image":"43\/e2\/24577\/square_48_1252919965.png","skin":{"Name":"Corporate Blue","Id":"1"}}};
var title = jsoncontent.VAL.title;
var spot_rank = jsoncontent.VAL.rank;

var jamespot_helper = {

  include_css : function (filename)
  {
    var head = document.getElementsByTagName('head')[0];
    css = document.createElement('link');
    css.rel='stylesheet';
    css.type='text/css';
    css.href = filename;
    head.appendChild(css)
  } ,
  include_script : function (filename){

      var head = document.getElementsByTagName('head')[0];
      script = document.createElement('script');
      script.src = filename;
      script.type = 'text/javascript';
      head.appendChild(script);
    },
  write_content : function()
  {
    print_widget()
  }
}

jamespot_helper.include_css("http://www.jamespot.com/widget/jamespot_widget.css");
jamespot_helper.include_script("http://www.jamespot.com/widget/jamesquery.php");

var widget_content = ''; 
widget_content += '		<div id="widget_jamespot">';
widget_content += '			<div id="widget_jamespot_left" class="floatLeft" style="background-color:#'+bgcolor+'">';
widget_content += '			</div>';
widget_content += '			<div id="widget_jamespot_center" class="floatLeft" style="background-color:#'+bgcolor+';">';
widget_content += '				<div id="bandeau"></div>';
widget_content += '				<p id="title_spot"><a href="http://www.jamespot.com/s/'+idspot+'" target="_blank">'+title+'</a></p>';


widget_content += '				<div class="divider"></div>';
widget_content += '				<div id="rank"><div id="star"></div>Spot\'rank : '+spot_rank+' &egrave;me</div>';
widget_content += '				<div class="divider"></div>';
widget_content += '				<div id="readers">';
var nb_user = 1;
var nb_reader = 0;
var nb_writer = 1;

widget_content += '					<div id="nb_readers"><div id="illus"></div>Spotter\'s count : '+nb_user+'</div>';
widget_content += '					<div id="avatars">';

var max = 25;

nbUserPrinted = 0;
flag = false;
if (!jsoncontent.VAL.user.Writer)
{
	// Spot 2008
	i=0;
	while (!flag)
	{
		if (jsoncontent.VAL.user[i])
		{
			nbUserPrinted++;
			if ((jsoncontent.VAL.user[i].Jimage!=null) && (jsoncontent.VAL.user[i].Jimage.Thumb!=null))
			{
				widget_content += '<a href=\"http://www.jamespot.com/u/'+jsoncontent.VAL.user[i]['Pseudo']+'\" title=\"'+jsoncontent.VAL.user[i]['Pseudo']+'\" target=\"_blank\"><img src=\"http://www.jamespot.com/userdata/user/thumb/'+jsoncontent.VAL.user[i].Jimage.Thumb.square_26.Url+'\" width=\"26px\" height=\"26px\" alt=\"'+jsoncontent.VAL.user[i]['Pseudo']+'\"/></a>';
			}else{ 
				widget_content += '<a href=\"http://www.jamespot.com/u/'+jsoncontent.VAL.user[i]['Pseudo']+'\" title=\"'+jsoncontent.VAL.user[i]['Pseudo']+'\" target=\"_blank\"><img src=\"http://www.jamespot.com/img/user_default/square_26_user_default.png\" width=\"26px\" height=\"26px\" alt=\"'+jsoncontent.VAL.user[i]['Pseudo']+'\"/></a>';	
			}
		}
		i++;
		if ((nbUserPrinted>=nb_user) || (nbUserPrinted>=max))
		{
			flag = true;
		}
	}
}else
{	
	// Spot 2009
	i=0;
	while (!flag)
	{
		if (jsoncontent.VAL.user.Writer[i])
		{
			nbUserPrinted++;
			if ((jsoncontent.VAL.user.Writer[i].Jimage!=null) && (jsoncontent.VAL.user.Writer[i].Jimage.Thumb!=null))
			{
				widget_content += '<a href=\"http://www.jamespot.com/u/'+jsoncontent.VAL.user.Writer[i]['Pseudo']+'\" title=\"'+jsoncontent.VAL.user.Writer[i]['Pseudo']+'\" target=\"_blank\"><img src=\"http://www.jamespot.com/userdata/user/thumb/'+jsoncontent.VAL.user.Writer[i].Jimage.Thumb.square_26.Url+'\" width=\"26px\" height=\"26px\" alt=\"'+jsoncontent.VAL.user.Writer[i]['Pseudo']+'\"/></a>';
			}else{ 
				widget_content += '<a href=\"http://www.jamespot.com/u/'+jsoncontent.VAL.user.Writer[i]['Pseudo']+'\" title=\"'+jsoncontent.VAL.user.Writer[i]['Pseudo']+'\" target=\"_blank\"><img src=\"http://www.jamespot.com/img/user_default/square_26_user_default.png\" width=\"26px\" height=\"26px\" alt=\"'+jsoncontent.VAL.user.Writer[i]['Pseudo']+'\"/></a>';	
			}
		}
		i++;
		if ((nbUserPrinted>=nb_writer) || (nbUserPrinted>max))
		{
			flag = true;
		}
	}
	max = max - nbUserPrinted+1;
	i = 0;
	if(max>0)
	{
		flag = false;
	}
	nbUserPrintedRead = 0;
	if (jsoncontent.VAL.user.Reader)
	{
		while (!flag)
		{
			if (jsoncontent.VAL.user.Reader[i])
			{
				nbUserPrinted++;
				nbUserPrintedRead++;
				if ((jsoncontent.VAL.user.Reader[i].Jimage!=null) && (jsoncontent.VAL.user.Reader[i].Jimage.Thumb!=null))
				{
					widget_content += '<a href=\"http://www.jamespot.com/u/'+jsoncontent.VAL.user.Reader[i]['Pseudo']+'\" title=\"'+jsoncontent.VAL.user.Reader[i]['Pseudo']+'\" target=\"_blank\"><img src=\"http://www.jamespot.com/userdata/user/thumb/'+jsoncontent.VAL.user.Reader[i].Jimage.Thumb.square_26.Url+'\" width=\"26px\" height=\"26px\" alt=\"'+jsoncontent.VAL.user.Reader[i]['Pseudo']+'\"/></a>';
				}else{ 
					widget_content += '<a href=\"http://www.jamespot.com/u/'+jsoncontent.VAL.user.Reader[i]['Pseudo']+'\" title=\"'+jsoncontent.VAL.user.Reader[i]['Pseudo']+'\" target=\"_blank\"><img src=\"http://www.jamespot.com/img/user_default/square_26_user_default.png\" width=\"26px\" height=\"26px\" alt=\"'+jsoncontent.VAL.user.Reader[i]['Pseudo']+'\"/></a>';	
				}
			}
			i++;
			if ((nbUserPrintedRead>=nb_reader) || (nbUserPrinted>max))
			{
				flag = true;
			}
		}
	}
}

widget_content += '					</div>';
widget_content += '				</div>';
widget_content += '				<div class="spacer"></div>';
widget_content += '				<p id="join"><a href="http://www.jamespot.com/s/'+idspot+'-'+title+'.html?widget=1&modal=1" target="_blank">Join Jamespot now</a></p>';
widget_content += '				<div class="spacer"></div>';
widget_content += '				<p id="spot_it"><a href="javascript:var d=document,ds=d.selection,w=window,wgs=w.getSelection,e=encodeURIComponent,dl=d.location;s=function(){return ds?ds.createRange().text:(d.getSelection?d.getSelection():(wgs?w.getSelection():\'\'))};{var u=\'http://www.jamespot.com/do?a=se&v=1&f=clip&tl=bk&u=\'+e(dl)+\'&t=\'+e(d.title)+\'&x=\'+e(s());go=function(){if(!window.open(u,\'_blank\'))dl.href=u+\'&sw=1\';};if (/Firefox/.test(navigator.userAgent))setTimeout(go,0);else{go();}}void(0)" title="Spot-It!"><img src="http://www.jamespot.com/widget/img/jbtn_plus_spotit.gif" title="Spot-It!"/></a></p>';
widget_content += '			</div>';
widget_content += '			<div id="widget_jamespot_right" class="floatLeft" style="background-color:#'+bgcolor+'">';
widget_content += '			</div>';
widget_content += '		</div>';

document.write(widget_content);

function print_widget(){
  jQready();
}

function alignAllHeight	() {
	jQuery("#widget_jamespot_right").height(jQuery("#widget_jamespot_center").height());
	jQuery("#widget_jamespot_left").height(jQuery("#widget_jamespot_center").height());
	jQuery("#widget_jamespot").height(jQuery("#widget_jamespot_center").height());
	//alert(jQuery("#widget_jamespot_center").height());
}

function jQready(){
  jQuery("#widget_jamespot").ready(function(){
	var allArticlesState = 0;
	jQuery("#widget_jamespot").css({'color' : '#'+textcolor});
    jQuery("#widget_jamespot #title_spot a").css({'color' : '#'+textcolor});
    jQuery("#widget_jamespot .article a.excerpt").css({'color' : '#'+textcolor});
    jQuery("#widget_jamespot .article a.details").css({'color' : '#'+textcolor});
    jQuery("#widget_jamespot .article a.excerpt").css({'color' : '#'+textcolor});
    jQuery("#widget_jamespot #more").css({'color' : '#'+textcolor});
    jQuery("#widget_jamespot .article img").css({'border' : 'solid 1px #'+textcolor});
    jQuery("#widget_jamespot #jamespotlink").css({'color' : '#'+textcolor});
    
    var totalwidth = '';
    if(widgwidth==0){
    	
        totalwidth = jQuery("#widget_jamespot:parent").css("width");
        totalwidth = parseFloat(totalwidth);
        totalwidth-=30;
        jQuery("#widget_jamespot_center").css({'width' : totalwidth});
    }
    else {
        widgwidth-=20;
    	jQuery("#widget_jamespot_center").css({'width' : widgwidth});
    }
        
    jQuery("#allArticles").hide();
    
    alignAllHeight();
    
	jQuery("#more").click(function () {
    	if(allArticlesState==0){
        	jQuery("#allArticles").slideDown('fast', alignAllHeight);
            allArticlesState = 1;
            jQuery("#more").html("Hidden all articles");
             jQuery("#more").css({'background' : 'url(http://www.jamespot.com/widget/img/arrow_up.png) no-repeat 100% 50%'});
        }
        else {
        	jQuery("#allArticles").slideUp('fast', alignAllHeight);
        	allArticlesState = 0;
            jQuery("#more").html("See all articles");
            jQuery("#more").css({'background' : 'url(http://www.jamespot.com/widget/img/arrow_down.gif) no-repeat 100% 50%'});
        }
      
      return true;
    });
});
}
