/**
 * version		$Id: global.js 5 2009-11-17 19:53:18Z sfekonja $
 * filesource
 */

/* ---------------------------------------------------------------------- */
/* AUTOLOAD */


/* ---------------------------------------------------------------------- */
/* VARS */


/* ---------------------------------------------------------------------- */
/* FUNCTIONS */
function activatePlaceholder() {			
	var detect = navigator.userAgent.toLowerCase();

	if (detect.indexOf('safari') > 0) {
		return false;
	}
	
	// Input
	var inputElements = document.getElementsByTagName('input');
	
	for (var i=0; i<inputElements.length; i++) {
		if (inputElements[i].getAttribute('placeholder') && inputElements[i].getAttribute('placeholder').length > 0) {
			inputElements[i].value = inputElements[i].getAttribute('placeholder');
			inputElements[i].style.color = '#808080';
			
			inputElements[i].onfocus = function() {
				if (this.value == this.getAttribute('placeholder')) {
					this.value = '';
					this.style.color = '#212121';
				}
				
				return false;
			}

			inputElements[i].onblur = function() {
				if (this.value.length < 1) {
					this.value = this.getAttribute('placeholder');
					this.style.color = '#808080';
				}
			}
		}
	}
	
	// Textarea
	var textareaElements = document.getElementsByTagName('textarea');
	
	for (var i=0; i<textareaElements.length; i++) {
		if (textareaElements[i].getAttribute('placeholder') && textareaElements[i].getAttribute('placeholder').length > 0) {
			textareaElements[i].innerHTML = textareaElements[i].getAttribute('placeholder');
			textareaElements[i].style.color = '#808080';
			
			textareaElements[i].onfocus = function() {
				if (this.innerHTML == this.getAttribute('placeholder')) {
					this.innerHTML = '';
					this.style.color = '#212121';
				}
				
				return false;
			}

			textareaElements[i].onblur = function() {
				if (this.innerHTML.length < 1) {
					this.innerHTML = this.getAttribute('placeholder');
					this.style.color = '#808080';
				}
			}
		}
	}
}