// JavaScript Document


$(function() {

		$.getJSON("/js/json/31CSN_flickr.txt", function(json) {
	        jJSON["media"] = (function() {
	            response = {
	                values: [],
	                count: 0
	            };
	            $.each(json.items,function(i,item) {
	                if (item.media.m != "undefined") {
	                    response.count++;
	                    response.values[i] = item.media.m;
	                }
	            });
	            return response;
	        })();
	 
	        jJSON["title"] = (function() {
	            response = {
                values: [],
	                count: 0
            };
	            $.each(json.items,function(i,item) {
	                if (item.title != "undefined") {
	                    response.count++;
	                    response.values[i] = item.title;
	                }
	            });
	            return response;
	        })();
	 
        /* Return a number of values for a given object */
	 
			for(var k=0;k<jJSON.getCount('media');k++)
			{
					var urlImg=jJSON.getValues('media',null)[k];
					var url=urlImg.split('/');
					var nameIMG=url[url.length-1];
					var finalImg=nameIMG.split('_m.jpg');
					var finalImg2=finalImg[0]+'_s.jpg';
					var finalImg3=finalImg[0]+'_m.jpg';
					var finalImg4=finalImg[0]+'_m.jpg';
					
					
					$(".imgContent").append("<img src='"+urlImg.split(nameIMG)[0]+finalImg4+"'   height='203'   style='position:absolute;left:58px;top:10px;'/>");
///		            
					
//					if(k==0)

				
					//console.log(urlImg.split(nameIMG)[0]+finalImg2);
				$("#contentLisGallery").append("<li class='img2'><a href='javascript:;' onclick='changeImg("+k+");' ><img src='"+urlImg.split(nameIMG)[0]+finalImg2+"'    class='borderImg' width='75' height='75'/></a></li>")
	}
	
				$(".imgContent img").hide();
				$(".imgContent img").eq(0).show();

	
	
	
		$("#containerPictures").jCarouselLite({
			btnNext: ".btnNext",
			btnPrev: ".btnprevious",
			scroll: 1,
			visible:4
		});	 
	        
	 
	    });
	});
	
	
	function changeImg(obj)
	{
	//console.log($(obj));
	/*	var url=$(obj).children("img").get(0).src.split('/');
		var nameIMG =url[url.length-1];
		var finalImg=nameIMG.split('_s.jpg');
		finalImg=finalImg[0]+'_m.jpg';*/
		//alert($(obj).children("img").get(0).src.split(nameIMG)[0] + finalImg);
		//$("#imgContentDinamic").attr('src',$(obj).children("img").get(0).src.split(nameIMG)[0] + finalImg).hide().show();
		
		$(".imgContent img").hide();
		$(".imgContent img").eq(obj).show();

	}	
	
	
var jJSON = {
    getValues: function(obj,num) {
        return jJSON[obj]["values"].slice(0,((num == null) ? jJSON[obj]["values"].length : num));
    },
    getCount: function(obj) {
        return jJSON[obj]["count"];
    },
    getRandomValues: function(obj,num) {
        var a = [];
        var b = jJSON[obj]["values"];
        var c = b.length;
        if (num != null && num < c) {
            c = num;
        }
        for (i = 0; i < c; i++) {
            var e = Math.floor(Math.random() * b.length);
            a[i] = b[e];
            b.splice(e,1);
        }
        return a;
    }
};



$(function() {
var followers_count=0;
var kop=0;
		$.getJSON("31CSN_Twitter.aspx", function(json) {
	        jJSON["description"] = (function() {
	            response = {
	                values: [],
	                count: 0
	            };

//				alert(json);
	//(json.user.followers_count);
	            $.each(json,function(i,item) {
					if(kop==0)
					{
						$("#numberFollowers").append(item.user.followers_count);
						kop=100;
					}
				
				
	                if (item.text != "undefined") {
	                    response.count++;
	                    response.values[i] = item.text;
	                }
	            });
	            return response;
	        })();
	 
	        jJSON["created_atT"] = (function() {
	            response = {
                values: [],
	                count: 0
            };
			
	            $.each(json,function(i,item) {
	                if (item.created_at != "undefined") {
	                    response.count++;
	                    response.values[i] = item.created_at;
	                }
	            });
	            return response;
	        })();
			
			
	 		
			
			
			
			for(var i=0;i<3;i++)
			{
				$("#contentTipsT").append("<div class='tipsFollowers'><span class='textTipWhite' id='description1'>"+jJSON.getValues('description',null)[i]+ "</span><br /><span class='textBrom'>"+jJSON.getValues('created_atT',null)[i]+"</span></div>");
			}

	    });
	});

//    $(document).ready(function() {
//
//		$("#containerPictures #contentLisGallery li a")
//      });
