var timerBig;
function setBigImg(id, clear) {
	if(id==lastBigImg) return;

	if(clear==1) {
		clearTimeout(timerBig);
		timerBig = setTimeout("setTimerBigImg()", motiveTime*1000);
	}
	
	$("#sq_"+lastBigImg).toggleClass("act");

/*
	$("#motive_" + lastBigImg).hide();
	$("#imgAnons_" + lastBigImg).hide();
*/
	$("#motive_" + lastBigImg).fadeOut(300)
	$("#imgAnons_" + lastBigImg).fadeOut(300)

	$("#sq_"+id).toggleClass("act");

/*
	$("#motive_" + id).show();
	$("#imgAnons_" + id).show();
*/
	$("#motive_" + id).fadeIn(300);
	$("#imgAnons_" + id).fadeIn(300);
	
	lastBigImg = id;

}
function setTimerBigImg() {
	var next = lastBigImg+1;
	if(next==6) next = 1;
	setBigImg(next, 0)
	clearTimeout(timerBig);
	timerBig = setTimeout("setTimerBigImg()", motiveTime*1000);
}


//////////////////////////////////////////////////////////////////////////////

function setTimerBigImgThree(toc_id) {
//	alert(toc_id)
	var next = lastBigImgThree[toc_id]+1;
	if(next==4) next = 1;
	setBigImgThree(next, 0, toc_id)
	clearTimeout(timerBigThree[toc_id]);
	timerBigThree[toc_id] = setTimeout(function(){setTimerBigImgThree(toc_id)}, motiveTimeThree[toc_id]*1000);
}

var timerBigThree = new Array();
var motiveTimeThree = new Array();
var lastBigImgThree = new Array();

function setBigImgThree(id, clear, toc_id) {
	if(id==lastBigImgThree[toc_id]) return;

	if(clear==1) {
		clearTimeout(timerBigThree[toc_id]);
		timerBigThree[toc_id] = setTimeout("setTimerBigImgThree()", motiveTime*1000);
	}
	
	$("#sq_" + toc_id + "_" + lastBigImgThree[toc_id]).toggleClass("act");

//	$("#motive_" + toc_id + "_" + lastBigImgThree[toc_id]).fadeOut(300)
	$("#imgAnons_" + toc_id + "_" + lastBigImgThree[toc_id]).fadeOut(300)

	$("#sq_" + toc_id + "_" + id).toggleClass("act");

//	$("#motive_" + toc_id + "_" + id).fadeIn(300);
	$("#imgAnons_" + toc_id + "_" + id).fadeIn(300);
	
	lastBigImgThree[toc_id] = id;

}
//////////////////////////////////////////////////////////////////////////////



function showFormGuestVisit() {
	if ($("#formGuestVisit").css("display") == "none" ) {
		$("#formGuestVisit").show();
		$(".banner-ind").css({
			visibility: "hidden"
		});
	}
	else {
		$("#formGuestVisit").hide();
		$(".banner-ind").css({
			visibility: "visible"
		});
	}
}

function showHideBlock(id) {
	if ($("#"+id).css("display") == "none" ) {
		$("#"+id).show();
	}
	else {
		$("#"+id).hide();
	}
}

//VIDEO
$(document).ready(function(){
	var h = $(document).height();
	$('.video_prev').click(function(){
		$('body').append('<div id="shadow"></div><div id="video_w"><img class="cls" src="/img/close.png" /></div>');
	$('#shadow').css('height', h+100);
	var html = $('#video').html();
	$('#video_w').append(html);

	var marginLeft = ($(window).width() - $('#video_w').width())/2 - 240 + 'px';
	var marginTop = (($(window).height() - $('#video_w').height())/2 + $(window).scrollTop()) - 135 + 'px';

	$('#video_w').css('top',marginTop);
	$('#video_w').css('left',marginLeft);	
	$('#shadow').fadeTo('500','0.3', function(){
		$('#video_w').stop().animate({height: '287px', width:'480px', opacity:'1'},600);
	});
	});
	$('#shadow').live('click',(function(){
		$('#video_w').stop().animate({height: '0px', width:'0px', opacity:'0'},600, function(){
			$('#shadow').stop().fadeOut('500',function(){
				$('#video_w').remove();	
			})		
		});
		
	}));
	$('.cls').live('click',(function(){
		$('#video_w').animate({height: '0px', width:'0px', opacity:'0'},600, function(){
			$(this).stop().fadeOut('fast');
			$('#shadow').stop().fadeOut('500', function(){
				$('#video_w').remove();		
			})		
		});
		
	}));
	
	//milk page

	$('a.fancy').click(function(){
		$('body').append('<div id="shadow"></div><div id="video_w"><img class="cls" src="/img/close.png" /></div>');
		var id = $(this).attr('id');

	$('#shadow').css('height', h+100);
	var html = $('#bmk'+id).html();
	$('#video_w').append(html);

	var marginLeft = ($(window).width() - $('#video_w').width())/2 - 240 + 'px';
	var marginTop = (($(window).height() - $('#video_w').height())/2 + $(window).scrollTop()) - 135 + 'px';

	$('#video_w').css('top',marginTop);
	$('#video_w').css('left',marginLeft);	
	$('#shadow').fadeTo('500','0.3', function(){
		$('#video_w').stop().animate({height: '287px', width:'480px', opacity:'1'},600);
	});
	return false;
	});
	
	$('.pop').live("click",(function(){
		var id = $(this).attr('id');
		var html = $('#bmk'+id).html();
		$('#video_w p').remove();
	$('#video_w').append(html);


	return false;
	}));
	var hide=true;
	$('a.pops').hover(function(e){

	//$('body').append('<div id="shadow"></div><div id="video_w"><img class="cls" src="/img/close.png" /></div>');
		var id = $(this).attr('id');

	//$('#shadow').css('height', h+100);
	var obj = $('#bmk'+id);
	
	var word = obj.html(); 
	var coord = $(this).offset();
	obj.css({left:coord.left-obj.width()/2+50,top:coord.top-obj.height()-30}).show(); 

	},function(e){

		var id = $(this).attr('id');
		var obj = $('#bmk'+id);
		obj.hide();	
	});
	
	//$('.pop').live("click",(function(){
	//	var id = $(this).attr('id');
	//	var html = $('#bmk'+id).html();
	//	$('#video_w p').remove();
	//$('#video_w').append(html);


	//return false;
	//}));
	
});

