/* ------------------------ cufon replace */
Cufon.replace('body:not(#zh_CN, #ru_RU) h1 a, body:not(#zh_CN, #ru_RU) div.navTop > ul > li > a, body:not(#zh_CN, #ru_RU) .jobs a', { hover:true });
Cufon.replace('body:not(#zh_CN, #ru_RU) h3:not(.not), body:not(#zh_CN, #ru_RU) h4:not(.not), body:not(#zh_CN, #ru_RU) h5:not(.not), body:not(#zh_CN, #ru_RU) h6:not(.not)');
/* ------------------------ function call */
$(function() {
	// header slider
	if ($('ul.imageSlider li').length > 1) {
		$('ul.imageSlider').cycle(header_slider);
	}
	
	// sub nav animation
	$('div.navTop > ul > li > ul').each(layer_change);
	$('div.navTop > ul > li').hover(layer_show, layer_hide);
	
	// company movie
	$('.movie').each(movie_each);
	
	// external links
	$('a.external').attr('target', '_blank');
	
	if($('a.thumbnail').length > 0) {
		$('a.thumbnail').attr('rel', 'colorbox[]');
		$('a.thumbnail').colorbox(colorbox_settings);
	}
});

/* ------------------------ functions */

/*
 * settings lightbox
 */
var colorbox_settings = {
	maxWidth: '80%',
	opacity: .8
}

/*
 * settings company flash
 */
movie_each_cnt = 0;
function movie_each() {
	var the_element = $(this);
	var movie_settings = {
		autoPlay: false, 
		loop: false, 
		autoBuffering: true, 
		initialScale: 'scale',	
		videoFile: the_element.attr('data-url'), 
		controlsOverVideo: 'ease', 
		showMenu:false, 
		showVolumeSlider:false
	}
	var movie_object = {
		src:'/javascripts/flowplayer/FlowPlayerDark.swf',
		width: the_element.attr('data-width'), 
		height: the_element.attr('data-height') 
	}
	var the_id = 'movie_' + movie_each_cnt;
	the_element.attr('id', the_id);
	flashembed(the_id, movie_object, { config: movie_settings });
	movie_each_cnt++;
}

/*
 * header slider
 */
var header_slider = {
	speed: 1000,
	timeout: 6000
}

/*
 * sub navigation before
 */
function layer_change() {
	$(this).show().attr('getheight', $(this).height()).css({
		'height': 0,
		'overflow': 'hidden',
		'opacity':'0'
	}).hide();
}

/*
 * sub navigation in
 */
function layer_show() {
	$(this).find('> ul').show().stop(false, false).animate({
		opacity: 1,
		height: $(this).find('> ul').attr('getheight')
	}, 400, function() { $(this).css('opacity', ''); });
}

/*
 * subnavigation out
 */
function layer_hide() {
	$(this).find('> ul').stop(false, false).animate({
		opacity: 0,
		height: 0
	}, 400, function() {
		 $(this).css('opacity', '').hide();
	});
}
