function AjaxUpdater(url,divid){
	//try{
	    var oAjax=new Ajax.Updater(divid, url, { method: 'get',insertion: Insertion.Bottom });
	/*}catch(e){
        alert('AJAX called failed');
	}*/
}

 function buildQuestion(){
    try{
        var qdivno=document.getElementById('questdivno').value;
		var url='index.php?action=questiondiv&print=ajax&qid=' + qdivno;
	    AjaxUpdater(url,'qust');
		document.getElementById('questdivno').value=(parseInt(qdivno)+1);
	}catch (e){
       alert('Could not create another question entry form.');
	}	
}

function removeElement(parentNode,childNode){
   try{
	    var child = document.getElementById(childNode);
        var parent = document.getElementById(parentNode);
        parent.removeChild(child);
  }catch (e){
       alert('Could not perform the action. There was an error.');
  }

}


 function buildEntryForm(){
    try{
		if(document.getElementById('txtGroupNo').value>40){
           alert('you can enter maximum only 40 names');
        }else{
        var groupno=document.getElementById('txtGroupNo').value;
        var currentno=document.getElementById('currentno').value;
		var id=document.getElementById('id').value;
		var url='groupdataform.php?groupno='+groupno+'&currentno='+currentno+'&type=ajax&id='+id;	    
		AjaxUpdater(url,'frmentry');
		document.getElementById('currentno').value=groupno;
		}
	}catch (e){
       alert('Could not create form entry form');
	}	
}


 function buildLocation(){
    try{
        var groupno=document.getElementById('txtGroupNo').value;
        var currentno=document.getElementById('currentno').value;
		var url='groupdataform.php&groupno='+groupno+'&currentno='+currentno+'&type=ajax';
	    AjaxUpdater(url,'frmentry');
		document.getElementById('currentno').value=groupno;
	}catch (e){
       alert('Could not create form entry form');
	}	
}


function buildDates(divid,lid,cid){
   // try{
       // var lid=document.getElementById('lid').value;
       // var cid=document.getElementById('cid').value;
		var ldivno=document.getElementById('locdivno').value;
		var url='index.php?action=datesdiv&print=ajax&lid=' + lid +'&cid='+cid+'&ldivno='+ldivno;
		document.getElementById('locdivno').value=(parseInt(ldivno)+1);
	    AjaxUpdater(url,divid);
    /*}catch (e){
       alert('Could not create another date field.');
    }*/	
}
