function check_proposal(form){
    form.organising_body.style.borderColor='';
    form.cousetitle.style.borderColor='';
    form.co_ordinator.style.borderColor='';
    form.co0_address.style.borderColor='';
    form.email.style.borderColor='';
    form.contactno.style.borderColor='';
    form.target_group.style.borderColor='';
    form.Aims.style.borderColor='';
    form.description.style.borderColor='';
    form.outcomes.style.borderColor='';
    form.min.style.borderColor='';
    form.max.style.borderColor='';
    form.reason1.style.borderColor='';
    form.success1.style.borderColor='';
    form.finsup_title.style.borderColor='';
    form.funding_name1.style.borderColor='';
    form.funding_fee1.style.borderColor='';
    form.funding_address1.style.borderColor='';
    form.funding_name2.style.borderColor='';
    form.funding_fee2.style.borderColor='';
    form.funding_address2.style.borderColor='';
    form.funding_fee1.style.borderColor='';
    form.roomtype.style.borderColor='';
    
    if(form.cousetitle.value==""){
        alert("Please enter a Couse Title");
        form.cousetitle.focus();
        form.cousetitle.style.borderColor='red';
        return false;
    }
    else if(form.organising_body.value==""){
        alert("Please enter the Organising Body");
        form.organising_body.focus();
        form.organising_body.style.borderColor='red';
        return false;
    }
    else if(form.co_ordinator.value==""){
        alert("Please enter the Co-ordinator");
        form.co_ordinator.focus();
        form.co_ordinator.style.borderColor='red';
        return false;
    }
    else if(form.co0_address.value==""){
        alert("Please enter the Co-ordinator's Address");
        form.co0_address.focus();
        form.co0_address.style.borderColor='red';
        return false;
    }
    else if(form.contactno.value==""){
        alert("Please enter a Contact Telephone No");
        form.contactno.focus();
        form.contactno.style.borderColor='red';
        return false;
    }
    else if(form.email.value==""){
        alert("Please enter the Email Address");
        form.email.focus();
        form.email.style.borderColor='red';
        return false;
    }
    else if (form.email.value.indexOf('@')==-1 || form.email.value.indexOf('.')==-1){
        alert("Email address doesn't seem to be valid, please enter a valid email address");
        form.email.focus();
        return false;
    }
    
    flg = 0;
    for(i=0;i<form.Sector.length;i++){
        
        if(form.Sector[i].checked == true){
            flg = 1;
            break;
        }
        else{
            flg = 0;
        }
    }
    
    if(flg == 0){
        alert("please indicate which sector the above course is designed primarily for");
        form.Sector[0].focus();
        return false;
    }
    
    if(form.target_group.value==""){
        alert("Please enter the Target Group");
        form.target_group.focus();
        form.target_group.style.borderColor='red';
        return false;
    }
    
    flg = 0;
    for(i=0;i<form.duration.length;i++){
        
        if(form.duration[i].checked == true){
            flg = 1;
            break;
        }
        else{
            flg = 0;
        }
    }
    
    if(flg == 0){
        alert("Duration has not been selected, Please Note: Minimum duration is one full day");
        form.duration[0].focus();
        return false;
    }
    

    flg = 0;
    for(i=0;i<form.dates.length;i++){
        
        if(form.dates[i].checked == true){
            flg = 1;
            break;
        }
        else{
            flg = 0;
        }
    }
    
    if(flg == 0){
        alert("Please select the prefered start date for your course");
        form.dates[0].focus();
        return false;
    }
    

    if(form.Aims.value==""){
        alert("Please enter Aims of the course.");
        form.Aims.focus();
        form.Aims.style.borderColor='red';
        return false;
    }
    else if(form.description.value==""){
        alert("Please enter a Description for the course");
        form.description.focus();
        form.description.style.borderColor='red';
        return false;
    }
    else if(form.outcomes.value==""){
        alert("Please enter the Learning Outcomes of the course");
        form.outcomes.focus();
        form.outcomes.style.borderColor='red';
        return false;
    }
    else if(form.min.value==""){
        alert("Please enter the minimum numbers");
        form.min.focus();
        form.min.style.borderColor='red';
        return false;
    }
    else if(form.max.value==""){
        alert("Please enter the max numbers");
        form.max.focus();
        form.max.style.borderColor='red';
        return false;
    }
    else if(form.min.value<=19 && form.reason1.value==""){
        alert("Please enter the reason why your numbers do not meet the minimum requirements.");
        form.reason1.focus();
        form.reason1.style.borderColor='red';
        return false;
    }
    else if(form.success1.value==""){
        alert("Please enter Success Criteria");
        form.success1.focus();
        form.success1.style.borderColor='red';
        return false;
    }
    else if(form.funding_fee1.value==""){
        alert("Please make sure you have entered a fee for this proposal");
        form.funding_fee1.focus();
        form.funding_fee1.style.borderColor='red';
        return false;
    }
    
    var myTest  = form.roomtype.selectedIndex;
    if(myTest==0){
        alert("Please select preferred room layout ");
        form.roomtype.focus();
        form.roomtype.style.borderColor='red';
        return false;
    }
    
    
    if(form.funding_name1.value!="" && form.funding_fee1.value==""){
        alert("Please enter a fee for "+form.funding_name1.value+" ");
        form.funding_fee1.focus();
        form.funding_fee1.style.borderColor='red';
        return false;
    }
    else if(form.funding_fee1.value!="" && form.funding_address1.value==""){
        alert("Please enter an address for: "+form.funding_name1.value);
        form.funding_address1.focus();
        form.funding_address1.style.borderColor='red';
        return false;
    }
    if(form.funding_name2.value!="" && form.funding_fee2.value==""){
        alert("Please enter a fee for "+form.funding_name2.value+" ");
        form.funding_fee2.focus();
        form.funding_fee2.style.borderColor='red';
        return false;
    }
    else if(form.funding_fee2.value!="" && form.funding_address2.value==""){
        alert("Please enter an address for: "+form.funding_name2.value);
        form.funding_address2.focus();
        form.funding_address2.style.borderColor='red';
        return false;
    }
    
    if(form.declaration.checked != true){
        alert("Declaration has not been agreed, If you have read the \nGuidelines and agree to abide by them please check the box.");
        form.declaration.focus();
        return false;
    }
    return true;
}

var form='inboxmessages';
function SetChecked(val,chkName) {
    dml=document.forms[form];
    len = dml.elements.length;
    var i=0;
    for( i=0 ; i<len ; i++) {
    if (dml.elements[i].name==chkName) {
    dml.elements[i].checked=val;
            }
        }
}

function ValidateSurvey(form){
        var lastused
        for (x=0;x<form.lastused.length;x++){
        if (form.lastused[x].checked==true){
        lastused=true
        break
        }
        }

        var navigation
        for (i=0;i<form.navigation.length;i++){
        if (form.navigation[i].checked==true){
        navigation=true
        break
        }
        }

    if(lastused!=true)
    {
        alert("Please select the last time you used the toolkit");
        return false;
    }
    else if(navigation!=true)
    {
        alert("You forgot to select how easy you find the navigation");
        return false;
    }
    else if (x!=0)
    {
        if (form.mostuseful.value==""){
        alert("Please enter what you thought was most useful");
        form.mostuseful.focus();
        return false;
        }
        else if (form.leastuseful.value==""){
            alert("Please enter what you thought was least useful");
            form.leastuseful.focus();
            return false;
        }
    }
    else if (form.name.value==""){
        alert("Please enter your Name");
        form.name.focus();
        return false;
    }
    else if (form.school.value==""){
        alert("Please enter the name of your School");
        form.school.focus();
        return false;
    }
    return true;
}

function Validatelogin(form){
    if(form.username.value==""){
        alert("Please enter your username, it seems to be left blank");
        form.username.focus();
        return false;
    }
    else if(form.password.value==""){
        alert("Please enter your Password");
        form.password.focus();
        return false;
    }
}

function ValidateDelete(me){
    MsgBox("Are you sure you want to delete messages", 4)
    return true;
}

function PictureTransition()
{
    if (document.all){  //if browser supports IE filters and it is defined on the object
        large.filters.blendTrans.Apply();
        large.src=imagename;
        large.filters.blendTrans.Play();
        //document.getElementById('largepiclink').href=imagename;
    }
    else{
        document.getElementById('large').src=imagename;
        document.getElementById('largepiclink').href=imagename;
    }
}


if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")



function myOnSubmitEventHandler(form) {
try {
        if(typeof(document.getElementById('editor1').EscapeUnicode) == 'undefined'){
        throw "Error"
        } 
    else{
	document.getElementById('editor1').EscapeUnicode = true;
	document.getElementById('xhtml1').value = document.getElementById('editor1').value;
        }
    if (form.title.value==""){
            alert("Please give the news item a title.");
            form.title.focus();
            return false;
        }
    else if(form.description.value==""){
            alert("Please give the news item a description.");
            form.description.focus();
            return false;}
    
    return true;
    }
    catch(er) {
            document.getElementById('xhtml1').value = document.getElementById('alternate1').value;
        }
    
    }

function myOnSubmitEventHandlerlinks(form) {
try {
        if(typeof(document.getElementById('editor1').EscapeUnicode) == 'undefined'){
        throw "Error"
        } 
    else{
	document.getElementById('editor1').EscapeUnicode = true;
	document.getElementById('xhtml1').value = document.getElementById('editor1').value;
        }
    
    if (form.linktitle.value==""){
            alert("Please give the link a title.");
            form.linktitle.focus();
            return false;
        }
    else if(form.linkdesc.value==""){
            alert("Please give the link a description.");
            form.linkdesc.focus();
            return false;}
    else if(form.linkurl.value=="http://" || form.linkurl.value==""){
            alert("Please provide the url link e.g (www.rtuni.org)");
            form.linkurl.value="http://";
            form.linkurl.focus();
            return false;}
    else if(form.linkcat.value==""){
            alert("Please give the link a catergory.");
            form.linkcat.focus();
            return false;}
    
    return true;
    }
    catch(er) {
            document.getElementById('xhtml1').value = document.getElementById('alternate1').value;
        }
    
    }

function validateemail(form){
    if(form.email.value==""){
        alert("Please enter your email address, it seems to have been left blank");
        form.email.focus();
        return false;
    }
    else if (form.email.value.indexOf('@')==-1 || form.email.value.indexOf('.')==-1){
        alert("Email address doesn't seem to be valid, please enter a valid email address");
        form.email.focus();
        return false;
    }
    return true;
}

function checksearch(form){
    if(form.keyword.value==""){
        alert("Search box has been left blank, please re-enter your search text");
        form.keyword.focus();
        return false;
    }
    return true;
}

function validatesearch(form){
    if(form.keyword.value==""){
        alert("Search text has been left blank, please re-enter your search text");
        form.keyword.focus();
        return false;
    }
    return true;
}

function validatedeletenews(){
    //onclick="if(!confirm(' Are you sure you want to delete this item?')){this.href='../scripts.php?func=deletenewsitem&id=<?=$newsdetails['id']?>&lid=<?=$lastid?>';return false;};return true;">
    if(!confirm('Are you sure you want to delete this item?'))
    {
        return false;
    }
    return true;
}
//----------------------------------------Used to check/uncheck all check boxes on form
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}


function validatedelete_ss_courses(){
    //----------------------------------------check if multiple checkboxes are selected and all delete if true
    flg = 0;
    for(i=0;i<document.DeleteSelected.delete_cid.length;i++){
        
        if(document.DeleteSelected.delete_cid[i].checked == true){
            flg = 1;
            break;
        }
        else{
            flg = 0;
        }
    }
    
    if(flg == 0){
        alert("Nothing has been selected, please select at least one item");
        return false;
    }
    else{
        if(!confirm('Are you sure you want to delete these items?'))
        {
            return false;
        }
        return true;
    }
}

function validatedeletelink(){
    //onclick="if(!confirm(' Are you sure you want to delete this item?')){this.href='../scripts.php?func=deletenewsitem&id=<?=$newsdetails['id']?>&lid=<?=$lastid?>';return false;};return true;">
    if(!confirm('Are you sure you want to delete this item?'))
    {
        return false;
    }
    return true;
}

function checkpublicationfiles(form){
    if(form.publicationtitle.value==""){
        alert("Please give you publication a title");
        form.publicationtitle.focus();
        return false;
    }
    else if (form.publicationdesc.value==""){
        alert("Please give you publication a description");
        form.publicationdesc.focus();
        return false;
    }
    else if (form.fileuploadedset.value==""){
        alert("You have forgotten to attach a document");
        form.uploadedfile.focus();
        return false;
    }
    return true;
}

function LimitMultiLineLength(obj)
{
var iKey;
var eAny_Event = window.event;
iKey = eAny_Event.keyCode;
var re 
re = new RegExp("\r\n","g")  
x = obj.value.replace(re,"").length ;
if ((x >= obj.maxLength) && ((iKey > 33 && iKey < 255) || (iKey > 95 && iKey < 106)) && (iKey != 13))
{

alert("The maximum allowance of 200 characters has been reached.");
window.event.returnValue=false;      
}
} 

function validatecontactform(form){
    if(form.name.value==""){
        alert("Please enter your name, field has been left empty");
        form.name.focus();
        return false;
    }
    else if(form.email.value==""){
        alert("Please enter your email address, field has been left empty");
        form.email.focus();
        return false;
    }
    else if (form.email.value.indexOf('@')==-1 || form.email.value.indexOf('.')==-1){
        alert("Email address doesn't seem to be valid, please enter a valid email address");
        form.email.focus();
        return false;
    }
    else if (form.phone.value==""){
        alert("Phone Number has been left blank, please enter a valid phone number");
        form.phone.focus();
        return false;
    }
    else if(isNaN(form.phone.value)){ 
         alert("Phone number doesn't seem to be valid, must be numeric"); 
         form.phone.focus();
         return (false); 
    }
    else if(form.comments.value==""){ 
         alert("Please leave us your comments or your query in the comments field"); 
         form.comments.focus();
         return (false); 
    }
    else if (form.email.value.indexOf('@')==-1 || form.email.value.indexOf('.')==-1){
        alert("Email address doesn't seem to be valid, please enter a valid email address");
        form.email.focus();
        return false;
    }
    return true;
}
function validatedeleteadmin(){
    //onclick="if(!confirm(' Are you sure you want to delete this item?')){this.href='../scripts.php?func=deletenewsitem&id=<?=$newsdetails['id']?>&lid=<?=$lastid?>';return false;};return true;">
    if(!confirm('Are you sure you want to delete this user?'))
    {
        return false;
    }
    return true;
}

function validatepwd(form){
    //onclick="if(!confirm(' Are you sure you want to delete this item?')){this.href='../scripts.php?func=deletenewsitem&id=<?=$newsdetails['id']?>&lid=<?=$lastid?>';return false;};return true;">
    if(form.password.value=="" || form.confirm.value==""){
        alert("Password and confirm password cannot be left empty");
        form.password.focus();
        return false;
    }
    else if(form.password.value!=form.confirm.value)
    {
        alert("Password doesn't seem to match the confirmed password please retype and try again");
        form.password.focus();
        return false;
    }
    return true;
}

function validateuseradmin(form){
    if(form.name.value==""){
        alert("Please enter the users name");
        form.name.focus();
        return false;
    }
    else if(form.username.value=="")
    {
        alert("Please provide the user with a username");
        form.username.focus();
        return false;
    }
    return true;
}

function validatereg(form){
    // set var radio_choice to false
    var radio_choice = false;
    for (counter = 0; counter < form.attend.length; counter++)
    {
        if (form.attend[counter].checked){
        radio_choice = true;
        }
    }
    
    if (!radio_choice)
    {
            alert("Please select if you are attending the conference or not");
            return false;
    }
    
    if(form.name.value==""){
        alert("Please enter your full name");
        form.name.focus();
        return false;
    }
    else if (form.school.value==""){
        alert("Please enter your full school name");
        form.school.focus();
        return false;
    }
    return true;
}

function validatepqhuser(form){
    if(form.name.value==""){
        alert("Please enter the users name");
        form.name.focus();
        return false;
    }
    else if(form.username.value=="")
    {
        alert("Please provide the user with a username");
        form.username.focus();
        return false;
    }
    else if(form.password.value=="")
    {
        alert("Please provide the user with password, cannot be left blank");
        form.password.focus();
        return false;
    }
    else if(form.confirmpassword.value=="")
    {
        alert("Please confirm the password");
        form.confirmpassword.focus();
        return false;
    }
    else if(form.confirmpassword.value!=form.password.value)
    {
        alert("Confirmed password doesn't match password");
        form.confirmpassword.focus();
        return false;
    }
    return true;
}
/************************************************************************************************************
(C) www.dhtmlgoodies.com, November 2005
This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.
Thank you!
www.dhtmlgoodies.com
Alf Magne Kalleland
************************************************************************************************************/

var dhtmlgoodies_slideSpeed = 10;	// Higher value = faster
var dhtmlgoodies_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
function showHideContent(e,inputId)
{
	if(dhtmlgoodies_slideInProgress)return;
	dhtmlgoodies_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

	objectIdToSlideDown = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
		}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			
			slideContent(numericId,dhtmlgoodies_slideSpeed);
		}
	}else{
		slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
		dhtmlgoodies_activeId = false;
	}	
}

/************************************************************************************************************
(C) www.dhtmlgoodies.com, November 2005
This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.
Thank you!
www.dhtmlgoodies.com
Alf Magne Kalleland
************************************************************************************************************/

var dhtmlgoodies_slideSpeed = 10;	// Higher value = faster
var dhtmlgoodies_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
function showHideContent(e,inputId)
{
	if(dhtmlgoodies_slideInProgress)return;
	dhtmlgoodies_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

	objectIdToSlideDown = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
		}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			
			slideContent(numericId,dhtmlgoodies_slideSpeed);
		}
	}else{
		slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
		dhtmlgoodies_activeId = false;
	}	
}

function slideContent(inputId,direction)
{
	
	var obj =document.getElementById('dhtmlgoodies_a' + inputId);
	var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);				
			}else{
				dhtmlgoodies_slideInProgress = false;
			}
		}else{
			dhtmlgoodies_activeId = inputId;
			dhtmlgoodies_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='dhtmlgoodies_question'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'dhtmlgoodies_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'dhtmlgoodies_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='dhtmlgoodies_answer_content';
			contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}		
	}	
}
window.onload = initShowHideDivs;

function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}