var globalids = new Array();
jQuery(document).ready( function($) {
	var vidindex = 0;


//STREAM ROTATOR ON HOME PAGE NEXT TO SPEAKERS//
	var imagewidth = 260;
	var images = $('#stream_images li').length;
	iwidth = imagewidth * images;
	$('#stream_images').css({'overflow':'hidden','position':'relative'});
	$('#stream_images ul').css({'width':iwidth,'position':'relative','left':-imagewidth});
	$('#stream_images li:first').before($('#stream_images li:last'));
	
	var textwidth = 220;
	var texts = $('#stream_title li').length;
	twidth = textwidth * texts;
	$('#stream_title').css({'overflow':'hidden','position':'relative'});
	$('#stream_title ul').css({'width':twidth,'position':'relative','left':-textwidth,'top':'0px'});
	$('#stream_title li').css({'float':'left','padding':'0px','width':'220px'});
	$('#stream_title li:first').before($('#stream_title li:last'));
	
	intervalspace = 3000
	interval = setInterval(function(){stream_move(-1)},intervalspace);
	
	
	function stream_move(d){
		clearInterval(interval)
		var inewleft = parseInt($('#stream_images ul').css('left')) + (d * imagewidth);

		$('#stream_images ul').animate({'left':inewleft},200, function(){
			if (d == -1){
				$('#stream_images li:last').after($('#stream_images li:first'));
			}else{
				$('#stream_images li:first').before($('#stream_images li:last'));
			}
			$('#stream_images ul').css({'left':-imagewidth});
		});

		var tnewleft = parseInt($('#stream_title ul').css('left')) + (d * textwidth);
		
		$('#stream_title ul').animate({'left':tnewleft},200, function(){
			if(d == -1){
				$('#stream_title li:last').after($('#stream_title li:first'));
			}else{
				$('#stream_title li:first').before($('#stream_title li:last'));
			}
			$('#stream_title ul').css({'left':-textwidth});
		});	
		interval = setInterval(function(){stream_move(-1)},intervalspace);
		return false;
		
	}
	
	$('#stream_control #left').click(function(){
		stream_move(-1);
	});
	
	$('#stream_control #right').click(function(){
		stream_move(1);
	});	
	
/*	
//HOME PAGE CONTENT ROTATOR	
	
	$('#el-buttons div').click(function(){
		var oldindex = $('#el-buttons .selected').index();
		$('#el-buttons .selected').removeClass('selected');
		var index = $(this).index();
		$('#el .el-top-depth').eq(oldindex).css({'display':'none'});
		$('#el .el-top-depth').eq(index).fadeIn(200);
		
		$(this).addClass('selected');
		
	});
*/	
	$.videoPopup({
		zIndex:500,
		jwplayer:true
	});

	if($().countdownToEvent) {
		$('#countdownToEvent').countdownToEvent({
			year:2012,
			month:5,
			day:23,
			hour:23,
			refresh:false,
			text:new Array('Days Left')
		});
	}

	if($().cycle){
		$('#testimonials').cycle({ 
			fx:    'fade', 
			timeout: 5000 
		});
	}
	
	if($().jCarouselLite && $(".exhibitor-list ul li").length >= 10){
		$(".exhibitor-list").jCarouselLite({
			vertical: true,
			visible: 10,
			auto:500,
			speed:1000
		});
	}
	
	if($().getTweetsList) {
		$('#twitter').getTweetsList({
			url:basepath+'/js/getTweetsList/php/getTweet.php',
			count:7,
			screenName:'LTEWorldSeries',
			refresh:8,
            display:3,
			single:false,
			duration:8000,
			RT:true,
			showAvatar:true,
			showRTAvatar:true,
			OAuth:true
		});
	}
	
	if($().newsTicker) {
		$('#latest_news_ticker').newsTicker();
	}
	
	$.jGFeed('http://lteconference.wordpress.com/feed/',
		function(feeds){
			// Check for errors
			if(!feeds){
			// there was an error
			return false;
			}
			// do whatever you want with feeds here
				for(var i=0; i<feeds.entries.length; i++){
				var entry = feeds.entries[i];
				var content = entry.content;
				//var content = entry.contentSnippet;

				var contentTruncate = content.substring(0,250);

				// Entry title

				$(".blog-entry").html($(".blog-entry").html()+"<p><span> <a target='_blank' href=\""+entry.link+"\">"+entry.title+"</a> </span></p><p>"+contentTruncate+" <a target='_blank' href=\""+entry.link+"\">...more</a></p>");
				}
			}, 1);
			
	if ("#companies-by-product"){
		$("#companies-by-product p").each(function(i){
			$(this).fadeOut(100);
		});
	}		
	

});

function update_form(companyids,productid){
	
	$("#companies-by-product p").each(function(i){
		$(this).fadeOut();
	});
	globalids[productid] = companyids;
	var results = []; 
	$(':checkbox:checked').each(function(i){
		results[i] = $(this).attr('id');
	});
	for (var i = 0; i < results.length; i++){
		var x = results[i];
		var temp = globalids[x];
		for (var j = 0; j < temp.length;j++){
			$('#'+globalids[x][j]).fadeIn(100);
		}
	}	
}


