/*--- IE6 png fix ---*/
var transparentImage = "images/none.gif";
function fixTrans() {
	if (typeof document.body.style.maxHeight == 'undefined') {
		var imgs = document.getElementsByTagName("img");
		for (i = 0; i < imgs.length; i++) {	
			if (imgs[i].src.indexOf(".png") != -1){
				var src = imgs[i].src;
				imgs[i].src = transparentImage;
				imgs[i].runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='crop')";
			}
		}	
	}
}
if (document.all && !window.opera) attachEvent("onload", fixTrans);

/*--- hidden block function ---*/
function hideBlock(){
	$$('div.quick-tip').each(function(_box){
		var t_btn = _box.getElementsByTagName('a');
		for(var i = 0; i < t_btn.length; i++){
			if(t_btn[i].className.indexOf('close') != -1) _btn = t_btn[i];
		}
		if(_btn){
			var _f = true;
			_box.moo = new Fx.Morph(_box, {
				duration: 400,
				transition: 'cubic:out',
				link:'cancel',
				'onComplete': function(_this){
					if(_f) _this.style.height = 'auto';
					else _this.destroy();//_this.setStyles({display: 'none', height: 'auto'});
				}
			});
			_btn.onclick = function(){
				if(_f){
					_f = false;
					_box.moo.start({opacity: 0, height: 0});
				}
				return false;
			}
		}
	});
}
/*--- autocomplete function ---*/
function initAutocomplete(){
	$$('input.with-autocomplete').each(function(_el){
		var t5 = new TextboxList(_el, {unique: true, plugins: {autocomplete: {
			minLength: 1,
			queryRemote: true,
			remote: {url: 'autocomplete2.php'}
		}}});
		t5.add('Elies Campo').add('Mat Austin').add('Xavi Orduña').add('Mat Austin2').add('Elies Campo2');
	});
}
/*--- datepicker ---*/
function initDatepicker(){
	$$('div.with-calendar').each(function(_this){
		var _btn = _this.getElement('span.open-link');
		var _field = _this.getElement('input');
		if(_btn && _field){
			new DatePicker(_field, {
				inputOutputFormat: 'd-m-Y',
				allowEmpty: true,
				toggleElements: _btn
			});
		}
		
	});
}
function initPage(){
	hideBlock();
	//initAutocomplete();
	initDatepicker();
}

//window.addEvent('domready',function(){initPage();});
if (window.addEventListener) window.addEventListener("load", initPage, false);
else if (window.attachEvent && !window.opera) window.attachEvent("onload", initPage);
