videoCount = 0;
thumbid= 0;
timer=setTimeout('void(0)',10000);
videolimit = 10;    

function showFeaturedVideos(postData) {
	var videoContainer = $('#albumscontentr');
	$('video',postData).each(function(i){
		if(i<videolimit) {
			var featuredVideo = $('#featured-video-tpl').clone();
			$('img',featuredVideo).attr('src',$('thumb',this).text());
			$('img',featuredVideo).attr('rsrc',$('thumb',this).text());
			$('img',featuredVideo).attr('id',$(this).attr('id'));
			$('.thumb-container > a',featuredVideo).attr('href',$('viewurl',this).text());
			$('.fvtitle > a',featuredVideo).attr('href',$('viewurl',this).text()).html($('title',this).text()).truncate(10,{chars:'', leave:false, trail:[false, "..", ""]});
			$('.fvdescription > span',featuredVideo).html($('description',this).text()).truncate(32,{chars:'', leave:false, trail:[false, "..", ""]});
			$('.fvauthor > a',featuredVideo).attr('href',$('authorurl',this).text()).html($('author',this).text()).truncate(17,{chars:'', leave:false, trail:[false, "..", ""]});
			$('.fvduration > span',featuredVideo).html($('duration',this).text());
			$('.fvviews > span',featuredVideo).html($('views',this).text());
			videoContainer.append(featuredVideo);
		}
	});
	$('.video-thumb-anim',videoContainer).mouseover(startAnimateImage);
	$('.video-thumb-anim',videoContainer).mouseout(stopAnimateImage);
}
function startAnimateImage(eventObject) {
	clearAnimation();
	thumbid=eventObject.target.id;
    animateImage(eventObject.target);
}
function animateImage(image) {
   img = document.createElement('img');
   img.id=thumbid;
   $(img).load(function() {
        timer = setTimeout(function(){
        	if(thumbid==image.id)$(image).attr('src',$(img).attr('src'));
        	else $(image).attr('src',$(img).attr('rsrc'));
            videoCount>=9?videoCount=0:videoCount++;
        	animateImage(image);},800);
    });
    if(thumbid==image.id)$(img).attr('src',$(image).attr('rsrc')+'-'+videoCount);
}
function stopAnimateImage(eventObject) {
    clearAnimation();
    $(eventObject.target).attr('src',$(eventObject.target).attr('rsrc'));
}
function clearAnimation() {
	clearTimeout(timer);
    videoCount=0;
    thumbid=0;
    timer=setTimeout('void(0)',10000);
}



function getCountries(){
	$.ajax({type: "GET", url: "/locations/country/countries00.xml",data:'',dataType: 'xml', success: DisplayCountries, timeout:3000});
}


function DisplayCountries(postData){
	var sSelectedContry=$('#CountrySelected').attr('value');
	var root = postData.getElementsByTagName("countries")[0];
    var countries = root.getElementsByTagName("country");
    var ctySelect = document.getElementById("countries");
    for(var i = 0; i < countries.length; i++) {
    	if (sSelectedContry == countries[i].getAttribute("id")){
    		ctySelect.options[i+1] = new Option(countries[i].getAttribute("name"), countries[i].getAttribute("id"),true,true);
    	}else{
    		ctySelect.options[i+1] = new Option(countries[i].getAttribute("name"), countries[i].getAttribute("id"),false,false);
    	}
    }
	if ( typeof(sSelectedContry) == 'undefined'){
		var elSel = document.getElementById("countries");
		sSelectedContry = elSel.options[ elSel.selectedIndex ].value
	}
}

function ShowShareTab(tab){
	if(tab != 'sendMail')
	$('#sendMail').hide();
	if(tab != 'insertVideo')
	$('#insertVideo').hide();
	if(tab != 'getLink')
	$('#getLink').hide();
	$('#' + tab).toggle();
}



