// ==UserScript==
// @name          Videoembed
// @description	 一个自动在“猛击这里查看视频”之类的链接后面嵌入视频的脚本
// @include       *
// @namespace   http://hergonan.blogspot.com/
// @copyright     2009, Firtina Ozbalikci
// @license         GPL 3 or later
// @version        5.09
// @exclude        http://youtube.*
// @exclude        http://*.youtube.*
// @exclude        http://glumbert.*
// @exclude        http://*.glumbert.*
// @exclude        http://metacafe.*
// @exclude        http://*.metacafe.*
// @exclude        http://video.google.*
// @exclude        http://animeepisodes.*
// @exclude        http://*.animeepisodes.*
// @exclude        http://myvideo.*
// @exclude        http://*.myvideo.*
// @exclude        http://video.tinypic.*
// @exclude        http://video.yahoo.*
// @exclude        http://spike.*
// @exclude        http://*.spike.*
// @exclude        http://vids.myspace.*
// @exclude        http://liveleak.*
// @exclude        http://*.liveleak.*
// @exclude        http://revver.*
// @exclude        http://*.revver.*
// @exclude        http://vimeo.*
// @exclude        http://*.vimeo.*
// @exclude        http://veoh.*
// @exclude        http://*.veoh.*
// @exclude        http://guba.*
// @exclude        http://*.guba.*
// @exclude        http://gamevideos.1up.*
// @exclude        http://gametrailers.*
// @exclude        http://*.gametrailers.*
// @exclude        http://pikniktube.*
// @exclude        http://*.pikniktube.*
// @exclude        http://tudou.*
// @exclude        http://*.tudou.*
// @exclude        http://collegehumor.*
// @exclude        http://*.collegehumor.*
// @exclude        http://5min.*
// @exclude        http://*.5min.*
// @exclude        http://ustream.*
// @exclude        http://*.ustream.*
// @exclude        http://fliggo.*
// @exclude        http://*.fliggo.*
// @exclude        http://overlay.*
// @exclude        http://*.overlay.*
// @exclude        http://webshots.*
// @exclude        http://*.webshots.*
// @exclude        http://clipshack.*
// @exclude        http://*.clipshack.*
// @exclude        http://cnettv,cnet.*
// @exclude        http://crackle.*
// @exclude        http://*.crackle.*
// @exclude        http://current.*
// @exclude        http://*.current.*
// @exclude        http://expertvillage.*
// @exclude        http://*.expertvillage.*
// @exclude        http://funnyordie.*
// @exclude        http://*.funnyordie.*
// @exclude        http://godtube.*
// @exclude        http://*.godtube.*
// @exclude        http://justin.*
// @exclude        http://*.justin.*
// @exclude        http://livevideo.*
// @exclude        http://*.livevideo.*
// @exclude        http://putfile.*
// @exclude        http://*.putfile.*
// @exclude        http://12seconds.*
// @exclude        http://*.12seconds.*
// @exclude        http://selfcasttv.*
// @exclude        http://*.selfcasttv.*
// @exclude        http://sevenload.*
// @exclude        http://*.sevenload.*
// @exclude        http://spikedhumor.*
// @exclude        http://*.spikedhumor.*
// @exclude        http://jumpcut.*
// @exclude        http://*.jumpcut.*
// @exclude        http://*.gamecorner.*
// @exclude        http://gamecorner.*
// ==/UserScript==

//---------------------------------------------------------------------------------------------------
//    Copyright (C) 2008  Firtina Ozbalikci
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    For a copy of the latest GNU General Public License, see <http://www.gnu.org/licenses/gpl.html>.

// If you distribute a modified version of Videoembed, you are encouraged to use
// my name in the credits, and a copy of the license above.
//---------------------------------------------------------------------------------------------------

var defaultSites = [
	{
		n:'Youtube',
		l:'^http:\/\/([a-zA-Z0-9]+\.|)youtube\.com\/.*v=([a-zA-Z0-9_-]+).*',
		args:[
       			 ['match','v=([a-zA-Z0-9_-]+)',1],
			],
		width:425,
		height:344,
		embed:'http://www.youtube.com/v/{0}&hl=en&fs=1', //&ap=%2526fmt=18
	},
	{
		n:'Glumbert',
		l:'^http:\/\/([a-zA-Z0-9]+\.|)glumbert\.com\/media\/([a-zA-Z0-9]+)',
		args:[
       			 ['match','/media/([a-zA-Z0-9]+)',1],
			],
		width:448,
		height:336,
		embed:'http://www.glumbert.com/embed/{0}'
	},
	{
		n:'Metacafe',
		l:'^http:\/\/([a-zA-Z0-9]+\.|)metacafe\.com\/watch\/([a-zA-Z0-9-]+)',
		args:[
			['match','/watch/([a-zA-Z0-9-]+)',1],
			],
		width:400,
		height:345,
		embed:'http://www.metacafe.com/fplayer/{0}/.swf',
	},
	{
		n:'Google',
		l:'^http://video\.google\.(.+).+docid=([a-zA-Z0-9-]+).',
		args:[
			['match','docid=([a-zA-Z0-9-]+)',1],
			],
		width:400,
		height:326,
		embed:'http://video.google.com/googleplayer.swf?docid={0}&fs=true',
	},
	{
		n:'Anime Episodes',
		l:'^http://([a-zA-Z0-9]+\.|)animeepisodes\.net/video/([a-zA-Z0-9-]+)',
		args:[
			['match','/video/([a-zA-Z0-9-]+)',1],
			['match','http://([a-zA-Z0-9]+\.|).animeepisodes\.net/video',1],
			],
		width:428,
		height:352,
		embed:'http://{1}.animeepisodes.net/vidiac.swf',
		attr:[
			['FlashVars','video={0}'],
			],
	},
	{
		n:'Myvideo',
		l:'^http://([a-zA-Z0-9]+\.|)myvideo.(.+)/watch/([a-zA-Z0-9-]+)',
		args:[
			['match','/watch/([a-zA-Z0-9-]+)',1],
			],
		width:470,
		height:406,
		embed:'http://www.myvideo.at/movie/{0}',
	},
	{
		n:'Tinypic',
		l:'^http://video\.tinypic\.com/.*v=([a-zA-Z0-9]+)',
		args:[
			['match','v=([a-zA-Z0-9]+)',1],
			],
		width:440,
		height:420,
		embed:'http://v1.tinypic.com/player.swf?file={0}&s=1',
	},
	{
		n:'Yahoo',
		l:'^http://video\.yahoo\.com/watch/([0-9]+)/([0-9]+)',
		args:[
			['match','/watch/([0-9]+)/',1],
			['match','/watch/([0-9]+)/([0-9]+)',2],
			],
		width:512,
		height:322,
		attr:[
			['FlashVars','id={1}&vid={0}'],
			],
		embed:'http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf?ver=2.2.30',
	},
	{
		n:'Spike',
		l:'^http://([a-zA-Z0-9]+\.|)(ifilm|spike)\.com/video/.+/([0-9]+)',
		args:[
			['match','video/.+/([0-9]+)',1],
			],
		width:448,
		height:365,
		attr:[
			['flashvars','flvbaseclip={0}'],
			],
		embed:'http://www.spike.com/efp',
	},
	{
		n:'Youtube Playlist',
		l:'^http://([a-zA-Z0-9]+\.|)youtube\.com/view_play_list.*p=([a-zA-Z0-9_-]+)',
		args:[
			['match','p=([a-zA-Z0-9_-]+)',1],
			],
		width:480,
		height:385,
		embed:'http://www.youtube.com/p/{0}',
	},
	{
		n:'Myspace',
		l:'^http://vids\.myspace\.com/.*[vV]ideo[iI][dD]=([0-9]+)',
		args:[
			['match','[vV]ideo[iI][dD]=([0-9]+)',1],
			],
		width:425,
		height:360,
		embed:'http://mediaservices.myspace.com/services/media/embed.aspx/m={0},t=1,mt=video,searchID=,primarycolor=,secondarycolor=',
	},
	{
		n:'Liveleak',
		l:'^http://([a-zA-Z0-9]+\.|)liveleak\.com/view.*i=([a-zA-Z0-9_]+)',
		args:[
			['match','i=([a-zA-Z0-9_]+)',1],
			],
		width:450,
		height:370,
		embed:'http://www.liveleak.com/e/{0}',
	},
	{
		n:'Revver',
		l:'^http://([a-zA-Z0-9]+\.|)revver\.com/(watch|video)/([0-9]+)',
		args:[
			['match','(watch|video)/([0-9]+)*(/|)',2],
			],
		width:480,
		height:392,
		embed:'http://flash.revver.com/player/1.0/player.swf',
		attr:[
			['flashvars','mediaId={0}'],
			],
	},
	{
		n:'Vimeo',
		l:'^http://([a-zA-Z0-9]+\.|)vimeo\.com.*[/=:]([0-9]+)',
		args:[
			['match','vimeo\.com.*[/=:]([0-9]+)',1],
			],
		width:400,
		height:300,
		attr:[
			['flashvars','clip_id={0}&server=vimeo.com&autoplay=0&fullscreen=1&md5=0&show_portrait=0&show_title=0&show_byline=0&force_embed=0&multimoog=&color=00ADEF'],
			],
		embed:'http://vimeo.com/moogaloop_local.swf?ver=19465',
	},
	{
		n:'Veoh',
		l:'^http://([a-zA-Z0-9]+\.|)veoh\..+videos/[a-zA-Z0-9]+',
		args:[
			['match','videos/([a-zA-Z0-9]+)',1],
			],
		width:410,
		height:341,
		embed:'http://www.veoh.com/videodetails.swf?permalinkId={0}&id=1&player=videodetailsembedded&videoAutoPlay=0',
		//embed:'http://www.veoh.com/veohplayer.swf?permalinkId={0}&id=anonymous&player=videodetailsembedded&videoAutoPlay=0',
	},
	{
		n:'Guba',
		l:'^http://([a-zA-Z0-9]+\.|)guba\..+/watch/([a-zA-Z0-9]+)',
		args:[
			['match','watch/([a-zA-Z0-9]+)',1],
			],
		width:375,
		height:360,
		embed:'http://www.guba.com/f/root.swf?bid={0}&isEmbeddedPlayer=true',
	},
	{
		n:'Gamevideos',
		l:'^http://gamevideos\.1up\.com/video/id/([0-9]+)',
		args:[
			['match','id/([a-zA-Z0-9]+)',1],
			],
		width:500,
		height:319,
		embed:'http://gamevideos.1up.com/swf/gamevideos11.swf?embedded=1&amp;fullscreen=1&amp;autoplay=0&amp;src=http://gamevideos.1up.com/video/videoListXML?id={0}&amp;adPlay=true',
	},
	{
		n:'Gametrailers',
		l:'^http://([a-zA-Z0-9]+\.|)gametrailers\.com\/player\/([0-9]+)',
		args:[
			['match','\/([0-9]+)',1],
			],
		width:480,
		height:392,
		embed:'http://www.gametrailers.com/remote_wrap.php?mid={0}',
	},
	{
		n:'Pikniktube',
		l:'^http://([a-zA-Z0-9]+\.|)pikniktube\.com/video.+Video=([a-zA-Z0-9]+)',
		args:[
			['match','Video=([a-zA-Z0-9]+)',1],
			],
		width:340,
		height:320,
		embed:'http://www.pikniktube.com/player/videoplayer2.swf',
		attr:[
			['flashvars','linktarget=_blank&embedded=1&xmlsrc=http://www.pikniktube.com/getxmle.asp?q={0}&a=1&c=0'],
			],
	},
	{
		n:'Tudou single',
		l:'^http://([a-zA-Z0-9]+\.|)tudou\.com/programs/view/([a-zA-Z0-9]+)',
		args:[
			['match','view/([a-zA-Z0-9]+)',1],
			],
		width:488,
		height:423,
		embed:'http://www.tudou.com/v/{0}',
	},
	{
		n:'Tudou playlist',
		l:'^http://([a-zA-Z0-9]+\.|)tudou\.com/playlist/id/([a-zA-Z0-9]+)',
		args:[
			['match','id/([a-zA-Z0-9]+)',1],
			],
		width:488,
		height:423,
		embed:'http://www.tudou.com/player/playlist.swf?lid={0}',
	},
	{
		n:'Collegehumor',
		l:'^http://([a-zA-Z0-9]+\.|)collegehumor\.com.+video[:=]([0-9]+)',
		args:[
			['match','video[:=]([0-9]+)',1],
			],
		width:480,
		height:360,
		embed:'http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id={0}&fullscreen=1',
	},
	{
		n:'5min',
		l:'^http://([a-zA-Z0-9]+\.|)5min\.com/[vV]ideo/[a-zA-Z0-9-]+-([0-9]+)',
		args:[
			['match','[a-zA-Z0-9-]+-([0-9]+)',1],
			],
		width:480,
		height:401,
		embed:'http://www.5min.com/Embeded/{0}/',
	},
	{
		n:'Ustream',
		l:'^http://([a-zA-Z0-9]+\.|)ustream\.tv.+recorded/([0-9]+)',
		args:[
			['match','recorded/([0-9]+)',1],
			],
		width:400,
		height:320,
		embed:'http://www.ustream.tv/flash/video/{0}',
		attr:[
			['flashvars','viewcount=false&autoplay=false&brand=embed'],
			],
	},
	{
		n:'Fliggo',
		l:'^http://([a-zA-Z0-9]+\.|)fliggo\.com/video/[a-zA-Z0-9]+',
		args:[
			['match','video/([a-zA-Z0-9]+)',1],
			],
		width:425,
		height:355,
		embed:'http://www.fliggo.com/embed/{0}',
	},
	{
		n:'Overlay',
		l:'^http://([a-zA-Z0-9]+\.|)overlay\.tv/overlay/[0-9]+',
		args:[
			['match','overlay/([0-9]+)',1],
			],
		width:504,
		height:475,
		embed:'http://static.overlay.tv/images/media/authoringtool.swf',
		attr:[
			['flashvars','overlay_id={0}&host=http://www.overlay.tv/&name=embed_config&config_gen=http://static.overlay.tv/player_config/generate'],
			],
	},
	{
		n:'Webshots',
		l:'^http://([a-zA-Z0-9]+\.|)webshots\.(com|net)/video/[0-9]+',
		args:[
			['match','video/([0-9]+)',1],
			],
		width:425,
		height:350,
		embed:'http://p.webshots.com/flash/smallplayer.swf?videoFile=http://videoserve.webshots.com/video/9659/{0}_v_0.flv&audio=on&displayImagePreview=http://videothumb20.webshots.com/thumb/9659/{0}still_002_0.jpg&videoPageUrl=http://travel.webshots.com/video/{0}&autoPlay=false&shareLink=http://cards.webshots.com/ecard/personalize?photoId={0}&source=v',
	},
	{
		n:'Clipshack',
		l:'^http://([a-zA-Z0-9]+\.|)clipshack\.com/.*key=([a-zA-Z0-9]+)',
		args:[
			['match','key=([a-zA-Z0-9]+)',1],
			],
		width:430,
		height:370,
		embed:'http://www.clipshack.com/player.swf?key={0}',
	},
	{
		n:'Cnet',
		l:'^http://cnettv\.cnet\.com/[0-9_-]+-([0-9]+)',
		args:[
			['match','[0-9_-]+-([0-9]+)',1],
			],
		width:335,
		height:360,
		embed:'http://www.cnet.com/av/video/flv/newPlayers/universal.swf',
		attr:[
			['flashvars','playerType=embedded&value={0}'],
			],
	},
	{
		n:'Crackle',
		l:'^http://([a-zA-Z0-9]+\.|)crackle\.com/c.+/([0-9]+)',
		args:[
			['match','c.+/([0-9]+)',1],
			['match','crackle\.com/c(.+)/[0-9]+',1],
			],
		width:400,
		height:328,
		embed:'http://crackle.com/p{1}.swf',
		attr:[
			['flashvars','id={0}'],
			],
	},
	{
		n:'Current',
		l:'^http://([a-zA-Z0-9]+\.|)current\.com/items/[0-9]+',
		args:[
			['match','items/([0-9]+)',1],
			],
		width:400,
		height:340,
		embed:'http://current.com/e/{0}/en_UK',
	},
	{
		n:'Expertvillage',
		l:'^http://([a-zA-Z0-9]+\.|)expertvillage\.com/video/([0-9a-zA-Z_-]+)\.htm',
		args:[
			['match','video/([0-9a-zA-Z_-]+)\.htm',1],
			],
		width:491,
		height:424,
		embed:'http://cdn-www.expertvillage.com/player.swf?flv={0}',
	},
	{
		n:'Funnyordie',
		l:'^http://([a-zA-Z0-9]+\.|)funnyordie\.com/videos/[a-zA-Z0-9]+',
		args:[
			['match','videos/([a-zA-Z0-9]+)',1],
			],
		width:464,
		height:388,
		embed:'http://www2.funnyordie.com/public/flash/fodplayer.swf?5320a921',
		attr:[
			['flashvars','key={0}'],
			],
		
	},
	{
		n:'Godtube',
		l:'^http://([a-zA-Z0-9]+\.|)godtube\.com/.*viewkey=([a-zA-Z0-9]+)',
		args:[
			['match','viewkey=([a-zA-Z0-9]+)',1],
			],
		width:330,
		height:270,
		embed:'http://godtube.com/flvplayer.swf',
		attr:[
			['flashvars','viewkey={0}'],
			],
	},
	{
		n:'Justin',
		l:'^http://([a-zA-Z0-9]+\.|)justin\.tv.*/([a-zA-Z0-9]+)',
		args:[
			['match','http://([a-zA-Z0-9]+\.|)justin\.tv.*/([a-zA-Z0-9]+)',2],
			],
		width:320,
		height:263,
		embed:'http://www.justin.tv/widgets/jtv_player.swf?channel={0}',
	},
	{
		n:'Livevideo',
		l:'^http://([a-zA-Z0-9]+\.|)livevideo\.com/liveshow/[a-zA-Z0-9]+',
		args:[
			['match','liveshow/([a-zA-Z0-9]+)',1],
			],
		width:423,
		height:270,
		embed:'http://www.livevideo.com/livetv/embed/{0}',
	},
	{
		n:'Putfile',
		l:'^http://([a-zA-Z0-9]+\.|)putfile\.com.*/([a-zA-Z0-9-]+)',
		args:[
			['match','http://([a-zA-Z0-9]+\.|)putfile\.com.*/([a-zA-Z0-9-]+)',2],
			],
		width:420,
		height:349,
		embed:'http://feat.putfile.com/flow/putfile.swf?videoFile={0}',
	},
	{
		n:'12Seconds',
		l:'^http://([a-zA-Z0-9]+\.|)12seconds\.tv/channel/.*/([0-9]+)',
		args:[
			['match','channel/.*/([0-9]+)',1],
			],
		width:430,
		height:360,
		embed:'http://embed.12seconds.tv/players/remotePlayer.swf',
		attr:[
			['flashvars','vid={0}'],
			],
	},
	{
		n:'Selfcasttv',
		l:'^http://([a-zA-Z0-9]+\.|)selfcasttv\.com/Selfcast/playVideo.*ref=[a-zA-Z0-9/]+',
		args:[
			['match','ref=([a-zA-Z0-9/]+)',1],
			],
		width:340,
		height:283,
		embed:'http://www.selfcasttv.com/Selfcast/selfcast.swf?video_1=/{0}',
	},
	{
		n:'Sevenload',
		l:'^http://([a-zA-Z0-9]+\.|)sevenload\.com/videos/[a-zA-Z0-9]+',
		args:[
			['match','videos/([a-zA-Z0-9]+)',1],
			],
		width:500,
		height:314,
		embed:'http://static.sevenload.com/swf/player/player.swf',
		attr:[
			['flashvars','configPath=http%3A%2F%2Fflash.sevenload.com%2Fplayer%3FportalId%3Den%26autoplay%3D0%26itemId%3D{0}&amp;locale=en_US&amp;autoplay=0&amp;environment='],
			],
	},
	{
		n:'Spikedhumor',
		l:'^http://([a-zA-Z0-9]+\.|)spikedhumor\.com/articles/[0-9]+',
		args:[
			['match','articles/([0-9]+)',1],
			],
		width:385,
		height:285,
		embed:'http://www.spikedhumor.com/player/vcplayer.swf?file=http://www.spikedhumor.com/videocodes/{0}/data.xml&auto_play=false',
	},
	{
		n:'Jumpcut',
		l:'^http://([a-zA-Z0-9]+\.|)jumpcut\.com/.*id=([a-zA-Z0-9]+)',
		args:[
			['match','id=([a-zA-Z0-9]+)',1],
			],
		width:408,
		height:324,
		embed:'http://www.jumpcut.com/media/flash/jump.swf?id={0}&asset_type=movie&asset_id={0}&eb=1',
	},
	{
		n:'Gamecorner',
		l:'^http://([a-zA-Z0-9]+\.|)gamecorner\.pl/gamecorner/[0-9]+,[0-9]+,[0-9]+',
		args:[
			['match','gamecorner/[0-9]+,([0-9]+),[0-9]+',1],
			['match','gamecorner/[0-9]+,[0-9]+,([0-9]+)',1],
			],
		width:425,
		height:350,
		embed:'http://bi.gazeta.pl/im/loader.swf',
		attr:[
			['flashvars','m=http://serwisy.gazeta.pl/getDaneWideo?xx={1}%26xxd={0}&e=1&f=http://bi.gazeta.pl/im/'],
			],
	},
	
/*
	{
		n:'',
		l:'^',
		args:[
			['match','',1],
			],
		width:,
		height:,
		embed:'',
	},
*/
		
]

//var sss = '';for(var ii=0;ii<defaultSites.length;ii++){sss += defaultSites[ii].n + '<br>';}document.write(defaultSites.length);

var gfx = {
	minus : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAw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BUsQJZWIM00xD5HAoCkL6QtqsrHK1iWZlo5rMR/eeE5nYUoToDYA5y7gZjDKW8AZGKQZ9/iUxWR23PgOYPtkaZsAqRdGxQ89YFofp2U6wSHZ1SmJAls/JmNj8FacD65COszAwhePKBxhJzQ9LnErAHOwhogCkuQPFs3GTlP2l+R8mKg3uOYPnVRayaTigsPQ3V00wIg4RzcmclS4VADinAVB/9cYj1Ufg6T0NZfAfOCkkoDi9KYolINuLkIItFugWktKgJJFkxUCzEIK152P09BMmBF/ImRDYBHvDATDwmiW7kPsxRAspMxGJmCTXHuqlJM7D5O2AmlygQh2J5QzAW3pCc7ZTFQubFEzgONcAR8sC+3wZ3716k7l9FqbAKvq0PyYmHsOrboezsCt9Ir/yCPjsMR9MZKrHcFJqtSvXxcncllBov3Hv6kZ2cRHJqBM3H+zWuqvyCv/OskRy/pkEy2LwHNiZcdFF9zkoQXteNzKd5/Bi9hZoT17VAsCXKqpuTXJyOLL+9o/lyC6htscG+T1RmWYoF8H14HCl7C4J9N7UdbUejfzanal8/T0TGnt3VfPWN0PXXWNctJFJt+Db1EZdv39Na2w7/vXKbLdJ/TraGekmqAiOnI2vk8H7sOZ4OjrDNOI4tJmmETcFGtB9sRzwex5epafB/UP8hhsOntEj0iramCwhhwWUHogPnL23F/RZgALZtJ5mXblnLAAAAAElFTkSuQmCC",
	close : "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%20%00%00%00%20%08%06%00%00%00szz%F4%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%0AOiCCPPhotoshop%20ICC%20profile%00%00x%DA%9DSgTS%E9%16%3D%F7%DE%F4BK%88%80%94KoR%15%08%20RB%8B%80%14%91%26*!%09%10J%88!%A1%D9%15Q%C1%11EE%04%1B%C8%A0%88%03%8E%8E%80%8C%15Q%2C%0C%8A%0A%D8%07%E4!%A2%8E%83%A3%88%8A%CA%FB%E1%7B%A3k%D6%BC%F7%E6%CD%FE%B5%D7%3E%E7%AC%F3%9D%B3%CF%07%C0%08%0C%96H3Q5%80%0C%A9B%1E%11%E0%83%C7%C4%C6%E1%E4.%40%81%0A%24p%00%10%08%B3d!s%FD%23%01%00%F8~%3C%3C%2B%22%C0%07%BE%00%01x%D3%0B%08%00%C0M%9B%C00%1C%87%FF%0F%EAB%99%5C%01%80%84%01%C0t%918K%08%80%14%00%40z%8EB%A6%00%40F%01%80%9D%98%26S%00%A0%04%00%60%CBcb%E3%00P-%00%60'%7F%E6%D3%00%80%9D%F8%99%7B%01%00%5B%94!%15%01%A0%91%00%20%13e%88D%00h%3B%00%AC%CFV%8AE%00X0%00%14fK%C49%00%D8-%000IWfH%00%B0%B7%00%C0%CE%10%0B%B2%00%08%0C%000Q%88%85)%00%04%7B%00%60%C8%23%23x%00%84%99%00%14F%F2W%3C%F1%2B%AE%10%E7*%00%00x%99%B2%3C%B9%249E%81%5B%08-q%07WW.%1E(%CEI%17%2B%146a%02a%9A%40.%C2y%99%192%814%0F%E0%F3%CC%00%00%A0%91%15%11%E0%83%F3%FDx%CE%0E%AE%CE%CE6%8E%B6%0E_-%EA%BF%06%FF%22bb%E3%FE%E5%CF%ABp%40%00%00%E1t~%D1%FE%2C%2F%B3%1A%80%3B%06%80m%FE%A2%25%EE%04h%5E%0B%A0u%F7%8Bf%B2%0F%40%B5%00%A0%E9%DAW%F3p%F8~%3C%3CE%A1%90%B9%D9%D9%E5%E4%E4%D8J%C4B%5Ba%CAW%7D%FEg%C2_%C0W%FDl%F9~%3C%FC%F7%F5%E0%BE%E2%24%812%5D%81G%04%F8%E0%C2%CC%F4L%A5%1C%CF%92%09%84b%DC%E6%8FG%FC%B7%0B%FF%FC%1D%D3%22%C4Ib%B9X*%14%E3Q%12q%8ED%9A%8C%F32%A5%22%89B%92)%C5%25%D2%FFd%E2%DF%2C%FB%03%3E%DF5%00%B0j%3E%01%7B%91-%A8%5Dc%03%F6K'%10Xt%C0%E2%F7%00%00%F2%BBo%C1%D4(%08%03%80h%83%E1%CFw%FF%EF%3F%FDG%A0%25%00%80fI%92q%00%00%5ED%24.T%CA%B3%3F%C7%08%00%00D%A0%81*%B0A%1B%F4%C1%18%2C%C0%06%1C%C1%05%DC%C1%0B%FC%606%84B%24%C4%C2B%10B%0Ad%80%1Cr%60)%AC%82B(%86%CD%B0%1D*%60%2F%D4%40%1D4%C0Qh%86%93p%0E.%C2U%B8%0E%3Dp%0F%FAa%08%9E%C1(%BC%81%09%04A%C8%08%13a!%DA%88%01b%8AX%23%8E%08%17%99%85%F8!%C1H%04%12%8B%24%20%C9%88%14Q%22K%915H1R%8AT%20UH%1D%F2%3Dr%029%87%5CF%BA%91%3B%C8%002%82%FC%86%BCG1%94%81%B2Q%3D%D4%0C%B5C%B9%A87%1A%84F%A2%0B%D0dt1%9A%8F%16%A0%9B%D0r%B4%1A%3D%8C6%A1%E7%D0%ABh%0F%DA%8F%3EC%C70%C0%E8%18%073%C4l0.%C6%C3B%B18%2C%09%93c%CB%B1%22%AC%0C%AB%C6%1A%B0V%AC%03%BB%89%F5c%CF%B1w%04%12%81E%C0%096%04wB%20a%1EAHXLXN%D8H%A8%20%1C%244%11%DA%097%09%03%84Q%C2'%22%93%A8K%B4%26%BA%11%F9%C4%18b21%87XH%2C%23%D6%12%8F%13%2F%10%7B%88C%C47%24%12%89C2'%B9%90%02I%B1%A4T%D2%12%D2F%D2nR%23%E9%2C%A9%9B4H%1A%23%93%C9%DAdk%B2%079%94%2C%20%2B%C8%85%E4%9D%E4%C3%E43%E4%1B%E4!%F2%5B%0A%9Db%40q%A4%F8S%E2(R%CAjJ%19%E5%10%E54%E5%06e%982AU%A3%9AR%DD%A8%A1T%115%8FZB%AD%A1%B6R%AFQ%87%A8%134u%9A9%CD%83%16IK%A5%AD%A2%95%D3%1Ah%17h%F7i%AF%E8t%BA%11%DD%95%1EN%97%D0W%D2%CB%E9G%E8%97%E8%03%F4w%0C%0D%86%15%83%C7%88g(%19%9B%18%07%18g%19w%18%AF%98L%A6%19%D3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7%EF%06%F1v%BE%8CVDt%F7%F0%C1%85%3CP%26%0E%91%7B%B8%F1%25%9E%7B%3As%FF%DBN%00%16E%B4%9DC%F7%99t%0E3%FC%1A%BF%DF9%E9v%1C%EF%BE%0D%FF%EF%09%FCm%003%80Qd%00%03%60%FD%00%00%00%00IEND%AEB%60%82"
}

var pushed=new Array();
var sites = defaultSites;
//var inter;
var settings;
var page_links;
//var ve_embed;

curlinkid = 0;

function checklinks2(){
	//if(page_links.length>1000)
	//return
	
	for (var i=0; i<page_links.length; i++){
		for(var ii=0;ii<sites.length;ii++){
			cursite = sites[ii]
			curlink = page_links[i]
			if(curlink.href.match(cursite.l) != null){
				var tp = replacer(cursite,curlink,cursite.n+':{0}');
				if((pushed.indexOf(tp) == -1 || settings.mode != "auto")&&(curlink.getAttribute("vembedded") != 1)) 
				{
					doit(cursite,curlink);
					curlink.setAttribute("vembedded",1);
					pushed.push(tp);
				}
				break;
			}
		}
	}
}

function checklinks3(){
	//if(page_links.length>1000)
	//return
	j = 0;
	toinc = settings.increment;
	if(toinc == -1)
		toinc = 5;
	for (; j<toinc; j++){
		i = curlinkid + j;
		
		if(i==page_links.length){
			break;
		}
		
		for(var ii=0;ii<sites.length;ii++){
			cursite = sites[ii]
			curlink = page_links[i]
			if(curlink.href.match(cursite.l) != null){
				var tp = replacer(cursite,curlink,cursite.n+':{0}');
				if((pushed.indexOf(tp) == -1 || settings.mode != "auto")&&(curlink.getAttribute("vembedded") != 1)) 
				{
					doit(cursite,curlink);
					curlink.setAttribute("vembedded",1);
					pushed.push(tp);
				}
				break;
			}
		}
		
	}
	
	curlinkid += j;
	if(curlinkid<page_links.length){
		window.setTimeout(checklinks3, 5);
	}
	//}
}
function doit(cursite,curlink)
{
	curlink.emb = document.createElement("embed");
	curlink.emb.setAttribute('allowFullScreen','true');
	curlink.emb.setAttribute('src',replacer(cursite,curlink,cursite.embed));
	curlink.emb.setAttribute('type','application/x-shockwave-flash');
	curlink.emb.setAttribute('width',cursite.width);
	curlink.emb.setAttribute('height',cursite.height);
	curlink.emb.setAttribute('bgcolor','#000000');
	curlink.emb.setAttribute('allowScriptAccess','always');
	if(cursite.attr){
		for(var iii=0;iii<cursite.attr.length;iii++){
			curlink.emb.setAttribute(cursite.attr[iii][0],replacer(cursite,curlink,cursite.attr[iii][1]));
		}
	}
	var mode = settings.mode;
	switch(mode){
		case 'auto':
			curlink.parentNode.insertBefore(document.createElement("br"),curlink.nextSibling);
			curlink.parentNode.insertBefore(curlink.emb,curlink.nextSibling);
			curlink.parentNode.insertBefore(document.createElement("br"),curlink.nextSibling);
			break;
		case 'google':
			curlink.button = document.createElement("label");
			curlink.func = function(curlink){return function(){embed(curlink);};}(curlink)
			curlink.func2 = function(curlink){return function(){unembed(curlink);};}(curlink);
			curlink.button.addEventListener('click',curlink.func,false);
			curlink.button.innerHTML = '<img style="position:relative !important; left:0 !important; right:0 !important; bottom:0 !important; top:0 !important;float:none !important; border:0 !important;padding:0 !important;margin:0 !important;width: 12px !important; height:12px !important" src="'+gfx.plus+'">';
			curlink.button.setAttribute("id",replacer(cursite,curlink,cursite.n+':{0}'));
			curlink.parentNode.insertBefore(curlink.button,curlink);
			curlink.emb.google = {src:replacer(cursite,curlink,cursite.embed),t:0,height:cursite.height};
			curlink.emb.setAttribute('height',0);
			curlink.emb.setAttribute('src','');
			curlink.cont = document.createElement("span");
			curlink.cont.appendChild(document.createElement("br"));
			curlink.cont.appendChild(curlink.emb);
			curlink.cont.appendChild(document.createElement("br"));
			break;
		case 'lightbox':
			curlink.button = document.createElement("label");
			curlink.func = function(cursite,curlink){return function(){box(cursite,curlink);};}(cursite,curlink);
			curlink.button.addEventListener('click',curlink.func,false);
			curlink.button.innerHTML = '<img style="position:relative !important; left:0 !important; right:0 !important; bottom:0 !important; top:0 !important;float:none !important; border:0 !important;padding:0 !important;margin:0 !important; width: 14px !important; height:15px !important" src="'+gfx.bulb+'">';
			curlink.button.setAttribute("id",replacer(cursite,curlink,cursite.n+':{0}'));
			curlink.parentNode.insertBefore(curlink.button,curlink);
	}
}
var NVF_UPDATEINTERVAL = 15;
var arr = [];
var arr2 = [];
var maxtime = 10;
function embed(curlink){
	curlink.parentNode.insertBefore(curlink.cont,curlink.nextSibling);
	curlink.button.removeEventListener('click',curlink.func,false);
	if(arr.indexOf([curlink.href,curlink]) == -1) 
		arr.push([curlink.href,curlink]);
}
function unembed(curlink){
	curlink.emb.setAttribute('src','');
	curlink.button.removeEventListener('click',curlink.func2,false);
	if(arr2.indexOf([curlink.href,curlink]) == -1) 
		arr2.push([curlink.href,curlink]);
}
function updv(){
	var i;
	for(i=0;i<arr.length;i++){
		curlink = arr[i][1];
		curlink.emb.setAttribute('height',curlink.emb.google.height*(curlink.emb.google.t/maxtime));
		curlink.emb.google.t++;
		if(curlink.emb.google.t==maxtime){
			curlink.emb.setAttribute('height',curlink.emb.google.height);
			curlink.emb.setAttribute('src',curlink.emb.google.src);
			curlink.button.innerHTML = '<img style="position:relative !important; left:0 !important; right:0 !important; bottom:0 !important; top:0 !important;float:none !important; border:0 !important;padding:0 !important;margin:0 !important;width: 12px !important; height:12px !important" src="'+gfx.minus+'">';
			curlink.button.addEventListener('click',curlink.func2,false);
			arr.splice(i,1);
		}
	}
	for(i=0;i<arr2.length;i++){
		curlink = arr2[i][1];
		curlink.emb.setAttribute('height',curlink.emb.google.height*(curlink.emb.google.t/maxtime));
		curlink.emb.google.t--;
		if(curlink.emb.google.t==0){
			curlink.emb.setAttribute('height',0);
			curlink.button.innerHTML = '<img style="position:relative !important; left:0 !important; right:0 !important; bottom:0 !important; top:0 !important;float:none !important; border:0 !important;padding:0 !important;margin:0 !important;width: 12px !important; height:12px !important" src="'+gfx.plus+'">';
			curlink.button.addEventListener('click',curlink.func,false);
			curlink.parentNode.removeChild(curlink.cont);
			arr2.splice(i,1);
		}
	}
}
function replacer(cursite,curlink,from)
{
	function replacex(str,p1){
		var method = cursite.args[p1][0];
    		switch (method) {
			case 'match':
				return curlink.href.match(cursite.args[p1][1])[cursite.args[p1][2]];
			case undefined:
				return eval(cursite.args[p1][1]);
		}
	}
	return from.replace(/{([0-9]+)}/g,replacex);
}


GM_registerMenuCommand("Videoembed options", optmenu);
function optmenu()
{
	if(settings.mode == "lightbox")
		unbox();
	var head, style, body;
	head = document.getElementsByTagName('head')[0];
	body = document.getElementsByTagName('body')[0];
	if (!head) { return; }
	style = document.createElement('style');
	style.type = 'text/css';
	style.innerHTML = '.vembopt_overlay{display: none;position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: black;z-index:999998;-moz-opacity: 1;opacity:1;filter: alpha(opacity=100);} .vembopt_white_content {width:100%;height:100%;display:block;vertical-align:middle;color:white;background-color: black;z-index:999999;overflow: auto;} .vembopt{min-width:300;min-height:200;padding:10;width:50%;height:50%;text-align:left;position:absolute;background-color:gray;left:25%;top:25%;border:2px solid white;color:black} .vembopt label{font-weight: bold;}';
	head.appendChild(style);
	blackoverlay = document.createElement("div");
	whitecontent = document.createElement("div");
	whitecontent.setAttribute("name","whitecontent");
	blackoverlay.setAttribute("name","blackoverlay");
	blackoverlay.setAttribute("class","vembopt_overlay");
	whitecontent.setAttribute("class","vembopt_white_content");
	body.appendChild(blackoverlay);
	blackoverlay.appendChild(whitecontent);
	//blackoverlay.addEventListener('click',unbox,false);
	blackoverlay.setAttribute("style","display:block");
	optdiv = document.createElement("div");
	optdiv.setAttribute('class','vembopt');
	whitecontent.appendChild(optdiv);
	optdiv.innerHTML = '<center><b>&nbsp;&nbsp;&nbsp;Videoembed Options&nbsp;&nbsp;&nbsp;</b></center>'
	optdiv.appendChild(document.createElement("hr"));
	var modelabel = document.createElement("label");
	modelabel.setAttribute("style","color:black");
	modelabel.innerHTML = "mode: ";
	optdiv.appendChild(modelabel);
	var modeselect = document.createElement("select");
	modeselect.name = "modeselect";
	var objopt;
		objopt = document.createElement("option");
		objopt.text = "Auto";
		objopt.value = "auto";
		modeselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Google";
		objopt.value = "google";
		modeselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Lightbox ( beta )";
		objopt.value = "lightbox";
		modeselect.options.add(objopt);
	modeselect.value = settings.mode;
	optdiv.appendChild(modeselect);
	optdiv.appendChild(document.createElement("br"));
	var sizeselect = document.createElement("select");
	var sizelabel = document.createElement("label");
	sizelabel.setAttribute("style","color:black");
	sizelabel.innerHTML = "size: ";
	optdiv.appendChild(sizelabel);
		objopt = document.createElement("option");
		objopt.text = "Half";
		objopt.value = "0.5";
		sizeselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Regular";
		objopt.value = "1";
		sizeselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Supersize";
		objopt.value = "1.5";
		sizeselect.options.add(objopt);
	sizeselect.value = settings.size;
	sizeselect.name = "sizeselect";
	optdiv.appendChild(sizeselect);
	optdiv.appendChild(document.createElement("br"));	
	var colorlabel = document.createElement("label");
	colorlabel.setAttribute("style","color:black");
	colorlabel.innerHTML = "youtube color: ";
	colorselect = document.createElement("select");
	colorselect.name = "colorselect";
	optdiv.appendChild(colorlabel);
		objopt = document.createElement("option");
		objopt.text = "Default";
		objopt.value = "";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Storm(dark gray + light gray)";
		objopt.value = "&color1=0x3a3a3a&color2=0x999999";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Iceberg(dark blue + light blue)";
		objopt.value = "&color1=0x2b405b&color2=0x6b8ab6";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Acid(light blue + lighter blue)";
		objopt.value = "&color1=0x006699&color2=0x54abd6";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Green(dark green + light green)";
		objopt.value = "&color1=0x234900&color2=0x4e9e00";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Orange(orange + yellow)";
		objopt.value = "&color1=0xe1600f&color2=0xfebd01";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Pink";
		objopt.value = "&color1=0xcc2550&color2=0xe87a9f";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Purple";
		objopt.value = "&color1=0x402061&color2=0x9461ca";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Rubyred";
		objopt.value = "&color1=0x5d1719&color2=0xcd311b";
		colorselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Black";
		objopt.value = "&color1=0x000000&color2=0x000000";
		colorselect.options.add(objopt);
	colorselect.value = settings.youtube.color;
	optdiv.appendChild(colorselect);
	optdiv.appendChild(document.createElement("br"));	
	var hqlabel = document.createElement("label");
	hqlabel.setAttribute("style","color:black");
	hqlabel.innerHTML = "youtube high quality: ";
	hqselect = document.createElement("select");
	hqselect.name = "hqselect";
	optdiv.appendChild(hqlabel);
		objopt = document.createElement("option");
		objopt.text = "Yes";
		objopt.value = "&ap=%2526fmt%3D18";
		hqselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "No";
		objopt.value = "";
		hqselect.options.add(objopt);
	hqselect.value = settings.youtube.hq;
	optdiv.appendChild(hqselect);
	optdiv.appendChild(document.createElement("br"));	
	var inclabel = document.createElement("label");
	inclabel.setAttribute("style","color:black");
	inclabel.innerHTML = "increment per run: ";
	incselect = document.createElement("select");
	incselect.name = "incselect";
	optdiv.appendChild(inclabel);
		objopt = document.createElement("option");
		objopt.text = "5";
		objopt.value = 5;
		incselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "10";
		objopt.value = 10;
		incselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "15";
		objopt.value = 15;
		incselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "20";
		objopt.value = 20;
		incselect.options.add(objopt);
		objopt = document.createElement("option");
		objopt.text = "Infinite(for fast computers)";
		objopt.value = -1;
		incselect.options.add(objopt);
	incselect.value = settings.increment;
	optdiv.appendChild(incselect);
	optdiv.appendChild(document.createElement("hr"));
	infolabel = document.createElement("label");
	infolabel.setAttribute("style","color:black");
	infolabel.innerHTML = "If you want to open the config again, right click the Greasemonkey button (on the bottom-right of the browser) and navigate to: Userscript Commands -> Videoembed options.";
	optdiv.appendChild(infolabel);
	cent = document.createElement("center")
	optdiv.appendChild(document.createElement("hr"));
	var savebutton = document.createElement("button");
	savebutton.innerHTML = "Save & Reload page";
	savebutton.addEventListener('click',saveopts,false);
	var cancelbutton = document.createElement("button");
	cancelbutton.innerHTML = "Cancel";
	cancelbutton.addEventListener('click',cancel,false);
	cent.appendChild(savebutton);
	cent.appendChild(cancelbutton);
	optdiv.appendChild(cent);
}
function cancel(){
	for(i in document.body.getElementsByTagName("div")){
		//alert(document.body.getElementsByTagName("div")[i].getAttribute("name"));
		if(document.body.getElementsByTagName("div")[i]){
			if (document.body.getElementsByTagName("div")[i].getAttribute("name") == "whitecontent" || document.body.getElementsByTagName("div")[i].getAttribute("name") == "blackoverlay"){
				document.body.removeChild(document.body.getElementsByTagName("div")[i])
				i = i - 1
			}
		}
	}
}
function saveopts(){
	settings.mode = document.getElementsByName("modeselect")[0].value;
	settings.size = document.getElementsByName("sizeselect")[0].value;
	settings.youtube.color = document.getElementsByName("colorselect")[0].value;
	settings.youtube.hq = document.getElementsByName("hqselect")[0].value;
	settings.increment = document.getElementsByName("incselect")[0].value;
	GM_setValue('settings',uneval(settings));
	window.location.reload();
}

function checkupd(){
	var d = new Date();
	if (GM_getValue('lastcheck') == d.getDate()) {
		return
	}
	GM_setValue('lastcheck',d.getDate());
	var elmInsertPoint = document.body;
	var elmD = document.createElement("div");
	elmD.setAttribute('style',"position:fixed;background:white;border:1px solid yellow;bottom:0")
	var elmA = document.createElement("a");
	elmA.setAttribute('style',"color:black")
	elmA.setAttribute("href", "http://userscripts.org/scripts/show/7686");
	elmA.innerHTML = 'Checking for new version of Videoembed';
	elmD.appendChild(elmA)
	elmInsertPoint.insertBefore(elmD, elmInsertPoint.lastChild);
	GM_xmlhttpRequest({
		method:"GET",
		url:'http://userscripts.org/scripts/source/7686.user.js',
		onload:function(result) {
			if (result.responseText.indexOf('@version        5.09') == -1) {
				upddiv = document.createElement("div")
				upddiv.setAttribute('style','padding:10;position:fixed;background:black;border:2px solid gray;left:5px;bottom:5px;color:white');
				upddiv.innerHTML = '<a style="color:white;visited color:white" href="http://userscripts.org/scripts/show/7686">There is a new version of the "videoembed" userscript. Click here to install it!</a>';
				document.body.appendChild(upddiv);
				elmA.setAttribute('style',"display:none")
			}
			else
				elmA.setAttribute('style',"display:none")
		}
	});
}

if(window==window.top)
{
	options();
}

function options(){
	if(!GM_getValue('settings')){
		settings = {
			mode : 'auto',
			size: 1,
			youtube : {
				color: "",
				hq: "",
			},
		};
		optmenu();
	}
	else{
		eval('settings = '+GM_getValue('settings'));
		init();
	}
}

var whitecontent;
var blackoverlay;
function init(){
	checkupd()
	for(var ii=0;ii<sites.length;ii++){
		cursite = sites[ii]
		if (cursite.n != "12Seconds" && cursite.n != "Current"){
			cursite.width = cursite.width * settings.size;
			cursite.height = cursite.height * settings.size;
		}
		if(cursite.n == "Youtube")
			cursite.embed = cursite.embed + settings.youtube.color + settings.youtube.hq;
	}
	if(settings.youtube.hq == undefined)
	{
		settings.youtube.hq = ""
	}
	if(settings.increment == undefined)
	{
		settings.increment = 10;
	}
	if(settings.mode == "lightbox"){
		ve_background = document.createElement("div");
		ve_background.setAttribute("style","position:fixed;background:black;top:0;left:0;width:100%;height:100%;opacity:0.9;z-index:999999");
		ve_embed = document.createElement("embed");
		ve_embed.setAttribute('allowFullScreen','true');
		ve_embed.setAttribute('type','application/x-shockwave-flash');
		ve_embed.setAttribute('bgcolor','#000000');
		ve_embed.setAttribute('allowScriptAccess','always');
		//ve_background.appendChild(ve_embed);
		ve_label = document.createElement("label");
		ve_label.setAttribute("style","color:white;position:absolute;top:0%;left:50%;")
		ve_background.appendChild(ve_label);
		ve_close = document.createElement("img");
		ve_close.setAttribute("src",gfx.close);
		ve_close.setAttribute("style","position:absolute;top:0;right:0;opacity:1;width:2.5%");
		ve_close.addEventListener('click', unbox, false);
		ve_background.appendChild(ve_close);
		ve_background.style.visibility = 'hidden';
		ve_embed.style.visibility = 'hidden';
		document.getElementsByTagName('body')[0].appendChild(ve_background);
		ve_background.appendChild(ve_embed);
		/*
		blackoverlay = document.createElement("div");
		whitecontent = document.createElement("div");
		blackoverlay.setAttribute("class","vemb_overlay");
		whitecontent.setAttribute("class","vemb_white_content");
		boxlabel = document.createElement("label");
		boxlabel.setAttribute("style","color:white");
		var head, style, body;
		head = document.getElementsByTagName('head')[0];
		body = document.getElementsByTagName('body')[0];
		if (!head) { return; }
		style = document.createElement('style');
		style.type = 'text/css';
		style.innerHTML = '.vemb_overlay{display: none;position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: black;z-index:999998;-moz-opacity: 0.9;opacity:.90;filter: alpha(opacity=90);} .vemb_white_content {width:50%;height:50%;display:table-cell;vertical-align:middle;text-align:center;background-color: black;z-index:999999;overflow: auto;}';
		head.appendChild(style);
		body.appendChild(blackoverlay);
		blackoverlay.appendChild(whitecontent);
		whitecontent.appendChild(boxlabel);
		whitecontent.addEventListener('click',unbox,false);
		*/
	}
	else if(settings.mode == "google"){
		inter = setInterval(updv, NVF_UPDATEINTERVAL);
	}
	
	page_links = document.links;
	if(settings.increment==-1)
		checklinks2();
	else
		checklinks3();
	window.addEventListener('load', reallystart, false);
}

function box(cursite,curlink){
	
	for (asd in document.getElementsByTagName('embed','object')){
		node = document.getElementsByTagName('embed','object')[asd];
		if(node != ve_embed && node ){
			node.style.visibility = "hidden";
		}
	}
	
	ve_label.innerHTML = curlink.innerHTML
	while(ve_label.getElementsByTagName("*")[0]){
		ve_label.removeChild(ve_label.getElementsByTagName("*")[0]);
	}
	ve_label.setAttribute("style","color:white;position:absolute;top:0%;left:"+(50-(ve_label.offsetWidth*100/window.innerWidth)/2)+"%;")
	
	//ve_embed.setAttribute("style","position:absolute;top:5%;left:"+(50-(cursite.width/2))+"%;width:"+cursite.width+"%;height:"+cursite.height+"%;opacity:1");
	//ve_embed.setAttribute('width',cursite.width);
	//ve_embed.setAttribute('height',cursite.height);
	if(cursite.attr){
		for(var iii=0;iii<cursite.attr.length;iii++){
			ve_embed.setAttribute(cursite.attr[iii][0],replacer(cursite,curlink,cursite.attr[iii][1]));
		}
	}
	ve_background.style.visibility = "visible"
	ve_embed.style.visibility = 'visible';
	ve_embed.setAttribute('src',replacer(cursite,curlink,cursite.embed));
	if(cursite.n == "Current" || cursite.n == "Gamecorner" || cursite.n =="12Seconds" ){
		ve_embed.setAttribute("style","position:absolute;top:"+(50-(cursite.height*100/window.innerHeight)/2)+"%;left:"+(50-(cursite.width*100/window.innerWidth)/2)+"%;width:"+cursite.width+"px;height:"+cursite.height+"px;opacity:1");
	}
	else{
		ve_embed.setAttribute("style","position:absolute;top:2.5%;left:2.5%;width:95%;height:95%;opacity:1");
	}
	ve_background.removeChild(ve_embed);
	ve_background.appendChild(ve_embed);
}

function unbox(){
	for (asd in document.getElementsByTagName('embed','object')){
		node = document.getElementsByTagName('embed','object')[asd];
		if(node != ve_embed && node ){
			node.style.visibility = 'visible';
		}
	}
	ve_embed.setAttribute("src","");
	ve_background.style.visibility = 'hidden';
		ve_embed.style.visibility = 'hidden';
}
function reallystart(){
	//if(settings.increment==-1)
	//	checklinks2();
	//else
	page_links = document.links;
	curlinkid = 0;
		window.setTimeout(checklinks3, 20);
}

if (window.Pagerization) {
	window.Pagerization.addEventListener('addPage', checklinks2);
}
