/*
Title  : vamet.la - Fabula quanta fui
URL    : http://www.vamet.la/
Author : Mateusz Kiczela
E-mail : webmaster@vamet.la
Script : Functions
Author : Unknown
*/
function flipBox(who) {
	var tmp;
	if (document.images['b_' + who].src.indexOf('_on') == -1) {
		tmp = document.images['b_' + who].src.replace('_off', '_on');
		document.getElementById('box_' + who).style.display = 'none';
		document.images['b_' + who].src = tmp;
	}
	else {
		tmp = document.images['b_' + who].src.replace('_on', '_off');
		document.getElementById('box_' + who).style.display = 'block';
		document.images['b_' + who].src = tmp;
	}
}

function switchImg(mEvent) {
	if (mEvent.srcElement) {
		element = mEvent.srcElement;
	}
	else if (mEvent.target) {
		element = mEvent.target;
	}

	if (mEvent.type == 'mouseover') {
		if (element.src.indexOf('_on') == -1 ) {
			element.src = element.src.replace('_off', '_off_over');
		}
		else {
			element.src = element.src.replace('_on', '_on_over');
		}
	}
	else if (mEvent.type == 'mouseout') {
		if (element.src.indexOf('_on') == -1 ) {
			element.src = element.src.replace('_off_over', '_off');
		}
		else {
			element.src = element.src.replace('_on_over', '_on');
		}
	}
}

function chars(amount, input, count) {
	var maxChars = amount;
	theInputBox = document.getElementById(input);
	theCountBox = document.getElementById(count);
	var currentChars = theInputBox.value.length;
	theCountBox.value = Math.max((maxChars - currentChars), 0);
	if (currentChars > maxChars) {
		theInputBox.value = theInputBox.value.substring(0, maxChars);
	}
	document.getElementById(count).innerHTML = theInputBox.value.length + " z " + maxChars + " (" + theCountBox.value + ")";
}

function charsleft() {
	var maxChars = 6;
	theInputBox = document.getElementById('codetext');
	theCountBox = document.getElementById('field_code');
	var currentChars = theInputBox.value.length;
	theCountBox.value = Math.max((maxChars - currentChars), 0);
	if (currentChars > maxChars) {
		theInputBox.value = theInputBox.value.substring(0, maxChars);
	}
	document.getElementById('field_code').innerHTML = theInputBox.value.length + " z " + maxChars + " (" + theCountBox.value + ")";
}

function over_help(imageName) {
	document.images['thumbnail_' + imageName].src='image_help_type_' + imageName + '_over.png';
}

function gray_help(imageName) {
	document.images['thumbnail_' + imageName].src='image_help_type_' + imageName + '_gray.png';
}

function over_galleries(imageName) {
	document.images['thumbnail_' + imageName].src='image_galleries_gallery_' + imageName + '_over.png';
}

function gray_galleries(imageName) {
	document.images['thumbnail_' + imageName].src='image_galleries_gallery_' + imageName + '_gray.png';
}

function over_links(imageName) {
	document.images['thumbnail_' + imageName].src='image_links_set_' + imageName + '_over.png';
}

function gray_links(imageName) {
	document.images['thumbnail_' + imageName].src='image_links_set_' + imageName + '_gray.png';
}

function over_hobby(imageName) {
	document.images['thumbnail_' + imageName].src='image_hobby_realm_' + imageName + '_over.png';
}

function gray_hobby(imageName) {
	document.images['thumbnail_' + imageName].src='image_hobby_realm_' + imageName + '_gray.png';
}
