var VIDEOCLICK=false;

VideoclickRun();

function VideoclickRun() {
	if (!_rbn.v.ad || _rbn.v.ad.length == 0) {
		setTimeout(VideoclickRun, 5000);
		return;
	}
	if (typeof(window._vc_run)!='undefined') {
		return;
	}
	window._vc_run = true;
	VIDEOCLICK = new Videoclick(_rbn.v.ad);
	if (_rbn != null && _rbn.v != null) {
		if (_rbn.v.inline_color != null) {
			VIDEOCLICK.w_style.color = _rbn.v.inline_color;
		}
		if (_rbn.v.is_use_marked != null) {
			VIDEOCLICK.params.use_marked = _rbn.v.is_use_marked;
		}
		if (_rbn.v.autostart_video != null) {
			VIDEOCLICK.params.autostart_video = _rbn.v.autostart_video;
		}
		if (_rbn.v.ad.length > 0 && _rbn.v.ad[0].lt && _rbn.v.ad[0].lt == "any") {
			VIDEOCLICK.params.inline_limit = 0;
		} else if (_rbn.v.inline_count_max != null) {
			VIDEOCLICK.params.inline_limit = _rbn.v.inline_count_max;
		}
		if (_rbn.v.ad.length > 0 && _rbn.v.ad[0].lm && _rbn.v.ad[0].lm == "dummy") {
			VIDEOCLICK.params.link_dummy = true;
		}
		if (_rbn.v.link_tags != null) {
			for (var i in _rbn.v.link_tags) {
				VIDEOCLICK.skip[_rbn.v.link_tags[i]] = 0;
			}
		}
		if (_rbn.v.w_style != null) {
			VIDEOCLICK.w_style = _rbn.v.w_style;
		}
	}
	VIDEOCLICK.run();
}

function _rbn_close() {
	_rbn_ev('close');
}

function _rbn_ev(ev) {
	var i = VIDEOCLICK.show_id, ads = VIDEOCLICK.ads;
	switch (ev) {
		case 'click':
		case 'close':
			setTimeout(function () {
				if (VIDEOCLICK.show_id > -1) {
					VIDEOCLICK.hideBanner(VIDEOCLICK.show_id);
				}
			}, 0);
			break;
		case 'ready':
			if (ads[i] && !ads[i].trace) {
				if (ads[i].trace_url) {
					VIDEOCLICK.cacheFile(ads[i].trace_url+'&ul='+VIDEOCLICK.location);
				}
				if (ads[i].trace_url2 && ads[i].trace_url2.length > 0) {
					VIDEOCLICK.cacheFile(ads[i].trace_url2);
				}
				if (ads[i].tci) {
					var tc = {"1": "autoplayerstart", "2": "bussinesplayerstart", "3": "smiplayerstart", "4": "softplayerstart", "5": "womanplayerstart"};
					if (tc[ads[i].tci]) {
						VIDEOCLICK.cacheFile("http://www.tns-counter.ru/V13a***R>"+document.referrer.replace(/\*/g,'%2a')+"*mediatoday_ru/ru/CP1251/tmsec=mediatoday_"+tc[ads[i].tci]+"/");
					}
				}
				VIDEOCLICK.ads[i].trace = true;
			}
			break;
		case 'quarter':
			if (ads[i] && ads[i].evq) {
				VIDEOCLICK.cacheFile(ads[i].evq);
			}
			break;
		case 'half':
			if (ads[i] && ads[i].evh) {
				VIDEOCLICK.cacheFile(ads[i].evh);
			}
			break;
		case 'threequarters':
			if (ads[i] && ads[i].evtq) {
				VIDEOCLICK.cacheFile(ads[i].evtq);
			}
			break;
		case 'complete':
			if (ads[i] && ads[i].evc) {
				VIDEOCLICK.cacheFile(ads[i].evc);
			}
			break;
	}
}

function Videoclick(ads) {
	this.ads = ads;
	this.params = {
		'use_marked'   : false,
		'inline_limit' : 5,
		'info_url' : 'http://videoclick.ru/',
		'show_timeout' : 100,
		'hide_timeout' : 700,
		'autostart_video': true,
		'link_dummy'   : false
	};
	this.skip = {
		'SCRIPT': 1,'NOSCRIPT': 1,'H1': 1,'H2': 1,'H3': 1,'H4': 1,'H5': 1,'H6': 1,'BIG': 1,'A': 1,'TH': 1,'FIELDSET': 1,'TEXTAREA': 1,'SELECT': 1,'LEGEND': 1,'ACRONYM': 1,'ADDRESS': 1,'LABEL': 1
	}
	this.w_bounds = '(^|$|[^0-9a-zA-Zа-яА-ЯёЁ_])';
	this.neg = [];
	this.negr = [];
	this.blocks = [];
	this.words = [];
	this.w_style = {
		'cursor'            : 'pointer',
		'color'             : '#009900',
		'textDecoration'    : 'none',
		'borderStyle'       : 'solid',
		'borderWidth'       : '0 0 1px 0'
	};
	this.dist_min = 300;
	this.dist_max = 800;
	this.dist2_min = 2000;
	this.dist2_max = 2500;
	this.showTimer = false;
	this.hideTime = false;
	this.show_id = -1;
	this.location = escape(window.location.href);

	this.run = function() {
		var n = document.getElementsByTagName("body")[0];
		this.prepareRegexp();
		this.scanBlocks(n);
		if (this.scanNeg()) {
			return;
		}
		this.scanWords();
		this.sendInlined();
	}

	this.prepareRegexp = function() {
		var i, j, n, w;
		for (i = 0; i < this.ads.length; i++) {
			this.ads[i].words = this.ads[i].keyword.split(";");
			this.ads[i].words.sort(function(){return (Math.round(Math.random())-0.5);});
			this.ads[i].regexp = new Array();
			this.ads[i].negr = new Array();
			this.ads[i].prefs = new Array();
			this.ads[i].inlined = new Array();
			this.ads[i].word = new Array();
			this.ads[i].wt = new Array();
			this.ads[i].skip = false;
			this.ads[i].wid = 0;
			for (j = 0; j < this.ads[i].words.length; j++) {
				w = this.ads[i].words[j];
				if (w.substr(w.length - 1, 1) == '*') {
					w = w.substr(0, w.length - 1) + '[0-9a-zA-Zа-яА-ЯёЁ_]+';
				}
				this.ads[i].regexp[j] = new RegExp(this.w_bounds + '(' + w + ')' + this.w_bounds, 'ig');
				this.ads[i].inlined[j] = false;
			}
			n = this.ads[i].negative.split(";");
			for (j = 0; j < n.length; j++) {
				if (n[j] != "") {
					this.ads[i].negr.push(new RegExp(this.w_bounds + '(' + n[j] + ')' + this.w_bounds, 'ig'));
				}
			}
			if (this.ads[i].prefixes) {
				n = this.ads[i].prefixes.split(";");
				for (j = 0; j < n.length; j++) {
					if (n[j] != "") {
						this.ads[i].prefs.push(new RegExp(n[j], 'ig'));
					}
				}
			}
		}
		for (i = 0; i < this.neg.length; i++) {
			this.negr[i]= new RegExp(this.w_bounds + '(' + this.neg[i] + ')' + this.w_bounds,'ig');
		}
	}

	this.scanBlocks = function(n, b) {
		if (n.nodeType == 3) {
			if (this.params.use_marked && !b) {
				return;
			}
			if (n.data.replace(/\s+/g, "")) {
				this.blocks.push(n);
			}
		} else {
			for (var i = n.firstChild; i != null; i = i.nextSibling) {
				if (this.skip[i.nodeName.toUpperCase()] == 1) {
					continue;
				}
				if (i.className) {
					if (i.className.indexOf("_noreachbanner_") != -1) {
						continue;
					}
					if (typeof(i.id)=="string" && i.id.indexOf("y5_direct") != -1) {
						continue;
					}
					if (i.className.indexOf("_reachbanner_") != -1) {
						this.scanBlocks(i, true);
						continue;
					}
				}
				this.scanBlocks(i, b);
			}
		}
	}

	this.scanNeg = function() {
		var i, j, k, r, n;
		for (k = 0; k < this.blocks.length; k++) {
			n = this.blocks[k];
			for (i = 0; i < this.negr.length; i++) {
				r = this.negr[i].exec(n.data);
				if (r != null) {
					return true;
				}
			}
			for (i = 0; i < this.ads.length; i++) {
				for (j = 0; j < this.ads[i].negr.length; j++) {
					r = this.ads[i].negr[j].exec(n.data);
					if (r != null) {
						this.ads[i].skip = true;
						break;
					}
				}
			}
		}
		return false;
	}

	this.negPrefix = function(txt, pos, prefs) {
		var i, pb, pe, len, pref;
		if (pos == 0) {
			return false;
		}
		for (pe = pos - 1; pe > 0; pe--) {
			if (txt.substr(pe, 1).search(/[0-9a-zA-Zа-яА-ЯёЁ_]/i) >= 0) {
				break;
			}
		}
		if (pe > 0) {
			pb = -1;
			for (i = pe; i >= 0; i--) {
				if (txt.substr(i, 1).search(/[^0-9a-zA-Zа-яА-ЯёЁ_]/i) >= 0) {
					pb = i;
					break;
				}
			}
			if (pb == -1) {
				pref = txt.substr(0, pe + 1);
			} else {
				pref = txt.substr(pb + 1, pe - pb);
			}
			len = prefs.length;
			for (i = 0; i < len; i++) {
				if (pref.search(prefs[i]) != -1) {
					return true;
				}
			}
		}
		return false;
	}

	this.scanWords = function() {
		var i, j, m, n, k, r, mi, mv, n, nn, p, w, wi, wm, wp, ws, ws2, words = [], stat = {}, res = [];
		p = 0;
		for (k = 0; k < this.blocks.length; k++) {
			n = this.blocks[k];
			for (i = 0; i < this.ads.length; i++) {
				if (this.ads[i].skip) {
					continue;
				}
				for (j = 0; j < this.ads[i].words.length; j++) {
					r = this.ads[i].regexp[j].exec(n.data);
					if (r != null) {
						if (this.ads[i].prefs.length && this.negPrefix(n.data, r.index + r[1].length, this.ads[i].prefs)) {
							continue;
						}
						w = {};
						w.aid = i;
						w.wid = this.ads[i].wid++;
						w.nid = k;
						w.pos = r.index + r[1].length;
						w.gpos = p + w.pos;
						w.len = r[2].length;
						w.word = n.data.substr(w.pos, w.len);
						words.push(w);
					}
				}
			}
			p += n.data.length;
		}
		words.sort(function(a,b){return a.gpos-b.gpos;});
		if (this.params.link_dummy) {
			res = [];
			for (i = 0; i < words.length; i++) {
				if (!(i > 0 && words[i].gpos == words[i - 1].gpos)) {
					res.push(words[i])
				}
			}
		} else {
			for (i = 0; i < this.ads.length; i++) {
				stat[i] = 0;
			}
			j = 0;
			for (i = 0; i < words.length; i++) {
				if (i > 0 && words[i].gpos == words[i - 1].gpos) {
					res[j - 1].push(words[i])
				} else {
					w = [];
					w.push(words[i]);
					res[j++] = w;
				}
			}
			words = res;
			res = [];
			if (words.length > 0) {
				n = 0;
				res[n++] = words[0][0];
				stat[res[0].aid]++;
				for (i = 1; i < words.length; i++) {
					ws = words[i];
					wp = res[n - 1];
					if (n > 4) {
						if (ws[0].gpos - wp.gpos < this.dist2_max) {
							continue;
						}
					} else if (ws[0].gpos - wp.gpos < this.dist_max) {
						continue;
					}
					wi = i;
					wm = 0;
					for (j = wi; j > 0; j--) {
						ws2 = words[j];
						if (n > 4) {
							if (ws2[0].gpos - wp.gpos < this.dist2_min) {
								break;
							}
						} else if (ws2[0].gpos - wp.gpos < this.dist_min) {
							break;
						}
						for (m = 0; m < ws2.length; m++) {
							if (stat[ws2[m].aid] < stat[words[wi][wm].aid]) {
								wi = j;
								wm = m;
							}
						}
					}
					res[n++] = words[wi][wm];
					stat[words[wi][wm].aid]++;
				}
			}
		}
		if (res.length) {
			if (this.params.inline_limit) {
				res = res.slice(0, this.params.inline_limit);
			}
			this.inlineWords(res);
		}
	}
	
	this.inlineWords = function(res) {
		var i, j, w, p, nd = {}, nn, pn, b, bt, a, k, im, d;
		for (i = 0; i < res.length; i++) {
			w = res[i];
			if (typeof(nd[w.nid])=='undefined') {
				nd[w.nid] = [];
			}
			nd[w.nid].push(w);
		}
		for (i in nd) {
			p = 0;
			nn = [];
			b = this.blocks[i];
			bt = b.data;
			for (j = 0; j < nd[i].length; j++) {
				w = nd[i][j];
				d = this.ads[w.aid];
				nn.push(document.createTextNode(bt.substr(p, w.pos - p)));
				a = document.createElement("A");
				a.href = 'javascript://';
				for (k in this.w_style) {
					a.style[k] = this.w_style[k];
				}
				a.onmouseover = new Function('VIDEOCLICK.eventWordMouseOver('+w.aid+','+w.wid+')');
				a.onmouseout = new Function('VIDEOCLICK.eventWordMouseOut('+w.aid+','+w.wid+')');
				a.appendChild(document.createTextNode(bt.substr(w.pos, w.len)));
				if (w.len < 32) {
					this.ads[w.aid].wt.push(this.encode(bt.substr(w.pos, w.len).toLowerCase()));
				}
				nn.push(a);
				if (typeof(d.icon_url) != "undefined" & d.icon_url != '') {
					im = document.createElement("IMG");
					im.src = d.icon_url;
					im.width = (typeof(d.icon_width) != "undefined" && d.icon_width != '') ? d.icon_width : '12';
					im.height = (typeof(d.icon_height) != "undefined" && d.icon_height != '') ? d.icon_height : '12';
					im.style.borderWidth = '0';
					im.style.margin = '0 0 0 3px';
					im.style.padding = '0';
					im.style.cssFloat = 'none';
					im.style.styleFloat = 'none';
					im.style.display = 'inline';
					nn.push(im);
				}
				this.ads[w.aid].word[w.wid] = a;
				p = w.pos + w.len;
			}
			if (bt.length > p) {
				nn.push(document.createTextNode(bt.substr(p)))
			}
			pn = b.parentNode;
			if (pn) {
				while (nn.length > 0) {
					b=pn.insertBefore(nn.pop(), b);
				}
				pn.removeChild(this.blocks[i]);
			}
		}
	}

	this.sendInlined = function() {
		for (var i = 0; i < this.ads.length; i++) {
			if (this.ads[i].wt.length > 0 && this.ads[i].link) {
				this.cacheFile(this.ads[i].link+this.ads[i].wt.join(";")+"&ul="+this.location);
			}
		}
	}

	this.encode = function(s) {
		var c,n,t="";
		for (n=0;n<s.length;n++) {
			c=s.charCodeAt(n);
			if (c<128) {
				t+=String.fromCharCode(c);
			} else if ((c>127) && (c<2048)) {
				t+='%'+((c >> 6) | 192).toString(16).toUpperCase();
				t+='%'+((c & 63) | 128).toString(16).toUpperCase();
			} else {
				t+='%'+((c >> 12) | 224).toString(16).toUpperCase();
				t+='%'+(((c >> 6) & 63) | 128).toString(16).toUpperCase();
				t+='%'+((c & 63) | 128).toString(16).toUpperCase();
			}
		}
		return t;
	}

	this.makeBannerHTML = function(i, j) {
		var o, v, n, m;
		if (typeof(this.ads[i].ver) != 'undefined' && this.ads[i].ver == "2") {
			v =  'clickTAG=' + escape(this.ads[i].click_url + '&kws=' + this.ads[i].wt[j] + '&ul=' + this.location) + '&fileURL=' + escape(this.ads[i].video_url) + '&statScript=' + escape("_rbn_ev,{event}");
			if (!this.params.autostart_video) {
				v += "&autoPlay=false";
			}
			v += "&fullScreen=false";
		} else {
			v =  'clickTAG=' + escape(this.ads[i].click_url + '&kws=' + this.ads[i].wt[j] + '&ul=' + this.location) + '&fileURL=' + escape(this.ads[i].video_url) + '&infoURL=' + escape(this.params.info_url);
			if (typeof(this.ads[i].xml) != 'undefined' && this.ads[i].xml != '') {
				v += "&tags="+this.ads[i].xml;
			}
			if (typeof(this.ads[i].banner) != 'undefined' && this.ads[i].banner != '') {
				v += "&banner="+this.ads[i].banner;
			}
			if (!this.params.autostart_video) {
				v += "&jsPause=PAUSE_ON";
			}
		}
		for (var k in this.ads[i].flash_vars) {
			v += "&"+k+"="+this.ads[i].flash_vars[k];
		}
		v += "&userAgent=" + escape(navigator.userAgent);
		if (typeof(this.ads[i].internalClick) != 'undefined' && this.ads[i].internalClick == "1") {
			v += "&internalClick=true";
		}
		o = '<object id="_vc_flash_' + i + '" width="' + this.ads[i].width + '"  height="' + this.ads[i].height + '" data="' + this.ads[i].flash_url + '" type="application/x-shockwave-flash">';
		o += '<param name="movie" value="' + this.ads[i].flash_url + '"/>';
		o += '<param name="quality" value="high"/>';
		o += '<param name="wmode" value="'+((typeof(this.ads[i].wmode) != 'undefined' && this.ads[i].wmode != '') ? this.ads[i].wmode : 'transparent')+'"/>';
		o += '<param name="bgcolor" value="#ffffff"/>';
		o += '<param name="scale" value="exactfit"/>';
		o += '<param name="swliveconnect" value="true"/>';
		o += '<param name="allowscriptaccess" value="always"/>';
		o += '<param name="allowFullScreen" value="true"/>';
		o += '<param name="flashvars" value=\'' + v + '\'>';
		o += '</object>';
		n = document.createElement("DIV");
		n.className = '_noreachbanner_';
		n.innerHTML = o;
		n.style.display = 'none';
		n.style.position = 'absolute';
		n.style.zIndex = 99999;
		n.style.width = this.ads[i].width + 'px';
		n.style.height = this.ads[i].height + 'px';
		return n;
	}
	
	this.showBanner = function(i, j) {
		this.createBanner(i, j);
		var b = this.ads[i].banner;
		if (b == null) {
			return;
		}
		var w = this.getPageWidth();
		var h = this.getPageHeight();
		var sy = this.getScrollY();
		var x = this.getPosX(this.ads[i].word[j]);
		var y = this.getPosY(this.ads[i].word[j]);
		var kw = this.ads[i].word[j].offsetWidth;
		var kh = this.ads[i].word[j].offsetHeight;
		var bx, by;
		var body = document.getElementsByTagName("body")[0];
		if (this.ads[i].pos && (this.ads[i].pos == "1" || this.ads[i].pos == "2" || this.ads[i].pos == "3" || this.ads[i].pos == "4")) {
			var px = this.ads[i].posx == "" ? 0 : parseInt(this.ads[i].posx), py = this.ads[i].posy == "" ? 0 : parseInt(this.ads[i].posy);
			//console.log("px: "+px+", py: "+py+", kw: "+kw+", kh: "+kh);
			bx = x + kw + px;
			by = y + kh + py;
			//console.log("bx: "+bx+", by: "+by);
			switch (this.ads[i].pos) {
				case "2":
					bx -= this.ads[i].width;
					break;
				case "3":
					bx -= this.ads[i].width;
					by -= this.ads[i].height;
					break;
				case "4":
					by -= this.ads[i].height;
					break;
			}
			//console.log("bx: "+bx+", by: "+by);
		} else {
			if (x < (w / 2)) {
				bx = x;
			} else {
				bx = x - this.ads[i].width + 30;
			}
			if ((y - sy) < (h / 2)) {
				by = y + kh + 3;
			} else {
				by = y - this.ads[i].height - 3;
			}
		}
		b.style.top = by + 'px';
		b.style.left = bx + 'px';
		b.style.display = 'block';
		VIDEOCLICK.show_id = i;
		VIDEOCLICK.showTimer = false;
		if (!this.ads[i].trace && !(typeof(this.ads[i].ver) != 'undefined' && this.ads[i].ver == "2")) {
			if (this.ads[i].trace_url) {
				this.cacheFile(this.ads[i].trace_url+'&ul='+this.location);
			}
			if (this.ads[i].trace_url2 && this.ads[i].trace_url2.length > 0) {
				this.cacheFile(this.ads[i].trace_url2);
			}
			this.ads[i].trace = true;
		}
		if (body) {
			body.appendChild(b);
		}
	}
	
	this.hideBanner = function(i) {
		var n = this.ads[i].banner;
		if (n) {
			var body = document.getElementsByTagName("body")[0];
			var o = document.getElementById("_vc_flash_"+i);
			if (o) {
				n.removeChild(o);
			}
			n.style.display = 'none';
			if (body) {
				body.removeChild(n);
			}
		}
		VIDEOCLICK.show_id = -1;
		VIDEOCLICK.hideTimer = false;
	}
	
	this.createBanner = function(i, j) {
		if (this.ads[i].word[j]) {
			this.ads[i].banner = this.makeBannerHTML(i, j);
			this.ads[i].banner.onmouseover = new Function('VIDEOCLICK.eventBannerMouseOver('+i+','+j+')');
			this.ads[i].banner.onmouseout = new Function('VIDEOCLICK.eventBannerMouseOut('+i+','+j+')');
		}
	}
		
	this.eventWordMouseOver = function(i, j) {
		this.ads[i].word[j].style.borderWidth = '0 0 2px 0';
		if (VIDEOCLICK.show_id > -1) {
			if (VIDEOCLICK.show_id == i) {
				if (VIDEOCLICK.hideTimer) {
					clearTimeout(VIDEOCLICK.hideTimer);
					VIDEOCLICK.hideTimer = false;
				}
				return;
			} else {
				VIDEOCLICK.hideBanner(VIDEOCLICK.show_id);
			}
		}
		VIDEOCLICK.showTimer = setTimeout('VIDEOCLICK.showBanner('+i+','+j+')', VIDEOCLICK.params.show_timeout);
	}

	this.eventWordMouseOut = function(i, j) {
		this.ads[i].word[j].style.borderWidth = this.w_style['borderWidth'];
		if (VIDEOCLICK.showTimer) {
			clearTimeout(VIDEOCLICK.showTimer);
			VIDEOCLICK.showTimer = false;
		}
		if (VIDEOCLICK.show_id > -1) {
			VIDEOCLICK.hideTimer = setTimeout('VIDEOCLICK.hideBanner('+i+')', VIDEOCLICK.params.hide_timeout);
		}
	}

	this.eventBannerMouseOver = function(i, j) {
		if (VIDEOCLICK.hideTimer) {
			clearTimeout(VIDEOCLICK.hideTimer);
			VIDEOCLICK.hideTimer = false;
		}
	}

	this.eventBannerMouseOut = function(i, j) {
		VIDEOCLICK.hideTimer = setTimeout('VIDEOCLICK.hideBanner('+i+')', VIDEOCLICK.params.hide_timeout);
	}
	
	this.cacheFile = function(u) {
		(new Image(10, 10)).src = u.replace("{rid}", Math.random()); 
	}
	
	this.getPosX = function(o) {
		var x = 0;
		if (o.offsetParent) {
			while (o) {
				x += o.offsetLeft;
				o = o.offsetParent;
			}
		} else {
			if (o.x) {
				x = o.x;
			}
		}
		return x;
	}
	
	this.getPosY = function(o) {
		var y = 0;
		if (o.offsetParent) {
			while (o) {
				y += o.offsetTop;
				o = o.offsetParent;
			}
		} else {
			if (o.y) {
				y = o.y;
			}
		}
		return y;
	}
	this.getPageWidth = function() {
		var x = 0;
		if (typeof(window.innerWidth) == 'number') {
			x = window.innerWidth;
		} else if (document.documentElement && document.documentElement.clientWidth) {
			x = document.documentElement.clientWidth;
		} else if (document.body && document.body.clientWidth) {
			x = document.body.clientWidth;
		}
		return x;
	}
	this.getPageHeight = function() {
		var y;
		if (typeof(window.innerHeight) == 'number') {
			y = window.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			y = document.documentElement.clientHeight;
		} else if (document.body.clientHeight) {
			y = document.body.clientHeight;
		}
		return y;
	}
	this.getScrollX = function() {
		var x = 0;
		if (typeof(window.pageXOffset) == 'number') {
			x = window.pageXOffset;
		} else if (document.body && document.body.scrollLeft) {
			x = document.body.scrollLeft;
		} else if (document.documentElement && document.documentElement.scrollLeft) {
			x = document.documentElement.scrollLeft;
		}
		return x;
	}
	this.getScrollY = function() {
		var y = 0;
		if (typeof(window.pageYOffset) == 'number') {
			y = window.pageYOffset;
		} else if (document.body && document.body.scrollTop) {
			y = document.body.scrollTop;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			y = document.documentElement.scrollTop;
		}
		return y;
	}    
}

