if(!YAHOO.Mevia){ YAHOO.namespace("Mevia"); }


YAHOO.Mevia.pageWidth = function() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}

YAHOO.Mevia.pageHeight = function() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 

YAHOO.Mevia.posLeft = function() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 
YAHOO.Mevia.posTop = function() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 

YAHOO.Mevia.posRight = function() {return posLeft()+pageWidth();} 
YAHOO.Mevia.posBottom = function() {return posTop()+pageHeight();}

YAHOO.Mevia.getFormCollections = function(collectionName,form){
	if(typeof(form).toLowerCase()=='string'){ form = YAHOO.util.Dom.get(form); }
	var a = [];
	var collection = form[collectionName+"[]"];
	if(collection){
		if(collection.tagName){
			if(collection.value != ''){					
				a.push(collection.value);
			}
		}else{
			for(var i=0;i<collection.length;i++){
				if(collection[i].value != ''){						
					a.push(collection[i].value);
				}
			}			
		}			
	}
	return a;
}

YAHOO.Mevia.getMultiCheckbox = function(collectionName,form){
	if(typeof(form).toLowerCase()=='string'){ form = YAHOO.util.Dom.get(form); }
	var a = [];
	var collection = form[collectionName+"[]"];
	if(collection){
		if(collection.tagName){
			if(collection.checked){
				a.push(collection.value);
			}
		}else{
			for (var i=0;i<collection.length;i++) {
				if (collection[i].checked) {				
					a.push(collection[i].value);
				}
			}
		}					
	}
	return a;
}

YAHOO.Mevia.getRadioValue = function(input_name){
	var radios = document.getElementsByName(input_name);
	if(radios){
		for(var i=0;i<radios.length;i++){
			if(radios[i].checked){
				return radios[i].value;
			}
		}		
	}
}

YAHOO.Mevia.checkboxIsChecked = function(input_id){
	var checkbox = YAHOO.util.Dom.get(input_id);
	return (checkbox.checked)? 1:0;
}

YAHOO.Mevia.removeMe = function(elt){
	var parent = elt.parentNode;
	parent.removeChild(elt);
}


YAHOO.Mevia.tabSwitcher = function(tabid){
	var yud = YAHOO.util.Dom;
	var links = yud.getElementsBy(function(){return true;},'a',tabid);
	var lis = yud.getElementsBy(function(){return true;},'li',tabid);
	YAHOO.util.Event.addListener(links,'click',function(){
		yud.removeClass(lis,'selected');
		yud.addClass(yud.getAncestorByTagName(this,"li"),'selected');
	});
}

YAHOO.Mevia.getDate = function(field_id){
	var yud = YAHOO.util.Dom;
	return yud.get(field_id+'_year').value+"-"+yud.get(field_id+'_month').value+"-"+yud.get(field_id+'_day').value;
}

// 
// 
// YAHOO.Mevia.Loader = function() {
// 	/* simple event */
// 	var loader = YAHOO.util.Dom.get('ajax_loader');
// 	YAHOO.util.Event.on (document.body, 'mousemove', function(e){
// 	  	var mouse = YAHOO.util.Event.getXY(e);
// 		if(mouse){
// 			loader.style.top = parseInt(mouse[1]+10)+'px';
// 			loader.style.left = parseInt(mouse[0]+10)+'px';			
// 		}
// 	});
// 	
// 	/* downshift the event execution */
// 	var _timeoutId = null;
// 	YAHOO.util.Event.on (document.body, 'mousemove', function(e){
// 	  var mouse = YAHOO.util.Event.getXY(e);
// 		if(mouse){
// 		  clearTimeout(_timeoutId);
// 	      _timeoutId = setTimeout(function(){
// 			loader.style.top = parseInt(mouse[1]+10)+'px';
// 			loader.style.left = parseInt(mouse[0]+10)+'px';
// 	        }, 150 );			
// 		}
// 	});
// }
// 
// 
// YAHOO.util.Event.onDOMReady(YAHOO.Mevia.Loader);