//******************** AJAX Goes Here ***********************************//

	var request;
	var dest;
	var do_show = true;
	
	function processStateChange(){
		if (request.readyState == 4){
				contentDiv = document.getElementById(dest);
				if (request.status == 200){
						response = request.responseText;
						contentDiv.innerHTML = response;
				} 
				else 
				{
					contentDiv.innerHTML = "Error: Status "+request.status;
				}
		}
	}

	function loadHTML(URL, destination){
		dest = destination;
		
				if (window.XMLHttpRequest){
						request = new XMLHttpRequest();
						request.onreadystatechange = processStateChange;
						request.open("GET", URL, true);
						request.send(null);
				} 
				else if (window.ActiveXObject) {
						request = new ActiveXObject("Microsoft.XMLHTTP");
									if (request) {
											request.onreadystatechange = processStateChange;
											request.open("GET", URL, true);
											request.send();
									}
				}
		}
		
 function get(destinationPage, placeHold) {
      var getstr = "?";
		  var obj = document.getElementsByTagName('input');
		  
		  for(var x=0;x<obj.length;x++){	
		  
		  	//------------ For Text Boxes------------------
			
				if(obj[x].type=='text' || obj[x].type=='TEXT'){
						getstr += obj[x].name + "=" + obj[x].value + "&";
				}
			//------------ For Hidden------------------
			
				if(obj[x].type=='hidden' || obj[x].type=='HIDDEN'){
						getstr += obj[x].name + "=" + obj[x].value + "&";
				}
				
			//------------ For Check Boxes------------------
			
				if(obj[x].type=='checkbox' || obj[x].type=='CHECKBOX'){
					if (obj[x].checked) {
					  getstr += obj[x].name + "=" + obj[x].value + "&";
					} else {
					  getstr += obj[x].name + "=&";
				   }
				}
			// ------------- For Password  --------------
				if(obj[x].type=='password' || obj[x].type=='PASSWORD'){
					getstr += obj[x].name + "=" + obj[x].value + "&";
			}
			
			//------------ For Radio Buttons------------------
			
				if(obj[x].type=='radio' || obj[x].type=='RADIO'){
					if (obj[x].checked) {
						getstr += obj[x].name + "=" + obj[x].value + "&";
				   }
				}
			}
			
			//------------ For Combo Boxes------------------
			
			  var obj = document.getElementsByTagName('select');
		  
		     for(var x=0;x<obj.length;x++){	
				var sel = obj[x];
                getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
	         } 
		loadHTML(destinationPage+getstr,placeHold);
	} 
	 
	 
	 function get2(destinationPage, placeHold) {
      clear();
	  var getstr = "&";
		  var obj = document.getElementsByTagName('input');
		  
		  for(var x=0;x<obj.length;x++){	
		  
		  	//------------ For Text Boxes------------------
			
				if(obj[x].type=='text' || obj[x].type=='TEXT'){
						getstr += obj[x].name + "=" + obj[x].value + "&";
				}
			//------------ For Hidden------------------
			
				if(obj[x].type=='hidden' || obj[x].type=='HIDDEN'){
						getstr += obj[x].name + "=" + obj[x].value + "&";
				}
				
			//------------ For Check Boxes------------------
			
				if(obj[x].type=='checkbox' || obj[x].type=='CHECKBOX'){
					if (obj[x].checked) {
					  getstr += obj[x].name + "=" + obj[x].value + "&";
					} else {
					  getstr += obj[x].name + "=&";
				   }
				}
			// ------------- For Password  --------------
				if(obj[x].type=='password' || obj[x].type=='PASSWORD'){
					getstr += obj[x].name + "=" + obj[x].value + "&";
			}
			
			//------------ For Radio Buttons------------------
			
				if(obj[x].type=='radio' || obj[x].type=='RADIO'){
					if (obj[x].checked) {
						getstr += obj[x].name + "=" + obj[x].value + "&";
				   }
				}
			}
			
			//------------ For Combo Boxes------------------
			
			  var obj = document.getElementsByTagName('select');
		  
		     for(var x=0;x<obj.length;x++){	
				var sel = obj[x];
                getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
	         } 
		loadHTML(destinationPage+getstr,placeHold);
	}

/*---------- NOTE : Use This Function When you have to submit a single form when multiple forms from the same name is available
              such as creating fomrs from a dynamic loop. Use HTML code as following. Works in IE only
			  
			  example :
			  
					  <table width="281" border="0">
						  <tr>
						  <form>
							<td width="144"><input name="txt" type="text" id="txt"></td>
							<td width="52"><input name="txt2" type="text" id="txt2"></td>
							<td width="71"><input type="button" name="Button2" value="Button" onClick="test(this)"></td>
						  </form>
						  </tr>
						
						
						  <tr>
							<form>
							<td><input name="txt" type="text" id="txt"></td>
							<td><input name="txt3" type="text" id="txt3"></td>
							<td><input type="button" name="Button3" value="Button" onClick="test(this)"></td>
							</form>
						  </tr>
						
						
						  <tr>
							<form>
							<td><input name="txt" type="text" id="txt"></td>
							<td><input name="txt4" type="text" id="txt4"></td>
							<td><input type="button" name="Button" value="Button" onClick="test(this)"></td>
							</form>
						  </tr>
					</table>
---------------------------------------------------------------------------------------------------------------------------------*/
	function getForm(firedObject,destinationPage, placeHold){
	
		var parent = firedObject;
		var getstr = "?";
		
		while(true){ 	
           parent = parent.parentNode;

		   if(parent.tagName=="FORM"){

				var childElemnts = parent.all;
				
						for(var x=0;x<childElemnts.length;x++){
			
								if(childElemnts[x].tagName=="input" || childElemnts[x].tagName=="INPUT"){	
										  
													//------------ For Text Boxes------------------
													
														if(childElemnts[x].type=='text' || childElemnts[x].type=='TEXT'){
																getstr += childElemnts[x].name + "=" + childElemnts[x].value + "&";
														}
												
														//------------ For Hidden------------------
			
														if(childElemnts[x].type=='hidden' || childElemnts[x].type=='HIDDEN'){
																	getstr += childElemnts[x].name + "=" + childElemnts[x].value + "&";
														}
															
														//------------ For Check Boxes------------------
														
															if(childElemnts[x].type=='checkbox' || childElemnts[x].type=='CHECKBOX'){
																if (childElemnts[x].checked) {
																  getstr += childElemnts[x].name + "=" + childElemnts[x].value + "&";
																} else {
																  getstr += childElemnts[x].name + "=&";
															   }
															}
															
														//------------ For Radio Buttons------------------
														
															if(childElemnts[x].type=='radio' || childElemnts[x].type=='RADIO'){
																if (childElemnts[x].checked) {
																	getstr += childElemnts[x].name + "=" + childElemnts[x].value + "&";
															   }
															}
								}	
								if(childElemnts[x].tagName=="select" || childElemnts[x].tagName=="SELECT"){
														var sel = childElemnts[x];
                										getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
								}		
						}
				loadHTML(destinationPage+getstr,placeHold);
				break;
		   }
		}		
	}
//----------------------- This is just a confirm deletion function. Nothing to do with AJAX ------------------------------------

function confirmDeletion(firedButton,destinationPage, placeHold){
				var fired = firedButton;
				var dest = destinationPage;
				var hold = placeHold;
				
				var option = confirm("Are You Sure That You Need To Delete all details of this player? ");
				
				if(option){
						getForm(fired,dest,hold);	
				}
}
function confirmDeletionOff(firedButton,destinationPage, placeHold){
				var fired = firedButton;
				var dest = destinationPage;
				var hold = placeHold;
				
				var option = confirm("Are You Sure That You Need To Delete all details of this Officer? ");
				
				if(option){
						getForm(fired,dest,hold);	
				}
}
//-------------------------------Numbers only----------------------------

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789vV").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}
//---------------------Form validation ------------------

function test()
{
alert("OK");	
}

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
} 
 
<!-- 
//initial checkCount of zero 
var checkCountT=0
var checkCountS=0
var checkCountWL=0
var checkCountWR=0

//maximum number of allowed checked boxes 
var maxchecksT=3
var maxchecksS=3
var maxchecksWL=1
var maxchecksWR=1

function clear(){
//initial checkCount of zero 
 checkCountT=0 
 checkCountS=0
 checkCountWL=0
 checkCountWR=0

}

//for Track and field
function checksTrack(obj){ 
//increment/decrement checkCount 
if(obj.checked){ 
checkCountT=checkCountT+1 
}else{ 
checkCountT=checkCountT-1 
} 
//if they checked a 4th box, uncheck the box, then decrement checkcount and pop alert 
if (checkCountT>maxchecksT){ 
obj.checked=false 
checkCountT=checkCountT-1 
alert('you may only choose up to '+maxchecksT+' options') 
} 
} 
function checksSwimming(obj){ 
//increment/decrement checkCount 
if(obj.checked){ 
checkCountS=checkCountS+1 
}else{ 
checkCountS=checkCountS-1 
} 
//if they checked a 4th box, uncheck the box, then decrement checkcount and pop alert 
if (checkCountS>maxchecksS){ 
obj.checked=false 
checkCountS=checkCountS-1 
alert('you may only choose up to '+maxchecksS+' options') 
} 
} 
function checksWeightlifting(obj){ 
//increment/decrement checkCount 
if(obj.checked){ 
checkCountWL=checkCountWL+1 
}else{ 
checkCountWL=checkCountWL-1 
} 
//if they checked a 4th box, uncheck the box, then decrement checkcount and pop alert 
if (checkCountWL>maxchecksWL){ 
obj.checked=false 
checkCountWL=checkCountWL-1 
alert('you may only choose up to '+maxchecksWL+' options') 
} 
} 
function checksWrestling(obj){ 
//increment/decrement checkCount 
if(obj.checked){ 
checkCountWR=checkCountWR+1 
}else{ 
checkCountWR=checkCountWR-1
} 
//if they checked a 4th box, uncheck the box, then decrement checkcount and pop alert 
if (checkCountWR>maxchecksWR){ 
obj.checked=false 
checkCountWR=checkCountWR-1
alert('you may only choose up to '+maxchecksWR+' options') 
} 
} 


