// ----- search -----
  
$().ready(function() {
  
  if ($('#query').val() == '') blurSearch();
  $('#query').bind('focus', focusSearch);
  $('#query').bind('blur', blurSearch);
  
})

function focusSearch() {
  if ($('#query').val() == 'Search...') {
    $('#query').val('');
    $('#query').removeClass('blur').addClass('focus');
  }
}

function blurSearch() {
  if ($('#query').val() == '') {
    $('#query').val('Search...');
    $('#query').removeClass('focus').addClass('blur');
  }
}


// ----- tooltip -----

$().ready(function() {

  $('#tools img[title]').tooltip({ effect: 'slide', offset: [10, 2] });

});


// ----- zoom -----
	
$().ready(function() {
	
	$("a[rel=gallery]").fancybox({
		'imageScale': true,
		'padding': 10,
		'zoomOpacity': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'zoomSpeedChange': 300,
		'overlayShow': true,
		'overlayColor': "#666666",
		'overlayOpacity': 0.3,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnOverlayClick': true,
		'hideOnContentClick': false,
		'callbackOnStart': null,
		'callbackOnShow': null,
		'callbackOnClose': null,
		'centerOnScroll': true,
		'titlePosition': 'inside',
	  'transitionIn'	:	'elastic',
	  'transitionOut'	:	'elastic'
	});
	
	$("a.fancy").fancybox({
		'imageScale': true,
		'padding': 10,
		'zoomOpacity': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'zoomSpeedChange': 300,
		'overlayShow': true,
		'overlayColor': "#666666",
		'overlayOpacity': 0.3,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnOverlayClick': true,
		'hideOnContentClick': false,
		'callbackOnStart': null,
		'callbackOnShow': null,
		'callbackOnClose': null,
		'centerOnScroll': true,
		'titlePosition': 'inside',
	  'transitionIn'	:	'elastic',
	  'transitionOut'	:	'elastic'
	});

});


// ----- Rotate headers -----

/*
$().ready(function() {

  if ($('#adnav').length) {
    $('#adnav').tabs('#adpanes div', { effect: 'fade', initialIndex: null, rotate: true }).slideshow({ interval: 5000, clickable: false });
    $('#adnav').data('slideshow').play();
  }

});
*/


// ----- rotate fdsoi -----

$().ready(function() {

  /*
  if ($('#fdnav').length) {
    $('#fdnav').tabs('#fdpanes a', {
      effect: 'fade',
      initialIndex: null,
      rotate: true
    }).slideshow({
      interval: 4000,
      clickable: false
    });
    
    $('#fdnav').data('slideshow').play();
  }
  */
  
  $('#fdpanes').nivoSlider({
    effect: 'slideInRight',
    controlNav: false,
    directionNav: false,
    pauseTime: 6000,
    animSpeed: 500,
    pauseOnHover: false,
    randomStart: true
  });

});


// ----- accordion -----

$('#accordion').ready(function() {

  $('#accordion').tabs('#accordion div.pane', {tabs: 'h3', initialIndex: 0 });

});


// ----- home teaser -----

$().ready(function() {
	$('#teaser').flash({
		swf: '/flash/player.swf',
		width: 350,
		height: 196,
		hasVersion: '9.0.16.60',
		expressInstaller: '/flash/expressinstall.swf',
		allowFullScreen: true,
		flashvars: {
			flv: '/about-soi/design-clinic/videos/0-event-teaser.flv',
    	autoplay: 0,
    	showiconplay: 1,
    	autoload: 1,
    	width: 350,
    	height: 196,
    	showfullscreen: 1,
    	ondoubleclick: 'fullscreen',
    	showtime: 1,
    	showvolume: 1,
    	volume: 100,
    	margin: 0,
    	videobgcolor: 'ffffff',
    	playercolor: '333333',
    	buttonovercolor: '5aa147',
    	sliderovercolor: '5aa147'
		}
	});
});
	
function changeVideo(video) {
	$('#videoPlayer').flash({
		swf: '/flash/player.swf',
		width: 400,
		height: 224,
		hasVersion: '9.0.16.60',
		expressInstaller: '/flash/expressinstall.swf',
		allowFullScreen: true,
		flashvars: {
			flv: '/about-soi/design-clinic/videos/' + video,
    	autoplay: 1,
    	autoload: 1,
    	width: 400,
    	height: 224,
    	showfullscreen: 1,
    	ondoubleclick: 'fullscreen',
    	showloading: 'always',
    	showtime: 1,
    	showvolume: 1,
    	volume: 100,
    	margin: 0,
    	videobgcolor: 'ffffff',
    	playercolor: '333333',
    	buttonovercolor: '5aa147',
    	sliderovercolor: '5aa147'
		}
	});
};

$('#videoPlayer').ready(function() {
	//changeVideo('');
});


// ----- home design clinic + ecosystem -----

$().ready(function() {

  if ($('#desnav').length) {
    $('#desnav').tabs('#despanes div', { effect: 'default', initialIndex: 0 });
  }

  if ($('#econav').length) {
    $('#econav').tabs('#ecopanes div', { effect: 'fade', initialIndex: null, rotate: true }).slideshow();
    $('#econav').data('slideshow').play();
  }

});


// ----- mini ecosystem -----

$().ready(function() {

  if ($('#minieconav').length) {
    $('#minieconav').tabs('#miniecopanes div', { effect: 'fade', initialIndex: null, rotate: true }).slideshow({ clickable: false });
    $('#minieconav').data('slideshow').play();
  }

});


// ----- applications -----

$('#type').ready(function() {
	$('#type').bind('change', function() {
		$('#keyword').load('/about-soi/update-keywords.php?type=' + $('#type').val());
  });
})

$('#type2').ready(function() {
	$('#type2').bind('change', function() {
		$('#keyword2').load('/about-soi/update-keywords.php?type=' + $('#type2').val());
  });
})

