//window.onload = prepareLinks;

function prepareLinks(){
	var anchors = document.getElementsByTagName("a");

	for(var i = 0; i < anchors.length; i++){
		if(anchors[i].className == "decFontSize"){
			anchors[i].onclick = function (){
				decreaseFontSize();
				return false;
			}
		}
		if(anchors[i].className == "setDefaultFontSize"){
			anchors[i].onclick = function (){
				setDefaultFontSize();
				return false;
			}
		}
		if(anchors[i].className == "incFontSize"){
			anchors[i].onclick = function (){
				increaseFontSize();
				return false;
			}
		}
	}
}

function setDefaultFontSize(){
	document.getElementsByTagName('body')[0].style.fontSize = "100%";
}

function increaseFontSize(){
	var currentSize = prepareFontSize();
	var newSize = parseInt(currentSize) + 10;

	document.getElementsByTagName('body')[0].style.fontSize = newSize + "%";
}

function decreaseFontSize(){
	var currentSize = prepareFontSize();
	var newSize = parseInt(currentSize) - 10;

	document.getElementsByTagName('body')[0].style.fontSize = newSize + "%";
}

function prepareFontSize(){
	var currentSize = document.getElementsByTagName('body')[0].style.fontSize;
	if(currentSize == ""){
		document.getElementsByTagName('body')[0].style.fontSize = "100%";
		currentSize = document.getElementsByTagName('body')[0].style.fontSize;
	}
	currentSize = currentSize.substring(0, currentSize.length - 1);

	return currentSize;
}

function initOverLabels() {
	if (!document.getElementById) return;

	var labels, id, field;

	// Set focus and blur handlers to hide and show
	// labels with 'overlabel' class names.
	labels = document.getElementsByTagName('label');
	for (var i = 0; i < labels.length; i++) {

		if (labels[i].className == 'overlabel') {

			// Skip labels that do not have a named association
			// with another field.
			id = labels[i].htmlFor || labels[i].getAttribute('for');
			if (!id || !(field = document.getElementById(id))) {
				continue;
			}

			// Change the applied class to hover the label
			// over the form field.
			labels[i].className = 'overlabel-apply';

			// Hide any fields having an initial value.
			if (field.value !== '') {
				hideLabel(field.getAttribute('id'), true);
			}

			// Set handlers to show and hide labels.
			field.onfocus = function () {
				hideLabel(this.getAttribute('id'), true);
			};
			field.onblur = function () {
				if (this.value === '') {
					hideLabel(this.getAttribute('id'), false);
				}
			};

			// Handle clicks to label elements (for Safari).
			labels[i].onclick = function () {
				var id, field;
				id = this.getAttribute('for');
				if (id && (field = document.getElementById(id))) {
					field.focus();
				}
			};

		}
	}
}
;

function hideLabel(field_id, hide) {
	var field_for;
	var labels = document.getElementsByTagName('label');
	for (var i = 0; i < labels.length; i++) {
		field_for = labels[i].htmlFor || labels[i].getAttribute('for');
		if (field_for == field_id) {
			labels[i].style.textIndent = (hide) ? '-1000px' : '0px';
			return true;
		}
	}
}

function prepareHover(){
	if(!document.getElementsByTagName) return false;

	var inputs = document.getElementsByTagName("input");

	for (var i = 0; i < inputs.length; i++){
		if(inputs[i].className == "input-submit"){
			inputs[i].onmouseover = function (){
				this.style.backgroundColor = "#fff";
			}
			inputs[i].onmouseout = function (){
				this.style.backgroundColor = "#484a52";
			}
		}
	}


}

window.onload = function () {
	prepareLinks();
	prepareHover();
	setTimeout(initOverLabels, 50);
};
