

var index = {
	firstLoad: true,
	buildSlider: function(){
		stepcarousel.setup({
			galleryid: 'kidsQuoting',
			beltclass: 'belt',
			panelclass: 'panel',
			panelbehavior: {speed:700, wraparound:false, persist:false},
			defaultbuttons: {enable: true, moveby: 1, leftnav: ['', -12, 43], rightnav: ['', 9, 43]},
			statusvars: ['startPanel', 'currentPanel', 'totalPanels'], 
			contenttype: ['ajax','asp_global/quotes.asp?action=getQuotes'],
			onslide:function(){
				if (!index.firstLoad){
					$('.sliderLink').show();
					$('.kidSelected').attr('src','img/kidsmenu/' + $('.kidSelected').attr('id') + '.jpg');
					var tmpPanel = parseInt(currentPanel) - 1;
					var kidName = $('div.panel:eq('+tmpPanel+')').attr('kid');
					$('#' + kidName).attr('src','img/kidsmenu/' + kidName + '_sel.jpg');
					$('.kidSelected').removeClass('kidSelected');
					$('#' + kidName).addClass('kidSelected');
				} else {
					index.firstLoad = false;	
				};
			},
			oninit: function(){
				var kidName = $('div.panel:first').attr('kid');
				$('#' + kidName).attr('src','img/kidsmenu/' + kidName + '_sel.jpg');
				$('#' + kidName).addClass('kidSelected');
			}
		});	
	},
	
	videoSettings: {
		clip: {  
			url: 'autismcode/Hauser-200.flv',  
			baseUrl: 'http://e1.simplecdn.net/',
			/*provider: 'simplecdn',  */
			autoPlay: true,
			accelerated: true,
			width: 432,
			height: 243,
			onFinish: function() {
				$f("videoflv").unload();
				//$('#videoflv').attr({'href':$('#video table td a.selected').attr("href")});
				index.videoSettings.clip.url = $('#video table td a.selected').attr("href");
				VSLT($('#video table td a.selected').attr('id') + '_END');
			},
			onStart: function() { 
				VSLT($('#video table td a.selected').attr('id') + '_START'); 
			}  
		}, 
		canvas: {
			backgroundColor: '#000000'	
		},
		// streaming plugins are configured under the plugins node  
		plugins: { 
			/*simplecdn: {  
				url: 'js/flowplayer.rtmp-3.1.2.swf',  
				netConnectionUrl: 'rtmpt://e1f1.simplecdn.net/play'  
			},*/
			controls: {
				autoHide: 'always',
				hideDelay: 2000,
				progressGradient: 'medium',
				buttonColor: '#e66700',
				sliderColor: '#555555',
				sliderGradient: 'none',
				volumeSliderGradient: 'none',
				buttonOverColor: '#fa8900',
				backgroundGradient: 'none',
				timeBgColor: '#555555',
				bufferGradient: 'none',
				progressColor: '#d07301',
				tooltipTextColor: '#ffffff',
				tooltipColor: '#e66700',
				timeColor: '#ffffff',
				backgroundColor: '#000000',
				volumeSliderColor: '#555555',
				durationColor: '#ff890f',
				bufferColor: '#b6b6b6',
				borderRadius: '5',
				height: 32,
				opacity: 1,
				tooltips: { 
					buttons: true, 
					play: 'נגן', 
					pause: 'עצור', 
					mute: 'השתקת קול',
					unmute: 'החזרת קול',
					fullscreen: 'מסך מלא',
					fullscreenExit: 'יציאה ממסך מלא'
				}
			}
		},
		play: {
			replayLabel: 'נגן שוב'
		},
		onLoad: function(){
			this.setVolume(100); 
		}
	},
	
	loadVideo: function(){
		$f('videoflv',"js/flowplayer-3.1.3.swf", index.videoSettings);
		//$f('videoflv',"js/flowplayer-3.1.3.swf", index.videoSettings).playlist("table.flvlist", {loop:false, manual:true});
		
		$("#video table td a:not(.selected)").live("click", function() {
			$f().play($(this).attr("href"), false);
			$('#video table td a.selected')
				.css({'background':'url(img/home/'+ $('#video table td a.selected').attr('id') +'.jpg) no-repeat'})
				.removeClass('selected');
			$(this).addClass('selected');
			return false;
		});
		
		$("#video table td a.selected").live("click", function() {
			return false;
		});
		
		$('#videoflv .video_start').live('mouseover',function(){
			$(this).attr({"src":"img/home/video_start_on.jpg"});
		});
		$('#videoflv .video_start').live('mouseout',function(){
			$(this).attr({"src":"img/home/video_start.jpg"});
		});
		
		$('#video table td a:not(.selected)').live('mouseover',function(){
			$(this).css('background','url(img/home/'+ $(this).attr('id') +'_sel.jpg) no-repeat');
		});
		$('#video table td a:not(.selected)').live('mouseout',function(){
			$(this).css('background','url(img/home/'+ $(this).attr('id') +'.jpg) no-repeat');
		});
		
		$('#video table td a.selected').css({'background':'url(img/home/'+ $('#video table td a.selected').attr('id') +'_sel.jpg) no-repeat'});
	},
	
	init: function(){
		$('.home').addClass('current');
		acw.buildMenu();
		$('#leftNavBtn, #rightNavBtn').hover(
			function() {
				if (!$(this).hasClass('btnDisabled')) {
					$(this).addClass('selected');
				}
			},
			function() {
				if (!$(this).hasClass('btnDisabled')) {
					$(this).removeClass('selected');
				}
			}
		);
		index.loadVideo();
		// ***** Event (20100215)
		
		// * Video
		var eventSettings = {
			clip: {  
				url: 'http://e1.simplecdn.net/thecode/video_event.flv',  
				autoPlay: true,
				accelerated: true,
				width: 326,
				height: 183,
				onFinish: function() {
					$f("videoevent").unload();
					//index.videoSettings.clip.url = $('#video table td a.selected').attr("href");
					VSLT('VideoEvent20100210_END');
				},
				onStart: function() {
					VSLT('VideoEvent20100210_START');
				}
			}, 
			canvas: {
				backgroundColor: '#000000'	
			},
			// streaming plugins are configured under the plugins node  
			plugins: { 
				/*simplecdn: {  
					url: 'javascript/flowplayer.rtmp-3.1.2.swf',  
					netConnectionUrl: 'rtmpt://e1f1.simplecdn.net/play'  
				},*/
				controls: {
					autoHide: 'always',
					hideDelay: 2000,
					progressGradient: 'medium',
					buttonColor: '#e66700',
					sliderColor: '#555555',
					sliderGradient: 'none',
					volumeSliderGradient: 'none',
					buttonOverColor: '#fa8900',
					backgroundGradient: 'none',
					timeBgColor: '#555555',
					bufferGradient: 'none',
					progressColor: '#d07301',
					tooltipTextColor: '#ffffff',
					tooltipColor: '#e66700',
					timeColor: '#ffffff',
					backgroundColor: '#000000',
					volumeSliderColor: '#555555',
					durationColor: '#ff890f',
					bufferColor: '#b6b6b6',
					borderRadius: '5',
					height: 25,
					opacity: 1,
					tooltips: { 
						buttons: true, 
						play: 'נגן', 
						pause: 'עצור', 
						mute: 'השתקת קול',
						unmute: 'החזרת קול',
						fullscreen: 'מסך מלא',
						fullscreenExit: 'יציאה ממסך מלא'
					}
				}
			},
			play: {
				replayLabel: ' '
			},
			onLoad: function(){
				this.setVolume(100); 
			}
		};
		
		$f('videoevent',"js/flowplayer-3.1.3.swf", eventSettings);

		$('#videoevent .video_event').live('mouseover',function(){
			$(this).attr({"src":"img/event/video_event_on.jpg"});
		});
		$('#videoevent .video_event').live('mouseout',function(){
			$(this).attr({"src":"img/event/video_event.jpg"});
		});
		
		// * Images Slide Show
		//$('#imgBox a.selected').css({'color':'#fff','background':'#ffa30b'});
		$('#imgBox a').click(function(){
			$('#imgBox a.selected').removeClass('selected');
			$(this).addClass('selected');
			var nIndex = parseInt($('#imgBox a').index(this)) + 1;
			$('#imgBox img').attr('src','img/event/bigpic'+ nIndex +'.jpg');
			return false;
		});
		
		// * Read More
		var $aLink = $('#event .eveContent #articles .article .link');
		if ($aLink.hasClass('short')){
			$aLink.css({'width':'235px'});
		};
		$('#event .eveContent #articles .article a').click(function(){
			var $pClose = $(this).parent().prev().children('p.close');
			$aLink = $(this).parent();
			if ($aLink.hasClass('short')){
				var aLinkWidth = '235px';
			} else {
				var aLinkWidth = '465px';
			};
			var $imgPad = $aLink.prev().prev('img.imgPad');
			var imgPx = $imgPad.attr('px');
			if ($pClose.css('display') == 'block'){
				$pClose.hide().next().show();
				$imgPad.css({'padding-bottom':imgPx+'px'});
				$(this).css({'background-image':'none','padding':'0 0 0 5px'}).parent().css({'width':'470px'});
				$(this).text('לסגירה');
			} else {
				$pClose.next().hide().prev().show();
				$imgPad.css({'padding-bottom':'0'});
				$(this).css({'background-image':'url(img/event/arrow_l_sm.gif)','padding-left':'10px'})
				.parent().css({'width':aLinkWidth});
				$(this).text('להמשך');
			};
			return false;
		});
		
		//*** End Event ****
		
	}
};



$(document).ready( function() {
	index.init();
});
//$(window).load(function () {
	//$.post('asp_global/quotes.asp',{action: 'getQuotes'}, function(callback){
	//	$('#kidsQuoting .belt')
	//		.empty()
	//		.append(callback);
	//});
	index.buildSlider();
//});

