/**********************************************/
/* Global variables
/**********************************************/
var current_id;

/**********************************************/
/* Shows item according to ID
/**********************************************/
function show_item(str_id) {
	var elem;
	
	// Hide current item
	if (current_id != null) hide_item(current_id);
	
	if (current_id == str_id) {
		current_id = null;	
	}
	else {	
		current_id = str_id;
		
		// Show icon
		elem = document.getElementById("icon-" + str_id);
		if (elem != null) elem.className = "icon-item";
		
		// Show content
		elem = document.getElementById("content-" + str_id);
		elem.className = "content-item";
		
		// Show meta information
		elem = document.getElementById("meta-" + str_id);
		elem.className = "meta-item";
		
		// Hide thumbnail
		elem = document.getElementById("image_tn-" + str_id);
		if (elem != null) elem.className = "image_tn-item hidden";
	}	
}

/**********************************************/
/* Hides items
/**********************************************/
function hide_item(str_id) {
	var elem;
		
	// Hide icon
	elem = document.getElementById("icon-" + str_id);
	if (elem != null) elem.className = "icon-item hidden";
	
	// Hide content
	elem = document.getElementById("content-" + str_id);
	elem.className = "content-item hidden";
	
	// Hide meta information
	elem = document.getElementById("meta-" + str_id);
	elem.className = "meta-item hidden";
	
	// Show thumbnail
	elem = document.getElementById("image_tn-" + str_id);
	if (elem != null) elem.className = "image_tn-item";	
}

/**********************************************/
/* Shows first item on page
/**********************************************/
function show_first_item() {
	var divs;
	var id;
	
	// Get all div containers
	divs = document.getElementsByTagName("div");
	id = "";
	
	// Go through all divs and find first post
	for (i=0;i<divs.length;i++) {
		if (divs[i].id.substr(0,4) == "post") {
			id = divs[i].id.substr(5);
			break;
		}
	}
	
	// Show first item if it was found
	if (id != "") {
		show_item(id);
	}
}

/**********************************************/
/* Submits form for newsletter registration
/**********************************************/
function newsletter_register() {
	document.frm_newsletter.submit();
	return true;
}