// JavaScript Document
var httpRequest=false;
function sendRequest(url,updateSection)
{ 
	var msxmlhttp = new Array('Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP');
	for (var i = 0; i < msxmlhttp.length; i++) 
	{
		try 
		{ 
			httpRequest = new ActiveXObject(msxmlhttp[i]); 
		}
		catch (e) { httpRequest =false;}
		if(!httpRequest && typeof XMLHttpRequest != "undefined")
		{
			try 
			{ 
				httpRequest = new XMLHttpRequest(); 
			}
			catch (e) { httpRequest = false;}
		}
				
	}
	httpRequest.open("GET", url, true); 
	httpRequest.onreadystatechange = function() {processRequest(updateSection); };
	httpRequest.send(null);
}

function processRequest(updateSection) 
{ 
    //To Show Searching Image.
	if(document.getElementById("srch_txt"))
	   document.getElementById("srch_txt").style.display='';
	
	if(httpRequest.readyState == 4) 
    { 
        if(httpRequest.status == 200) 
        {
           	//Update the HTML 
			var msg=httpRequest.responseText
			//alert(msg);
			
			//To Hide Searching Image.
			if(document.getElementById("srch_txt"))
			   document.getElementById("srch_txt").style.display='none';
			
			//To Show <TR> (ROW ) in response has to be written. (not required..only for show).
			if(document.getElementById("warn_msg"))
			   document.getElementById("warn_msg").style.display='';
			
			//------ RESPONSE GENERATED & REPLACED BY 'Display Section'----------//
			if(document.getElementById(updateSection))
			  document.getElementById(updateSection).innerHTML=msg;

            //To Change Color of Button particularly in 'e_mod_vendor.php & e_cust_edit_vendor.php'
            if(document.getElementById("btn_text"))
			  document.getElementById("btn_text").innerHTML="<input type='submit' name='Submit' value='Continue' class='button2'>";
			  
        } 
        else 
        { 
            alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText); 
        }
    }         
} 
//######## Function Used in BRIDE(brd_select_vendor_cat.php)..for selecting NOTE according to chosen Service Category  ######//
function getCat()
{
	var id_scatt = document.getElementById("scatt");
	var recid = document.frm.hid_recid.value;
	var recid1 = document.frm.hid_recid1.value;

	var val_scatt = id_scatt.options[id_scatt.selectedIndex].value;
	//alert(id_scatt.options[id_scatt.selectedIndex].value);//alert(id_scatt.value);
	var url="brd_sel_ven_cat_save.php?cat="+val_scatt+"&recid="+recid+"&recid1="+recid1+"&opr=1";
	//alert(url);
	sendRequest(url,"comment");	
}

//##### Function To get Date According to Selected Month..(For Bride) ####//
function dateGet(url_main,id,date_box_name)
{
	//var id_mon = document.getElementById("cmb_mon"); //id for date..
	var id_mon = document.getElementById(id); //id for date..	
	var val_mon = id_mon.value;
	
	//alert(val_mon);
	//var url = "date_check_save.php?mon="+val_mon+"&opr=1";
	
	//id_show ==>>  To Replace Response in Particular space (eg: Here Name of 'COMBO BOX').. 
	var url = url_main+"?mon="+val_mon+"&show_date="+date_box_name+"&opr=1";
	//alert(url);
	sendRequest(url,"id_date");
}

// Function Used in 'CHANGE_PWD.php' for checking of Invalid Old Password.
   function check_old_pwd(url_main,id,updateSection,op)
   {
	   var id_old_pwd = document.getElementById(id);  //Id of TXT_OLD_PASSWORD.
	   var val_old_pwd = id_old_pwd.value;  //Value  of Old Password.
	   
	   var url = url_main+"?old_pwd="+val_old_pwd+"&opr="+op;
	   //alert(url);
	   sendRequest(url,updateSection);
   }
  
 //GENERAL Function Used for selecting PDF (BRIDE/ADMIN/add_brochures.php). 
   function getItem(url_main,id,updateSection,op)
   {
	   var id = document.getElementById(id);  //Id of COMBO BOX.
	   var val = id.value;  //Value of Combo Box.
	   
	   var url = url_main+"?val="+val+"&opr="+op;
	   //alert(url);
	   sendRequest(url,updateSection);
   }
   
   //Used in BRIDE/EMP/e_cust_edit_vendor.php, e_cust_add_vendor & e_add_vendor & e_mod_vendor 
   //for checking duplicate entries.
   function getDupEntry(url_main,ven_id,st,ct,add,op)
   {
	   var state='';
	   var city='';
	   var address='';
	   var url='';
	   var f=document.frm;
	   
	   /*state = f.txt_state.value;  //Value of Combo Box(state).
	   city = f.txt_city.value;
	   address = f.txt_address.value;*/
	   
	   state = st.value;  //Value of Combo Box(state).
	   city = ct.value;
	   address = add.value;
	      
	   url = url_main+"?st="+state+"&ct="+city+"&add="+address+"&ven_id="+ven_id+"&opr="+op;
	   //alert(url);
	   sendRequest(url,"show");
   }
   
  //Function for moving vendors to choice list..
/*    function moveto_choice(url)
	{
		var url_main = url+"&opr=1";
		alert(url_main);
	    sendRequest(url,"show_msg");
	}*/
  
  
  // General Function Used in Ajax (Returning '1' value & '1' ID in query string through '2' IDs)
   /*function getItem_value(url_main,id,rec_val,updateSection,op)
   {
	   var id = document.getElementById(id);  //Id of COMBO BOX.
	   var val = id.value;  //Value of Combo Box.
	   
	   var url = url_main+"?val="+val+"&rec_val="+rec_val+"&opr="+op;
	   //alert(url);
	   sendRequest(url,updateSection);
   }*/

