//FUNCTIONS FOR DEMENTION OF CLIENT WIDTH, HEIGHT, SCROLLLEFT AND SCROLLTOP

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
//============================================================================


//AUTOSCROLL DECLARATION
//--//$(document).ready(function(){$.autoscroll.init({step: 30,interval:1}); });

/* if (document.addEventListener){
	document.addEventListener("DOMMouseScroll", function(e) {e.preventDefault()} ,true);
	document.addEventListener("mousewheel", function(e) {e.preventDefault()} ,true);
} else {
	document.attachEvent("onmousewheel", function(e) {return false});
} */


//FANCYBOX DECLARATION
$(document).ready(function() {
	$("a.iframe").fancybox({'frameWidth': 800, 'frameHeight': 600, 'callbackOnClose': function(){$("#fancy_wrap").remove(); $(window).resize(doFluid); doFluid(); /* resizing();$.autoscroll.init({step: 30,interval:1}); */ }, 'callbackOnStart': function(){/* $.autoscroll.init({step: 0,interval:0});*/ } } ); 
	$('a.iframe').click(function() {$.fn.fancybox.build();});
}); 


//TOOLTIP DECLARATION
$(function() {

$(".a-fancy").tooltip({
	track: true,
	delay: 500,
	/* fade: 700, */
	showURL: false,
	/* showBody: " | ", */
	fixPNG: false,
	extraClass: "fancy",
	top: -100,
	left: -60
});

});

/* //POSITION CENTER FIXING
function resizing()
{
	var d=new Date();
	var w=f_clientWidth();
	//var w=$(window).width();
	//document.title = "DBG / w = " + w + "/ d = " + d;
	//var b=1650; //Ширина одной ячейки 150px, всей таблицы 150*колстолбцов.
	var b=150*14;
	var left=(w-b)/2;
	if(left<0) left=0;
	$(".tpl-header-all").css("left",left);
	$("#tpl-thumbtable").css("left",left);
	if(w<b) $(".style-switcher").css("width",w-30); else $(".style-switcher").css("width",b-30);
}
 */
//--//$(document).ready(function() {resizing();}); 
//--//$(window).resize(function() {resizing();});


$(document).ready(function() {

	var day = [
		'Черный!'
	/*	'Выключите свет!',
		'Хочу в ночь!',
		'Взываю к темным силам!',
		'Нас ждут из темноты…',
		'Я продал душу тьме',
		'Зал Клана Темных Воинов!',
		'Затмение!',
		'Не Вижу, Но Слышу!' */
	]
	
	var night = [
		'Белый!'
	/*	'Да будет свет!',
		'Я люблю когда светло!',
		'Выйти из сумрака!',
		'Пусть всегда будет солнце!',
		'Прозрение!',
		'Просветление!',
		'В Рай!',
		'К Свету!',
		'Включить Освещение!' */
	]
	
	rnd_wr1=rand(day.length - 1);
	rnd_wr2=rand(night.length - 1);
	
	$('.style-switcher a').text(day[rnd_wr1]);

	$('.style-switcher a').click(function(){

		rnd_wr1=rand(day.length - 1);
		rnd_wr2=rand(night.length - 1);
		$('body').toggleClass('night');
		if($('body').hasClass('night')) $('.style-switcher a').text(night[rnd_wr2]);
		else $('.style-switcher a').text(day[rnd_wr1]);

});

}); 

/* function rand(max)
	  {
		  var num=Math.round(Math.random()*100)
		  if(num==0) num=1;
		  num=Math.round((num)*max/100);
		  //alert(num);
		  return num;
	  }

*/

function rand (max){
	var n = Math.floor(Math.random() * (max + 1));
	return n;
}

