$(document).ready(function(){

// 1. google buzz
getGoogleBuzz('etel.good', 8, $('#buzzwidget')); //change username here

function getGoogleBuzz(username,n, div){
   // params for Google Feed API proxy : Buzz Feed URL, Number of Entries 
   var data = {q:'http://buzz.googleapis.com/feeds/'+username+'/public/posted' 
            ,num:n
            ,output:'json'
            ,v:'1.0'};
   // call Google Feed API
   $.ajax({
      url:'http://ajax.googleapis.com/ajax/services/feed/load'
      ,data:data
      ,dataType:'jsonp'
      ,success:function(json){
         // json from Google Feed API was returned successfully..

         // error with Google Buzz feed ?
         if(json.responseStatus!=200) {
            div.html('<b style="color:red">'+ json.responseDetails +'</b>');
            return; 
         };
         // Buzz entries array
         var entries= json.responseData.feed.entries;
         var length= entries.length;
         // no entries!
         if(length==0) return; 

         // start output by appendding a hidden unordered list
         var ul = $('<ul class="gb" style="display:none"></ul>').appendTo(div.html(''));

         // loop buzz entries
         for(var i=0; i<length; i++){
            // parse published-date string
            var pDate = new Date(entries[i].publishedDate);
            // using entry snippet version
            var snippet = entries[i].contentSnippet;
            // convert links that start with http to hyperlinks using regular expression
            snippet = snippet.replace(/\b(https?\:\/\/\S+)/gi,' <a href="$1">$1</a>');
            // append buzz to UL
            ul.append('<li>'
               +'<span class="gb-content">'+ snippet +'</span>'
               +'<span class="gb-meta">'
                  + '<a href="'+ entries[i].link +'">'+ pDate.toLocaleString() +'</a>'
               +'</span>'
            +'</li>');
         };

         // now show-in the unordered list
         ul.show('slow');
      }
   });
}

// 2. script fancybox start: this is a modified version, mainly for YouTube Videos presentation inside eclub video.
							   

			$("#video1").click(function() {
			$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 360,
			'overlayOpacity': .7,
			'overlayColor'	: 000,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

			return false;
		});
			

			$("#video2").click(function() {
			$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 360,
			'overlayOpacity': .7,
			'overlayColor'	: 000,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

			return false;
		});
			
			$("#video3").click(function() {
			$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 360,
			'overlayOpacity': .7,
			'overlayColor'	: 000,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

			return false;
		});
			
			$("#video4").click(function() {
			$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 360,
			'overlayOpacity': .7,
			'overlayColor'	: 000,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

			return false;
		});
			
			$("#video5").click(function() {
			$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 360,
			'overlayOpacity': .7,
			'overlayColor'	: 000,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

			return false;
		});

// 10. animate chinese ribbon on hover
  $('#chineselink a img').hover(function(){
    $(this).animate({paddingTop: '+=70px'}, 200);
  }, function(){
    $(this).animate({paddingTop: '-=70px'}, 500);
  });

// 3. animate puppy logo bottom on hover
  $('#logobottom img').hover(function(){
    $(this).animate({paddingLeft: '+=160px'}, 800);
  }, function(){
    $(this).animate({paddingLeft: '-=160px'}, 800);
  });

// 4. animate icon on top navigation
  $('#homeBtn').hover(function(){
    $('#homeIcon .jump')
            // first jump  
            .animate({top:"-10px"}, 200).animate({top:"0px"}, 100)
            // second jump
            .animate({top:"-6px"}, 100).animate({top:"0px"}, 80)
            // final jump
            .animate({top:"-3px"}, 80).animate({top:"0px"}, 30);
	}, function(){			
    });


// 5. give highlight for every div with class high
	$('div.high').hover(function() {
	$(this).addClass('highme');
	}, function() {
	$(this).removeClass('highme');
	});	

// 6. give highlight for every tr with class high
	$('tr.high').hover(function() {
	$(this).addClass('highmeB');
	}, function() {
	$(this).removeClass('highmeB');
	});	

  $('#productBtn').hover(function(){
    $('#productIcon .jump')
            // first jump  
            .animate({top:"-10px"}, 200).animate({top:"0px"}, 100)
            // second jump
            .animate({top:"-6px"}, 100).animate({top:"0px"}, 80)
            // final jump
            .animate({top:"-3px"}, 80).animate({top:"0px"}, 30);
	}, function(){			
    });

  $('#supportBtn').hover(function(){
    $('#supportIcon .jump')
            // first jump  
            .animate({top:"-10px"}, 200).animate({top:"0px"}, 100)
            // second jump
            .animate({top:"-6px"}, 100).animate({top:"0px"}, 80)
            // final jump
            .animate({top:"-3px"}, 80).animate({top:"0px"}, 30);
	}, function(){			
    });

  $('#accountBtn').hover(function(){
    $('#accountIcon .jump')
            // first jump  
            .animate({top:"-10px"}, 200).animate({top:"0px"}, 100)
            // second jump
            .animate({top:"-6px"}, 100).animate({top:"0px"}, 80)
            // final jump
            .animate({top:"-3px"}, 80).animate({top:"0px"}, 30);
	}, function(){			
    });

  $('#eClubBtn').hover(function(){
    $('#eClubIcon .jump')
            // first jump  
            .animate({top:"-10px"}, 200).animate({top:"0px"}, 100)
            // second jump
            .animate({top:"-6px"}, 100).animate({top:"0px"}, 80)
            // final jump
            .animate({top:"-3px"}, 80).animate({top:"0px"}, 30);
	}, function(){			
    });

// 9. fancebox eclub gallery
$("a.grouped_elements").fancybox();	

// 10. cookie and popup

//Attach fancy box to language function
$('a#inline').fancybox({
	'hideOnContentClick': true
});

if ($.cookie('language') == null){ //check to see if a cookie with name of "language" exists
// popup language option automatically on load
  $("#inline").trigger('click');
}

$('#lang_en').click(function(){
	/*$.cookie("language", "english");*//*expires when logout browser*/
	$.cookie("language", "english", { expires: 30 });
});

// 11. logo animation spinner
// $('#spinlogo').sprite({fps: 20, no_of_frames: 47});


}); // end of script main

