var dropDown_cached_id=null;
dropDown = function(id,force) {
	
	if (!document.getElementById(id).innerHTML)
		return;
	if (document.getElementById(id).style.display != 'block') {
		if(dropDown_cached_id) 
			document.getElementById(dropDown_cached_id).style.display = 'none';		
		document.getElementById(id).style.display = 'block';
		dropDown_cached_id=id;
	}
	else if(!is_ie5_5 && !is_ie6 ) {
		document.getElementById(id).style.display = 'none';		
	}

}

dropClose=function() {
	if(dropDown_cached_id) 
		document.getElementById(dropDown_cached_id).style.display = 'none';	
}

var fldm_current=null;
var fldm_timer=null;
function fldm_open(object) {
	
	fldm_close();
	object.style.display='block';
	fldm_current=object;
}
function fldm_cancel() {
	if(fldm_current!=null) {
		
		if(fldm_timer!=null) 
			window.clearInterval(fldm_timer);
		// IE6 is working now, no timer required
		fldm_timer=window.setInterval("fldm_close();",10);
	}
}
function fldm_keep() {
	window.clearInterval(fldm_timer);
	fldm_timer=null;
}
function fldm_close(object) {
	if(!object && fldm_current!=null);
		object=fldm_current;
	if(object && object.style)
		object.style.display='none';
	fldm_current=null;
	if(fldm_timer!=null) {
		window.clearInterval(fldm_timer);
		fldm_timer=null;
	}
}

fldm = function(object) {
	this.object=object;
	this.object.fldm=this;
	
	this.open=function() {		
		cDivs=this.object.getElementsByTagName('div');
		if(cDivs[0] && cDivs[0].innerHTML) {			
			cDivs[0].style.display='block';			
			cDivs[0].onmouseout=function() {
				this.style.display='none';
			}
		}
	}
	this.close=function() {		
		cDivs=this.object.getElementsByTagName('div');
		if(cDivs[0]) {
			cDivs[0].style.display='none';			
		}
	}
}

function goToAnchor(anchor) {
	curUrl = String(window.location);
	dashPos = curUrl.indexOf('#');
	if(dashPos > 0) 
		url = curUrl.substring(0, dashPos) + '#' + anchor;
	else
		url = curUrl + '#' + anchor;
	window.location = url;
}

function activate_this(obj, id, flag) {
	if(flag == true)
		obj.id = id;
	else
		obj.removeAttribute('id');
}

function zebraTables(id) {
	objContainer = document.getElementById('cosas_verdes_page');
	objTables = objContainer.getElementsByTagName('table');
	counter = 0;
	for(i = 0; i < objTables.length; i++) {
		if(objTables[i].className == 'cosas_verdes_records') {
			objRows = objTables[i].getElementsByTagName('tr');
			for(r = 0; r < objRows.length; r++) {
				if(objRows[r].getElementsByTagName('td').length > 0 && objRows[r].className !== 'table_footer') {
					if(counter == 0) {
						objRows[r].className = 'element_odd';
						counter++;
					}
					else {
						objRows[r].className = 'element_even';
						counter = 0;
					}
				}
			}
		}
	}
}

function faq(obj) {
	container = obj.parentNode.parentNode.parentNode;
	
	//Show or hide the answer
	questions = obj.parentNode.parentNode.getElementsByTagName('div');
	for(i = 0; i < questions.length; i++) {
		if(questions[i].className = 'answer')
			if(questions[i].style.display !== 'block') {
				questions[i].style.display = 'block';
				questions[i].setAttribute('id', 'active');
			}
			else
				questions[i].style.display = 'none';
	}
	
	// Hide all answers
	answers = container.getElementsByTagName('div');
	for(i = 0; i < answers.length; i++) {
		if(answers[i].className == 'answer') {
			if(answers[i].getAttribute('id')) 
				answers[i].removeAttribute('id');
			else
				answers[i].style.display = 'none';
		}
	}
	
	return false;
}

function shortenByClass(t, c, l, e) {
	o = document.getElementsByTagName(t);
	for(i = 0; i < o.length; i++) {
		if(o[i].className == c) {
			t = o[i].firstChild;
			if(t.length > l) {
				t.nodeValue = t.nodeValue.substring(0, l);
				if(t.nodeValue.substring(t.nodeValue.length - 1, t.nodeValue.length) == ' ')
					t.nodeValue = t.nodeValue.substring(0, t.nodeValue.length - 1);
				if(e)
					t.parentNode.innerHTML += e;
			}
		}
	}
}

function login() {
	b = document.getElementsByTagName('base')[0].href;
	a = document.getElementById('logos_right').getElementsByTagName('a');
	for(i = 0, j = a.length; i < j ; i++) {
		if(a[i].href == b + 'login')
			a[i].target = '_self'
	};
};