// JavaScript Document

function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 }
 var anchors = document.getElementsByTagName("area"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
window.onload = externalLinks;

function showAnswer(faqId){
	answerDivs=$$('div.faqAnswerWrapper');
	var alreadyOpen=null;
	for(var i=0;i<answerDivs.length;i++){
		if ($(answerDivs[i]).style.display!='none'){
			Effect.BlindUp(answerDivs[i], {duration:0.75, queue: { position: 'end', scope: 'answerHideScope' }} );
			alreadyOpen=answerDivs[i];	
		}
	}
	if ( alreadyOpen!=$('faqAnswer:'+faqId) ){
		Effect.BlindDown($('faqAnswer:'+faqId), {duration:0.75, queue: { position: 'end', scope: 'answerShowScope' }} );		
	}
}

function showMessage(messageText){
    	$('messageContainer').update(messageText);
    	$('messageContainer').appear({ duration: 1, from: 0, to: 1 , queue: { position: 'end', scope: 'messageScope' } });
    	$('messageContainer').appear({ duration: 4, from: 1, to: 1 , queue: { position: 'end', scope: 'messageScope' } });
    	$('messageContainer').fade({ duration: 1, from: 1, to: 0 , queue: { position: 'end', scope: 'messageScope' } });
}

function toggleCategoryBlind(element){
	if ($(element).style.display=='none'){
		Effect.BlindDown(element, {duration:0.75, queue: { position: 'end', scope: 'categoryBlindScope' }} );
	} else {
		Effect.BlindUp(element, {duration:0.75, queue: { position: 'end', scope: 'categoryBlindScope' }} );		
	}

}

function launchEditBox(element,id){
	var offset=$(element).cumulativeOffset();
	$('editContainer').style.left=offset['left']+"px";
	$('editContainer').style.top=offset['top']+"px";
	
	$('overlay').appear({ duration: 1, from: 0, to: 0.25 , queue: { position: 'end', scope: 'overlayScope' } });
	new Ajax.Updater('editContainer', "tjs/edit.php?column="+element.id+"&id="+id,
			{ method: 'get',
			evalScripts: true,
			onComplete: function() {
				//$('editContainer').
				$('editContainer').appear({ duration: 0.25, from: 0, to: 1 , queue: { position: 'end', scope: 'popupScope' } });
			}
			});	
}

function closeEditBox(){
	$('overlay').fade({ duration: 0.25, from: 0.25, to: 0 , queue: { position: 'end', scope: 'overlayScope' } });
	$('editContainer').fade({ duration: 0.25, from: 1, to: 0 , queue: { position: 'end', scope: 'popupScope' } });
}


