(function($) {

	

	function VideoGallery(element, options) {
		
		var self=this;
		
		this.settings = $.extend({}, $.fn.videoGallery.defaults, options);
		
		this.isMobile = jQuery.browser.mobile;
		//console.log(this.isMobile);
		
		this._componentInited=false;
		this._body = $('body');
		this._window = $(window);
		this._doc = $(document);
		this._windowResizeInterval = 100;//execute resize delay
		this._windowResizeIntervalID;
		this._mediaPath;	
		this._mediaType;
		this._vimeoPlayer;
		this._vimeoInited=false;
		this._youtubeInited=false;
		this._youtubeFrameId= 'ytplayer';
		this._thumbSizeSet = false;
		this._finalThumbHeight;
		this._thumbInnerContainerSize;//for scroll math
		this._thumbScrollIntervalID;
		this._thumbArr=[];
		this._thumbHolderArr=[];
		this._thumbInnerContainerStartBuffer;
		this._videoProcessCounter=0;//for processing single vimeo feeds
		this._videoProcessData=[];
		this._videoProcessDataUrl=[];
		this._playlistQueryCounter=0;//for processing playlists queries
		this._playlistQueryUrl=[];
		this._shareOpened=false;
		this._playlistLength;
		this._playlistOpened=false;
		this._playlistTransitionOn=true;
		this._descriptionDataArr=[];
		
		this._iconLoader=this.settings.iconLoader;
                this._iconClose=this.settings.iconClose;
                this._iconCloseOn=this.settings.iconCloseOn;
                this._iconOpen=this.settings.iconOpen;
                this._iconOpenOn=this.settings.iconOpenOn;       
                this._iconBackwardOn=this.settings.iconBackwardOn;
                this._iconBackward=this.settings.iconBackward;
                this._iconForwardOn=this.settings.iconForwardOn;
                this._iconForward=this.settings.iconForward;
                this._iconShare=this.settings.iconShare;
                this._iconShareOn=this.settings.iconShareOn;
                this._iconThumbForward=this.settings.iconThumbForward;
                this._iconThumbForwardV=this.settings.iconThumbForwardV;
                this._iconThumbForwardOn=this.settings.iconThumbForwardOn;
                this._iconThumbForwardVOn=this.settings.iconThumbForwardVOn;
                this._iconThumbBackward=this.settings.iconThumbBackward;
                this._iconThumbBackwardV=this.settings.iconThumbBackwardV;
                this._iconThumbBackwardOn=this.settings.iconThumbBackwardOn;
                this._iconThumbBackwardVOn=this.settings.iconThumbBackwardVOn;

		this._componentFixedSize=this.settings.componentFixedSize;
		this._animateVideoSizeOnPlaylistClose=this.settings.animateVideoSizeOnPlaylistClose;
		this.autoPlay=this.settings.autoPlay;
		this._autoAdvanceToNextVideo=this.settings.autoAdvanceToNextVideo;
		this._youtubeChromeless = this.settings.youtubeChromeless;
		this.thumbBackgroundColor = this.settings.thumbBackgroundColor;
		this.randomPlay = this.settings.randomPlay;
		this.loopingOn = this.settings.loopingOn;
		this._activePlaylist=this.settings.activePlaylist;
		this.defaultVolume =this.settings.defaultVolume;
		if(this.defaultVolume<0) this.defaultVolume=0;
		else if(this.defaultVolume>1)this.defaultVolume=1;
		this._thumbOrientation = this.settings.thumbOrientation;
		this._playlistOutside=this.settings.playlistOutside.value;
		this._thumbsScrollValue=Math.abs(this.settings.thumbsScrollValue);
		this._thumbSpacing=this.settings.thumbSpacing;
		this._closePlaylistOnVideoSelect=this.settings.closePlaylistOnVideoSelect;
		this._autoOpenPlaylist = this.settings.autoOpenPlaylist;
		this._thumbWidth=this.settings.thumbWidth;
		this._thumbHeight=this.settings.thumbHeight;
		
		
		
		this.componentWrapper = $(element);
		this._componentWidth= parseInt( this.componentWrapper.css('width'), 10);
		this._componentHeight= parseInt( this.componentWrapper.css('height'), 10);
		
		this.componentPlaylist = this.componentWrapper.find('.componentPlaylist');
		this.mediaPreloader=this.componentWrapper.find('.mediaPreloader');
		this.mediaPreloader.css('display','block');
		
		this.mediaWrapper=this.componentWrapper.find('.mediaWrapper');
		this.youtubeHolder=this.componentWrapper.find('.youtubeHolder');
		this.vimeoHolder=this.componentWrapper.find('.vimeoHolder');
		this.thumbHolder=this.componentWrapper.find('.thumbHolder');
		this.thumbHolder.css('zIndex', 99);
		
		this.thumbHolder.bind('mousewheel', function(event, delta, deltaX, deltaY){
			if(!self._componentInited || self._playlistTransitionOn) return;
			var d = delta > 0 ? 1 : -1, value;//normalize
			if(self._thumbOrientation =='horizontal'){
				if(self._thumbInnerContainerSize < self._getComponentSize('w')-self._thumbBackwardSize-self._thumbForwardSize) return;//if centered
				value = parseInt(self.thumbInnerContainer.css('left'),10);
				value+=self._thumbsScrollValue*d;
				if(value > self._thumbSpacing){
					value=self._thumbSpacing;	
				}else if(value < self._getComponentSize('w')- self._thumbInnerContainerSize - self._thumbForwardSize - self._thumbBackwardSize){
					value=self._getComponentSize('w')- self._thumbInnerContainerSize - self._thumbForwardSize - self._thumbBackwardSize;	
				}
				self.thumbInnerContainer.css('left', value+'px');
			}else{
				if(self._thumbInnerContainerSize < self._getComponentSize('h')-self._thumbBackwardSize-self._thumbForwardSize) return;
			    value = parseInt(self.thumbInnerContainer.css('top'),10);
				value+=self._thumbsScrollValue*d;
				if(value > self._thumbSpacing){
					value=self._thumbSpacing;	
				}else if(value < self._getComponentSize('h')- self._thumbInnerContainerSize - self._thumbForwardSize - self._thumbBackwardSize){
					value=self._getComponentSize('h')- self._thumbInnerContainerSize - self._thumbForwardSize - self._thumbBackwardSize;	
				}
				self.thumbInnerContainer.css('top', value+'px');
		 	}
			return false;
		});
		
		this.thumbContainer=this.componentWrapper.find('.thumbContainer');
		this.thumbBackward = this.componentWrapper.find('.thumbBackward');
		this.thumbForward = this.componentWrapper.find('.thumbForward');
		this.thumbBackward.css('cursor','pointer');
		this.thumbForward.css('cursor','pointer');
		this.thumbBackward.css('display','none');
		this.thumbForward.css('display','none');
	
		if(this._thumbOrientation == 'horizontal'){
			this._thumbBackwardSize = parseInt(this.thumbBackward.css('width'),10);
			this._thumbForwardSize = parseInt(this.thumbForward.css('width'),10);
			this.thumbContainer.css('width', this._getComponentSize('w')-this._thumbBackwardSize-this._thumbForwardSize+'px');
		}else{
			this._thumbBackwardSize = parseInt(this.thumbBackward.css('height'),10);
			this._thumbForwardSize = parseInt(this.thumbForward.css('height'),10);
			this.thumbContainer.css('height', this._getComponentSize('h')-this._thumbBackwardSize-this._thumbForwardSize+'px');
		}
			
		this.thumbInnerContainer = this.componentWrapper.find('.thumbInnerContainer');
		if(this._thumbOrientation == 'horizontal'){
			this.thumbInnerContainer.css('left', this._thumbSpacing+'px');
			this._thumbInnerContainerStartBuffer = parseInt(this.thumbInnerContainer.css('top'), 10);
		}else{
			this.thumbInnerContainer.css('top', this._thumbSpacing+'px');
			this._thumbInnerContainerStartBuffer = parseInt(this.thumbInnerContainer.css('left'), 10);
		}
		
		this.shareHolder =this.componentWrapper.find('#shareHolder');
		this.player_share = this.componentWrapper.find('.player_share');
		
		this.slideshow_controls = this.componentWrapper.find('.slideshow_controls');
		this.slideshow_controls.css('zIndex', 100);
		this.controls_prev = this.componentWrapper.find('.controls_prev');
		this.controls_toggle = this.componentWrapper.find('.controls_playlist_toggle');
		this.controls_next = this.componentWrapper.find('.controls_next');
		this.controls_prev.css('cursor', 'pointer');
		this.controls_toggle.css('cursor', 'pointer');
		this.controls_next.css('cursor', 'pointer');
		this.player_share.css('cursor', 'pointer');
		
		this._controlsPrevSrc=this.controls_prev.children('img');
		this._controlsNextSrc=this.controls_next.children('img');
		this._controlsToggleSrc=this.controls_toggle.children('img');
		this._thumbForwardSrc=this.thumbForward.children('img');
		this._thumbBackwardSrc=this.thumbBackward.children('img');
		this._playerShareSrc=this.player_share.children('img');
		
		this.controls_prev.bind('click', function(){
			if(self._playlistTransitionOn) return;
			self._enableActiveItem();
			self._playlistManager.advanceHandler(-1, true);
			return false;
		});
		this.controls_toggle.bind('click', function(){
			if(self._playlistTransitionOn) return;
			self._togglePlaylist(true);//on buttons
			return false;
		});
		this.controls_next.bind('click', function(){
			if(self._playlistTransitionOn) return;
			self._enableActiveItem();
			self._playlistManager.advanceHandler(1, true);
			return false;
		});
		this.player_share.bind('click', function(){
			self._toggleShare();
			return false;
		});
		
		this.controls_prev.bind('mouseover', function(){
			self._controlsPrevSrc.attr('src', this._iconBackwardOn);
			return false;
		});
		this.controls_toggle.bind('mouseover', function(){
			if(self._playlistOpened){
				self._controlsToggleSrc.attr('src', this._iconCloseOn);
			} else{
				self._controlsToggleSrc.attr('src', this._iconOpenOn);
			}
			return false;
		});
		this.controls_next.bind('mouseover', function(){
			self._controlsNextSrc.attr('src', this._iconForwardOn);
			return false;
		});
		this.player_share.bind('mouseover', function(){
			self._playerShareSrc.attr('src', this._iconShareOn);
			return false;
		});
		
		this.thumbForward.bind('mouseover', function(){
			self._thumbForwardSrc.attr('src', self._thumbOrientation == 'horizontal' ? this._iconThumbForwardOn : this._iconThumbForwardVOn);
			return false;
		});
		this.thumbBackward.bind('mouseover', function(){
			self._thumbBackwardSrc.attr('src', self._thumbOrientation == 'horizontal' ? this._iconThumbBackwardOn : this._iconThumbBackwardVOn);
			return false;
		});
		
		this.controls_prev.bind('mouseout', function(){
			self._controlsPrevSrc.attr('src', this._iconBackward);
			return false;
		});
		this.controls_toggle.bind('mouseout', function(){
			if(self._playlistOpened){
				self._controlsToggleSrc.attr('src', this._iconClose);
			} else{
				self._controlsToggleSrc.attr('src', this._iconOpen);
			}
			return false;
		});
		this.controls_next.bind('mouseout', function(){
			self._controlsNextSrc.attr('src', this._iconForward);
			return false;
		});
		this.player_share.bind('mouseout', function(){
			self._playerShareSrc.attr('src', this._iconShare);
			return false;
		});
		
		this.thumbForward.bind('mouseout', function(){
			self._thumbForwardSrc.attr('src', self._thumbOrientation == 'horizontal' ? this._iconThumbForward : this._iconThumbForwardV);
			return false;
		});
		this.thumbBackward.bind('mouseout', function(){
			self._thumbBackwardSrc.attr('src', self._thumbOrientation == 'horizontal' ? this._iconThumbBackward : this._iconThumbBackwardV);
			return false;
		});
			
		if(!this._componentFixedSize) this._window.bind('resize', function(){
			if(!self._componentInited) return false;
			if(self._windowResizeIntervalID) clearInterval(self._windowResizeIntervalID);
			self._windowResizeIntervalID = setTimeout(function() { self._doneResizing(); }, self._windowResizeInterval);
			return false;
		});
		
		var pm_settings = {'randomPlay': this.randomPlay, 'loopingOn': this.loopingOn};
		this._playlistManager = $.playlistManager(pm_settings);
		$(this._playlistManager).bind('ap_PlaylistManager.COUNTER_READY', function(){
			self._disableActiveItem();
			self._findMedia();	
		});
		$(this._playlistManager).bind('ap_PlaylistManager.PLAYLIST_END', function(){
			self._disableActiveItem();
		});
		
		if(this._playlistOutside) this._setComponents();
		
		if(this.isMobile){
			this.thumbBackward.bind('mousedown touchstart MozTouchDown', function(){
				if(self._playlistTransitionOn) return;
				if(self._thumbScrollIntervalID) clearInterval(self._thumbScrollIntervalID);
				self._thumbScrollIntervalID = setInterval(function() { self._scrollThumbsBack(); }, 100);
				return false;
			});
			this.thumbBackward.bind('mouseup touchend MozTouchUp', function(){
				if(self._thumbScrollIntervalID) clearInterval(self._thumbScrollIntervalID);
				return false;
			});
			this.thumbForward.bind('mousedown touchstart MozTouchDown', function(){
				if(self._playlistTransitionOn) return;
				if(self._thumbScrollIntervalID) clearInterval(self._thumbScrollIntervalID);
				self._thumbScrollIntervalID = setInterval(function() { self._scrollThumbsForward(); }, 100);
				return false;
			});
			this.thumbForward.bind('mouseup touchend MozTouchUp', function(){
				if(self._thumbScrollIntervalID) clearInterval(self._thumbScrollIntervalID);
				return false;
			});
		}else{
			this.thumbBackward.bind('mouseenter', function(){
				if(self._playlistTransitionOn) return;
				if(self._thumbScrollIntervalID) clearInterval(self._thumbScrollIntervalID);
				self._thumbScrollIntervalID = setInterval(function() { self._scrollThumbsBack(); }, 100);
				return false;
			});
			this.thumbBackward.bind('mouseleave', function(){
				if(self._thumbScrollIntervalID) clearInterval(self._thumbScrollIntervalID);
				return false;
			});
			this.thumbForward.bind('mouseenter', function(){
				if(self._playlistTransitionOn) return;
				if(self._thumbScrollIntervalID) clearInterval(self._thumbScrollIntervalID);
				self._thumbScrollIntervalID = setInterval(function() { self._scrollThumbsForward(); }, 100);
				return false;
			});
			this.thumbForward.bind('mouseleave', function(){
				if(self._thumbScrollIntervalID) clearInterval(self._thumbScrollIntervalID);
				return false;
			});
		}
			
		//init	
		this._setPlaylist();	
				
		
	} /* VideoGallery Constructor End */
	/* -------------------------------------VideoGallery Prototype------------------------------------------------------*/
	VideoGallery.prototype = {
			 
			// PUBLIC 
			getMediaID:function() {	
				if(!this._componentInited || this._playlistTransitionOn) return;
                                if(this._playlistManager.getCounter() == -1){
                                        alert('No active Item for description, counter = -1');
                                        return;
                                }
				return this._playlistManager.getCounter();
			},	
			getDescription:function(c) {	
				if(!this._componentInited || this._playlistTransitionOn) return;
				if(c){
					if(c> this._playlistLength-1)c=this._playlistLength-1;
					else if(c<0) c=0;
				}else{
					if(this._playlistManager.getCounter() == -1){
						alert('No active Item for description, counter = -1');
						return;
					}
					c = this._playlistManager.getCounter();
				}
				//console.log(this._descriptionDataArr[c]);
				return this._descriptionDataArr[c] ? this._descriptionDataArr[c] : null;
			},	
			playMedia:function() {
				if(!this._componentInited || this._playlistTransitionOn || !this._mediaType) return;
				if(this._mediaType == 'vimeo'){
					if(this._vimeoPlayer) this._vimeoPlayer.play();
				}else if(this._mediaType == 'youtube'){
					if(this._youtubePlayer) this._youtubePlayer.play();
				}
			}, 
			pauseMedia:function() {	
				if(!this._componentInited || this._playlistTransitionOn || !this._mediaType) return;
				if(this._mediaType == 'vimeo'){
					if(this._vimeoPlayer) this._vimeoPlayer.pause();
				}else if(this._mediaType == 'youtube'){
					if(this._youtubePlayer) this._youtubePlayer.pause();
				}
			},	
			nextMedia:function() {
				if(!this._componentInited || this._playlistTransitionOn) return;
				this._enableActiveItem();
				this._playlistManager.advanceHandler(1, true);
			},
			previousMedia:function() {	
				if(!this._componentInited || this._playlistTransitionOn) return;
				this._enableActiveItem();
				this._playlistManager.advanceHandler(-1, true);
			},	
			loadMedia:function(num) {
				if(!this._componentInited || this._playlistTransitionOn) return;
				if(num<0)num=0;
				else if(num > this._playlistLength-1)num=this._playlistLength-1;
				this._enableActiveItem();
				this._playlistManager.processPlaylistRequest(num);
			}, 
			destroyMedia:function() {
				if(!this._componentInited || !this._mediaType) return;
				this._cleanMedia();
			}, 
			togglePlaylistState:function() {
				if(!this._componentInited || this._playlistTransitionOn) return;
				this._togglePlaylist();
			}, 
			setVolume:function(val) {
				if(!this._componentInited || this._playlistTransitionOn || !this._mediaType) return;
				if(val<0) val=0;
				else if(val>1) val=1;
				this._setVolume(val);
			}, 
			inputPlaylist:function(id) {
				if(!this._componentInited || this._playlistTransitionOn) return;
				this._activePlaylist=id;
				this._setPlaylist();
			}, 
			
			
			//********** PRIVATE	
			
			_processJson:function () {
				var type = this._videoProcessDataUrl[this._videoProcessCounter].type;
				if(RegExp('youtube').test(type)) {
					this._processYoutube();
				}else{
					this._processVimeo();
				}	
			},
			_getPlaylist:function () {
				/*
				https://developers.google.com/youtube/2.0/developers_guide_jsonc
				&start-index=1&max-results=50&v=2&alt=jsonc
				*/
				var self = this;
			  
				this._videoProcessCounter=0;//reset
				this._videoProcessData=[];
				this._videoProcessDataUrl=[];
				this._descriptionDataArr=[];
				var obj, _item;
					
				var playlist = $(this.componentPlaylist.find("ul[id="+this._activePlaylist+"]"));
				this._playlistLength=playlist.children('li').size();
				playlist.children('li').each(function() { 
					_item=$(this);
					obj = {};
					obj.type = _item.attr('data-type');
					obj.path = _item.attr('data-path');
					if(obj.type == 'youtube_playlist'){
						//check for 'PL'
						/*var pth = obj.path;
						if(_item.attr('data-path').substr(0,2).toUpperCase() == 'PL'){
							path = _item.attr('data-path').substring(2);
						}*/
					}
					self._videoProcessDataUrl.push(obj);
					//console.log(obj.type,obj.path);
				});
				this._processJson();
		
		
				//YOUTUBE
				//var u =  'http://gdata.youtube.com/feeds/api/videos?q=mtb+dh&v=2&alt=jsonc';//query videos
				//var u4_1 =  'https://gdata.youtube.com/feeds/api/playlists/snippets?q=mtb&max-results=5&v=2&alt=jsonc';//query playlists
			  
				//var u2 = 'http://gdata.youtube.com/feeds/api/videos/eJcIS_pDkX0?v=2&alt=jsonc';//single video
				
				//var u3 = 'http://gdata.youtube.com/feeds/api/users/GoProCamera?v=2&alt=json'; //users - "Jsonc is not enabled for this feed"
				
				/*
				"Jsonc is not enabled for this feed"
				u3
				console.log(response);//	
				//console.log(response.entry.gd$feedLink[5].href);
				for (var i = 0; i < response.entry.gd$feedLink.length; i++) {
				var item=response.entry.gd$feedLink[i];
				//console.log(item.href);
				
				http://gdata.youtube.com/feeds/api/users/goprocamera/favorites?v=2
				http://gdata.youtube.com/feeds/api/users/goprocamera/contacts?v=2
				http://gdata.youtube.com/feeds/api/users/goprocamera/inbox?v=2
				http://gdata.youtube.com/feeds/api/users/goprocamera/playlists?v=2
				http://gdata.youtube.com/feeds/api/users/goprocamera/subscriptions?v=2
				http://gdata.youtube.com/feeds/api/users/goprocamera/uploads?v=2
				http://gdata.youtube.com/feeds/api/users/goprocamera/newsubscriptionvideos?v=2
				
				if(RegExp('favorites').test(item.href)) {	
					callJSON(item.href+'&alt=jsonc');		
				}else if(RegExp('playlists').test(item.href)) {	
					//callJSON(item.href+'&alt=jsonc');
				}else if(RegExp('uploads').test(item.href)) {	
					//callJSON(item.href+'&alt=jsonc');
				}
				}*/
				
				//var u4 = 'http://gdata.youtube.com/feeds/api/playlists/809A4E0A2CCDABEF?v=2&alt=jsonc';//playlist
				
				//var u5 = 'http://gdata.youtube.com/feeds/api/users/Antoine1223/favorites?v=2&alt=jsonc';//user favourites
				
				//var u6 = 'http://gdata.youtube.com/feeds/api/users/goprocamera/uploads?v=2&alt=jsonc';//user uploads
				
				//var u7 = 'http://gdata.youtube.com/feeds/api/users/goprocamera/subscriptions?v=2&alt=jsonc';//user subscriptions - "Jsonc is not enabled for this feed", ne radi ni json!
				
				/*var u8 = 'https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?v=2&alt=jsonc';
				var u8 = 'https://gdata.youtube.com/feeds/api/standardfeeds/top_favorites?v=2&alt=jsonc';
				var u8 = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_viewed?v=2&alt=jsonc';
				var u8 = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=jsonc';
				var u8 = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_recent?v=2&alt=jsonc';
				var u8 = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_discussed?v=2&alt=jsonc';
				var u8 = 'https://gdata.youtube.com/feeds/api/standardfeeds/most_responded?v=2&alt=jsonc';
				var u8 = 'https://gdata.youtube.com/feeds/api/standardfeeds/recently_featured?v=2&alt=jsonc';*/
				//other experimental
				
				/*
				additional:
				
				Retrieving region-specific standard video feeds
				http://gdata.youtube.com/feeds/api/standardfeeds/regionID/feedID?v=2
				For example, to retrieve a list of the top-rated videos in Japan, you would send a GET request to the following URL:
				http://gdata.youtube.com/feeds/api/standardfeeds/JP/top_rated?v=2
		
				Retrieving category-specific standard video feeds
				https://gdata.youtube.com/feeds/api/standardfeeds/regionID/feedID_CATEGORY_NAME?v=2
				For example, to retrieve a list of the top-rated comedies in Japan, you would send a GET request to the following URL:
				https://gdata.youtube.com/feeds/api/standardfeeds/JP/top_rated_Comedy?v=2
		
				*/
				
				//var u9 = 'https://gdata.youtube.com/feeds/api/channels?q=soccer&start-index=1&max-results=10&v=2&alt=json';//channel, "Jsonc is not enabled for this feed"
			
				/*
				<ul id='playlist13'> 
				<!--  -->
				<li data-type='youtube_user_videos' data-path="http://gdata.youtube.com/feeds/api/users/XTremeVideo?v=2&alt=json" />
				</ul>
				<ul id='playlist14'> 
				<!--  -->
				<li data-type='youtube_channel_query' data-path="http://gdata.youtube.com/feeds/api/channels?q=soccer&start-index=1&max-results=50&v=2&alt=json" />
				</ul>
				*/
				
				
				/*
				VIMEO
				
				var vimeoUserName = 'user1089639';
				var video_id='14665315';
				var group_id='28082';
				var channel_name='mountainbiking';
				var album_id='1705896';
			
				var user_url = 'http://vimeo.com/api/v2/' + vimeoUserName + '/videos.json';//user videos
				var video_url = 'http://vimeo.com/api/v2/video/' + video_id + '.json';//video
				//http://vimeo.com/api/v2/group/groupname/request.output
				var group_url = 'http://vimeo.com/api/v2/group/' + group_id + '/videos.json';//group videos
				//http://vimeo.com/api/v2/channel/channelname/request.output
				var channel_url = 'http://vimeo.com/api/v2/channel/' + channel_name + '/videos.json';//channel videos
				//http://vimeo.com/api/v2/album/album_id/request.output
				var album_url = 'http://vimeo.com/api/v2/album/' + album_id + '/videos.json';//album videos
				*/	 
			},
			_processYoutube:function () {
				//console.log('this._processYoutube');
				var self = this;
				var type = this._videoProcessDataUrl[this._videoProcessCounter].type;
				var url = this._videoProcessDataUrl[this._videoProcessCounter].path;
				//console.log(type,url);
				
				if(type == 'youtube_single'){
					this._processYoutubeSingle(url);
					return;
				}else if(type == 'youtube_playlist'){
					
				}else if(type == 'youtube_user_favourites'){
		
				}else if(type == 'youtube_user_uploads'){
		
				}else if(type == 'youtube_video_query'){
		
				}else if(type == 'youtube_playlist_query'){
		
				}else if(type == 'youtube_standard_feed'){
		
				}else if(type == 'youtube_user_videos'){
					//********
				}else if(type == 'youtube_channel_query'){
					//********
				}else{
					alert('Invalid data-type in playlist!');
					return;
				}
				
				jQuery.ajax({
					 url: url,
					 dataType: 'jsonp', 
					 success:function(data){
						 self._processYotubeSuccess(data);
					 },
					 error:function(er){
						self._processYotubeError(er);
					 }
				});	 
			},
			_processYoutubeSingle:function (url) {
				var self = this;
				jQuery.ajax({
					 url: url,
					 dataType: 'jsonp', 
					 success:function(data){
						 self._processYotubeSingleSuccess(data);
					 },
					 error:function(er){
						self._processYotubeError(er);
					 }
				});	
			},
			_processYoutubePlaylistQuery:function () {
				//console.log('this._processYoutubePlaylistQuery');
				var self = this;
				var url =this._playlistQueryUrl[this._playlistQueryCounter];
				jQuery.ajax({
					 url: url,
					 dataType: 'jsonp', 
					 success:function(data){
						 self._processYoutubePlaylistQuerySuccess(data);
					 },
					 error:function(er){
						self._processYotubeError(er);
					 }
				}); 
			},
			_processYoutubePlaylistQuerySuccess:function (response) {//Only process max 50 results per playlist here.
				 if(response.error){
					alert(response.error.message);
					return;	
				 } 
				 
				 var len = response.data.items.length, i = 0, obj, _item;
				 //console.log('len = ', len);
				 
				 for(i; i < len; i++){
					_item = response.data.items[i].video;
					
					obj = {};
					obj.type = 'youtube';
					obj.id = _item.id;
					obj.title=_item.title;
					obj.description=_item.description;
					obj.thumbnail=_item.thumbnail.hqDefault ? _item.thumbnail.hqDefault : _item.thumbnail.sqDefault;
					
					this._videoProcessData.push(obj); 
				 }
				 
				 this._playlistQueryCounter++;
				 if(this._playlistQueryCounter>this._playlistLength - 1){
					this._buildPlaylist(); 
				 }else{
					this._processYoutubePlaylistQuery();
				 }	
			},
			_processYotubeSuccess:function (response) {
				 // console.log('this._processYotubeSuccess');
				 if(response.error){
					alert(response.error.message);
					return;	
				 } 
				 
				 var len = response.data.items.length, i = 0, type = this._videoProcessDataUrl[this._videoProcessCounter].type, obj, _item;
				 //console.log('len = ', len);
				 
				 if(type == 'youtube_playlist_query'){
					this._playlistQueryCounter=0;//reset
					this._playlistQueryUrl=[];
					var url;
					this._playlistLength = len;
					for(i; i < len; i++){
						url = 'http://gdata.youtube.com/feeds/api/playlists/' + response.data.items[i].id + '?&start-index=1&max-results=50&v=2&alt=jsonc';
						this._playlistQueryUrl.push(url);//save playlists id
						//console.log(response.data.items[i].id);
					}
					this._processYoutubePlaylistQuery();
					return;
				 }		 
				 
				 for(i; i < len; i++){
					if(type == 'youtube_user_uploads' || type == 'youtube_video_query' || type == 'youtube_standard_feed'){
						_item = response.data.items[i];
					}else{
						_item = response.data.items[i].video;
					}
					obj = {};
					obj.type = 'youtube';
					obj.id = _item.id;
					obj.title=_item.title;
					obj.description=_item.description;
					obj.thumbnail=_item.thumbnail.hqDefault ? _item.thumbnail.hqDefault : _item.thumbnail.sqDefault;
					
					this._videoProcessData.push(obj); 
				 }
				 
				 this._videoProcessCounter++;
				 if(this._videoProcessCounter>this._playlistLength - 1){
					this._buildPlaylist(); 
				 }else{
					this._processJson(); 
				 }
			},
			_processYotubeSingleSuccess:function (response) {
				 //console.log(response);
				 /*
				 console.log(response.data);
				 console.log(response.data.title);
				 console.log(response.data.description);
				 console.log(response.data.id);
				 console.log(response.data.thumbnail.sqDefault);
				 console.log(response.data.thumbnail.hqDefault);
				 */
				 
				 var obj = {}, _item;
				 _item = response.data;
				 obj.type = 'youtube';
				 obj.id = _item.id;
				 obj.title=_item.title;
				 obj.description=_item.description;
				 obj.thumbnail=_item.thumbnail.hqDefault ? _item.thumbnail.hqDefault : _item.thumbnail.sqDefault;
				 this._videoProcessData.push(obj);
				 
				 this._videoProcessCounter++;
				 if(this._videoProcessCounter>this._playlistLength - 1){
					this._buildPlaylist(); 
				 }else{
					this._processJson(); 
				 }
			},
			_processYotubeError:function (er) {
				//alert(er);
			},
			
			//************** VIMEO
			_processVimeo:function () {
				//console.log('this._processVimeo');
				
				var self=this;
				
				var type = this._videoProcessDataUrl[this._videoProcessCounter].type;
				var url = this._videoProcessDataUrl[this._videoProcessCounter].path;
				//console.log(type,url);
				
				if(type == 'vimeo_single'){
					this._processVimeoSingle(url);
					return;
				}else if(type == 'vimeo_user'){
					
				}else if(type == 'vimeo_group'){
					
				}else if(type == 'vimeo_channel'){
					
				}else if(type == 'vimeo_album'){
					
				}else{
					alert('Invalid data-type in playlist!');
					return;
				}
				
				jQuery.ajax({
					 url: url,
					 dataType: 'jsonp', 
					 success:function(data){
						 self._processVimeoSuccess(data);
					 },
					 error:function(er){
						self._processVimeoError(er);
					 }
				});
			},
			_processVimeoSingle:function (url) {
				var self=this;
				jQuery.ajax({
					 url: url,
					 dataType: 'jsonp', 
					 success:function(data){
						 self._processVimeoSingleSuccess(data);
					 },
					 error:function(er){
						self._processVimeoError(er);
					 }
				});
			},
			_processVimeoSuccess:function (data) {
				 var len = data.length, i = 0, obj;
				 for(i; i < len; i++){
					obj = {};
					obj.type = 'vimeo';
					obj.id = data[i].id;
					obj.title=data[i].title;
					obj.description=data[i].description;
					obj.thumbnail=data[i].thumbnail_medium;
					this._videoProcessData.push(obj);
				 }
				 
				 this._videoProcessCounter++;
				 if(this._videoProcessCounter>this._playlistLength - 1){
					this._buildPlaylist(); 
				 }else{
					this._processJson(); 
				 }
			},
			_processVimeoSingleSuccess:function (data) {
				 var obj = {};
				 obj.type = 'vimeo';
				 obj.id = data[0].id;
				 obj.title=data[0].title;
				 obj.description=data[0].description;
				 obj.thumbnail=data[0].thumbnail_medium;
				 this._videoProcessData.push(obj);
				 
				 this._videoProcessCounter++;
				 if(this._videoProcessCounter>this._playlistLength - 1){
					this._buildPlaylist(); 
				 }else{
					this._processJson(); 
				 }
			},
			_processVimeoError:function (er) {
				//alert(er);
			},
			
			/*
			VIMEO THUMBNAIL SIZES
			http://vimeoapi.tumblr.com/post/137195847
			100x75 (small)
			200x150 (medium)
			640px width (large)
			1280px width (HD only, will be available in the future)
			
			YOUTUBE
			sqDefault
			320x240
			hqDefault
			480x360
			*/
			
			_getThumbSize:function (url) {
				//console.log('_getThumbSize');
				var self=this;
				var thumb=$(new Image());
				thumb.load(function() {
					var r=this.width/this.height;///thumb ratio
					self._finalThumbHeight = self._thumbWidth / r;
					//console.log('getThumbSize :', self._finalThumbHeight, ', ', self._finalThumbHeight);
					self._buildPlaylist();
				}).attr('src', url);
			},
			_buildPlaylist:function () {
				if(!this._thumbSizeSet){
					this._thumbSizeSet=true;
					var url=this._videoProcessData[0].thumbnail;
					this._getThumbSize(url);
					return;	
				}
				var self=this;
				//console.log('this._buildPlaylist');
				
				this.mediaPreloader.css('display','none');
				this._thumbInnerContainerSize = 0;//reset
				this._playlistOpened=false;//reset for bottom this._autoOpenPlaylist selection
				
				this._playlistLength = this._videoProcessData.length;
				var i = 0, thumb, div, url, titleDiv, _item, type, thumb_id;
				//console.log(this._playlistLength);
				
				for (i; i < this._playlistLength; i++) {
					//console.log(_item.description);
					
					_item = this._videoProcessData[i];
					url=_item.thumbnail;
					//if(i == 0) console.log(_item.description);
					this._descriptionDataArr[i]=_item.description;
					
					div = $('<div/>');
					this._thumbHolderArr[i] = div;
					div.attr('data-id', i);
					//console.log(_item.type, _item.id);
					div.attr('data-type', _item.type);
					div.attr('data-path', _item.id);
					div.bind('click', function(e){
						if(!self._componentInited || self._playlistTransitionOn) return;
						//console.log('this._clickPlaylistItem');
						if (!e) var e = self._window.event;
						if(e.cancelBubble) e.cancelBubble = true;
						else if (e.stopPropagation) e.stopPropagation();
						
						var currentTarget = $(e.currentTarget);
						var id = currentTarget.attr('data-id');
						//console.log(id);
						
						if(id == self._playlistManager.getCounter()) return;//active item
						
						self._enableActiveItem();
						self._playlistManager.processPlaylistRequest(id);
						
						if(self._closePlaylistOnVideoSelect) {
							self._togglePlaylist();
						}
						return false;
					});
					div.bind('mouseover', function(e){
						if(!self._componentInited || self._playlistTransitionOn) return;
						if (!e) var e = self._window.event;
						if(e.cancelBubble) e.cancelBubble = true;
						else if (e.stopPropagation) e.stopPropagation();
						
						var currentTarget = $(e.currentTarget);
						var id = currentTarget.attr('data-id');
					
						//console.log(currentTarget.find("div[data-title='titleDiv']"));
						var titleDiv = currentTarget.find("div[data-title='titleDiv']");
						if(titleDiv){
							//console.log(currentTarget.height(), titleDiv.height());
							var value=currentTarget.height()-titleDiv.height()-parseInt(titleDiv.css('paddingBottom'),10)-parseInt(titleDiv.css('paddingTop'),10);
							titleDiv.stop().animate({ 'top': value+'px'},  {duration: 300, easing: 'easeOutQuart'});
						}
						return false;	
					});
					div.bind('mouseout', function(e){
						if(!self._componentInited || self._playlistTransitionOn) return;
						//console.log('_outPlaylistItem');
						if (!e) var e = self._window.event;
						if(e.cancelBubble) e.cancelBubble = true;
						else if (e.stopPropagation) e.stopPropagation();
						
						var currentTarget = $(e.currentTarget);
						var id = currentTarget.attr('data-id');
						//console.log('id = ', id, ', this._playlistManager.getCounter() = ',  this._playlistManager.getCounter());
						
						if(id == self._playlistManager.getCounter()) return;//active item
						
						var titleDiv = currentTarget.find("div[data-title='titleDiv']");
						if(titleDiv){
							titleDiv.stop().animate({ 'top': currentTarget.height()+'px'},  {duration: 300, easing: 'easeOutQuart'});
						}
						return false;	
					});
					if(this._thumbOrientation == 'horizontal'){
						div.css({
						   position: 'relative',
						   width: this._thumbWidth + 'px',
						   height: this._finalThumbHeight+'px',
						   top : 0+'px',
						   left : 0+'px',
						   'float': 'left',
						   marginRight: this._thumbSpacing +'px',
						   cursor: 'pointer',
						   opacity: 0,
						   overflow: 'hidden',
						   backgroundColor: this.thumbBackgroundColor,
						   backgroundImage: 'url("'+this._iconLoader+'")',
						   backgroundRepeat: 'no-repeat',
						   backgroundPosition: 'center center'
						});
					}else{
						div.css({
						   position: 'relative',
						   width: this._thumbWidth + 'px',
						   height: this._finalThumbHeight+'px',
						   top : 0+'px',
						   left : 0+'px',
						   clear: 'both',
						   marginBottom: this._thumbSpacing +'px',
						   cursor: 'pointer',
						   opacity: 0,
						   overflow: 'hidden',
						   backgroundColor: this.thumbBackgroundColor,
						   backgroundImage: 'url("'+this._iconLoader+'")',
						   backgroundRepeat: 'no-repeat',
						   backgroundPosition: 'center center'
						});
					}
					
					titleDiv = $('<div/>');
					div.titleDiv = titleDiv;
					titleDiv.attr('data-title', 'titleDiv');
					titleDiv.css({
					   left : 0+'px',
					   top: this._finalThumbHeight+'px'
					});
					//console.log(i, ', ',_item.title);
					titleDiv.html(_item.title);
					titleDiv.addClass('thumb_title');
					
					thumb=$(new Image());
					thumb.attr('alt', _item.title);
					thumb.attr('id', i);
					thumb.css({
					   top : 0+'px',
					   left : 0+'px',
					   display : 'block',
					   width: this._thumbWidth+'px',
					   height: this._finalThumbHeight+'px'
					}).load(function() {
						thumb_id = $(this).attr('id');
						self._thumbHolderArr[thumb_id].css('backgroundImage', '');//remove preloaders
					}).attr('src', url);
					
					div.append(thumb);
					div.append(titleDiv);
					this.thumbInnerContainer.append(div);
					
					div.stop().animate({ 'opacity': 1},  {duration: 500, easing: 'easeOutSine'});
					
					if(this._thumbOrientation == 'horizontal'){
						this._thumbInnerContainerSize+=this._thumbWidth+this._thumbSpacing;
					}else{
						this._thumbInnerContainerSize+=this._finalThumbHeight+this._thumbSpacing;
					}
				}
				
				this.thumbInnerContainer.css('width', this._thumbInnerContainerSize+'px');
				this._checkThumbPosition();
				
				this._playlistTransitionOn=false;
				
				this._playlistLength=this._thumbHolderArr.length;
				//console.log('this._playlistLength = ', this._playlistLength);
				//console.log('this._descriptionDataArr.length = ', this._descriptionDataArr.length);
				this._playlistManager.setPlaylistItems(this._playlistLength);
				var c = this.settings.activeVideo;
				if(c> this._playlistLength-1)c=this._playlistLength-1;
				else if(c<-1) c=-1;
				if(c>-1){
					this._playlistManager.setCounter(c, false);
				}
				
				if(this._autoOpenPlaylist){
					this._togglePlaylist();
				}else{
					this._playlistOpened=true;//reverse to close component
					this._togglePlaylist();
				}
				
				if(!this._componentInited){
					this._componentInited=true;
					//fade in controls
					this.slideshow_controls.css('opacity', 0);
					this.slideshow_controls.css('display', 'block');
					this.slideshow_controls.stop().animate({ 'opacity': 1},  {duration: 500, easing: 'easeOutSine'});
					
					this.settings.videoGallerySetupDone.call(this);
				}
			},
			_checkThumbPosition:function () {
				//console.log(this._thumbInnerContainerSize, this._getComponentSize('w'),this._thumbBackwardSize,this._thumbForwardSize);
				if(this._thumbOrientation == 'horizontal'){
					if(this._thumbInnerContainerSize > this._getComponentSize('w')-this._thumbBackwardSize-this._thumbForwardSize){
						this.thumbBackward.css('display','block');
						this.thumbForward.css('display','block');
						var value = parseInt(this.thumbInnerContainer.css('left'),10);
						if(value < this._getComponentSize('w')- this._thumbInnerContainerSize - this._thumbForwardSize - this._thumbBackwardSize){
							if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
							value=this._getComponentSize('w')- this._thumbInnerContainerSize - this._thumbForwardSize - this._thumbBackwardSize;	
						}else if(value > this._thumbSpacing){
							value=this._thumbSpacing;
						}
						this.thumbInnerContainer.css('left', value+'px');
					}else{
						//center thumbs if less
						this.thumbBackward.css('display','none');
						this.thumbForward.css('display','none');
						this.thumbInnerContainer.css('left', this._getComponentSize('w') / 2 - this._thumbInnerContainerSize / 2 - this._thumbBackwardSize +'px');
					}
				}else{
					if(this._thumbInnerContainerSize > this._getComponentSize('h')-this._thumbBackwardSize-this._thumbForwardSize){
						this.thumbBackward.css('display','block');
						this.thumbForward.css('display','block');
						var value = parseInt(this.thumbInnerContainer.css('top'),10);
						if(value < this._getComponentSize('h')- this._thumbInnerContainerSize - this._thumbForwardSize - this._thumbBackwardSize){
							if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
							value=this._getComponentSize('h')- this._thumbInnerContainerSize - this._thumbForwardSize - this._thumbBackwardSize;	
						}else if(value > this._thumbSpacing){
							value=this._thumbSpacing;
						}
						this.thumbInnerContainer.css('top', value+'px');
					}else{
						//center thumbs if less
						this.thumbBackward.css('display','none');
						this.thumbForward.css('display','none');
						this.thumbInnerContainer.css('top', this._getComponentSize('h') / 2 - this._thumbInnerContainerSize / 2 - this._thumbBackwardSize +'px');
					}
				}
			},
			_overPlaylistItem:function (e) {
				if(!this._componentInited || this._playlistTransitionOn) return;
				if (!e) var e = this._window.event;
				if(e.cancelBubble) e.cancelBubble = true;
				else if (e.stopPropagation) e.stopPropagation();
				
				var currentTarget = $(e.currentTarget);
				var id = currentTarget.attr('data-id');
			
				//console.log(currentTarget.find("div[data-title='titleDiv']"));
				var titleDiv = currentTarget.find("div[data-title='titleDiv']");
				if(titleDiv){
					//console.log(currentTarget.height(), titleDiv.height());
					var value=currentTarget.height()-titleDiv.height()-parseInt(titleDiv.css('paddingBottom'),10)-parseInt(titleDiv.css('paddingTop'),10);
					titleDiv.stop().animate({ 'top': value+'px'},  {duration: 300, easing: 'easeOutQuart'});
				}
				
				return false;
			},
			_outPlaylistItem:function (e) {
				if(!this._componentInited || this._playlistTransitionOn) return;
				//console.log('_outPlaylistItem');
				if (!e) var e = this._window.event;
				if(e.cancelBubble) e.cancelBubble = true;
				else if (e.stopPropagation) e.stopPropagation();
				
				var currentTarget = $(e.currentTarget);
				var id = currentTarget.attr('data-id');
				//console.log('id = ', id, ', this._playlistManager.getCounter() = ',  this._playlistManager.getCounter());
				
				if(id == this._playlistManager.getCounter()) return;//active item
				
				var titleDiv = currentTarget.find("div[data-title='titleDiv']");
				if(titleDiv){
					titleDiv.stop().animate({ 'top': currentTarget.height()+'px'},  {duration: 300, easing: 'easeOutQuart'});
				}
				
				return false;
			},
			_clickPlaylistItem:function (e) {
				if(!this._componentInited || this._playlistTransitionOn) return;
				//console.log('this._clickPlaylistItem');
				if (!e) var e = this._window.event;
				if(e.cancelBubble) e.cancelBubble = true;
				else if (e.stopPropagation) e.stopPropagation();
				
				var currentTarget = $(e.currentTarget);
				var id = currentTarget.attr('data-id');
				//console.log(id);
				
				if(id == this._playlistManager.getCounter()) return;//active item
				
				this._enableActiveItem();
				this._playlistManager.processPlaylistRequest(id);
				
				if(this._closePlaylistOnVideoSelect) {
					this._togglePlaylist();
				}
				
				return false;
			},
			_enableActiveItem:function () {
				//console.log('this._enableActiveItem');
				if(this._playlistManager.getCounter()!=-1){
					var _item = $(this._thumbHolderArr[this._playlistManager.getCounter()]);
					_item.css('cursor', 'pointer');
					var titleDiv = _item.find("div[data-title='titleDiv']");
					if(titleDiv) titleDiv.stop().animate({ 'top': _item.height()+'px'},  {duration: 500, easing: 'easeOutQuart'});
				}
			},
			_disableActiveItem:function () {
				//console.log('this._disableActiveItem');
				var _item = $(this._thumbHolderArr[this._playlistManager.getCounter()]);
				_item.css('cursor', 'default');
				var titleDiv = _item.find("div[data-title='titleDiv']");
				var value=_item.height()-titleDiv.height()-parseInt(titleDiv.css('paddingBottom'),10)-parseInt(titleDiv.css('paddingTop'),10);
				if(titleDiv) titleDiv.stop().animate({ 'top': value+'px'},  {duration: 500, easing: 'easeOutQuart'});
			},
			_clickControls:function (e) {
				if(!this._componentInited) return;
				if (!e) var e = this._window.event;
				if(e.cancelBubble) e.cancelBubble = true;
				else if (e.stopPropagation) e.stopPropagation();
			
				var currentTarget = $(e.currentTarget);
				var c=currentTarget.attr('class');
				var img=currentTarget.find('img');
				
				if(c=='this.controls_prev'){
					if(this._playlistTransitionOn) return;
					this._enableActiveItem();
					this._playlistManager.advanceHandler(-1, true);
				}else if(c=='controls_playlist_toggle'){
					if(this._playlistTransitionOn) return;
					this._togglePlaylist(true);//on buttons
				}else if(c=='this.controls_next'){
					if(this._playlistTransitionOn) return;
					this._enableActiveItem();
					this._playlistManager.advanceHandler(1, true);
				}else if(c=='this.player_share'){
					this._toggleShare();
				}
				
				return false;
			},
			_overControls:function (e) {
				if(!this._componentInited) return;
				if (!e) var e = this._window.event;
				if(e.cancelBubble) e.cancelBubble = true;
				else if (e.stopPropagation) e.stopPropagation();
				
				var currentTarget = $(e.currentTarget);
				var c=currentTarget.attr('class');
				var img=currentTarget.find('img');
				
				if(c=='this.controls_prev'){
					this._controlsPrevSrc.attr('src',  $this._iconBackwardOn);
				}else if(c=='controls_playlist_toggle'){
					if(this._playlistOpened){
						this._controlsToggleSrc.attr('src', this._iconCloseOn);
					} else{
						this._controlsToggleSrc.attr('src', this._iconOpenOn);
					}
				}else if(c=='this.controls_next'){
					this._controlsNextSrc.attr('src', $this._iconForwardOn);
				}
				else if(c=='this.thumbBackward'){
					this._thumbBackwardSrc.attr('src', this._thumbOrientation == 'horizontal' ? $this._iconThumbBackwardOn : $this._iconThumbBackwardVOn);
				}
				else if(c=='this.thumbForward'){
					this._thumbForwardSrc.attr('src', this._thumbOrientation == 'horizontal' ? $this._iconThumbForwardOn : $this._iconThumbForwardVOn);
				}else if(c=='this.player_share'){
					img.attr('src', $this._iconShareOn);
				}
				
				return false;
			},
			_outControls:function (e) {
				if(!this._componentInited) return;
				if (!e) var e = this._window.event;
				if(e.cancelBubble) e.cancelBubble = true;
				else if (e.stopPropagation) e.stopPropagation();
				
				var currentTarget = $(e.currentTarget);
				var c=currentTarget.attr('class');
				var img=currentTarget.find('img');
				
				if(c=='this.controls_prev'){
					this._controlsPrevSrc.attr('src', $this._iconBackward);
				}else if(c=='controls_playlist_toggle'){
					if(this._playlistOpened){
						this._controlsToggleSrc.attr('src', this._iconClose);
					} else{
						this._controlsToggleSrc.attr('src', this._iconOpen);
					}
				}else if(c=='this.controls_next'){
					this._controlsNextSrc.attr('src', $this._iconForward);
				}
				else if(c=='this.thumbBackward'){
					this._thumbBackwardSrc.attr('src', this._thumbOrientation == 'horizontal' ? $this._iconThumbBackward : $this._iconThumbBackwardV);
				}
				else if(c=='this.thumbForward'){
					this._thumbForwardSrc.attr('src', this._thumbOrientation == 'horizontal' ? $this._iconThumbForward : $this._iconThumbForwardV);
				}else if(c=='this.player_share'){
					img.attr('src', $this._iconShare);
				}
				
				return false;
			},
			_toggleThumbBg:function (on) {
				//console.log('_toggleThumbBg');
				var value;
				if(this._thumbOrientation == 'horizontal'){
					value=this._thumbInnerContainerStartBuffer + this._finalThumbHeight + this._thumbInnerContainerStartBuffer;
					if(on){
						this.thumbHolder.stop().animate({ 'height': value+'px'},  {duration: 500, easing: 'easeOutQuart'});
						this.thumbBackward.stop().animate({ 'height': value+'px'},  {duration: 500, easing: 'easeOutQuart'});
						this.thumbForward.stop().animate({ 'height': value+'px'},  {duration: 500, easing: 'easeOutQuart'});
					}else{
						this.thumbHolder.stop().animate({ 'height': 0+'px'},  {duration: 500, easing: 'easeOutQuart'});
						this.thumbBackward.stop().animate({ 'height': 0+'px'},  {duration: 500, easing: 'easeOutQuart'});
						this.thumbForward.stop().animate({ 'height': 0+'px'},  {duration: 500, easing: 'easeOutQuart'});
					}
				}else{
					value=this._thumbInnerContainerStartBuffer + this._thumbWidth + this._thumbInnerContainerStartBuffer;
					if(on){
						this.thumbHolder.stop().animate({ 'width': value+'px'},  {duration: 500, easing: 'easeOutQuart'});
						this.thumbBackward.stop().animate({ 'width': value+'px'},  {duration: 500, easing: 'easeOutQuart'});
						this.thumbForward.stop().animate({ 'width': value+'px'},  {duration: 500, easing: 'easeOutQuart'});
					}else{
						this.thumbHolder.stop().animate({ 'width': 0+'px'},  {duration: 500, easing: 'easeOutQuart'});
						this.thumbBackward.stop().animate({ 'width': 0+'px'},  {duration: 500, easing: 'easeOutQuart'});
						this.thumbForward.stop().animate({ 'width': 0+'px'},  {duration: 500, easing: 'easeOutQuart'});
					}
				}
			},
			_togglePlaylist:function (buttons_on) {
				if(this._playlistOpened){
					this._toggleThumbBg();
					this._playlistOpened=false;
					if(buttons_on){
						this._controlsToggleSrc.attr('src', this._iconOpenOn);
					}else{
						this._controlsToggleSrc.attr('src', this._iconOpen);
					}
					if(this._animateVideoSizeOnPlaylistClose){
						if(this._thumbOrientation=='horizontal'){
							this.mediaWrapper.stop().animate({ 'height': this._getComponentSize('h')+'px'},  {duration: 500, easing: 'easeOutQuart'});
							this.youtubeHolder.stop().animate({ 'height': this._getComponentSize('h')+'px'},  {duration: 500, easing: 'easeOutQuart'});
							this.vimeoHolder.stop().animate({ 'height': this._getComponentSize('h')+'px'},  {duration: 500, easing: 'easeOutQuart'});
						}else{
							this.mediaWrapper.stop().animate({ 'width': this._getComponentSize('w')+'px'},  {duration: 500, easing: 'easeOutQuart'});
							this.youtubeHolder.stop().animate({ 'width': this._getComponentSize('w')+'px'},  {duration: 500, easing: 'easeOutQuart'});
							this.vimeoHolder.stop().animate({ 'width': this._getComponentSize('w')+'px'},  {duration: 500, easing: 'easeOutQuart'});
						}
					}
				} else{
					this._toggleThumbBg(true);
					this._playlistOpened=true;
					if(buttons_on){
						this._controlsToggleSrc.attr('src', this._iconCloseOn);
					}else{
						this._controlsToggleSrc.attr('src', this._iconClose);
					}
					if(this._animateVideoSizeOnPlaylistClose){
						var pval;
						if(this._thumbOrientation=='horizontal'){
							if(this._playlistOutside){
								pval = this._getComponentSize('h') - this.settings.playlistOutside.playlistSize;
							}else{
								pval = this._getComponentSize('h') - this._finalThumbHeight - 2 * parseInt(this.thumbInnerContainer.css('top'),10);
							}
							this.mediaWrapper.stop().animate({ 'height': pval+'px'},  {duration: 500, easing: 'easeOutQuart'});
							this.youtubeHolder.stop().animate({ 'height': pval+'px'},  {duration: 500, easing: 'easeOutQuart'});
							this.vimeoHolder.stop().animate({ 'height': pval+'px'},  {duration: 500, easing: 'easeOutQuart'});
						}else{
							if(this._playlistOutside){
								pval = this._getComponentSize('w') - this.settings.playlistOutside.playlistSize;
							}else{
								pval = this._getComponentSize('w') - this._thumbWidth - 2 * parseInt(this.thumbInnerContainer.css('left'),10);
							}
							this.mediaWrapper.stop().animate({ 'width': pval+'px'},  {duration: 500, easing: 'easeOutQuart'});
							this.youtubeHolder.stop().animate({ 'width': pval+'px'},  {duration: 500, easing: 'easeOutQuart'});
							this.vimeoHolder.stop().animate({ 'width': pval+'px'},  {duration: 500, easing: 'easeOutQuart'});
						}
					}
				}
			},
			_cleanPlaylist:function () {
				this.thumbBackward.css('display','none');
				this.thumbForward.css('display','none');
				this._cleanMedia();
				this.thumbInnerContainer.empty();
				this._thumbHolderArr=[];
				if(this._thumbOrientation == 'horizontal'){//scroll on beginning
					this.thumbInnerContainer.css('left', this._thumbSpacing+'px');
				}else{
					this.thumbInnerContainer.css('top', this._thumbSpacing+'px');
				}
			},
			_setPlaylist:function () {
				this._playlistTransitionOn=true;
				this.mediaPreloader.css('display','block');
				this._cleanPlaylist();
				this._getPlaylist();
			},
			_mediaAdvance:function () {
				//console.log('this._mediaAdvance');
				this._enableActiveItem();
				this._playlistManager.advanceHandler(1, true);
			},
			_findMedia:function () {
				//console.log('this._findMedia, c = ', this._playlistManager.getCounter());
				this._cleanMedia();
				var activeItem = this._thumbHolderArr[this._playlistManager.getCounter()];
				this._mediaPath = activeItem.attr('data-path');
				this._mediaType = activeItem.attr('data-type');
				//console.log(this._mediaPath, this._mediaType);
				
				if(this._mediaType == 'vimeo'){
					this._initVimeo();
				}else if(this._mediaType == 'youtube'){
					this._initYoutube();
				}else{
					alert('Error in this._findMedia!');	
				}
			},
			_cleanMedia:function () {
				//console.log('this._cleanMedia');
				if(this._mediaType == 'vimeo'){
					if(this._vimeoPlayer) this._vimeoPlayer.clean();
				}else if(this._mediaType == 'youtube'){
					if(this._youtubePlayer) this._youtubePlayer.stop();
					this.youtubeHolder.css('left', - this._getComponentSize('w')-5+'px');
				}
			},
			_setVolume:function (val) {
				if(this._mediaType == 'vimeo'){
					if(this._vimeoPlayer) this._vimeoPlayer.setVolume(val);
				}else if(this._mediaType == 'youtube'){
					if(this._youtubePlayer) this._youtubePlayer.setVolume(val);
				}
			},
			
			//************* VIMEO
			_initVimeo:function () {
				//console.log('this._initVimeo');
		
				var self=this;
				
				if(!this._vimeoInited){
					var data={'autoPlay': this.autoPlay, 'defaultVolume': this.defaultVolume, 
					'mediaPath': this._mediaPath, 'vimeoHolder': this.vimeoHolder};
					this._vimeoPlayer = $.vimeoPlayer(data);
					
					$(this._vimeoPlayer).bind('ap_VimeoPlayer.END_PLAY', function(){
						if(self._autoAdvanceToNextVideo){
							self._mediaAdvance();
						}else{
							if(self.autoPlay) self._vimeoPlayer.api('play');
						}
					});
					this._vimeoInited=true;
				}else{
					this._vimeoPlayer.initVideo(this._mediaPath);
				}
			},
			
			//**************** YOUTUBE	
			_initYoutube:function () {
				if(!this._youtubeInited){
					var self=this;
					var data={'frameId': this._youtubeFrameId , 'autoPlay': this.autoPlay, 'defaultVolume': this.defaultVolume, 
					'mediaPath': this._mediaPath, 'youtubeHolder': this.youtubeHolder, 'youtubeChromeless': this._youtubeChromeless};
					this._youtubePlayer = $.youtubePlayer(data);
					$(this._youtubePlayer).bind('ap_YoutubePlayer.START_PLAY', function(){
						self.youtubeHolder.css('left', 0+'px');
					});
					$(this._youtubePlayer).bind('ap_YoutubePlayer.END_PLAY', function(){
						if(self._autoAdvanceToNextVideo){
							self._mediaAdvance();
						}else{
							if(self.autoPlay){
								self._youtubePlayer.play();
							}
						}
					});
					this._youtubeInited=true;
				}else{
					this.youtubeHolder.css('left', 0+'px');
					this._youtubePlayer.initVideo(this._mediaPath);
				}
			},
			
			//*********
			_toggleShare:function () {
				if(!this._shareOpened){
					this.shareHolder.css('display','block');
					this._shareOpened = true;	
				}else{
					this.shareHolder.css('display','none');
					this._shareOpened=false;
				}
			},
			_getComponentSize:function (type) {
				if(type == "w"){//width
					return this.componentWrapper.width();
				}else{//height
					return this.componentWrapper.height();
				}
			},
			_getDocumentWidth:function () {
				return Math.max(
					//_doc.width(),
					self._window.width(),
					/* For opera: */
					_doc.documentElement.clientWidth
				);
			},
			_getDocumentHeight:function () {
				return Math.max(
					self._window.height(),
					/* For opera: */
					_doc.documentElement.clientHeight
				);
			},
			_stringCounter:function (i) {
				var s;
				if(i < 9){
					s = "0" + (i + 1);
				}else{
					s = i + 1;
				}
				return s;
			},
			_preventSelect:function (arr) {
				$(arr).each(function() {           
				$(this).attr('unselectable', 'on')
					   .css({
						   '-moz-user-select':'none',
						   '-webkit-user-select':'none',
						   'user-select':'none'
					   })
					   .each(function() {
						   this.onselectstart = function() { return false; };
					   });
				});
			},
			//thumb scroll
			_initScrollBack:function (e) {
				if(this._playlistTransitionOn) return;
				if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
				this._thumbScrollIntervalID = setInterval(this._scrollThumbsBack, 100);
				return false;
			},
			_stopScrollBack:function (e) {
				if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
				return false;
			},
			_scrollThumbsBack:function () {
				var value;
				if(this._thumbOrientation == 'horizontal'){
					value = parseInt(this.thumbInnerContainer.css('left'),10);
					value+=this._thumbsScrollValue;
					if(value > this._thumbSpacing){
						if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
						value=this._thumbSpacing;	
					}
					this.thumbInnerContainer.css('left', value+'px');
				}else{
					value = parseInt(this.thumbInnerContainer.css('top'),10);
					value+=this._thumbsScrollValue;
					if(value > this._thumbSpacing){
						if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
						value=this._thumbSpacing;	
					}
					this.thumbInnerContainer.css('top', value+'px');
				}
			},
			_initScrollForward:function (e) {
				if(this._playlistTransitionOn) return;
				if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
				this._thumbScrollIntervalID = setInterval(this._scrollThumbsForward, 100);
				return false;
			},
			_stopScrollForward:function (e) {
				if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
				return false;
			},
			_scrollThumbsForward:function () {
				var value;
				if(this._thumbOrientation == 'horizontal'){
					value = parseInt(this.thumbInnerContainer.css('left'),10);
					value-=this._thumbsScrollValue;
					if(value < this._getComponentSize('w')- this._thumbInnerContainerSize - this._thumbForwardSize - this._thumbBackwardSize){
						if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
						value=this._getComponentSize('w')- this._thumbInnerContainerSize - this._thumbForwardSize - this._thumbBackwardSize;	
					}
					this.thumbInnerContainer.css('left', value+'px');
				}else{
					value = parseInt(this.thumbInnerContainer.css('top'),10);
					value-=this._thumbsScrollValue;
					if(value < this._getComponentSize('h')- this._thumbInnerContainerSize - this._thumbForwardSize - this._thumbBackwardSize){
						if(this._thumbScrollIntervalID) clearInterval(this._thumbScrollIntervalID);
						value=this._getComponentSize('h')- this._thumbInnerContainerSize - this._thumbForwardSize - this._thumbBackwardSize;	
					}
					this.thumbInnerContainer.css('top', value+'px');
				}
			},
			_setComponents:function () {
				var pval;
				if(this.settings.playlistOutside.orientation == 'horizontal'){
					pval = this._getComponentSize('h') - this.settings.playlistOutside.playlistSize;
					this.mediaWrapper.css('height', pval+'px');
					this.youtubeHolder.css('height', pval+'px');
					this.vimeoHolder.css('height', pval+'px');
					this.thumbHolder.css('top', pval+'px');
				}else{
					pval = this._getComponentSize('w') - this.settings.playlistOutside.playlistSize;
					this.mediaWrapper.css('width', pval+'px');
					this.youtubeHolder.css('width', pval+'px');
					this.vimeoHolder.css('width', pval+'px');
					this.thumbHolder.css('left', pval+'px');
				}
			},
			_resizeHandler:function () {
				if(!this._componentInited) return false;
				if(this._windowResizeIntervalID) clearInterval(this._windowResizeIntervalID);
				this._windowResizeIntervalID = setTimeout(this._doneResizing, this._windowResizeInterval);
			},
			_doneResizing:function () {
				this._componentWidth= parseInt( this.componentWrapper.css('width'), 10);
				this._componentHeight= parseInt( this.componentWrapper.css('height'), 10);
				
				if(this._playlistOutside) this._setComponents();
				
				if(this._thumbOrientation == 'horizontal'){
					this.thumbContainer.css('width', this._getComponentSize('w')-this._thumbBackwardSize-this._thumbForwardSize+'px');
				}else{
					this.thumbContainer.css('height', this._getComponentSize('h')-this._thumbBackwardSize-this._thumbForwardSize+'px');
				}
				if(!this._playlistTransitionOn) this._checkThumbPosition();
			}
			
	}; /* VideoGallery.prototype end */
	
	$.fn.videoGallery = function(options) {    	
		return this.each(function(){
			var videoGallery = new VideoGallery($(this), options);
			$(this).data("videoGallery", videoGallery);
			
			//PUBLIC METHODS
			$.fn.videoGallery.getMediaID = function() {	
				return videoGallery.getMediaID();
			}
                        $.fn.videoGallery.getDescription = function(c) {	
				return videoGallery.getDescription(c);
			}
			$.fn.videoGallery.playMedia = function() {	
				videoGallery.playMedia();
			}
			$.fn.videoGallery.pauseMedia = function() {	
				videoGallery.pauseMedia();
			}
			$.fn.videoGallery.nextMedia = function() {	
				videoGallery.nextMedia();
			}
			$.fn.videoGallery.previousMedia = function() {	
				videoGallery.previousMedia();
			}
			$.fn.videoGallery.loadMedia = function(num) {	
				videoGallery.loadMedia(num);
			}
			$.fn.videoGallery.destroyMedia = function() {	
				videoGallery.destroyMedia();
			}
			$.fn.videoGallery.togglePlaylistState = function() {	
				videoGallery.togglePlaylistState();
			}
			$.fn.videoGallery.setVolume = function(val) {	
				videoGallery.setVolume(val);
			}
			$.fn.videoGallery.inputPlaylist = function(id) {	
				videoGallery.inputPlaylist(id);
			}
			
		});
	};

	$.fn.videoGallery.defaults = {   
	
			<!-- this._componentFixedSize: true/false. If you use 100% for width/height, or both on #componentWrapper in css, set this to false. -->
			componentFixedSize: false,
			/* _playlistOutside: Special setting for having video 100% this._window size minus the playlist size. 
			_componentFixedSize has to be 'false' for 
			value: true/false, 
			orientation: horizontal/vertical,
			playlistSize: value in pixels, we have put 170 because we know this is going to be the height of the thumbnails(150) + 2 x thumbInnerContainer top/left position(10)=170.
			Since _thumbWidth is 200, height is going to be 150 (under current vimeo/youtube thumbnail dimenstions/ratios) */
			playlistOutside: {value: false, orientation: 'horizontal', playlistSize: 170},
			/*_animateVideoSizeOnPlaylistClose: enlarge video on playlist close to full component size. Use if thumb playlist is not over the component but on its side. */
			animateVideoSizeOnPlaylistClose: false,
			/*_thumbOrientation: horizontal, vertical (for scrolling) */
			thumbOrientation: 'horizontal',
			/*this.defaultVolume: 0-1 */
			defaultVolume:0.5,
			/*activePlaylist: enter element 'id' attributte */
			activePlaylist:'preview1',
			/*activeVideo: video number to start with (-1 = none, 0 = first, 1 = second, 2 = third ...etc) */
			activeVideo:0,
			/*this.autoPlay: true/false (video autoplay) */
			autoPlay:true,
			/* this.loopingOn: loop playlist on end, true/false */
			loopingOn:true,
			/* this.randomPlay: random play in playlist, true/false */
			randomPlay:false,
			/*autoAdvanceToNextVideo: true/false */
			autoAdvanceToNextVideo:true,
			/* youtubeChromeless: use youtube player without controls. true/false */
			youtubeChromeless:false,
			/* thumbWidth: width of the thumb, height will be proportionally calculated (in the case of horizontal thumbOrientation) */
			thumbWidth: 200,
			/* thumbHeight: height of the thumb, width will be proportionally calculated (in the case of vertical thumbOrientation) */
			thumbHeight: 120,
			/* thumbsScrollValue: speed of the thumb scroll (number bigger than 0) */
			thumbsScrollValue: 150,
			/* autoOpenPlaylist: open playlist on start (true/false) */
			autoOpenPlaylist: true,
			/* closePlaylistOnVideoSelect: close playlist on video select (only for full component size and playlist click) */
			closePlaylistOnVideoSelect: false,
			/* this.thumbBackgroundColor: background color behind thumbs, visible only until thumb loads */
			thumbBackgroundColor: '#222',
			/* thumbSpacing: margin between thumbnails (set top/left overall thumb position in css for #componentWrapper .this.thumbInnerContainer) */
			thumbSpacing: 10,
			
                        iconLoader: 'data/loader.gif',
                        iconClose: 'data/icons/close.png',
                        iconCloseOn: 'data/icons/close_on.png',
                        iconOpen: 'data/icons/open.png',
                        iconOpenOn: 'data/icons/open_on.png',
                        iconBackwardOn: 'data/icons/backward_on.png',
                        iconBackward: 'data/icons/backward.png',
                        iconForwardOn: 'data/icons/forward_on.png',
                        iconForward: 'data/icons/forward.png',
                        iconShare: 'data/icons/share.png',
                        iconShareOn: 'data/icons/share_on.png',
                        iconThumbForward: 'data/icons/thumb_forward.png',
                        iconThumbForwardV: 'data/icons/thumb_forward_v.png',
                        iconThumbForwardOn: 'data/icons/thumb_forward_on.png',
                        iconThumbForwardVOn: 'data/icons/thumb_forward_v_on.png',
                        iconThumbBackward: 'data/icons/thumb_backward.png',
                        iconThumbBackwardV: 'data/icons/thumb_backward_v.png',
                        iconThumbBackwardOn: 'data/icons/thumb_backward_on.png',
                        iconThumbBackwardVOn: 'data/icons/thumb_backward_v_on.png',

			videoGallerySetupDone: function(){},        //Callback, triggers when component is ready to receive public function calls
			videoGalleryPlaylistEnd: function(){}        // Callback, triggers when playlist comes to an end (looping or not)
			//http://stackoverflow.com/questions/2534436/jquery-plugin-adding-callback-functionality
			
	}; /* default options end */

	$.fn.videoGallery.settings = {};

})(jQuery);




/**
 * jQuery.browser.mobile (http://detectmobilebrowser.com/)
 *
 * jQuery.browser.mobile will be true if the browser is a mobile device
 *
 **/
(function(a){jQuery.browser.mobile=/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera);


