jQuery(document).ready( function($) {
	
	/////////////////////////////////////////
	// VIDEO CONTENT (videobox.php) //
	/////////////////////////////////////////
	var videoscreen = $('#video_screen');
	var videowidth = 478;
	var videoheight = 232;
	var autoplay = false;
	
	changeVideo('http://media.telecoms.com/cdn/cableCongress/cable_congress_2011_promo.mov','http://media.telecoms.com/cdn/cableCongress/cable_congress_2011_promo.jpg');
	
	if($.fn.imageListViewer) {
		$('#video_navi').imageListViewer({
			//controller:{right:basepath+'/js/rightctl.png',left:basepath+'/js/leftctl.png'},
			controller:{height:15,color:'#F90ED4'},
			controllerIE6:{right:basepath+'/js/rightctl.gif',left:basepath+'/js/leftctl.gif'},
			easing:'easeOutBack',
			alpha:0.2,
			listClick:function(index) {
				var videosrc = $('#video_navi .navi_icons').find('li').eq(index).attr('videosrc');
				var videoimg = $('#video_navi .navi_icons').find('li').eq(index).attr('videoimg');
				changeVideo(videosrc, videoimg);
			}
		});
	}
	
	function changeVideo(videosrc, videoimg) {
		videoscreen.empty();
		if((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {	
			var videoTag = $('<video></video>').prop({'src':videosrc,'controls':'controls','width':videowidth,'height':videoheight,'autoplay':autoplay});
			if(videoimg != null) videoTag.prop('poster',videoimg);	
		}else{
			var flashvarsObj = {url:videosrc, autoplay:autoplay};
			if(videoimg != null) flashvarsObj.image = videoimg; 
			var videoObj = {
				id:'vplayer',
				swf:'http://media.telecoms.com/video_page/vPlayer2.swf?r='+Math.random(),
				width:videowidth,
				height:videoheight,
				allowScriptAccess:'always',
				allowFullScreen:true,
				quality:'high',
				wmode:'transparent',
				scale:'noscale',
				salign:'tl',
				expressInstaller:'http://media.telecoms.com/jqueryplugins/expressInstall.swf',
				flashvars:flashvarsObj
			}
			if(!window.XMLHttpRequest) videoObj.scale = 'default';
			var videoTag = videoscreen.flash(videoObj);
		}
		videoscreen.append(videoTag);
		videoTag = null, videoObj = null;
		return false;
	}
	
	//MAIN SLIDE BANNER
	if($.fn.fadeBanners) {
		var map1 = '<area shape="rect" coords="715,20,960,71" href="'+baseurl+'/register/" alt="Go to Register page"/><area shape="rect" coords="715,87,960,140" href="'+baseurl+'/press-registration/" alt="Go to Contact Us page"/><area shape="rect" coords="715,156,960,208" href="'+baseurl+'/agenda_policy_session" alt="Go to Policy Session"/>';
		$('#main_slide_banner').fadeBanners({
			duration:8000,
			duration2:500,
			loading:true,
			buttonStyle:false,
			maps:new Array(map1,map1,map1,map1,map1,map1,map1)
		});
	}
	
	//TWITTER
	if($.fn.getTweetsList) {
		$('#twitter_box').getTweetsList({
			url:basepath+'/js/getTweetsList/php/getTweet.php',
			refresh:5,
			count:5,
			display:2,
			screenName:'CableCongress',
			single:false,
			showAvatar:true,
			RT:true,
			showRTAvatar:true,
			OAuth:true
		});
	}
	
	//NEWS TICKER
	if($.fn.newsTicker) {
		$('#news-scroll').newsTicker({
			margin:100,
			speed:1,
			fps:50
		});
	}
	
});
