function fm_img_teaser_getOffset(elem) {
    if (elem.getBoundingClientRect) {
        return fm_img_teaser_getOffsetRect(elem);
    } else {
        return fm_img_teaser_getOffsetSum(elem);
    }
}
function fm_img_teaser_getOffsetSum(elem) {
    var top=0, left=0
    while(elem) {
        top = top + parseInt(elem.offsetTop)
        left = left + parseInt(elem.offsetLeft)
        elem = elem.offsetParent
    }

    return {top: top, left: left}
}
function fm_img_teaser_getOffsetRect(elem) {
    var box = elem.getBoundingClientRect()
    var body = document.body
    var docElem = document.documentElement
    var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop
    var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft
    var clientTop = docElem.clientTop || body.clientTop || 0
    var clientLeft = docElem.clientLeft || body.clientLeft || 0
    var top  = box.top +  scrollTop - clientTop
    var left = box.left + scrollLeft - clientLeft
    return { top: Math.round(top), left: Math.round(left) }
}
function fm_img_teaser_isIE()
{
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if (browser=="Microsoft Internet Explorer")
		return true;
			else return false;	
}
var super_teaser__target;
function offsetPosition(element) {

}
function teaser_img_slider()
{
	this.intervalID = false;
}
teaser_img_slider.prototype.clearInterval = function()
{
	if (this.intervalID)
	{
		clearInterval(this.intervalID)
		this.intervalID = false;
	}
}
teaser_img_slider.prototype.setInterval = function(func)
{
	this.intervalID = setInterval(func, 30);
}
teaser_img_slider.prototype.show = function(obj, max)
{
	if (obj.hidden)
		return;
	this.clearInterval();
	obj.style.display='';
	this.setInterval(function()
	{
		obj.style.height = (parseInt(obj.style.height)+0.3*(max-parseInt(obj.style.height)))+'px';
	}
	);
}
teaser_img_slider.prototype.hide = function(obj)
{
	this.clearInterval();
	this.setInterval(function()
		{
			obj.style.height = (0.6*parseInt(obj.style.height))+'px';
			if (parseInt(obj.style.height)  < 5)
			{
				obj.style.display='none';
				return;
			}
		});
}
teaser_img_slider.prototype.resize = function(obj, dist)
{
	if (obj.hidden)
		return;
	setInterval(function()
	{
		var dx;
		dx = Math.floor(dist*0.3);
		if (dx == 0)
		{
			if (dist < 0)
				dx = -1;
			if (dist > 0)
				dx = 1;
		}
		obj.style.height = (parseInt(obj.style.height) + dx) + 'px';
		dist -= dx;
		if (dist == 0)
			return;
	}, 30);
}
teaser_img_slider.prototype.move = function(obj, dist, min_left, max_left)
{
	var preved = this;
	var intervalID = setInterval(function()
		{
			var dx;
			dx = Math.floor(dist*0.3);
			if (dx == 0)
			{
				if (dist < 0)
					dx = -1;
				if (dist > 0)
					dx = 1;
			}
			obj.style.left = (parseInt(obj.style.left) + dx)+'px';
			dist -= dx;
			if (parseInt(obj.style.left) <= min_left)
			{
				obj.style.left = min_left + 'px';
				clearInterval(intervalID);
				preved.onNoScrollLeft();
			} else preved.onCanScrollLeft();
			if (parseInt(obj.style.left) >= max_left)
			{
				obj.style.left = max_left + 'px';
				clearInterval(intervalID);
				preved.onNoScrollRight();
			} else preved.onCanScrollRight();
			if (dist == 0)
				return;
		}, 30);
}
function teaser_img_adv(img, teaser_id)
{
	this.img = img;
	this.slider = new teaser_img_slider();
	
	this.adv = this.createAdv(teaser_id);
	var img_adv = this;
	this.slider.onNoScrollLeft = function()
	{
		img_adv.adv.button_right.src = "http://t1.cmix.org/img/right_disabled.gif";
	}
	this.slider.onNoScrollRight = function()
	{
		img_adv.adv.button_left.src = "http://t1.cmix.org/img/left_disabled.gif";
	}
	this.slider.onCanScrollLeft = function()
	{
		img_adv.adv.button_right.src = "http://t1.cmix.org/img/right_enabled.gif";
	}
	this.slider.onCanScrollRight = function()
	{
		img_adv.adv.button_left.src = "http://t1.cmix.org/img/left_enabled.gif";
	}
	super_teaser__target = this.adv;
	this.adv.adv = this;
}
teaser_img_adv.prototype.createAdv = function(teaser_id)
{
	var element = this.img, offsetLeft = 0, offsetTop = 0;
    do {
        offsetLeft += element.offsetLeft;
        offsetTop  += element.offsetTop;
    } while (element = element.offsetParent);
	var div		= window.document.createElement('div');
	var wrapper	= window.document.createElement('div');
	wrapper.appendChild(div);
	div.id		= "super_teaser__teaser_" + teaser_id;
	window.document.body.appendChild(wrapper);
	wrapper.style.zIndex=100000;
	wrapper.style.position='absolute';
	wrapper.style.top = offsetTop+'px';
	wrapper.style.left = offsetLeft + 'px';
	wrapper.style.width=this.img.width+'px';
	
	wrapper.style.backgroundColor='#444';
	div.style.position='relative';
	wrapper.style.opacity=0.8;
	wrapper.style.filter = 'alpha(opacity=80)';
	div.style.filter = 'alpha(opacity=100)';
	div.style.opacity=1;
	wrapper.style.height='0px';
	wrapper.style.overflow='hidden';
	/*
	var del = document.createElement('img');
	del.src='http://pusher.dev.we/delete2.gif';
	del.style.top = offsetTop + 'px';
	del.style.left = this.img.width - 20 + 'px';
	del.style.top = '10px';
	del.style.position='absolute';
	del.style.cursor='pointer';
	del.onclick = function()
	{
		slider.hide(wrapper);
		wrapper.hidden = true;
	};
	wrapper.del = del;
	wrapper.appendChild(del);
	*/
	this.img.showImage=wrapper;
	var super_teaser__css_text = '<div style="height:0px;">&nbsp;</div> <style type="text/css"> #tizer_table *{background:none!important;clear:none!important;clip:auto!important;cursor:auto!important;float:none!important;;font-variant:normal!important;font-weight:normal!important;letter-spacing:normal!important;line-height:normal!important;margin:0!important;overflow:hidden!important;padding:0!important;position:static!important;text-decoration:none!important;text-indent:0!important;text-transform:none!important;vertical-align:baseline!important;visibility:visible!important;white-space:normal!important;width:auto!important;word-spacing:normal!important;z-index:auto!important;} #tizer_table a,#tizer_table a *{cursor:pointer!important; text-decoration:none!important;} #tizer_table b{font-weight:bold!important;} #tizer_table a,#tizer_table b,#tizer_table em,#tizer_table ins,#tizer_table span{display:inline!important;} #tizer_table div,#tizer_table img,#tizer_table object{display:block!important;} #tizer_table table{border-collapse:collapse!important;display:table!important;table-layout:fixed!important;} #tizer_table tbody{display:table-row-group!important;} #tizer_table tr{display:table-row!important;} #tizer_table th,#tizer_table td{vertical-align:top!important;} #tizer_table ul,#tizer_table li{display:list-item!important;list-style:none outside none!important;} #tizer_table wbr{display:inline-block!important;} table.fm_teaser_block_814{	height:200px;	table-layout:fixed;	overflow:hidden;	background-color:#;	border-spacing:3px;	border-collapse:separate; } div.fm_teaser_814{	color:#FFFF33;	font-size:12px;	font-family:Arial;	overflow:hidden;	width:100%;	height:100%;	text-align:center; } table.fm_teaser_block_814 td{	} table.fm_teaser_block_814 div.fm_teaser_814 a{ color:#FFFF33; } table.fm_teaser_block_814 div.fm_teaser_814 a:hover{	color:#; } </style> ';
var super_teaser__teaser_template = '<div class="fm_teaser_814">	<table width="100%" height="120"><tr><td width="100%" height="100%" align="center" valign="middle" style="border:none">	<a target="_blank" href="{URL}">	<img style="border:none;padding:5px;margin:auto;display:block;" src="http://photosex.biz/imager/w_120/h_120/{THUMB_HOST_ID}.{THUMB_HOST_TYPE}" /></a>	</td></tr></table>	<a target="_blank" href="{URL}">{NAME}<br />	<small style="color:#;font-size:12px">{DOWNLOAD}&nbsp;&#187;</small>	</a>	</div> ';
var super_teaser__teaser_data = [{"name":"[3D FLASH][Koonya] H shiyouyo Lovely Play Mate","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=vzEqWjulG47c3LX1naeExbFS4NW-NxEuD3IJP6UHJh4&id_profile=720","thumb_hosting_id":"f814d223ef4f7ffed0a0ecaceb553406","thumb_hosting_type":"jpg","id_language":"2"},{"name":"Fashion for Hot Strike","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=HGVjC_QwiTp1780Hk-A84SCIkg201njrp8Eqbe7MXtg&id_profile=720","thumb_hosting_id":"269289d1c7e986232a68e63776ad1790","thumb_hosting_type":"jpg","id_language":"2"},{"name":"Kytana","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=Nd51NkK1va4AqRq1dRTQKiCIkg201njrp8Eqbe7MXtg&id_profile=720","thumb_hosting_id":"43a90f1c8f154b160153653f27bb99d6","thumb_hosting_type":"jpg","id_language":"2"},{"name":"Wild Thing II","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=PhNy0qcWuWZaL1yMKQGD5CCIkg201njrp8Eqbe7MXtg&id_profile=720","thumb_hosting_id":"50d218b6ac3bfd5535d4ec27cb427566","thumb_hosting_type":"jpg","id_language":"2"},{"name":"ps pe070 - Victoria 4.2 Morphs++","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=nTuHTQKdGYKsgsNKJr6F3SCIkg201njrp8Eqbe7MXtg&id_profile=720","thumb_hosting_id":"79991949443913cdc67663474e750cd5","thumb_hosting_type":"jpg","id_language":"2"},{"name":"Pack Photoshop Brushes - 2009","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=W3iirkCWiKFTNyGwTjDhWHw7KA9SKB3Kp6sA6lTQUpw&id_profile=720","thumb_hosting_id":"7caaf4358a0ac8bc5d6d981b24fa3ac5","thumb_hosting_type":"jpg","id_language":"2"},{"name":"Tijuana Bible (Tifa 3D H-Game)","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=JZrHsfnfl4vglIpmYZUpT7FS4NW-NxEuD3IJP6UHJh4&id_profile=720","thumb_hosting_id":"4b18797a2555fb2312fb7fbf6c0a5189","thumb_hosting_type":"jpg","id_language":"2"},{"name":"Meet'N'Fuck BDSM Club","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=GOT8wWEVvHjOZgn41-6F5rFS4NW-NxEuD3IJP6UHJh4&id_profile=720","thumb_hosting_id":"44a97cc48ae6b677523be2bceea7851e","thumb_hosting_type":"jpg","id_language":"2"},{"name":"Ashlyn for Laura","url":"http:\/\/vipfile.biz\/teaser_client.php?pcode=L929q1N_qdCtKJYhYuQldCCIkg201njrp8Eqbe7MXtg&id_profile=720","thumb_hosting_id":"fac33e0c956f03abd4445660c6b09bf3","thumb_hosting_type":"jpg","id_language":"2"}];
var super_teaser__teaser_row_count=1;
var super_teaser__teaser_col_count=20;
var super_teaser__teaser_files_count = 50;	var super_teaser__files = [];
	var super_teaser__temp = [];
	super_teaser__teaser_files_count = super_teaser__teaser_data.length;
	if (super_teaser__teaser_data.length > 15)
		super_teaser__teaser_files_count = 15;
			else super_teaser__teaser_files_count = super_teaser__teaser_data.length;
	if (super_teaser__teaser_files_count >= super_teaser__teaser_data.length)
		var super_teaser__files = super_teaser__teaser_data;
			else while (super_teaser__files.length < super_teaser__teaser_files_count)
			{
				var index = Math.floor(Math.random()*super_teaser__teaser_data.length);
				if (super_teaser__temp[index] == undefined)
				{
					super_teaser__temp[index] = 1;
					super_teaser__files.push(super_teaser__teaser_data[index]);
				}
			}
	var html = '<div style="position:relative;height:200px;margin-left:20px;margin-right:20px;width:'+(this.img.width-40)+'px">';
	html += '<img class="move_left" src="http://t1.cmix.org/img/left_enabled.gif" style="opacity:0.8; position:absolute;z-index:10;left:-17px;top:92px;cursor:pointer" />';
	html += '<img class="move_right" src="http://t1.cmix.org/img/right_enabled.gif" style="opacity:0.8; position:absolute;z-index:10;left:' + (this.img.width-38).toString() + 'px;top:92px;cursor:pointer" />';
	html += '<div style="overflow:hidden;height:200px;">';
	html += '<div style="width:10000px;position:relative;left:0px;" class="fm_teaser_img_move_div">';
	html += '<table onmouseover="//this.border=1" onmouseout="//this.border=0" class="fm_teaser_block_814" style="table-layout:fixed;height:200px;" cellpadding="0" cellspacing="0">';
	super_teaser__teaser_col_count = super_teaser__teaser_files_count;
	super_teaser__teaser_row_count=1;
	for (i = 0; i < 1; i++)
	{
		html += '<tr valign="middle">';
		for (j = 0; j < super_teaser__teaser_files_count; j++)
		{
			html += '<td height="' +Math.floor(100/super_teaser__teaser_row_count)+ '%" width="130" style="padding:5px">';
			var temp = super_teaser__teaser_template;
			var file = super_teaser__files[i+super_teaser__teaser_row_count*j];
			if (!file)
				break;
			temp = temp.replace('{URL}', file.url);
			temp = temp.replace('{URL}', file.url);
			temp = temp.replace('{URL}', file.url);
			temp = temp.replace('{NAME}', file.name);
			temp = temp.replace('{THUMB_HOST_ID}', file.thumb_hosting_id);
			temp = temp.replace('{THUMB_HOST_TYPE}', file.thumb_hosting_type);
			if (file.id_language == 1)
				temp = temp.replace('{DOWNLOAD}', 'c\u043a\u0430\u0447\u0430\u0442\u044c');
					else temp = temp.replace('{DOWNLOAD}', 'Download');
			html += temp;
			html += '</td>';
		}
		html += '</tr>';
	}
	html += '</table>';
	html += '</div>';
	html += '</div>';
	html += '</div>';
	wrapper.innerHTML = html+super_teaser__css_text;
	var list = wrapper.getElementsByTagName('div');
	for (i = 0; i < list.length; i ++)
	{
		if (list[i].className == 'fm_teaser_img_move_div')
		{
			var move_div = list[i];
			break;
		}
	}
	var td_list = move_div.childNodes[0].childNodes[0].childNodes[0].childNodes;
	var td_count = Math.floor((this.img.width-30)/156);
	if (td_list.length < td_count)
		td_count = td_list.length;
	var td_width = Math.floor((this.img.width-30)/td_count)-15;
	if (fm_img_teaser_isIE())
		td_width += 15;
	wrapper.childNodes[0].padding=Math.floor((this.img.width-td_count*td_width)/2) + 'px';
	for (i = 0; i < td_list.length; i ++)
	{
		td_list[i].width = td_width;
		td_list[i].style.width = td_width + 'px';
	}
	var td_dist = 12;
	move_div.style.left = td_dist + 'px';
	move_div.style.width = (td_list.length)*(td_width+td_dist) + 'px';
		var list = wrapper.getElementsByTagName('img');
	var slider = this.slider;
	for (i = 0; i < list.length; i ++)
	{
		if (list[i].src)
		{
			if (list[i].className == 'move_left')
			{
				wrapper.button_left = list[i];
				var img_width = this.img.width;
				list[i].onclick = function()
					{
						if (parseInt(move_div.style.left) < 0)
							slider.move(move_div, td_width+td_dist, -(td_width+td_dist)*(super_teaser__teaser_files_count-3), 0);
								else slider.onNoScrollRight();
					};
			}
		if (list[i].className == 'move_right')
			{
				wrapper.button_right = list[i];
				list[i].onclick = function()
					{
						if (parseInt(move_div.style.left) > -(td_width+td_dist)*(super_teaser__teaser_files_count-3))
							slider.move(move_div, -(td_width+td_dist), -(td_width+td_dist)*(super_teaser__teaser_files_count-3), 0);
								else slider.onNoScrollLeft();
					};
			}
		}
	}
	slider.move(move_div, 0, -(td_width+td_dist)*td_count, 0);
	
	return wrapper;
}
teaser_img_adv.prototype.show = function()
{
	this.slider.show(this.adv, 200);
}
teaser_img_adv.prototype.hide = function()
{
	this.slider.hide(this.adv);
}

if (window.captureEvents){ // если Netscape Navigator
    window.captureEvents(Event.MOUSEOVER);
    window.onmouseover = handle_mouseover;
	window.captureEvents(Event.MOUSEOUT);
	window.onmouseout = handle_mouseout;
}else{
    document.onmouseover = handle_mouseover;
	document.onmouseout = handle_mouseout;
}
function handle_mouseover(e){
	var obj;
	if (e && e.target)
		obj = e.target;
			else obj = event.srcElement;
	var element = obj;
	do {
        if (element.adv)
		{
			element.adv.show();
		}
    } while (element = element.offsetParent);
	if (!obj.src || !obj.width || !obj.height || obj.width < 180 || obj.height < 250)
		return;
	if (!obj.teaser_img_adv)
		obj.teaser_img_adv = new teaser_img_adv(obj, 814);
	var yo = '';
	var element = obj, offsetLeft = 0, offsetTop = 0;
    do {
        offsetLeft += element.offsetLeft;
        offsetTop  += element.offsetTop;
		yo += element.style.position + ' ';
    } while (element = element.offsetParent);
	obj.teaser_img_adv.adv.style.left = offsetLeft + 'px';
	obj.teaser_img_adv.adv.style.top = offsetTop + 'px';
	
	obj.teaser_img_adv.adv.style.left = fm_img_teaser_getOffset(obj).left + 'px';
	obj.teaser_img_adv.adv.style.top = fm_img_teaser_getOffset(obj).top + 'px';
	
	
	obj.teaser_img_adv.show();
}
function handle_mouseout(e) {
	var obj;
	if (e && e.target)
		obj = e.target;
			else obj = event.srcElement;
	var element = obj;
	do {
        if (element.adv)
			element.adv.hide();
    } while (element = element.offsetParent);
	if (!obj.src)
		return;
	if (!obj.teaser_img_adv)
		return;
	obj.teaser_img_adv.hide();
}

