/* Menu Collapse, Tab Show/Hide */

function showBlock(id) {
	document.getElementById(id).style.display = "block";
}

function hideBlock(id) {
	document.getElementById(id).style.display = "none";
}

function toggleBlock(id) {
	// toggle visibility of selected element
	if(document.getElementById(id).style.display == "none") {
		showBlock(id);
	} else {
		hideBlock(id);
	}
}

function setTabVisibility(id, state) {
	// show/hide layer
	var obj = document.getElementById(id);
	obj.style.display = state ? "block" : "none";
	// swap tab btn
	var obj = document.getElementById('tabbtn-' + id);
	obj.style.display = state ? "block" : "none";
}

function selectTab(id) {
	setTabVisibility('info', id=='info');
	setTabVisibility('rate', id=='rate');
	setTabVisibility('comment', id=='comment');
}

/* Hide focus borders */

function link_down() {
	this.onfocus= this.blur;
}

function link_up() {
	this.onfocus= window.clientInformation ? null : window.undefined;
}

function link_bind() {
	var i;
	for (i= 0; i<document.links.length; i++) {
		document.links[i].onmousedown= link_down;
		document.links[i].onmouseup= link_up;
	}
}

function fullScreenPopup(url) {
	width = screen.width - 12;
	height = screen.height - (2*32);
	if(navigator.appVersion.indexOf("Mac") != -1)
		height -= 5;
	if(navigator.appVersion.indexOf("Mac") != -1 && document.all){
		if(screen.width == 1280 && screen.height == 1024)
			height +=12;
		if(screen.width == 1024 && screen.height == 768)
			height +=55;
	}
	str = "width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no";
	var popupwin = window.open(url,"popupwin",str);
	popupwin.focus();
}

/* Rating */

function showStars(rating) {
	document.ratingForm.rate.value = rating;
	for(var i=1;i<=rating;i++) {
		var obj = document.getElementById('star' + i);
		obj.src = "/images/ui/star_on.gif";
	}
	for(var i=rating+1;i<=5;i++) {
		var obj = document.getElementById('star' + i);
		obj.src = "/images/ui/star_off.gif";
	}
}

function maillink() {
	str_arr = new Array();
	str2_arr = new Array();
	str = location.host;
	str_arr = str.split(".");
	str2_arr[str2_arr.length] = str_arr.pop();
	str2_arr[str2_arr.length] = str_arr.pop();
	str2_arr.reverse();
	str = str2_arr.join(".");
	str = '@' + str;
	str = 'david' + str;
	str = '<a href="mailto:' + str + '">David Udvardy</a>';
	document.write(str);
}

