// $RCSfile: general.js,v $
// @version $Source: /cvs/eei-onlineweb-live/js/general.js,v $, $Revision: 1.5 $, $Date: 2009/09/16 16:21:48 $, $State: Exp $ 

Event.observe(window, 'load', function() {
    loadOptions();
    searchSetup();
    setupVF();
    docReorder();
    setupEnquiry();
    setupCaptcha();
    setupEvents();
    addAttendee();
    Attendee1clear();
    Registrantclear();
	setupNews();
    setupMoreHelp();
    setupFindOutMore();
    setupSeminarDetails();
});

function loadOptions(){
	if($('options')){
    $('options').onclick = function(){
		 toggleOptions();
	}
}

function toggleOptions(){
	        //$('optionsBubble').style.display='none';
        if($('options').className == 'closed'){
            $('options').className = 'open';
            new Effect.Morph($('options').parentNode,{
              style:{
                width:'600px'
              }
              ,afterFinish: function(){
                new Effect.Morph($('options').parentNode,{
                  style:{
                    height:'530px'
                  }
                  ,afterFinish: function(){
                    $('options').getElementsByTagName('a')[0].innerHTML = 'options - (x)close';
                    new Effect.Appear('mapoptions');
                  }
                });
              }
            });
        }else if($('options').className == 'open'){
            $('options').className = 'closed';
            $('options').getElementsByTagName('a')[0].innerHTML = 'options';
            new Effect.Fade('mapoptions',{
              afterFinish: function(){
                new Effect.Morph($('options').parentNode,{
                  style:{
                    height:'55px'
                  }
                  ,afterFinish: function(){
                    $('options').parentNode.morph('width:600px');
                  }
                });
              }
            });
        }
    }
}

function searchSetup(){
    if($('advancedlink')){
        $('advancedlink').onclick = function(){
            new Effect.toggle($('advancedsearch'),'blind',{
            duration: 0.6            
            });
            if(this.className=='advancedlink'){
                this.className = 'advancedlink-open';
            }else{
                this.className = 'advancedlink';
            }
        }
    }
}

function setupFindOutMore() {

	if($('findoutmorelink') && $('findoutmore')) {
        $('findoutmorelink').onclick = function() {
            new Effect.toggle($('findoutmore'),'blind',{
            duration: 0.6
            });
            setTimeout(scrollToMore, 600);
        }
    }
}

function scrollToMore(){
    new Effect.ScrollTo($('saveInfo'));	
	//alert("here");
}

function setupEnquiry(){
    if(document.getElementsByClassName('questionClick')){
        var questions = document.getElementsByClassName('questionClick');
        for(i=0;i<questions.length;i++){
            if((questions[i].value=='1')&&(questions[i].checked==true)){
                new Effect.BlindDown($('advancedform'),{
                duration: 0.4            
                });
            }
            questions[i].onclick = function(){
                if((this.value=='1')&&(this.checked==true)){
                    new Effect.BlindDown($('advancedform'),{
                    duration: 0.4            
                    });
                }else{
                    new Effect.BlindUp($('advancedform'),{
                    duration: 0.4            
                    });
                }
            }
        }
    }
}

function setupVF(){
    if($('sortable_list')){
//alert('vf');	
        if($('sortable_list').className=='multimedia'){
            var ismm = 1;
        }else{
            var ismm = 0;
        }
        Sortable.create("sortable_list",{
            onChange: function(){
                //alert(getOrder());
                new Ajax.Request("js/ajax.php",{
                    method: "post",
                    parameters: { 
                        updatevf : 'y',
                        ismm: ismm,
                        data: getOrder("sortable_list","name")
                    }
                });
            }
        });
        setupTooltips();
    }
    if($('list_bin')){
        Droppables.add('list_bin', {
            onDrop:removeItem
        })
    }
}

function docReorder(){
    if($('docsorder')){
           Sortable.create("docsorder",{
            onChange: function(){
                new Ajax.Request("js/ajax.php",{
                    method: "post",
                    parameters: { 
                        updateorder : 'y',
                        data: getOrder("docsorder","value"),
						type: document.forms['frmDocuments'].type.value,
						key: document.forms['frmDocuments'].key.value,
						webpage: document.forms['frmDocuments'].webpage.value
                    }
                });
            }
        });
    }
}

function destroyVF() {
	if($('sortable_list')){
        Sortable.destroy("sortable_list");
	}
	 if($('list_bin')){
        Droppables.remove('list_bin');
	 }
}

function removeItem(element, dropon, event){
    var itemID = element.getElementsByTagName('input')[0].getAttribute('name');
    $('sortable_list').removeChild(element);
    if($('sortable_list').className=='multimedia'){
        deletefromud(itemID); // Delete from user docs
    }else{
        deletefromvf(itemID); // Delete from VF
    }
}

function getOrder(eleid,item) {
  var orderList = '';
  orderedNodes = document.getElementById(eleid).getElementsByTagName("li");
  for (var i=0;i < orderedNodes.length;i++) {
    orderList += orderedNodes[i].getElementsByTagName('input')[0].getAttribute(item) + ', ';
  }
  return orderList;
}

function setupTooltips(){
    var ulList = $('sortable_list');
	var liList = ulList.getElementsByTagName('li');
	for (var n = 0; n < liList.length; n++) {
        var myspan = liList[n].getElementsByTagName('span');
        if(myspan[0]){
            myspan[0].setAttribute("tooltiptext",myspan[0].innerHTML);
            myspan[0].onmouseover = function gomouseover(){
            ddrivetip(this.getAttribute("tooltiptext"))
            }
            myspan[0].onmouseout = function gomouseout(){
            hideddrivetip(); 
            }
        }
	}
}


function setupMoreHelp(){
    var bubble = $('morehelpbubble');
    Element.extend(bubble);
    if(bubble){
	    var bubblelink = document.getElementsByClassName('morehelp');
	    for (var n = 0; n < bubblelink.length; n++) {
            bubblelink[n].onmouseover = function(){
                bubble.show();
            }
            bubblelink[n].onmouseout = function(){
                bubble.hide();
            }
        }
    }
}

function setupCaptcha() {
    if($('refreshCaptcha')){
        $('refreshCaptcha').onclick = function() {
            var currentTime = new Date().getTime();
    
            $('testVar1').src = 'randomImage.php?timestamp=' + currentTime;
            
            var updateForm = new Ajax.Request('randomImage.php', {
                parameters: 'update=true',
                method: 'post',
                onComplete: handleResponse
            })
            $('testVar2').value = "";
            return false;
        }
    }
}


function handleResponse(requestObject) {
	$('captchaHash').value = requestObject.responseText;
}


function setupEvents(){
    if($('eventsList')){
        var eventsList = document.getElementsByClassName('eventbutton');
        if(eventsList.length>0){
            for(i=0;i<eventsList.length;i++){
                var eventButton = eventsList[i].getElementsByTagName('span');
                eventButton[0].onclick = function(){
                    var eventID = this.parentNode.id;
                    var openID = eventID.replace("open","");
                    //alert(openID);
                    //new Effect.ScrollTo(openID, {offset: -24});
                    Effect.toggle(openID,'blind',{
                        duration: 0.4                    
                    });
                }            
            }
        }
    }
}

var attendees = 1;

function addAttendee(){
	var intAvailable = 1;
	if($('addAttendee')){
		$('addAttendee').onclick = function(){
			if(typeof(eventsPlacesCheck) == 'function')
				intAvailable = eventsPlacesCheck($('eventID').value);
				if((intAvailable - attendees) > 0){
					attendees++;
					$('attendeesNum').value = attendees;
					var nextAttendee = $('nextAttendee').value.replace(/1/g,attendees);
					new Insertion.Bottom('registeresults', nextAttendee);
				}else {
					alert("Sorry, there are not enough places remaining to add any more attendees, or you have reached your organisation's allocation of places.");
				}
		}    
	}
}

function moveSelectOptions(sourceSelectElement, destinationSelectElement){
	// Move selected options from one select element to another
	// Uses Prototype Library
	if($(sourceSelectElement).options.length > 0)
    {
        for(intCount = $(sourceSelectElement).options.length - 1 ; intCount >= 0 ; intCount--)
        {
			if($(sourceSelectElement).options[intCount].selected)
			{
				var strOptionText = $(sourceSelectElement).options[intCount].text;
				var strOptionValue = $(sourceSelectElement).options[intCount].value;
				$(sourceSelectElement).remove(intCount);
				var objOption = new Option(strOptionText, strOptionValue);
				$(destinationSelectElement).options.add(objOption);
			}
        }
    }
}

function selectAllSelectOptions(sourceSelectElement){
	if($(sourceSelectElement).options.length > 0)
    {
        for(intCount = 0 ; intCount < $(sourceSelectElement).options.length ; intCount++)
        {
			$(sourceSelectElement).options[intCount].selected = true;	
		}
	}
}

function validateEventRegistrants(){
	var blValid = true;
	var intAttendeeCount = $('attendeesNum').value;
	var oForm = $('eventregister'); // the FORM
	
	for(intCount = 1 ; intCount <= intAttendeeCount ; intCount++){
		
		// if at least one field set test the rest
		// (can't have org stuff if no email and we're checking for email already)
		if($('firstname' + intCount).value != "" 
			 || $('surname' + intCount).value != "" 
			 || $('email' + intCount).value != "" 
			 || $('telephone' + intCount).value != ""
			 || $('organisationname').value != ""
			 || $('address1').value  != ""
			 || $('city').value  != ""
			 || $('zip').value  != ""
				 
			 /*|| ($('organisation'+intCount) && $('organisation'+intCount).selectedIndex > -1) 
			 || ($('other'+intCount) && $('other'+intCount).value != "")
			 NOTE BELOW! organisationname1 is specified because all attendees are assumed to be from same
			 */ ){
								
					if($('firstname' + intCount).value == "" 
						 || $('surname' + intCount).value == "" 
						 || $('email' + intCount).value == "" 
						 || $('organisationname').value  == "" 
						 || $('address1').value  == "" 
						 || $('city').value  == "" 
						 || $('zip').value  == "" 
						 || validateEmailAddress($('email' + intCount).value) != true 
						 || $('telephone' + intCount).value == "") {
						blValid = false;
					}
					
		//			alert(oForm);
		//			oOrg = oForm.getInputs('radio','organisation'+intCount);
		//			alert(oOrg.length);
		//			alert( $('organisation'+intCount) );
		//			alert( $('other'+intCount).value );
					/*if( (oOrg && oOrg.checked == -1) 
						&& ($('other'+intCount) && $('other' + intCount).value == "") ) {*/
					/*if(!validateOrg(oForm, intCount)) {
						blValid = false;
					}*/
				}
				else{
					// remove attendee
					var attnum = $('attendeesNum').value; 
					$('attendeesNum').value = attnum - 1;
					$("att"+intCount).innerHTML = "";	
				}
				
	} // end of 'For' loop
	//return false;
	return blValid;
}

function validateP2eEventRegistrants(){

	var blValid = true;
	var intAttendeeCount = $('attendeesNum').value;
	var oForm = $('eventregister'); // the FORM
	for(intCount = 1 ; intCount <= intAttendeeCount ; intCount++){
    
    var form = $('eventregister');
    var theCheckbox = form['penaltyConfirmed1'];
    
    //alert(theCheckbox.checked);
		// if at least one field set test the rest
		// (can't have org stuff if no email and we're checking for email already)
		if($('firstname' + intCount).value != "" 
			 || $('surname' + intCount).value != "" 
			 || $('email' + intCount).value != "" 
			 || $('tel' + intCount).value != ""
			 /*|| theCheckbox.checked == "1"
			 || ($('organisation'+intCount) && $('organisation'+intCount).selectedIndex > -1) 
			 || ($('other'+intCount) && $('other'+intCount).value != "")*/ ){
			if($('firstname' + intCount).value == "" 
				 || $('title' + intCount).value == "" 
				 || $('title' + intCount).value == " " 
				 || $('surname' + intCount).value == "" 
				 || $('email' + intCount).value == "" 
				 || $('otherorgname' + intCount).value == "" 
				 || $('otheraddr1' + intCount).value == "" 
				 || $('othercity' + intCount).value == "" 
				 || $('otherpostcode' + intCount).value == "" 
				 || (intCount==1 && theCheckbox.checked != "1") 
				 || validateEmailAddress($('email' + intCount).value) != true 
				 || $('tel' + intCount).value == "") {
				blValid = false;
			}
            
            
            
            
//			alert(oForm);
//			oOrg = oForm.getInputs('radio','organisation'+intCount);
//			alert(oOrg.length);
//			alert( $('organisation'+intCount) );
//			alert( $('other'+intCount).value );
			/*if( (oOrg && oOrg.checked == -1) 
				&& ($('other'+intCount) && $('other' + intCount).value == "") ) {*/
                
                // if it's the first attendee, check the org
                
                // no need now it's removed
                
            /* if(intCount==1){
                
                if(!validateOrg(oForm, intCount)) {
                    blValid = false;
            
                }
            }
            
            */
            
		}
		else{
			// remove attendee
			var attnum = $('attendeesNum').value; 
			$('attendeesNum').value = attnum - 1;
			$("att"+intCount).innerHTML = "";	
		}
	}
	//return false;
	return blValid;
}

function validateOrg(form, number) {

	var other = $('other'+number);
	var radios = form.getInputs('radio', 'organisation'+number);
	var ans = false;
	
	// 1. check each RADIO: if one is checked, we have an organisation
	for(var i=0; i<radios.length; i++) {
		if(radios[i].checked) {
			ans = true;
			//alert(number+': -- radiio '+i+" radio name = "+radios[i].name);
            
            if(radios[i].value=="other"){
            
                //alert(radios[i].name+" is checked - it's the OTHER radio button");
                ans = true; // set to true, then set back to false if any mandatory fields are empty 
                
                // get names of required fields for the 'other' organisation
                
                var orgNameField = radios[i].name.replace("organisation", "otherorgname");                
                var boxToCheck = document.getElementById(orgNameField);

                if(boxToCheck.value==""){                
                    ans = false;
                }

                var orgNameField = radios[i].name.replace("organisation", "otheraddr1");                
                var boxToCheck = document.getElementById(orgNameField);
                
                if(boxToCheck.value==""){                
                    ans = false;
                }

                var orgNameField = radios[i].name.replace("organisation", "othercity");                
                var boxToCheck = document.getElementById(orgNameField);
                
                if(boxToCheck.value==""){                
                    ans = false;
                }

                var orgNameField = radios[i].name.replace("organisation", "otherpostcode");                
                var boxToCheck = document.getElementById(orgNameField);
                
                if(boxToCheck.value==""){                
                    ans = false;
                }

            } else {
            
    			break; // can stop checking now
            }
		}
	}
	// 2. if no checked, see if OTHER box has text, if so we have an organisation
    
    // Try taking this out - This check now performed above
    
/*
	if(!ans && other && other.value != "") {
    alert("other = "+other.value);
		ans = true;
		alert(number+': other');
	}
    
    */
	// 3. if none, there is no organisation

//alert("here - end - "+ans);

	return ans; // TRUE if organisation set, FALSE if not
}

function validateRegistrant(){
	var blValid = true;
	
	if($('email').value == "" || !validateEmailAddress($('email').value)){
		blValid = false;
	}
	if($('firstname').value == "" ){
		blValid = false;
	}
	if($('surname').value == "" ){
		blValid = false;
	}
	if($('tel').value == "" ){
		blValid = false;
	}
	if(!validateOrg($('eventregister'), '')) {
		blValid = false;
    }

	if($('tel').value == "" ){
		blValid = false;
	}

	return blValid;
}


function validateNewRegistrant(){
	var blValid = true;
	
	if($('email').value == "" || !validateEmailAddress($('email').value)){
		blValid = false;
	}
	if($('firstname').value == "" ){
		blValid = false;
	}
	if($('surname').value == "" ){
		blValid = false;
	}

	if(!validateOrg($('registerform'), '')) {
		blValid = false;
	}

	return blValid;
}



function validateEmailAddress(sourceEmailAddress){

    // Next line commented out as it breaks in IE6
    // var strRegex =/^[a-z0-9]+([_\.-][a-z0-9\ü\ö\ä\ß\Ä\Ö\Ü]+)*@([a-z0-9\ü\ö\ä\ß\Ä\Ö\Ü]+([\.-][a-z0-9\ü\ö\ä\ß\Ä\Ö\Ü]+)*)+\.[a-z]{2,}$/i;
    
    // This is the working line that it replaced

    var strRegex = /^([\w\.\-])+@+([\w\.\-])+([\.])+([\w\.\-])+$/i;
    
	var ans = strRegex.test(sourceEmailAddress);
//	alert('email '+ans);
	return ans;
}

/******************************
 * SEARCHTREE
 ******************************/

   Event.observe(window,'load',function(){
       searchtreeSetup();
   });
    
   function searchtreeSetup(){
   
       /*Find Trees*/
       var trees = document.getElementsByClassName('searchtree');
       if(trees ) {
       for(i=0;i<trees.length;i++){
          var findlis = trees[i].getElementsByTagName('li');
          for(n=0;n<findlis.length;n++){
              var theCheckbox = findlis[n].getElementsByTagName('input')[0];
              
              /* Check to see if there are any children */
              var childrenUls = findlis[n].getElementsByTagName('ul');
              if(childrenUls[0]){
                  var ocLink = document.createElement('span');
                  var ocLinkC = document.createTextNode('+');
                  ocLink.appendChild(ocLinkC);
                  ocLink.setAttribute('title','Open');
                  if(document.all){
                    nextone = findlis[n].nextSibling;
                  }else{
                    nextone = findlis[n].nextSibling ? findlis[n].nextSibling.nextSibling : null;
                  }
                  if(nextone){
                    /* If it has children and has a next sibling */
                    ocLink.className = 'treeopen';
                    findlis[n].className = 'line';
                  }else{
                    if(n==0){
                        ocLink.className = 'treeopenstart';
                    }else{
                        ocLink.className = 'treeopenbottom';
                    }
                  }    
                  findlis[n].insertBefore(ocLink,theCheckbox.parentNode);
                  
                  /*Setup open close*/ 
                  ocLink.onclick = function(){
                    //alert(this.className);
                    if((this.className == 'treeopen')||(this.className == 'treeopenbottom')||(this.className == 'treeopenstart')){
                        if(this.className == 'treeopen'){
                            this.className = 'treeclose';                    
                        }else if(this.className == 'treeopenbottom'){  
                            this.className = 'treeclosebottom';                
                        }else if(this.className == 'treeopenstart'){
                            this.className = 'treeclosestart'; 
                        }
                        this.innerHTML = '-';
                        this.setAttribute('title','Close');
                        var theChildren = this.parentNode.getElementsByTagName('ul')[0];
                        Element.extend(theChildren);
                        if(document.all){
                            theChildren.show();
                        }else{
                            new Effect.BlindDown(theChildren);
                        }
                    }else{
                        if(this.className == 'treeclose'){
                            this.className = 'treeopen';                    
                        }else if(this.className == 'treeclosebottom'){  
                            this.className = 'treeopenbottom';                
                        }else if(this.className == 'treeclosestart'){  
                            this.className = 'treeopenstart';                
                        }
                        this.innerHTML = '+';
                        this.setAttribute('title','Open');
                        var theChildren = this.parentNode.getElementsByTagName('ul')[0];
                        Element.extend(theChildren);
                        if(document.all){
                            theChildren.hide();
                        }else{
                            new Effect.BlindUp(theChildren);
                        }
                    }
                 }
                 
              }else{
              
                 var ocLink = document.createElement('span');
                 var ocLinkC = document.createTextNode(' ');
                 ocLink.appendChild(ocLinkC);
                 if(document.all){
                    nextone = findlis[n].nextSibling;
                  }else{
                    nextone = findlis[n].nextSibling ? findlis[n].nextSibling.nextSibling : null;
                  }
                  if(nextone){
                    ocLink.className = 'treenone'; 
                  }else{
                    ocLink.className = 'treenonebottom'; 
                 }  
                 findlis[n].insertBefore(ocLink,theCheckbox.parentNode);
              }
              
              if(!trees[i].className.match(/noclick/)) { /* NOCLICK class stops this bit */
                  /*Setup checkbox onclicks*/
                  theCheckbox.onclick = function(){
                    
                    if(this.checked == false){
                        var childrenCheckboxes = this.parentNode.parentNode.getElementsByTagName('input');
                        for(m=0;m<childrenCheckboxes.length;m++){
                            childrenCheckboxes[m].checked = '';
                            
                            /* Now Find Parent Nodes and Uncheck them */
                            uncheckParents(this.parentNode.parentNode);
                        }
                    }else{
                        var childrenCheckboxes = this.parentNode.parentNode.getElementsByTagName('input');
                        for(m=0;m<childrenCheckboxes.length;m++){
                            childrenCheckboxes[m].checked = 'checked';
                        }
                        
                        checkParents(this.parentNode.parentNode);
                        
                        
                    }
                    numChecked(this);
                  }
              }
          }
          
          /* Hide ULs */
          var finduls = trees[i].getElementsByTagName('ul');
          for(n=0;n<finduls.length;n++){
             finduls[n].hide();
          }
       } // for
       } // if   
   }
   
   function uncheckParents(item){
        //alert("uncheckParents");       
        /* find Parent */
	   
	   /* Removed by request of EEI - Now require ability to tick parents but not children
	   
        if(item.parentNode.tagName=="UL"){
            var parentItem = item.parentNode.parentNode;
            if(parentItem.getElementsByTagName('input')){
                var theCheckbox = parentItem.getElementsByTagName('input')[0];
                theCheckbox.checked = '';
                uncheckParents(parentItem);
            }
        }
        
        */
   }
   
   function checkParents(item){
        if(item.parentNode.tagName=="UL"){
            var parentItem = item.parentNode.parentNode;
            if(parentItem.getElementsByTagName('input')){
                var childrenCheckboxes = parentItem.getElementsByTagName('input');
                for(i=1;i<childrenCheckboxes.length;i++){
                    if(childrenCheckboxes[i].checked==false){
                        var error = 1;
                    }
                }
                if(!error){
                    childrenCheckboxes['0'].checked = 'checked';
                }
            }
            checkParents(parentItem);
        }
   }
   
   function numChecked(item){
        var numChecked = 0;
        //alert('find num checked');
        var topItem = findTop(item.parentNode.parentNode.parentNode);
        var childrenCheckboxes = topItem.getElementsByTagName('input');
        for(i=1;i<childrenCheckboxes.length;i++){
            if(childrenCheckboxes[i].checked==true){
                numChecked++;
            }
        }
        //alert(item.name+ ' - checked ' + numChecked);
        var tickedTotalSpan = item.name+"_ticked";
        //alert(tickedTotalSpan);
        $(tickedTotalSpan).innerHTML = "&nbsp;("+numChecked+" ticked)";
   }
   
   function findTop(item){
    //alert(item.tagName);
    if(item.className=="searchtree"){
        //alert(item.innerHTML);
        return item;
    }else if(item.tagName=='UL'){
         return findTop(item.parentNode.parentNode);
    }else{
        return false;
    }
   }

function clearInput(input){
    $(input).value = '';
}

function areyousure(message){
    if (confirm(message)) {
        return true;
    }else{
        return false;
    }
}

function onsubmitFCK(form){
    form.summary.value = FCKeditorAPI.GetInstance('summary').GetXHTML();
}

function alert2(content){
    var arrayPageScroll = getPageScroll();
    var arrayPageSize = getPageSize();
    var topPos = arrayPageScroll[1] + (arrayPageSize[3] / 2);
    if(content){
        if(!$('alertbox')){
            var objBody = document.getElementsByTagName("body").item(0);
            var objalert = document.createElement("div");
                objalert.setAttribute('id','alertbox');
                alertbg = new Image();
                if(document.all){
                    alertbg.src = '../images/alertbg.gif';
                }else{
                    alertbg.src = 'images/alertbg.gif';
                }
                objBody.appendChild(objalert);
                objalert.style.top = topPos + 'px';
                objalert.innerHTML = content;
                Element.extend(objalert);
                objalert.show();
        }else{
            $('alertbox').style.top = topPos + 'px';
            $('alertbox').innerHTML = content;
            $('alertbox').show();
        }
    }
}

function closealert2(){
    $('alertbox').hide();
    return false;
}

// clear first attendee boxes
function Attendee1clear(){
	if($('Attendee1clear')){
		var Attendee1clear1 = $('Attendee1clear');
		Attendee1clear1.onclick = function Attendee1clearfunc(){
			$('firstname1').value = "";
			$('surname1').value = "";
			$('email1').value = "";
			$('tel1').value = "";
			//
			$('organisation1').update();
			/*if($('organisation')) {
				$('organisation1').selectedIndex = -1;
			}
			if($('other1')) {
				$('other1').value = "";
			}*/
		}
	}

}

// clear first attendee boxes
function Registrantclear(){
	if($('Registrantclear')){
		var Registrantclear1 = $('Registrantclear');
		Registrantclear1.onclick = function Registrantclearfunc(){
			$('firstname').value = "";
			$('surname').value = "";
			$('email').value = "";
			$('tel').value = "";
			$('organisation').update();
			$('heardofus').selectedIndex = 0;
			//
			/*if($('organisation')) {
				$('organisation').selectedIndex = -1;
			}
			if($('other')) {
				$('other').value = "";
			}*/
		}
	}

}

/* SEARCH NOW button on news page */
function setupNews() {
	var btn = $('searchnews');
	if(btn) {
		btn.onclick = function() {
			var userid = document.getElementById('userid').innerHTML;
			if(userid){
				return true;
			}
			else{
				alert2("<h3>Alert</h3><p>Please sign in to use this feature.</p><ul><li><a href=\"register.php\">Register</a></li><li><a href=\"javascript:void(0)\" onclick=\"closealert2();\">Close</a></li></ul>");
				return false;
			}
		}
	}
}

function ita_selected(theForm){

    if(theForm.p2e_ita.value=="NULL"){
    
        alert("Please select your ITA");
        
        return false;
    
    } else {
    
        return true;
    
    }

}

function clearSearch(theBox){

	theBox.value = '';

}

/* Check Event registrant's details are complete */

function orgEditCheck(orgEditForm){

	var errorString = "";

	if(orgEditForm.name.value==""){

		errorString = errorString+"Organisation name\r\n";
	}

	if(orgEditForm.address1.value==""){

		errorString = errorString+"First line of address\r\n";
	}

	if(orgEditForm.city.value==""){

		errorString = errorString+"City\r\n";
	}

	if(orgEditForm.zip.value==""){

		errorString = errorString+"Postcode/Zip\r\n";
	}

	if(errorString == ""){

		return true;

	} else {
		
		alert("Please enter the following;\r\n"+errorString);
		return false;

	}
}

function addSeminarRow(){

    var theDiv = $('seminarSlots');
    var theCounter = $('seminar_slots').value;
    var theNewCounter = (theCounter*1)+1;
    var theOriginalContent = theDiv.innerHTML;
    var theExtraFields = "<input type=\"text\" name=\"timeslot_"+theNewCounter+"\" size=\"5\" /> <input type=\"text\" name=\"titles_"+theNewCounter+"\" size=\"55\" /><br />"
    theDiv.innerHTML = theOriginalContent+theExtraFields;

    $('seminar_slots').value = theNewCounter;


}


function setupSeminarDetails() {

	if($('seminar_detailslink') && $('seminar_details')) {
        $('seminar_detailslink').onclick = function() {
            new Effect.toggle($('seminar_details'),'blind',{
            duration: 0.6
            });
        }
    }
}
/* EOF */