// Ajax function----------

function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	
//function for getting Sub-Categories ------------	
	
function ShowAjaxWork(val,respo) {	//alert(respo); exit();
		var strURL="response.php?value="+val+"&response="+respo;
		var req = getXMLHTTP();		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						
						if(respo=='ShowNewTable')
						{
						document.getElementById('MachineInfo').innerHTML=req.responseText;	
					    }else{
						document.getElementById('NewDiv').innerHTML=req.responseText;	
							}

                  } else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}else{
					
					if(respo=='ShowNewTable')
					{
				document.getElementById('MachineInfo').innerHTML='<div style="height:60px; padding-left:250px; padding-top:15px" align="left"><br><img src="images/loadingAnimation.gif" /><br><span style="padding-left:70px">Processing....</span></div>';		
						}else{
						document.getElementById('NewDiv').innerHTML='<div style="margin-top:100px;" align="center"><img src="images/loadingAnimation.gif" width="208" height="13" /><br> Processing....</div>';
						}
						
						
					}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}

//function for Check Email ------------	
	
function ShowAjaxWork2(val,respon) {	//alert(respon); exit();
        if(respon=='SearchVal') {
		var strURL="../response.php?value="+val+"&response="+respon;
		                  }else{
		var strURL="response.php?value="+val+"&response="+respon;					  
							  }
		var req = getXMLHTTP();		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						
					if(respon=='email') {	
						document.getElementById('MailId').innerHTML=req.responseText;
					                    }
					if(respon=='subCate') {	
						document.getElementById('SubCate').innerHTML=req.responseText;
					                    }
                    if(respon=='SearchVal') {	
						document.getElementById('ErrId').innerHTML=req.responseText;
					                    }
					if(respon=='faqs') {	
						document.getElementById('ShoFaq').innerHTML=req.responseText;
					                    }
					if(respon=='NewCode') {
						/*
						if(req.responseText=='')
						{ 
						document.getElementById('SubNewId').disabled = false 
						}else{
						document.getElementById('SubNewId').disabled = true 	
							}
						*/	
						document.getElementById('ShowCode').innerHTML=req.responseText;
					                    }
					//if(respon!='subCate' || respon!='email')
					//{ document.getElementById('ViewDiv').innerHTML=req.responseText;  }
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}else{
					if(respon=='email') {	
						document.getElementById('MailId').innerHTML='<input name="email" type="text" size="30" value="'+val+'" />&nbsp;&nbsp;<img src="images/loader.gif">';
					                    }
					if(respon=='subCate') {	
						document.getElementById('SubCate').innerHTML='<select name="subcate" id="subcate" style="width:210px" disabled><option value="">--Select a Sub-Category--</option></select>';
					                    }
					if(respon=='SearchVal') {	
						document.getElementById('ErrId').innerHTML='Checking Please wait....';
					                    }
					if(respon=='faqs') {	
						document.getElementById('ShoFaq').innerHTML='Processing Please wait....';
					                    }
					if(respon=='NewCode') {	
						document.getElementById('ShowCode').innerHTML='checking code......';
					                    }
					//if(respon!='subCate' || respon!='email')
					                    //{ 
						//document.getElementById('ViewDiv').innerHTML='Processing, Please wait....';  
						                //}
					}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}	

