function doOnload(){
	  
		if (ie_above_ver5()) {
			

			if (document.getElementById("ticker0")){
			   obj0=document.getElementById('ticker0');
			   //obj1=document.getElementById('ticker1');
			   obj2=document.getElementById('tickerHolder');

			   j=obj0.offsetWidth;
			   //k=obj1.offsetWidth;

			   // control where will the message starts again...
			   tickerRestart=1000;
			   

			   //obj1.className='';
			   obj2.className='setup'

			   obj0.style.width=j+'px';
			   //obj1.style.width=k+'px';

			   imgScroll();

			obj2.onmouseover=function(){
			   clearTimeout(scroller);
			 }
			obj2.onmouseout=function(){
			   imgScroll();
			}
		}
	}
}	  

function ie_above_ver5() {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion<6)
			return false;
		else
			return true;
	} else {
		return true;
	}

}

function imgScroll() {

	   obj0.style.left=i+'px';
	   //obj1.style.left=j+'px';
	      
	   i--;
	   j--;

	if(i<-tickerRestart) {
	   i=ticker_start;
	 }
	//if(j<-k) {
	//   j=temp;
	 //} 
	  scroller=setTimeout('imgScroll()',speed);
}

// Codes to hide and display questions and answer - by Paul Brennan
function onload_function(onload_params){
    try {
        //main onload function
    }
    catch (e) {
        //not sure if we want to have an alert here?
    }
    try {
        //page specific onload.
        eval(onload_params)
    }
    catch (e) {
    }

    //Add autocomplete
    elements = document.getElementsByTagName("input")
    if (elements != null) {
        for (var i = 0; i < elements.length; i++) {
            element = elements[i];
            element.setAttribute("autocomplete", "off");
        }
    }
}

function switchJsForFeedbacks(){
    document.getElementById('noJavascript').innerHTML = "Results will update automatically";
}


function hide_questions(){
    sections = getElementsByClassName('section')
    for (var i = 0; i < sections.length; i++) {
        showHideDiv(sections[i].id, false);
    }
    answers = getElementsByClassName('answer')
    for (var i = 0; i < answers.length; i++) {
        showHideDiv(answers[i].id, false);
    }
}

function hide_documents(){
    sections = getElementsByClassName('section')
    for (var i = 0; i < sections.length; i++) {
        showHideDiv(sections[i].id, false);
    }
    answers = getElementsByClassName('answer')
    for (var i = 0; i < answers.length; i++) {
        showHideDiv(answers[i].id, false);
    }
    showHideSection('doc_selection')
}

function showAnswer(answer_id){
    elem = document.getElementById(answer_id)
    Effect.toggle(elem, 'blind')
    elem.style.display = elem.style.display == 'none' ? 'block' : 'none'
    answers = getElementsByClassName('answer')
    for (var i = 0; i < answers.length; i++) {
        if (answers[i].id != elem.id) {
            showHideDiv(answers[i].id, false);
        }
    }
}

function showHideSection(section_name){
    elem = document.getElementById(section_name)
    elem.style.display = elem.style.display == 'none' ? 'block' : 'none'
    sections = getElementsByClassName('section')
    for (var i = 0; i < sections.length; i++) {
        if (sections[i].id != elem.id) {
            showHideDiv(sections[i].id, false);
        }
    }
}

function toggleElem(div_id){
    Effect.toggle(document.getElementById(div_id), 'blind');
}

function showHideDiv(div_id, show){
    //hides or shows the div given
    if (show == true) {
        document.getElementById(div_id).style.display = 'block';
    }
    else {
        document.getElementById(div_id).style.display = 'none'
    }
}


function sayHello(phrase){
    //This function can be used to check that javascript code is being called correctly
    //either pass a varaibe to check value of that variable. Otherwise it just alerts a
    //hello message
    if (!phrase) {
        phrase = "Hello World"
    }
    alert(phrase)
}


function getElementsByClassName(findClass){
	returnValue = new Array();
    index = 0;
    var aElm = document.body.getElementsByTagName('*');
    for (var i = 0; i < aElm.length; i++) {
        if (aElm[i].className == findClass) {
            returnValue[index] = aElm[i]
            index++;
        }
    }
    return returnValue;
}

function GetXmlHttpObject(handler){
    var objXMLHttp = null
    if (window.XMLHttpRequest) {
        objXMLHttp = new XMLHttpRequest()
    }
    else
        if (window.ActiveXObject) {
            objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
        }

    return objXMLHttp
}

function toggleFlag(id){
    xmlHttp = GetXmlHttpObject()
    var url = "/admin/toggle_flag/" + id;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}




/* Show/hide content for document area by Paul Brennan (paul.brennan@ahc.uk.com) */

function showHideDiv(div_id, show){
	//hides or shows the div given
	if (show==true){
		document.getElementById(div_id).style.display='block';
	}else{
		document.getElementById(div_id).style.display = 'none'
	}
}

function hideDivs(exception_div_id){
	var show_hide_container = document.getElementById('showHideContainer')
	if (show_hide_container) {
		var div_tags_array = show_hide_container.getElementsByTagName('div')
		for (var k = 0; k < div_tags_array.length; k++) {
			div_tags_array[k].style.display = 'none';
		}
	}
}

function hideAllItemsWithClass(hide_class) {
    if (ie_above_ver5()) {
		var showHideItems = getElementsByClassName(hide_class);
        for(var i=0; i<showHideItems.length; i++) {
			showHideItems[i].style.display = 'none';
        }
    }
}

function showAllDivs(){	
	var aElm=document.body.getElementsByTagName('div');
		for(var i=0; i<aElm.length; i++) {
			if(aElm[i].style.display == 'none') {
				aElm[i].style.display = 'block'
			}
	}
}

function toggle_div(div_id, hide_class){
	if (hide_class!=undefined){
		hideAllItemsWithClass(hide_class);
	}
	Effect.toggle(document.getElementById(div_id),'appear');	
}


function showHideID(div_id,className,toggle){
	if (toggle == null){
  		 toggle = true;
 	}

	//this function hides all elements with the class name given
	//then toggles the display status of teh div_id given
	//className is optional can be run as just showHideID(div_id)
	//if toggle is set to true then it will not hide it when clicked for
	//the second time

	//first get the element that wants to change
	var element = document.getElementById(div_id);
	//If it is already shown will be only one open so only need to change to style to none
	if (element.style.display=='block' && toggle){
    	element.style.display='none'
  	}else{
		//show the element
    	element.style.display='block'
    	if (className) {
			//if given a class to hide
			var elements = document.getElementsByClassName(className);
			//go through all elements with selected class
			if (elements!=null){
				for (var i = 0; i < elements.length; i++) {
					if (elements[i].id != div_id) {
					//as long as isn't the selected element - hide
						elements[i].style.display = 'none'
					}
				}
			}
		}
  	}

}

function hideDiv(div_id){
	document.getElementById(div_id).style.display = 'none';
}



function ie_above_ver5() {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion<6)
			return false;
		else
			return true;
	} else {
		return true;
	}

}

// END of the codes to hide and display questions and answer
