
function voteNow (elementId, elementType, elementRate, containerId, containerIdent) {
	advAJAX.get({
		url: "/vote.php?eId=" + elementId + "&elementType=" + elementType + "&elementRate=" + elementRate,
	    timeout : 6000,
		onTimeout : function() {  },
	    retry: 3,
		retryDelay: 2000,
	    onRetry : function() {  },
		onRetryDelay : function() {  },
	    onSuccess : function(obj) { res = obj.responseText;
		if (res != 'verr') {
		document.getElementById('vRate_' + containerIdent).innerHTML = obj.responseText;
		}
		else {
		alert('Głosowałes(as) już na ten element.');
		} },
		onError : function(obj) {  }
	});
}

function vOver (elementId, elementVal) {

	for (i = elementVal; i > 0; i--)
	{
		document.getElementById(elementId + '_' + i).src = '/i/fireOn.gif';
	}
}

function vOut (elementId) {
	for (i = 1; i < 6; i++)
	{
		document.getElementById(elementId + '_' + i).src = '/i/fireOff.gif';
	}
}

function vSubMenu(id, container) {

	var mname = "sMenu" + id;
	var hmenu = document.getElementById(mname);
	var hcontainer = document.getElementById(container);



	hcontainer.innerHTML = hmenu.innerHTML;
}

function hSubMenu(container) {
	timeo = setTimeout("hide('" + container + "')", 6000);
}

function sSubMenuH() {
	clearTimeout(timeo);

}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function showMenu(elem, name) {
	if ($(elem) && $(name)) {
		pos = findPos($(elem.id));
		posMenu = findPos($("menu-main"));
		$(name).style.top = pos[1] + 48 + 'px';
		$(name).style.left = ((pos[0] - posMenu[0]) > 640) ? (pos[0] - 103) + 'px' : (pos[0] + 1) + 'px';
		$(name).style.display = 'block';
		$(name).style.visibility = 'visible';
		$(name).style.opacity = '.95'; 
		$(name).style.filter = 'alpha(opacity=95);';
		
		$(name).onmouseover = function over() {
			$(name).style.display = 'block'; 
			$(name).style.visibility = 'visible';
			
			
		};
		$(name).onmouseout = function out() {
			$(name).style.display = 'none'; 
			$(name).style.visibility = 'hidden';
		};
	}
}

function hideMenu(elem, name) {
	if ($(elem) && $(name)) {
		pos = findPos($(elem.id));
		$(name).style.display = 'none';
		$(name).style.visibility = 'hidden';
	}
}


function loadPhoto (photoUrl, photoWidth, photoHeight) {

	windowWidth = document.width;
	windowWidth = document.body.offsetWidth;
	photoWidth = photoWidth+10;
	math_1 = photoWidth/2;
	math_2 = windowWidth/2;

	marginLeft = math_2-math_1;
	marginLeft = marginLeft +5;
	document.getElementById('photoArea').style.marginLeft = marginLeft + "px";
	document.getElementById('photoArea').style.display = 'block';

	document.getElementById('loadImg').style.display = 'none';
	document.getElementById('loader').style.display = 'block';
	document.getElementById('loadImg').src = photoUrl;
}

function oloadPhoto (){
	document.getElementById('loadImg').style.display = 'block';
	document.getElementById('loader').style.display = 'none';
}

function closePhoto () {
	document.getElementById('photoArea').style.display = 'none';
}
