﻿/**
 *
 */
var siteColor = new Array('white','black');
var colorIndex;

// set cookies
function setCookie (name, value, expires, path, domain, secure) {
	  document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}


function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function changeSiteColor(color)
{
	$('body').attr('class','');
	$('body').addClass(siteColor[colorIndex]);
	
	if (colorIndex == 0) {
		colorIndex = 1;
		$('.change-color a').find('span').text('Сменить цвет фона на чёрный');
	}
	else {
		colorIndex = 0;
		$('.change-color a').find('span').text('Сменить цвет фона на белый');
	}
	
	setCookie("colorIndex", colorIndex, "", "/");
		
}

$(document).ready(function(){
		
		colorIndex = parseInt(getCookie("colorIndex"));
		if (!colorIndex) colorIndex = 0;
		
		$('.change-color a').click(function(){
			changeSiteColor();
			return false;
		})
		
		$('.main-menu .item').hover(
			function(){$(this).addClass('hover')},
			function(){$(this).removeClass('hover')}
		)
	
		$('.thickbox').fancybox({
			'zoomSpeedIn': 200,
			'zoomSpeedOut': 200,
			'frameWidth': 100,
			'frameHeight': 100,
			'overlayShow': true,
			'callbackOnStart': function()
			{
				$('body').css('overflow','hidden');
			},
			'callbackOnClose': function()
			{
				$('body').css('overflow','visible');
			}
		});
		
		$('.thickbox-item').fancybox({
			'frameWidth': 600,
			'frameHeight': 650,
			'zoomSpeedIn': 200, 
			'zoomSpeedOut': 200,
			'overlayShow': true,
			'overlayOpacity' : 0.5,
			'padding': 0,
			'centerOnScroll': false,
			'zoomOpacity': true,
			'hideOnContentClick': false,
			'callbackOnShow': function()
			{
				$('#fancy_content').css('overflow-x','hidden');
				$('#fancy_overlay').height($('.page').height());
			},
			'callbackOnClose': function()
			{
				$('#fancy_ajax').css('overflow','visible');
			}
		});
	
})

