//alert("faq");

function doFaqInit(){

	var questions = $$("#itemlist dt");
	var answers = $$("#itemlist dd");
	
	for(var i = 0; i<questions.length; i++){
		var question = questions[i];
		var answer = answers[i];
		
		if(document.all){
			question.onmouseover=function() {
				this.className+=" hover";
			}
			question.onmouseout=function() {
				this.className=this.className.replace(" hover", "");
			}
		}
		
		question.onclick=function(){
			var answer = this.nextSibling;
			while(answer.tagName == undefined)
				answer = answer.nextSibling;
				
			//alert(answer + " : " + answer.innerHTML + " : " + answer.style.display);
			if(answer.style.display == "block"){
				this.className = "";
				answer.style.display = "none";
			}
			else{
				this.className += " open";
				answer.style.display = "block";
			}
		}
		
	}
	
}


EventUtils.addEventListener(window,'load',doFaqInit);

opacity=0;
fadeIn = function() {
	element = $('fadeyoutey');
	if( opacity < 0.30 )
		opacity = opacity + .15;
	if( opacity < 0.30)
		setTimeout("fadeIn()", 1);
	
	element.style['opacity'] = opacity;
	element.style['filter'] = 'alpha(opacity='+ (opacity * 100) + ')';
}

fadeOut = function() {
	element = $('fadeyoutey');
	if( opacity > 0.0 )
		opacity = opacity - .15;
	if( opacity > 0.0 )
		setTimeout("fadeOut()", 1);
	else
		element.style['display'] = 'none';
	
	element.style['opacity'] = opacity;
	element.style['filter'] = 'alpha(opacity='+ (opacity * 100) + ')';
}

Behaviour.register({
	'#closepopupbutton': {
		initialize: function(){
			element = $('fadeyoutey');
			element.style['display'] = 'block';
			fadeIn();
			return false;
		},
		onclick : function(e){
			$('emspopupholder').style.display = 'none';
			fadeOut();
			var data = '';
			new Ajax.Request('home/emspopupclosed', {
				method : 'post', postBody : data,
				onSuccess : function(response) {
					//alert('success: '+response.responseText);
				}, 
				onFailure : function(response) {
					alert('feilure: '+response.responseText);
				}
			});
			return false;
		}
	}
});
