function trim (str) {
	str = this != window? this : str;
	return str.replace(/^\s+|\s+$/g,"");
}

function on_click(input) {
	var value = input.value;
	switch(input.name) {
		case 'phone_number':
			if (value == '+ 7 032 345 5636') {
				input.value = '';
			}
			break;
		case 'passcode':
			if (value == 'Passcode') {
				input.value = '';
			}
			break;
		case 'captcha':
			if (value == 'UFENIE') {
				input.value = '';
			}
			break;
		default:
		  break;
	}
}

function on_blur(input) {
	var value = input.value;
	switch(input.name) {
		case 'phone_number':
			if (trim(value) == '') {
				input.value = '+ 7 032 345 5636';
			}
			break;
		case 'passcode':
			if (trim(value) == '') {
				input.value = 'Passcode';
			}
			break;
		case 'captcha':
			if (trim(value) == '') {
				input.value = 'UFENIE';
			}
			break;
		default:
		  break;
	}
}

function setButtonsAttributes() {
	$$('.custom_buttons').invoke('observe', 'mouseover', function(event) {
		this.className = 'custom_buttons b_hover';
	});
	$$('.custom_buttons').invoke('observe', 'mouseout', function(event) {
		this.className = 'custom_buttons';
	});
	$$('.custom_buttons').invoke('observe', 'click', function(event) {
		this.className = 'custom_buttons b_click';
	});
	
	$$('.custom_buttons_big').invoke('observe', 'mouseover', function(event) {
		this.className = 'custom_buttons_big b_hover';
	});
	$$('.custom_buttons_big').invoke('observe', 'mouseout', function(event) {
		this.className = 'custom_buttons_big';
	});
	$$('.custom_buttons_big').invoke('observe', 'click', function(event) {
		this.className = 'custom_buttons_big b_click';
	});
}

/*
function getButtonsClassName() {
	buttons = document.getElementsByTagName("div");
	for(a = 0; a < buttons.length; a++) {
		if(buttons[a].className == "custom_buttons") {
			//buttons[a].setAttribute('onmouseover', 'buttonHover(this)');
			//buttons[a].setAttribute('onmouseout', 'function() { buttonOut(this); }');
			//buttons[a].setAttribute('onclick', 'buttonClick(this)');
		}
	}
}

function buttonHover(buttons) {
	//buttons.setAttribute('class', 'custom_buttons b_hover');
	var divs = buttons.getElementsByTagName("div");
	for(a = 0; a < divs.length; a++) {
		if(divs[a].className == "buttons_left")
		{
			divs[a].style.backgroundPosition = '0 -28px';
		}
		else if(divs[a].className == "buttons_right")
		{
			divs[a].style.backgroundPosition = '100% -28px';
		}
		
		var inputs = divs[a].getElementsByTagName("input");
		for(b = 0; b < inputs.length; b++) {
			inputs[b].style.backgroundPosition = '0 -28px';
		}
	}
}

function buttonOut(buttons) {
	//buttons.setAttribute('class', 'custom_buttons');
	var divs = buttons.getElementsByTagName("div");
	for(a = 0; a < divs.length; a++) {
		if(divs[a].className == "buttons_left")
		{
			divs[a].style.backgroundPosition = '0 0';
		}
		else if(divs[a].className == "buttons_right")
		{
			divs[a].style.backgroundPosition = '100% 0';
		}
		
		var inputs = divs[a].getElementsByTagName("input");
		for(b = 0; b < inputs.length; b++) {
			inputs[b].style.backgroundPosition = '0 0';
		}
	}
}

function buttonClick(buttons) {
	//buttons.setAttribute('class', 'custom_buttons b_click');
	var divs = buttons.getElementsByTagName("div");
	for(a = 0; a < divs.length; a++) {
		if(divs[a].className == "buttons_left")
		{
			divs[a].style.backgroundPosition = '0 -56px';
		}
		else if(divs[a].className == "buttons_right")
		{
			divs[a].style.backgroundPosition = '100% -56px';
		}
		
		var inputs = divs[a].getElementsByTagName("input");
		for(b = 0; b < inputs.length; b++) {
			inputs[b].style.backgroundPosition = '0 -56px';
		}
	}
}

function getElementsByClassName(classname, node) {
	if(!node) node = document.getElementsByTagName("body")[0];
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for(var i=0,j=els.length; i<j; i++)
	if(re.test(els[i].className))a.push(els[i]);
	return a;
}
*/
window.onload = Globals.initialize;
