var waitingQ=0;

var idspot = 24570;

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

var textcolor = 'ce6816';

var type = 0

 
var jsoncontent = {"RC":{"CODE":0,"MSG":""},"STATS":{"TIME":179},"VAL":{"idSpot":"24570","title":"Jasonparker700's Spot","baseline":"","user":{"0":{"IdUser":"25319","Pseudo":"Jasonparker700","Jimage":null,"KarmaComputed":"2"},"Reader":null,"Writer":[{"Pseudo":"Jasonparker700","KarmaComputed":"2","ImageUrl":"nemo","ImageV2":null,"IdUser":"25319","timestamp":"1255098381","Description":"","TimeStamp":"1255098381","RF_level":"0","RF_levelName":"Creator","Jimage":null,"Logged":0}]},"rank":"6389","skin":{"Name":"Sweet Orange","Id":"7"},"articles":[{"title":"","smallimage":"","image":"","id":"371143","desc":"...","PublishedDate":"2009-10-09 16:19:28"},{"title":"Golden Retriever Crate Training - Associated Content - associatedcontent.com","smallimage":"49\/ab\/24570\/square_48_1255097941.png","image":{"Url":"49\/ab\/24570\/max_75_1255097941.png","Height":"75","Width":75},"id":"371142","desc":"Learn to crate train your golden retriever dogs and puppies....","PublishedDate":"2009-10-09 16:18:53"},{"title":"Psoriasis Scalp Treatment: Treating Scalp Psoriasis Naturally - Associated Content - associatedcontent.com","smallimage":"49\/ab\/24570\/square_48_1255097914.png","image":{"Url":"49\/ab\/24570\/max_75_1255097914.png","Height":56.5,"Width":"75"},"id":"371141","desc":"Psoriasis is a non-contagious autoimmune disease that affects skin and joints of the body. Read more to know about Psoriasis scalp treatment....","PublishedDate":"2009-10-09 16:18:18"},{"title":"Pee Wee Herman Appears on The Jay Leno Show - Associated Content - associatedcontent.com","smallimage":"49\/ab\/24570\/square_48_1255097873.png","image":{"Url":"49\/ab\/24570\/max_75_1255097873.png","Height":"75","Width":75},"id":"371138","desc":"Paul Reubens, better known as Pee Wee Herman, makes an appearance on The Jay Leno Show....","PublishedDate":"2009-10-09 16:17:42"}]}};
		var title_article_1 = '';
		var img_article_1 = '';
		var url_article_1 = 'a/'+'371143';
		var date_article_1 = '2009-10-09 16:19:28';
				var title_article_2 = 'Golden Retriever Crate Training - Associated Content - associatedcontent.com';
		var img_article_2 = '49/ab/24570/square_48_1255097941.png';
		var url_article_2 = 'a/'+'371142';
		var date_article_2 = '2009-10-09 16:18:53';
				var title_article_3 = 'Psoriasis Scalp Treatment: Treating Scalp Psoriasis Naturally - Associated Content - associatedcontent.com';
		var img_article_3 = '49/ab/24570/square_48_1255097914.png';
		var url_article_3 = 'a/'+'371141';
		var date_article_3 = '2009-10-09 16:18:18';
		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="article">';
		widget_content += '	<a class="image"href="http://www.jamespot.com/'+url_article_1+'" target="_blank"><img class="floatLeft"src="http://www.jamespot.com/userdata/spot/thumb/'+img_article_1+'" width="50"  alt=""/></a>';
		widget_content += '	<a class="excerpt floatLeft" href="http://www.jamespot.com/'+url_article_1+'" target="_blank">'+title_article_1+'</a>';
		widget_content += '	<a class="details floatLeft" href="http://www.jamespot.com/'+url_article_1+'" target="_blank">Spot\'Date: '+ date_article_1+'</a>';
		widget_content += '</div>';
		widget_content += '<div class="spacer"></div>';
					widget_content += '<div id="allArticles">';
							widget_content += '<div class="article">';
		widget_content += '	<a class="image"href="http://www.jamespot.com/'+url_article_2+'" target="_blank"><img class="floatLeft"src="http://www.jamespot.com/userdata/spot/thumb/'+img_article_2+'" width="50"  alt=""/></a>';
		widget_content += '	<a class="excerpt floatLeft" href="http://www.jamespot.com/'+url_article_2+'" target="_blank">'+title_article_2+'</a>';
		widget_content += '	<a class="details floatLeft" href="http://www.jamespot.com/'+url_article_2+'" target="_blank">Spot\'Date: '+ date_article_2+'</a>';
		widget_content += '</div>';
		widget_content += '<div class="spacer"></div>';
						widget_content += '<div class="article">';
		widget_content += '	<a class="image"href="http://www.jamespot.com/'+url_article_3+'" target="_blank"><img class="floatLeft"src="http://www.jamespot.com/userdata/spot/thumb/'+img_article_3+'" width="50"  alt=""/></a>';
		widget_content += '	<a class="excerpt floatLeft" href="http://www.jamespot.com/'+url_article_3+'" target="_blank">'+title_article_3+'</a>';
		widget_content += '	<a class="details floatLeft" href="http://www.jamespot.com/'+url_article_3+'" target="_blank">Spot\'Date: '+ date_article_3+'</a>';
		widget_content += '</div>';
		widget_content += '<div class="spacer"></div>';
			widget_content += '</div>';
	widget_content += '<span id="more" class="floatLeft" >See all articles</span>';
	widget_content += '<div class="spacer"></div>';
	
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;
    });
});
}
