// ---- Spoilers -----
function Spoiler(id) {
	var spl = document.getElementById('spl'+id);
	var hnt = document.getElementById('hnt'+id);

	$(spl).css("width", $("#Main_content").width()-40);
	h = $(spl).height();
	
	if (spl.style.display == "block")
	{
		$(spl).animate({  opacity: 0 }, 500, function () {
			if (hnt)
			{
				$(hnt).css("display", "block");
				$(hnt).animate({ opacity: 1 }, 500);
			}
			$(this).animate({ height: 0 }, 500, function () {
				$(this).css("display", "none");
				$(this).css("height", h);
			});
		});
	} else {
		$(spl).css("height", 0);
		$(spl).css("display", "block");
		if (hnt)
		{
			$(hnt).animate({ opacity: 0 }, 500, function () {
				$(this).css("display", "none");
			});
		}
		$(spl).animate({ height: h }, 500, function () {
			$(this).animate({ opacity: 1 }, 500);
		});

	}
}
// ---- SC Menu -----
function scAnim(div,ul,ulPadding) {
	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars
	div.css({overflow: 'hidden'});

	//Find last image container
	var lastLi = ul.find('li:last-child');

	//When user move mouse over menu
	div.mousemove(function(e){

		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
}
// ---- Infoban -----
function blink(id) {
	$(id).hide();
	setTimeout(function(){$(id).show();setInterval(function(){$(id).toggle();},1000)},1000);
}
// ---- Callback -----
function chCall() {
	var name = document.getElementsByName('call_name')[0];
	var phone = document.getElementsByName('call_phone')[0];

	if (name.value != '' && phone.value != '')
	{
		document.getElementById('call_form').submit();
	} else {
		name.style.backgroundColor = (name.value == '')? '#ffc7c7': '';
		phone.style.backgroundColor = (phone.value == '')? '#ffc7c7': '';
	}
}
function callback() {
	if (!$('#popup-window').length) {
		$('body').prepend('<div id="popup-window"></div>');
		$('#popup-window').css("position", "absolute");
		$('#popup-window').css("z-index", "9999");
		$('#popup-window').html(
			'<table width="100%" border="0" cellpadding="0" cellspacing="0">'+
			'  <tr>'+
			'	 <td width="20" height="20"><img src="files/Ramki/top-left.jpg" width="20" height="20" align="top"></td>'+
			'	 <td width="*" height="20" background="files/Ramki/top.jpg"></td>'+
			'	 <td width="20" height="20"><img src="files/Ramki/top-right.jpg" width="20" height="20" align="top"></td>'+
			'  </tr>'+
			'  <tr>'+
			'	<td width="20" background="files/Ramki/left.jpg"></td>'+
			'	<td width="*" bgcolor="#ffffff" align="center" class="opisanie_style">'+
			'	  <form method="post" id="call_form">'+
			'		Пожалуйста, представьтесь:<br>'+
			'		<input type="text" name="call_name" style="width: 160px"><br><br>'+
			'		Ваш телефон:<br>'+
			'		<input type="text" name="call_phone" style="width: 160px"><br><br>'+
			'		<input type="button" name="call_submit" value="Перезвоните мне" onclick="chCall();">'+
			'	  </form>'+
			'	</td>'+
			'	<td width="20" background="files/Ramki/right.jpg"></td>'+
			'  </tr>'+
			'  <tr>'+
			'	<td width="20" height="20" background="files/Ramki/bottom-left.jpg"></td>'+
			'	<td height="20" background="files/Ramki/bottom.jpg"></td>'+
			'	<td width="20" height="20" background="files/Ramki/bottom-right.jpg"></td>'+
			'  </tr>'+
			'</table>'
		);
		$('#popup-window').offset( function(){
			var pos = $('#callback').position();
			var l = pos.left-($('#popup-window').width()-$('#callback').width())/2;
			return {top: $('#apDiv6').height(), left: l};
		});
		
		if (event.stopPropagation) {
			event.stopPropagation()
			event.preventDefault();
		} else {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
	}

	$('#popup-window').click(function() {
		window.event.cancelBubble = true;
		window.event.returnValue = true;
	});
	$('body').click(function() {
		$('#popup-window').remove();
		$('body').unbind('click');
	});
}
// ---- RightMouse off -----
var message = "";

function clickIE()
{
   if (document.all) (message);
   return false;
}

function clickNS(e)
{
	if (document.layers || (document.getElementById && !document.all))
	{
		if (e.which == 2)
		{
			(message);
			return false;
		}
	}
}
	   
if (document.layers)
{
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown = clickNS;
}
else
{
	document.onmouseup = clickNS;
	document.oncontextmenu = clickIE;
}
	   
document.oncontextmenu = new Function("return false");

