function openWin(src){
	myWin= open("", "displayWindow", "width=1000,height=750,status=yes,toolbar=yes,menubar=yes");
	
	myWin.document.open();
	myWin.document.write("<html><head><title>");
	myWin.document.write("</title></head><body style='padding: 0;margin: 0'><img src='" + src + "'/>");
	myWin.document.write("</body></html>");
	myWin.document.close();  
}
var spec = $('.bem-spec');
var specLi = spec.find('li');
var q = specLi.length;
var timer = 1900;

function fadeString(obj){
	var curIndex = obj.attr('index'), next;
	if( curIndex == q - 1 ){
		next = 0
	} else next = curIndex * 1 + 1
	var nextLi = specLi.eq(next);
	nextLi.fadeIn(1700, function(){
		t = setTimeout(function(){
			nextLi.fadeOut(1700, function(){
				fadeString(nextLi)
			})
		}, timer)
	})
}
$(document).ready(function(){
	$('table.table').wrap('<div class="table"></div>');
	$('table.table td').each(function(){
		var td = $(this);
		td.prepend('<i class="del"></i>');
		td.find('.del').css('height', td.innerHeight() - 4);	
	})
	if( $('.bem-gal a').length > 0 ) $('.bem-gal a').lightBox();
	$('.popup span').click(function(){
		var pr = $(this).parent(); 
		if( pr.hasClass('popup_act') ){
			pr.removeClass('popup_act').find('.bem-popup').css('left', '-9999px')
		} else pr.addClass('popup_act').find('.bem-popup').css('left', '0')
	})
	$('.popup .close').click(function(){
		var pr = $('.popup'); 
		pr.removeClass('popup_act').find('.bem-popup').css('left', '-9999px')
	})
	var maxH = specLi.eq(0).height();
	specLi.each(function(i){
		if( maxH < specLi.eq(i).height() ) maxH = specLi.eq(i).height();
		specLi.eq(i).attr('index', specLi.index(specLi.eq(i)))
	})
	spec.find('ul').css({'position':'static', 'height':maxH})
	specLi.hide().eq(0).show();
	setTimeout(function(){
		$('.bem-spec li:eq(0)').fadeOut(1000, function(){
			fadeString($(this))
		})
	}, timer);
	
	// added by psp: 01.12.2010 - клик по блоку-баннеру справа вверху
	var $a = spec.find('a');
	if ($a.length > 0 && $a.get(0).href != "") {
		spec.click(function(){
			document.location.href = $a.get(0).href;
		}).css({ cursor: 'pointer' });
	}
});

/** added by psp: 20.04.2010 */
jQuery(function($){
	$('form[action$=/webforms/send/]').submit(function(){
		$.post($(this).attr('action').replace("send", "mod_send"), $(this).serialize(), function(data){
			$('form[action$=/webforms/send/]').before(data);
		});
		return false;
	});
});
