$(document).ready(function(){

$("a.moresummary").click(function(){ $("div.expandablesummary").find("div.summary:hidden").slideDown("slow"); });
$("a.lesssummary").click(function(){ $("div.expandablesummary").find("div.summary:visible").slideUp("slow"); });

$("a.moreauthor").click(function(){ $("div.expandableauthor").find("div.author:hidden").slideDown("slow"); });
$("a.lessauthor").click(function(){ $("div.expandableauthor").find("div.author:visible").slideUp("slow"); });

$("a.moreanswer").click(function(){ $("div.expandableanswer").find("div.answer:hidden").slideDown("slow"); });
$("a.lessanswer").click(function(){ $("div.expandableanswer").find("div.answer:visible").slideUp("slow"); });

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) {
	var delta = maxValue - minValue;
	var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
	return Math.ceil(stepp)
}

function addFade() {
		doBGFade(this,[255,255,100],[255,255,255],'transparent',75,20,4);
	}
	
function doBGFade(elem,startRGB,endRGB,finalColor,steps,intervals,powr) {
	if (elem.bgFadeInt) window.clearInterval(elem.bgFadeInt);
	var actStep = 0;
	elem.bgFadeInt = window.setInterval(
		function() {
			elem.style.backgroundColor = "rgb("+
				easeInOut(startRGB[0],endRGB[0],steps,actStep,powr)+","+
				easeInOut(startRGB[1],endRGB[1],steps,actStep,powr)+","+
				easeInOut(startRGB[2],endRGB[2],steps,actStep,powr)+")";
			actStep++;
			if (actStep > steps) {
			elem.style.backgroundColor = finalColor;
			window.clearInterval(elem.bgFadeInt);
			}
		}
		,intervals)
}


});

function ClearInput(value, id){ 
var input = document.getElementById(id);

if(value == input.value){
input.value = '';
}else{
input.value = input.value;
}
}

function loadurl(dest) { 

try { 

	// Moz supports XMLHttpRequest. IE uses ActiveX. 
	// browser detction is bad. object detection works for any browser  
 	xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): 
		new ActiveXObject("Microsoft.XMLHTTP"); 
		
} 
catch (e) { 
	// browser doesn't support ajax. handle however you want
}

// the xmlhttp object triggers an event everytime the status changes  
// triggered() function handles the events  
xmlhttp.onreadystatechange = triggered; 

// open takes in the HTTP method and url.  
xmlhttp.open("GET", dest); 

// send the request. if this is a POST request we would have  
// sent post variables: send("name=aleem&gender=male)  
// Moz is fine with just send(); but  
// IE expects a value here, hence we do send(null);  
xmlhttp.send(null); 

} 

function triggered() {

// if the readyState code is 4 (Completed)  
// and http status is 200 (OK) we go ahead and get the responseText  
// other readyState codes:  
// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive  
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { 

	// xmlhttp.responseText object contains the response.  
	document.getElementById("output").innerHTML
	 = xmlhttp.responseText; 
	 } 
}

/* global document */

function changeclass_abs() {
var ABS = document.getElementById("abs");
ABS.className="activelink";
var REF = document.getElementById("ref");
REF.className="inactivelink";
reinitialiseScrollPane;
var PLAIN = document.getElementById("plain");
PLAIN.className="inactivelink";
reinitialiseScrollPane;
var CONC = document.getElementById("conc");
CONC.className="inactivelink";
reinitialiseScrollPane;
} 

function changeclass_ref() {
var ABS = document.getElementById("abs");
ABS.className="inactivelink";
var REF = document.getElementById("ref");
REF.className="activelink";
var PLAIN = document.getElementById("plain");
PLAIN.className="inactivelink";
var CONC = document.getElementById("conc");
CONC.className="inactivelink";
} 

function changeclass_plain() {
var ABS = document.getElementById("abs");
ABS.className="inactivelink";
var REF = document.getElementById("ref");
REF.className="inactivelink";
var PLAIN = document.getElementById("plain");
PLAIN.className="activelink";
var CONC = document.getElementById("conc");
CONC.className="inactivelink";
} 

function changeclass_conc() {
var ABS = document.getElementById("abs");
ABS.className="inactivelink";
var REF = document.getElementById("ref");
REF.className="inactivelink";
var PLAIN = document.getElementById("plain");
PLAIN.className="inactivelink";
var CONC = document.getElementById("conc");
CONC.className="activelink";
} 