//Copyright 2007 www.liteweb.info
//Version 1.0
String.prototype.TrimLeft=function()
{
	return this.replace(/^(\s|\xA0|&nbsp;)*/,"");
};
String.prototype.TrimRight=function()
{
	return this.replace(/(\s|\xA0|&nbsp;)*$/,"");
};
String.prototype.trim = String.prototype.Trim=function()
{
	return this.TrimLeft().TrimRight();
};
String.prototype.Format = function()
{
	var s=this;
	for(var i=0;i<arguments.length;i++)
	{
		var reg = new RegExp("\\\{"+i+"\\\}","g");
		s=s.replace(reg,arguments[i]);
	}
	return s;
}
function Dimension(el)
{
	this.width = el.offsetWidth;
	this.height = el.offsetHeight;
}
function GetPosition(el)
{
	var l=el.offsetLeft,t=el.offsetTop;
	while ((el = el.offsetParent) != null)
	{
		l+=el.offsetLeft;
		t+=el.offsetTop;
	}
	var obj = {
		"top": t, "left": l
	};
	return obj;
};
function GetMousePosition(f)
{
	var top = event.y + window.document.body.scrollTop;
	var left = event.x + window.document.body.scrollLeft;
	if(f)
	{
		var pos = GetPosition(f.frameElement);
		top += pos.top;
		left += pos.left;
	}
	var obj = {
		"top": top, "left": left
	};
	return obj;
}
var __popCurrentFade = 0;
var __popCurrentZoom = 0;
var __ZoomStartX, __ZoomStartY;
var __ZoomStartW, __ZoomStartH;
function ZoomoutPopup()
{
	var div = document.getElementById("PopupInfo");
	if(!div)
		return;
	__popCurrentZoom -= 10;
	div.style.zoom = __popCurrentZoom + "%";
	if(__popCurrentZoom < 10)
	{
		div.style.visibility = "hidden";
		return;
	}
	div.style.top = parseInt(__ZoomStartY) + 20 + "px";
	div.style.left = (parseInt(__ZoomStartX) +  parseInt(__ZoomStartW) - 35 - parseInt(__ZoomStartW)*__popCurrentZoom/100) + "px";

	setTimeout(ZoomoutPopup, 10);
}
function ZoominPopup()
{
	var div = document.getElementById("PopupInfo");
	if(!div)
		return;
	
	if(__popCurrentZoom >= 100)
		return;

	if(__popCurrentZoom == 0)
		div.style.visibility = "visible";
		
	__popCurrentZoom += 10;
	div.style.zoom = __popCurrentZoom + "%";
	
	div.style.top = (parseInt(__ZoomStartY) + parseInt(__ZoomStartH) - parseInt(div.offsetHeight) + (120 - 120*__popCurrentZoom/100)) + "px";
	div.style.left = (parseInt(__ZoomStartX) +  parseInt(__ZoomStartW) - parseInt(__ZoomStartW)*__popCurrentZoom/100) + "px";
	
	setTimeout(ZoominPopup, 10);
}
function FadeInPopup()
{
	var div = document.getElementById("PopupInfo");
	if(!div)
		return;

	if(__popCurrentFade > 100)
	{
		if("string" == typeof div.style.filter)
			div.style.filter = "";
		return;
	}
	if(__popCurrentFade == 0)
		div.style.visibility = "visible";
	
	if("string" == typeof div.style.filter)
	{
		__popCurrentFade += 10;
		div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity={0})".Format(__popCurrentFade);
	}
	else
	{
		__popCurrentFade += 2;
		div.style.opacity = __popCurrentFade/100;
	}
	setTimeout(FadeInPopup, 10);
}
function FadeOutPopup()
{
	var div = document.getElementById("PopupInfo");
	if(!div)
		return;
		
	if(__popCurrentFade < 0)
	{
		div.style.visibility = "hidden";
		__popCurrentFade = 0;
		return;
	}

	if("string" == typeof div.style.filter)
	{
		__popCurrentFade -= 10;
		div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=2,opacity={0})".Format(__popCurrentFade);
	}
	else
	{
		__popCurrentFade -= 2;
		div.style.opacity = __popCurrentFade/100;
	}
	
	
	setTimeout(FadeOutPopup, 10);
}
function HideInfoPopup()
{
	
	var div = document.getElementById("PopupInfo");
	if(!div)
		return;
		
	if("string" == typeof div.style.filter)
	{
		__ZoomStartX = div.style.left;
		__ZoomStartY = div.style.top;
		__ZoomStartW = parseInt(div.offsetWidth);
		__ZoomStartH = div.offsetHeight;
		ZoomoutPopup();
	}
	else
		FadeOutPopup();
	return;
	var div = document.getElementById("PopupInfo");
	if(!div)
		return;
	div.style.visibility = "hidden";
}
function InfoPopup(field, text)
{
	__popCurrentFade = 0;
	var div = document.getElementById("PopupInfo");
	if(!div)
		return;
	
	div.innerHTML = text;
	var pos = GetPosition(field);
	var dim = new Dimension(field);
	
	div.style.top = (parseInt(pos.top) - 80) + "px";
	div.style.left = pos.left + dim.width - 40 - 225 + "px";
	if("string" == typeof div.style.filter)
	{
		__ZoomStartX = div.style.left;
		__ZoomStartY = parseInt(div.style.top);
		__ZoomStartW = parseInt(div.offsetWidth);
		__ZoomStartH = div.offsetHeight;
		ZoominPopup();
	}
	else
		FadeInPopup();
	//div.style.visibility = "visible";
}
function Trank(str,len)
{
	return str.length > len? str.substring(0, len) + (len > 3? "...": ""): str;
}
function InitFormValue(f, v)
{
	switch(f.type)
	{
		case "file":
			break;
		case "select-one":
			for(var j = 0; j < f.options.length; j++)
			{
				if(f.options[j].value == v)
				{
					f.options[j].selected = true;
					break;
				}
			}
			break;
		case "checkbox":
			f.checked = v;
			break;
		case "radio":
			f.checked = v;
			break;
		default:
			f.value=value;
			break;
	}
}
function defined(a)
{
	var ret = (typeof(a)=="undefined");
	if (ret == true) 
	   return false;
	if (typeof(a) == "string" && a=="")
	   return false;
	return (a!=null);
}
function GetViewWidth(full)
{
	if(!jQuery)
		return null;
	return full ? Math.max(jQuery(document).width(), jQuery(window).width()) : jQuery(window).width();
}

function GetViewHeight(full)
{
	if(!jQuery)
		return null;
	return full ? Math.max(jQuery(document).height(), jQuery(window).height()) : jQuery(window).height();
}
function displaynews(i)
{
	if(i == liteweb.lastNews)
		return;
	$(".n-pages a:eq(" + liteweb.lastNews + ")").removeClass("ac");
	$(liteweb.newsList[liteweb.lastNews]).fadeOut(500);
	$(liteweb.newsList[i]).fadeIn(1500);
	liteweb.lastNews = i;
	$(".n-pages a:eq(" + i + ")").addClass("ac");
}
function displaytesti(i)
{
	if(i == liteweb.lastTesti)
		return;
	$(".nav a:eq(" + liteweb.lastTesti + ")").removeClass("ac");
	$(liteweb.testiList[liteweb.lastTesti]).fadeOut("slow");
	$(liteweb.testiList[i]).fadeIn("slow");
	liteweb.lastTesti = i;
	$(".nav a:eq(" + i + ")").addClass("ac");
}

function displaygallery(i)
{
	if(i == liteweb.lastGallery)
		return;
	$(".g-pages a:eq(" + liteweb.lastGallery + ")").removeClass("ac");
	$(liteweb.GalleryList[liteweb.lastGallery]).fadeOut(500);
	$(liteweb.GalleryList[i]).fadeIn(1500);
	liteweb.lastGallery = i;
	$(".g-pages a:eq(" + i + ")").addClass("ac");
}
function addStyle(name, rules)
{
	var node = document.createElement("style");
	node.setAttribute("type", "text/css");
	var text = "{0}{{1}}".Format(name, rules);
	var isIE = /msie/i.test(navigator.userAgent);
	if(!isIE)
		node.appendChild(document.createTextNode(text));
	document.getElementsByTagName("head")[0].appendChild(node);
	if(isIE && document.styleSheets && document.styleSheets.length > 0)
	{
		var lastStyle = document.styleSheets[document.styleSheets.length - 1];
		if(typeof(lastStyle.addRule) == "object")
			lastStyle.addRule(name, rules);
	}
}
