
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;
}


//additional properties for jQuery object
$(document).ready(function(){
	//align element in the middle of the screen
	$.fn.alignCenter = function() {
		var msie = ((navigator.appVersion.indexOf("MSie")!= -1)&&!window.opera)? true : false;
		
		//get margin left
		var hscroll =  f_scrollLeft();
		
		var marginLeft = Math.max(40, parseInt($(window).width()/2 - $(this).width()/2)) + parseInt(hscroll) + 'px';
		
		//get margin top
		var vscroll = f_scrollTop();
		var marginTop = Math.max(40, parseInt($(window).height()/2 - $(this).height()/2)) + parseInt(vscroll) + 'px';
		
		//return updated element
		return $(this).css({'margin-left':marginLeft, 'margin-top':marginTop});
	};

	$.fn.togglePopup = function(){
		//detect whether popup is visible or not
		if($('#popup').hasClass('hidden'))
		{
			//hidden - then display
			//when IE - fade immediately
			if($.browser.msie)
			{
				$('#opaco').height($(document).height()).toggleClass('hidden');
			}
			else
			//in all the rest browsers - fade slowly
			{
				$('#opaco').height($(document).height()).toggleClass('hidden').fadeTo('slow', 0.7);
			}

			$('#popup')
			.html($(this).html())
			.alignCenter()
			.toggleClass('hidden');
		}
		else
		{
			//visible - then hide
			$('#opaco').toggleClass('hidden').removeAttr('style');
			$('#popup').toggleClass('hidden');
		}
	};
});


window.onscroll = function () {
	margin_top = f_scrollTop();
	if (margin_top > 240) {
		margin_top = 240;
	}
	y = 240 - margin_top;
	$('.bigpic').css({'top': y, 'position': 'fixed'});
	//document.getElementByClass("big")
}
function allsite(id){
    obj = document.getElementById(id);
if (obj) {
  if (obj.className=='hidden')  { obj.className='visible'; } else {obj.className='hidden'; }
}
}
function hidediv(id){
    obj = document.getElementById(id);
if (obj) {
  if (obj.className=='visible')  { obj.className='hidden'; }
}
}
