/* homepage banner effect */
var szNormal = 224, szSmall  = 203, szFull = 287, smHeight = 263;
var kwicks = $$("#banner .kwick");
var smallcontents = $$(".kwick .small-content");
var fxk = new Fx.Elements(kwicks, {wait: false, duration: 700, transition: 'Quint:out'});
var fxc = new Fx.Elements(smallcontents, {wait: false, duration: 700, transition: 'Quint:out'});
kwicks.each(function(kwick, i) {
	kwick.addEvent("mouseenter", function(event) {
		var k = {};
		var c = {};
		k[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
		c[i] = {height: [smallcontents[i].getStyle("height").toInt(), 0]};
		kwicks.each(function(other, j) {
			if(i != j) {
				var w = other.getStyle("width").toInt();
				var h = smallcontents[j].getStyle("height").toInt();
				if(w != szSmall) k[j] = {width: [w, szSmall]};
				if(h != smHeight) c[j] = {height: [h, smHeight]};
			}
		});
		fxk.start(k);
		fxc.start(c);
	});
});

$("banner").addEvent("mouseleave", function(event) {
	var k = {};
	var c = {};
	kwicks.each(function(kwick, i) {
		k[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
		c[i] = {height: [smallcontents[i].getStyle("height").toInt(), smHeight]};
	});
	fxk.start(k);
	fxc.start(c);
});

/* form text inputs handler */
var tis = $$("form input.text");  // store form text input elements in an array
var defs = {}; // holds the default values
tis.each(function(ti, i) {
	defs[i] = ti.value;
	ti.addEvent("focus", function() {
		if(ti.value == 'password') {
			var newInput = document.createElement('input');
   			newInput.type = 'password'; // that should work even with IE
   			newInput.name = ti.name;
   			newInput.value = '';
			newInput.className = 'text';
   			ti.parentNode.replaceChild(newInput, ti);
			newInput.focus();
			newInput.select();
		}
		if(ti.value == defs[i]) ti.value = '';
	});
	
	/*ti.addEvent("blur", function() {
		if(ti.value == '') { 
			ti.value = defs[i]; 
		}
	});*/
	
});

/* this can be removed after implementation */
var anchors = $$("a");
anchors.each(function(anchor) {
	if(anchor.get('href') == '#') {
		anchor.addEvent("click", function() {
			return false;
		});
	}
});