
//function ab_debug(str){
//	var debug_elm = $('debug');
//	
//	if(debug_elm)
//		debug_elm.update(debug_elm.innerHTML + '\n > ' + str);
//	
//}


/* ------------------------------------------------------------------
*	focus login form on page load
*/

//$("fe-login-username").focus();



/* ------------------------------------------------------------------
*	phones slider
*/


slider_arr = new Array();
slider_arr[0] = 'navigation';
slider_arr[1] = 'localsearch';
slider_arr[2] = 'skobblercloud';

var active_slide_item = 0,
	switching = false;

function initSlider(){

	if($('phones_nav_navigation') == null){
		return;
	}
			
	$('phones_nav_navigation').observe('click', function(e){
		Event.stop(e);
		switchElm(this, 0);
	});
	$('phones_nav_localsearch').observe('click', function(e){	
		Event.stop(e);
		switchElm(this, 1);
	});
	$('phones_nav_skobblercloud').observe('click', function(e){
		Event.stop(e);
		switchElm(this, 2);
	});
	
	
	$$('.phones .slider_box .slider .slider_item').each(function(slider_elm, i_int){	
		
		slider_elm.setStyle({
			left: (i_int == 0 ? 0:-1000) + 'px',
			top: (-1 * i_int * 270) + 'px',
			display: 'block'
		});		
			
	});	
	
	
	$$('.phones .slider_box .image div').each(function(slider_elm, i_int){	
		
		if(i_int != 0){
						
			new Effect.Opacity(slider_elm, { to:0, duration:0 });
			
			slider_elm.setStyle({
				top: (-1 * i_int * 330) + 'px',
				display: 'block'
			});
		}
			
	});		
		
	
	function switchElm(elm_obj, switch_to_int){	
		
		var step_int = 1000;
		
		if(switch_to_int == active_slide_item ||
			switching == true)
			return false;
			
		switching = true;
		
		var switch_up = active_slide_item  < switch_to_int? 1:-1;	
		
		if(switch_up > 0){
			var next_move = -500,
				next_new_pos = 500;	
		}else{
			var next_move = 500,
				next_new_pos = -500;	
		}	
		
		var next_elm,
			active_elm;
			
		var img_elm_arr = $$('.phones .slider_box .image div');
		
	
		$$('.phones .slider_box .slider .slider_item').each(function(slider_elm, i_int){
						
			if(i_int == switch_to_int){
				slider_elm.setStyle({
					left: next_new_pos + 'px'
				});			
				next_elm = slider_elm;
				
				new Effect.Opacity(img_elm_arr[i_int], {duration:0.8, from:0, to:1});

				
			}else if(i_int == active_slide_item){
				
				active_elm = slider_elm;
				
				new Effect.Opacity(img_elm_arr[i_int], {duration:0.5, from:1, to:0});
				
				
			}else{
				
			}
		});	
	
		new Effect.Move(active_elm, {
			x: next_move, y: 0, mode: 'relative',
			transition: Effect.Transitions.sinoidal,
			queue: { position: 'end', scope: 'sliderScope'},
			duration: 0.5
		});	
		
		
	
		new Effect.Move(next_elm, {
			x: next_move, y: 0, mode: 'relative',
			transition: Effect.Transitions.sinoidal,
			queue: { position: 'end', scope: 'sliderScope'},
			duration: 0.5
		});		
		
		
		var phones_image_elm = $('phones_image')
		
		phones_image_elm.removeClassName(slider_arr[active_slide_item]);	
		phones_image_elm.addClassName(slider_arr[switch_to_int]);	
	
		$('phones_nav_' + slider_arr[active_slide_item]).removeClassName('active');	
		elm_obj.addClassName('active');
		
		active_slide_item = switch_to_int;	
		
		switching = false;
	}
	
	
}

initSlider();


/* ------------------------------------------------------------------
*	slide show
*/

 oMySlides = new iSlideShow({
	slides : [
		'image-2',	// pedestrian
//		'image-3',	// navigation landscape
//		'image-4',	// ls2.0
//		'image-5',	// ls2.0 search result
		'image-6',	// ls2.0 search results map
//		'image-7',	// dest msg 1-3
//		'image-8',	// dest msg 2-3
//		'image-9',	// dest msg 3-3
		'image-10'	// twitter
	],	
	caption : 'slide-caption'
});

/* ------------------------------------------------------------------
*	video section
*/

var active_video_section = null;
function initVideoSection()
{
	if($('videoinfo') == null || $('textinfo') == null) return;
	$('videoinfo').observe('click', function(e){
		Event.stop(e);
		if(active_video_section != 'video'){
			active_video_section = 'video';
			this.addClassName('active');
			$('textinfo').removeClassName('active');
			$('video-container').setStyle({display:'block'});
			$('text-container').setStyle({display:'none'});
		}
	});
	$('textinfo').observe('click', function(e){	
		Event.stop(e);
		if(active_video_section != 'text'){
			active_video_section = 'text';
			this.addClassName('active');
			$('videoinfo').removeClassName('active');
			$('video-container').setStyle({display:'none'});
			$('text-container').setStyle({display:'block'});
		}
	});
	
}

initVideoSection();