var focused = new Array;

var initFunctions = 
{
	init: function (){
		objects = Core.getElementsByClass("inputformfooter");
		for(i=0; i<objects.length; i++){
			objects[i].onfocus = initFunctions.focusHandler;
			objects[i].onblur = initFunctions.blurHandler;
			objects[i].onmouseover = initFunctions.mouseoverHandler;
			objects[i].onmouseout = initFunctions.mouseoutHandler;			
		}
		objectsContact = Core.getElementsByClass("inputFormContact");
		for(i=0; i<objectsContact.length; i++){
			objectsContact[i].onfocus = initFunctions.focusHandler;
			objectsContact[i].onblur = initFunctions.blurHandler;
			objectsContact[i].onmouseover = initFunctions.mouseoverHandler;
			objectsContact[i].onmouseout = initFunctions.mouseoutHandler;			
		}
		var links = document.getElementsByTagName("a");
		for (var j=0; j<links.length; j++) {
			var curentLink = links[j];
			if (curentLink.getAttribute("href") && curentLink.getAttribute("rel") == "external")
				curentLink.onclick = initFunctions.externalLink;
			else if (curentLink.getAttribute("rel") == "top")
				curentLink.onclick = initFunctions.topLink;
		}
		var terms = document.getElementById("terms");
			terms.onclick = initFunctions.terms;
		var privacy = document.getElementById("privacy");
			privacy.onclick = initFunctions.privacy;
	},
	focusHandler: function (){
		this.style.borderColor = '#C46A6A';
		focused[this.name] = true;
	},
	blurHandler: function (){
		this.style.borderColor = '#ccc';
		focused[this.name] = false;

	},
	mouseoverHandler: function (){
		this.style.borderColor = '#999999';
	},
	mouseoutHandler: function (){
		if (focused[this.name] == true)
			this.style.borderColor = '#C46A6A';
		else
			this.style.borderColor = '#ccc';
	},
	externalLink: function(){
		window.open(this.href);
		return false;
	},
	topLink: function(){
		var topElement = document.getElementById('top');
		new SmoothScroll({duration:400}).toElement(topElement);
	},
	terms: function(){
		window.open('terms.php','terms', 'width=400, height=500, scrollbars=yes');
		return false;
	},
	privacy: function(){
		window.open('privacy.php','privacy', 'width=400, height=500, scrollbars=yes');
		return false;
	}
}

Core.start(initFunctions);
