$(document).ready(function(){

	/*===========================
	*
	* Pluginname: jquery easyslider1.5
	* Date Created: 28/08/2009
	* Last Update: 28/08/2009
	*	Source: http://cssglobe.com/lab/easyslider1.5/05.html
	* Description: slider
	*
	*===========================*/

	$("#slider").easySlider({
		controlsBefore:	'<p id="controls">',
		controlsAfter:	'</p>',
		auto: true,
		speed: 1000,
		pause: 4000,
		continuous: true
	});

	/*===========================
	*
	* Pluginname: jquery.prettyPhoto.js
	* Date Created: 07/09/2009
	* Last Update: 07/09/2009
	*	Source: http://www.visionmasterdesigns.com
	* Description: lightbox
	*
	*===========================*/

	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'light_rounded',
		allowresize: false
	})

  $('#countries').hover( function() {
    $('ul.switch-language', this).slideDown(100);
  }, function() {
    $('ul.switch-language', this).slideUp(100);
  });

	 // initialize scrollable
	$("div.scrollable").scrollable({
		vertical: true,
		size: 3

		// use mousewheel plugin
	}).mousewheel();

	// get iframe src once
	$('.open-new-clip').click(function() {
		hash = $(this).attr('rel');
		if (hash != '') {
			iframe = $('.s5iframe iframe');

			// get current token
			src = iframe.attr('src');

//			var tokenStart = src.indexOf('token=') + 6;
//			var tokenEnd = src.substr(tokenStart, src.length).indexOf('.-1');
//
//			var currentToken = src.substr(tokenStart, tokenEnd);
//
//			// replace current token
//			src = src.replace(currentToken, hash);
			if ((position = src.indexOf('&deeplink=')) != -1) {
				src = src.substr(0, position)+'&deeplink='+hash;
			} else {
				src = src+'&deeplink='+hash;
			}

			$('.s5iframe iframe').attr('src', src);
		}
	});
});
