var played = false;
var period = null
var dots = 0;

function flashNext(){
	return Playlist.skip();
}

function sendToFriend(url, title){
	var body = 'Ho trovato questo su Tiscali Video e ho pensato ti potesse interessare.%0d%0a%0d%0a';
	body += 'Per vederlo vai a questo link:%0d%0a' + escape(url);
	var mail = 'mailto:?subject=Tiscali Video: ' + title + '&body=' + body;
    window.location.href = mail;
}

function playerFlash(host, url, title, path){
//	var autostart = '?autoplay=true';
	var autostart = '';

	var html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="objectVideo" width="642" height="448">';
	html += '<param name="allowScriptAccess" value="always" />';
	html += '<param name="allowFullScreen" value="true" />';
	html += '<param name="movie" value="/inc/TiscaliVideo.swf" />';
	html += '<param name="quality" value="high" />';
	html += '<param name="bgcolor" value="#000000" />';
	html += '<param name="FlashVars" value="vURL=http://' + host + '/asx/'+ url +'.asx' + autostart + '" />';
	html += '<embed src="/inc/TiscaliVideo.swf" width="642" height="448" quality="high" bgcolor="#000000" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="vURL=http://' + host + '/asx/'+ url +'.asx' + autostart + '" />';
	html += '</object>';

	var html2 = '<object width="642" height="448">';
	html2 += '<param name="allowScriptAccess" value="always" />';
	html2 += '<param name="allowFullScreen" value="true" />';
	html2 += '<param name="movie" value="http://' + host + '/inc/TiscaliVideo.swf" />';
	html += '<param name="bgcolor" value="#FFFFFF" />';
	html2 += '<param name="FlashVars" value="vURL=http://' + host + '/asx/'+ url +'.asx' + autostart + '" />';
	html2 += '<embed src="http://' + host + '/inc/TiscaliVideo.swf" quality="high" bgcolor="#FFFFFF" allowScriptAccess="always" type="application/x-shockwave-flash" flashvars="vURL=http://' + host + '/asx/'+ url +'.asx' + autostart + '" allowFullScreen="true" width="642" height="448" />';
	html2 += '</object>';


	$('video_container').innerHTML = html;
	if(embd = $('embed_code')){
		embd.value = html2;
		embd.onclick = focusAndSelect;
	}
	var myAjax = new Request.HTML({method: 'get'}).get('/lastview.php?id='+url);

}

function playerWMV(host, url, title, path){
	var autostart = 'true';

	var html = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="objectVideo" height="327" width="468">';
	html += '<param name="url" value="http://' + host + '/asx/'+ url +'.asx" />';
	html += '<param name="src" value="http://' + host + '/asx/'+ url +'.asx" />';
	html += '<param name="autostart" value="' + autostart + '" />';
	html += '<param name="showstatusbar" value="1" />';
	html += '<param name="showcontrols" value="true" /> ';
	html += '<!--[if !IE]>-->';
	html += '<object type="video/x-ms-wmv" data="http://' + host + '/asx/'+ url +'.asx" height="327" width="468">';
	html += '<param name="src" value="http://' + host + '/asx/'+ url +'.asx" />';
	html += '<param name="autostart" value="' + autostart + '" />';
	html += '<param name="controller" value="true" />';
	html += '<param name="enablecontextmenu" value="true" />';
	html += '<param name="showstatusbar" value="1" />';
	html += '</object>';
	html += '<!--<![endif]-->';
	html += '</object>';

	var html2 = html;

	$('video_container').innerHTML = html;
	$('embed_code').value = html2;
	$('embed_code').onclick = focusAndSelect;

	// Attacco l'evento playStateChange
	if($('objectVideo').attachEvent){
		// Netratings
		var params = new Array();
//		davInitStream(playerObj,             url,                                           cid,            streamName,    freq,    playerName,   container,                                  custom);
		davInitStream(document.objectVideo, 'http://secure-it.imrworldwide.com/cgi-bin/m', 'tiscalidav-it', title,         10,      path,         'http://' + host + '/video/' + url + '.html',  params);

		$('objectVideo').attachEvent('OpenStateChange', openPleiadi);
		$('objectVideo').attachEvent('PlayStateChange', pleiadi);
	}
}

function focusAndSelect(){
	this.focus();
	this.select();
}

function openPleiadi(state){
	davPlayerOpenStateChange(state);
}

function pleiadi(state){
	davPlayerStateChange(state);

	switch(state){
		case 3:			// Playing
			played = true;
			break;

		case 10:		// Finished
			if(played)
				Playlist.skip();
			break;
    }
}

var Labels = {
	init: function(){
		$('right').getElement('ul.labels').getElements('a').each(function(el){
			el.onclick = Labels.change;
		});
	},
	change: function(){
		var pos = 0;
		var elm = this;

		// Elimino la selezione da tutti gli elementi
		$('right').getElement('ul.labels').getElements('a').each(function(el, i){
			el.removeClass('selected');

			if(el == elm) pos = i;
		});

		// Seleziono l'elemento corrente
		elm.addClass('selected');

		// Mostro la lista relativa
		Labels.showList(pos);

		return false;
	},
	showList: function(pos){
		var lists = $('right').getElements('.box_lista');

		lists.each(function(el){
			el.setStyle('display', 'none');
		});

		if(lists[pos])
			lists[pos].setStyle('display', 'block');
	}
}

var vSwitchImg = function(i){
	var urls = new Array('inevidenza.html','mosaico.html');
	var url = urls[i];
	var vToggle =	new Fx.Tween('vSwitchCnt', {
						property: 'opacity',
						transition: Fx.Transitions.Cubic.easeInOut,
						onComplete: function(a){
							if(a.getStyle('opacity') == 0){
								var myAjax = new Request.HTML({
									method: 'get',
									onComplete: function(tree, elements, html, js) {
										$('vSwitchCnt').innerHTML = html;
										vToggle.start(1);
									}
								}).get('/immagini/cache/hp/' + url);
							}else{
								$('vBottomSwitcherImg').getElements('a').each(function(a){
									a.removeClass('selected');
								});
								$('vSwithc' + (i + 1)).getElement('a').addClass('selected');
							}
						}
					});

	vToggle.start(0);
}

var vSwitch = function(i){
	var urls = new Array('chart_c0.html','mosaico.html','editor.html');
	var url = urls[i];
	var vToggle =	new Fx.Tween('vSwitchCnt', {
						property: 'opacity',
						transition: Fx.Transitions.Cubic.easeInOut,
						onComplete: function(a){
							if(a.getStyle('opacity') == 0){
								var myAjax = new Request.HTML({
									method: 'get',
									onComplete: function(tree, elements, html, js) {
										$('vSwitchCnt').innerHTML = html;
										vToggle.start(1);
									}
								}).get('/cache/hp/' + url);
							}else{
								$('vBottomSwitcher').getElements('a').each(function(a){
									a.removeClass('selected');
								});
								$('vSwithc' + (i + 1)).getElement('a').addClass('selected');
							}
						}
					});

	vToggle.start(0);

	/*var Toggle = new Fx.Style(
		'vSwitchCnt',
		'opacity',
		{
			transition: Fx.Transitions.Cubic.easeInOut,
			onComplete: function(a){
				if(a.getStyle('opacity') == 0){
					var myAjax = new Ajax(
						'/cache/hp/' + url,
						{
							method: 'get',
							onComplete: function(){
								var result_txt = this.transport.responseText;
								$('vSwitchCnt').innerHTML = result_txt;
								Toggle.start(1);
							}
						}
					).request();
				}else{
					$('vBottomSwitcher').getElements('a').each(function(a){
						a.removeClass('selected');
					});
					$('vSwithc' + (i + 1)).getElement('a').addClass('selected');
				}
			}
		}
	);
	Toggle.start(0);*/

}

var Rating = {
	url: '/inc/rate.php',
	reset: 1,
	init: function(id_video){
		// Chiamo stelle e strisce
		var params = 'getrate=true&id_video=' + id_video;

		var myAjax = new Request({method: 'post',
						 url: Rating.url,
						 onSuccess: function(txt,xml) {

							$('rating').innerHTML = txt;
							Rating.hovera();
						 }
					}).send(params);

		/*var myAjax = new Ajax(
			Rating.url,
			{
				postBody: params,
				onComplete: function(){
					var result_txt = this.transport.responseText;
					$('rating').innerHTML = result_txt;
					Rating.hovera();
				}
			}
		).request();*/
	},
	truveoInit: function(id_video){
		// Chiamo stelle e strisce
		var params = 'getrate=true&truveo=true&id_video=' + id_video;

			var myAjax = new Request({method: 'post',
						 url: Rating.url,
						 onSuccess: function(txt,xml) {

							$('rating').innerHTML = txt;
							Rating.hovera();
						 }
					}).send(params);


		/*var myAjax = new Ajax(
			Rating.url,
			{
				postBody: params,
				onComplete: function(){
					var result_txt = this.transport.responseText;
					$('rating').innerHTML = result_txt;
					Rating.hovera();
				}
			}
		).request();*/
	},
	send: function(rate, id_video){
		var params = 'rate=' + rate + '&id_video=' + id_video;
		Rating.reset = 0;

			var myAjax = new Request({method: 'post',
						 url: Rating.url,
						 onSuccess: function(txt,xml) {

							$('rating').innerHTML = '<span>Fatto!</span>' + txt;
							var img = new Element('img', {src:'/img/vote/voto_' + Math.floor(Math.random()*10000000000) + '_' + id_video + '.gif'})
						 }
					}).send(params);



		/*var myAjax = new Ajax(
			Rating.url,
			{
				postBody: params,
				onComplete: function(){
					var result_txt = this.transport.responseText;
					if(result_txt){
						$('rating').innerHTML = '<span>Fatto!</span>' + result_txt;
						var img = new Element('img', {src:'/img/vote/voto_' + Math.floor(Math.random()*10000000000) + '_' + id_video + '.gif'})
					}
				}
			}
		).request();*/
	},
	truveoSend: function(rate, id_video){
		var params = 'rate=' + rate + '&truveo=true&id_video=' + id_video;
		Rating.reset = 0;

		var myAjax = new Request({method: 'post',
						 url: Rating.url,
						 onSuccess: function(txt,xml) {
							$('rating').innerHTML = '<span>Fatto!</span>' + txt;
							var img = new Element('img', {src:'/img/vote/voto_truveo_' + Math.floor(Math.random()*10000000000) + '_' + id_video + '.gif'});
						 }
					}).send(params);



	/*	var myAjax = new Ajax(
			Rating.url,
			{
				postBody: params,
				onComplete: function(){
					var result_txt = this.transport.responseText;
					if(result_txt){
						$('rating').innerHTML = '<span>Fatto!</span>' + result_txt;
						var img = new Element('img', {src:'/img/vote/voto_truveo_' + Math.floor(Math.random()*10000000000) + '_' + id_video + '.gif'})
					}
				}
			}
		).request();*/
	},
	hovera: function(){
		// Se il voto è già presente esco
		if($('stars') && $('stars').getElement('a.over')) return false;

		$('stars').getElements('a').each(function(el, i){
			el.onmouseover = function(){
				var stop = false;
				var current = this;
				$('stars').getElements('a').each(function(il){
					if(stop)
						il.removeClass('over');
					else
						il.addClass('over');

					if(il == current) stop = true;
				});
			}

			el.onmouseout = function(){
				$('stars').getElements('a').each(function(il){
					if(Rating.reset)
						il.removeClass('over');
				});
			}
		});
	}
}

function pluginError(){
	$('video_container').innerHTML = '<div class="message">Per vedere questo video devi aggiornare il player Adobe Flash alla versione 9 o successiva.<br /><br />Il download può essere effettuato al seguente indirizzo:<br /><a href="http://www.adobe.com/go/getflashplayer" target="_blank">http://www.adobe.com/go/getflashplayer</a></div>';
}

function pluginNotPresent(){
	$('video_container').innerHTML = '<div class="message">Per vedere i contenuti di Tiscali Video devi installare il player Adobe Flash.<br /><br />Puoi scaricare il software al seguente indirizzo:<br /><a href="http://www.adobe.com/go/getflashplayer" target="_blank">http://www.adobe.com/go/getflashplayer</a></div>';
}

function showMore(){
	var minH = 60;
	var h = $('v_description').getCoordinates().height;
	var text = $('v_description').getElement('.text');
	var to = text.getCoordinates().height + 30;
	var switcher = $('v_description').getElement('.switcher2');
	var title = $('v_description').getElement('h2');


	var Toggle = new Fx.Tween('v_description', {
						property: 'height',
						transition: Fx.Transitions.Cubic.easeInOut,
						onComplete: function(a){
							if(!switcher) return false;
							if(h > minH && dots == 0){
								switcher.innerHTML = '.';
								period = (function(){
									if(dots >= 2){
										$clear(period);
										dots = 0;
										return false;
									}

									switcher.innerHTML += '.';
									dots++;
								}).periodical(100);
							}
							else
								switcher.innerHTML = 'chiudi';
						}
					});

	/*

	var Toggle = new Fx.Style(
		'v_description',
		'height',
		{
			transition: Fx.Transitions.Cubic.easeInOut,
			onComplete: function(){
				if(!switcher) return false;

				if(h > minH && dots == 0){
					switcher.innerHTML = '.';
					period = (function(){
						if(dots >= 2){
							$clear(period);
							dots = 0;
							return false;
						}

						switcher.innerHTML += '.';
						dots++;
					}).periodical(100);
				}
				else
					switcher.innerHTML = 'chiudi';
			}
		}
	);*/

	if(h <= minH){
		Toggle.start(to);
		title.addClass('selected');
	}
	else{
		Toggle.start(minH);
		if(switcher) switcher.innerHTML = '';
		title.removeClass('selected');
	}
}

function toggleCorrelated(string){
	var div = $(string);
	var h2 = div.getElement('h2');
	var ul = div.getElement('ul');
	var h = div.getStyle('height').toInt();
	var h2_height = h2.getStyle('height').toInt();
	var tot = h2_height + ul.getStyle('height').toInt();

	var Toggle = new Fx.Tween(div, {property: 'height',transition: Fx.Transitions.Cubic.easeInOut});

	//var Toggle = new Fx.Style(div, 'height', {transition: Fx.Transitions.Cubic.easeInOut});

	if(h >= tot){ // <---------------------------------------------- Chiudo
		h2.removeClass('selected');
		Toggle.start(h2_height);
		Cookie.set('box_status_' + string, 'close', {path: '/'});
	}
	else{ // <------------------------------------------------------ Apro
		h2.addClass('selected');
		Toggle.start(tot);
		Cookie.set('box_status_' + string, 'open', {path: '/'});
	}
}

function toggleHeader(){
	var div = $('truveoHeaderInt');
	var h = div.getPosition().y;
// 	console.log(h);
// 	var Toggle = new Fx.Morph(div, {duration: 'short', transition: Fx.Transitions.Sine.easeOut});

	var Toggle = new Fx.Tween(div, {transition: Fx.Transitions.Cubic.easeInOut});
	//var Toggle = new Fx.Styles(div, {transition: Fx.Transitions.Cubic.easeInOut});

	if(h == 0){ // <---------------------------------------------- Chiudo
		Toggle.start('margin-top',0,'-202px');
		$('truveoContent').setStyle('height', window.getSize().y - $('truveoChiudi').getSize().y);
// 		Toggle.start({height: 0, 'padding-top': 0});
	}
	else{ // <------------------------------------------------------ Apro
		Toggle.start('margin-top', '-202px', 0);
		$('truveoContent').setStyle('height', window.getSize().y - ($('truveoHeader').getSize().y +  $('truveoChiudi').getSize().y));
// 		Toggle.start({height: '150px', 'padding-top': '20px'});
	}
}

function closeCorrelated(string){
	var div = $(string);

	var h2 = div.getElement('h2');
	var h2_height = h2.getStyle('height').toInt()

	h2.removeClass('selected');
	div.setStyle('height', h2_height);
}

function switchList(string){
	var div = $(string)
	var el = div.getElement('.switcher');
	var ul = div.getElement('ul');

	if(ul.hasClass('short')){
		ul.removeClass('short');
		ul.addClass('long');
		el.addClass('thumbs');
		Cookie.set('box_style_' + string, 'list', {path: '/'});
	}
	else{
		ul.removeClass('long');
		ul.addClass('short');
		el.removeClass('thumbs');
		Cookie.set('box_style_' + string, 'thumbs', {path: '/'});
	}

	// Mostro la lista se è nascosta
	var h = div.getCoordinates().height;
	if(h < 171) toggleCorrelated(div);
}

function longList(string){
	var div = $(string)
	var el = div.getElement('.switcher');
	var ul = div.getElement('ul');

	ul.removeClass('short');
	ul.addClass('long');
	el.addClass('thumbs');
}

var Abuse = {
	init: function(id){
		if(Cookie.read('abuse') && Cookie.read('abuse').test(id + 'I'))
			$('abuse').innerHTML = '<b title="Grazie per la segnalazione!"></b>';
		else
			$('abuse').innerHTML = '<a href="./" onclick="Abuse.set(' + id + ', this); return false;" title="segnala un abuso"></a>';
	},
	set: function(id, el){
		var params = 'abuse=' + id;

		var myAjax = new Request({method: 'post',
					 url: '/inc/abuse.php',
					 onSuccess: function(txt,xml) {
						var new_el = new Element('span').setHTML('Grazie per la segnalazione!');
						$(el).replaceWith(new_el);
					 }
				}).send(params);

		/*var myAjax = new Ajax(
			'/inc/abuse.php',
			{
				postBody: params,
				onComplete: function(){
					var result_txt = this.response.text;

					var new_el = new Element('span').setHTML('Grazie per la segnalazione!');
					$(el).replaceWith(new_el);
				}
			}
		).request();*/
	}
}

var Favorite = {
	init: function(id){
		if(Cookie.read('favorite') && Cookie.read('favorite').test(id + 'I'))
			$('favorite').innerHTML = '<b title="Aggiunto ai preferiti"></b>';
		else
			$('favorite').innerHTML = '<a href="./" onclick="Favorite.set(' + id + ', this); return false;" title="aggiungi ai preferiti"></a>';
	},
	set: function(id, el){
		var params = 'favorite=' + id;

		var myAjax = new Request({method: 'post',
					 url: '/inc/favorite.php',
					 onSuccess: function(txt,xml) {
						if(isNaN(txt))
							alert(txt);
						else
							$(el).replaceWith(new Element('span').setHTML('Aggiunto ai preferiti'));
						}
				}).send(params);


		/*var myAjax = new Ajax(
			'/inc/favorite.php',
			{
				postBody: params,
				onComplete: function(){
					var result_txt = this.response.text;

					if(isNaN(result_txt))
						alert(result_txt);
					else
						$(el).replaceWith(new Element('span').setHTML('Aggiunto ai preferiti'));
				}
			}
		).request();*/
	}
}
var url = escape(document.location.href);
// var ttl = $(document.getElementsByTagName('title').item(0)).get('text');
// var ttl = document.getElementsByTagName('title').item(0).innerText;

var ttl = escape($$('title')[0].text);

var Social = {
	urls: {
		'del': 'http://del.icio.us/post?url=' + url + '&title=' + ttl,
		'okn': 'http://oknotizie.alice.it/post.html.php?url=' + url + '&title=' + ttl + '&category=',
		'digg': 'http://digg.com/submit?phase=2&url=' + url + '&title=' + ttl,
		'ggl': 'http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=' + url + '&title=' + ttl,
		'fcb': 'http://www.facebook.com/sharer.php?u=' + url + '&t=' + ttl
	},
	init: function(){
		$$('#social ul li').each(
			function(li){
				li.addEvent('click', Social.addSocial);
			}
		);
	},
	addSocial: function(e){
		var e = new Event(e);e.stop();
		window.open(Social.urls[this.id]);
	}
};

function doAccordionsAgain(){
	var myNewAcc = new Fx.Accordion(
		$$('#vVideoInfo ul#vTabsInfo > li'),
		$$('#vDisappear > div'),
		{
			display: 1,
			initialDisplayFx: true,
			alwaysHide: true,
			onActive: function(tg, el){
				$('vDisappear').setStyles({'border-width':'1px','border-top': 0});
				if(tg.hasClass('last'))
					tg.addClass('lastSelected');
				else
					tg.addClass('selected');
				el.inject(el.getParent(),'top');
// 				el.getParent().setStyle('padding','10px');
			},
			onBackground: function(tg,el){
				el.setStyle('height',el.getSize().y);
				if(tg.hasClass('last'))
					tg.removeClass('lastSelected');
				else
					tg.removeClass('selected');
// 				if(!$$('#vVideoInfo ul#vTabsInfo > li.selected').length)
				el.getParent().setStyle('padding','0');
			},
			onComplete: function(){
				if($$('#vVideoInfo ul#vTabsInfo > li.selected').length || $$('#vVideoInfo ul#vTabsInfo > li.lastSelected').length)
					$('vDisappear').getFirst('div').setStyles(
						{
							'height': 'auto'
						}
					);
				else
					$('vDisappear').setStyle('border-width',0);
			}
		}
	);
}

function doAccordions(){
	var vHeight = 450;
	if($chk($('vUserInfo'))){
		vHeight = vHeight - $('vUserInfo').getSize().y - 10;
	}
	$$('#vCorrelated h2.title2').each(function(el){vHeight = vHeight - el.getSize().y;});
	$$('#vCorrelated div.lista ul').each(function(el){el.setStyle('height', (vHeight -1) + 'px');});
	$$('#vCorrelated div.lista div.vScroller').each(function(el){el.setStyle('height', (vHeight -1) + 'px');});
	$$('#vCorrelated div.lista div.vScroller span.vMiddle').each(function(el){el.setStyle('height', (vHeight - 41) + 'px');});
	$$('#vCorrelated div.lista div.vScroller span.vMiddle b').each(
		function(el){
			var hB = el.getParent().getSize().y;
			var ul = el.getParent().getParent().getParent().getElement('ul');
			var hU = ul.getScrollSize().y;
			var hS = ((vHeight * hB) / hU).toInt();
			var vRatio = ((hU - vHeight)/(hB - hS));
			if(hU > ul.getSize().y){
				el.setStyle('height', hS + 'px');
				makeScrollbar(ul,el.getParent(),el);
			}else{
				el.getParent().getParent().setStyle('display','none');
			}

/*			el.makeDraggable(
				{
					container: el.getParent(),
					onDrag:function(dr){
						console.log('drag');
						ul.scrollTo(0,(el.getStyle('top').toInt() * vRatio));
					}
				}
			);*/
		}
	);
	var myAcc = new Fx.Accordion(
		$$('#vCorrelated h2.title2'),
		$$('#vCorrelated div.lista'),
		{
			fixedHeight: vHeight + 'px',
			initialDisplayFx: false,
			onActive: function(el){
				el.addClass('selected');
			},
			onBackground: function(el){
				el.removeClass('selected');
			}
		}
		);

}
var intervallo = false;

function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
	var slider = new Slider(scrollbar, handle, {
		steps: steps,
		mode: (horizontal?'horizontal':'vertical'),
		onChange: function(step){
			// Scrolls the content element in x or y direction.
			var x = (horizontal?step:0);
			var y = (horizontal?0:step);
			content.scrollTo(x,y);
		}
	}).set(0);
	if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;
			slider.set(step);
		});
	}
	scrollbar.getParent().getElements('span').each(
		function(el){
			if(el.hasClass('vUp') || el.hasClass('vDown')){
				el.addEvents(
					{
						'mousedown': function(e){
							e = new Event(e);
							intervallo = (function(){
								var step = slider.step - ($(e.target).hasClass('vUp')?1:-1) * 20;
								slider.set(step);
							}).periodical(100);
						},
						'mouseup': function(){
							$try($clear(intervallo));
							slider.drag.stop();
						},
						'mouseleave': function(){
							$try($clear(intervallo));
							slider.drag.stop();
						}
					}
				);
			}
		}
	);
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
}

// window.addEvents({
// 	'domready': function(){
// 		$('vBottomSwitcher').getElements('a').each(function(a){
// 			a.removeClass('selected');
// 		});
// 		$('vSwithc1').getElement('a').addClass('selected');
// 	}
// });