
function menu_popup1(i)
{

	//alert(123);
//	var hd_count=document.getElementById('hd_count').value;
	//var x;
	alert(i);



}
function menu_popup(i)
{

	
	var hd_count=document.getElementById('hd_count').value;
	var x;
	//alert(hd_count);
	for(x=1;x<=hd_count;x++)
	{
	if(i==x)
	{
	
	var div_nm='div_popup'+x;
	//var div_nm_chlng='div_chlng'+x;
   document.getElementById(div_nm).style.display="block";
  // document.getElementById(div_nm_chlng).style.display="none";
   }
   else
   {
	   
   var div_nm='div_popup'+x;
   //alert(div_nm);
  document.getElementById(div_nm).style.display="none";
   }
   
  
   }

}
function menu_popup_close(i)
{

	//alert(123);
	var hd_count=document.getElementById('hd_count').value;
	var x;
	
	for(x=1;x<=hd_count;x++)
	{
	if(i==x)
	{
	
	var div_nm='div_popup'+x;
	var div_nm_chlng='div_chlng'+x;
   document.getElementById(div_nm).style.display="none";
   document.getElementById(div_nm_chlng).style.display="none";
   }
   else
   {
   var div_nm='div_popup'+x;
   document.getElementById(div_nm).style.display="none";
   }
   
  
   }

}
function menu_chlng_close(i)
{

var hd_count=document.getElementById('hd_count').value;
	var x;
	
	for(x=1;x<=hd_count;x++)
	{
	if(i==x)
	{
	var div_nm='div_popup'+x;
	// var div_nm_chlng='div_chlng'+x;
  
  // document.getElementById(div_nm_chlng).style.display="none";
    document.getElementById(div_nm).style.display="none";
   }
   else
   {
	  
   var div_nm_chlng='div_popup'+x;
      
   //document.getElementById(div_nm).style.display="none";
   
   }
   
  
   }
}

function menu_chlng1(i,sess_user_id,user_id,msg_text,sess_username,username)
{

var hd_count=document.getElementById('hd_count').value;
	var x;
	
	for(x=1;x<=hd_count;x++)
	{
	if(i==x)
	{

		
	var div_nm='div_popup'+x;
	 var div_nm_chlng='div_chlng'+x;
   check_chlng_status(div_nm_chlng,x,sess_user_id,user_id,msg_text,sess_username,username);
   
   document.getElementById(div_nm_chlng).style.display="block";
    document.getElementById(div_nm).style.display="none";
   }
   else
   {
	  
   var div_nm_chlng='div_chlng'+x;
      
   document.getElementById(div_nm_chlng).style.display="none";
   
   }
   
  
   }
}

function check_chlng_status(dv,dv_id,sess_user_id,user_id,msg_text,sess_username,username) 
	{	
	var resp;	
		strURL="process_challenge.php";
		strURL+="?sess_user_id="+sess_user_id+"&user_id="+user_id+"&msg_text="+msg_text+"&dv_id="+dv_id+"&sess_username="+sess_username+"&username="+username;

		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					resp=req.responseText;
					//alert(resp)					;
						document.getElementById(dv).innerHTML=req.responseText;						
						//alert(req.responseText);
						//document.getElementById(dv).innerHTML="111";
						//alert(dv);
						var div_chlng="div_chlng"+dv_id;
                       var frmcheck="frmcheck"+dv_id;
						
						agewindow=dhtmlmodal.open('frmcheck', 'div',div_chlng, ' ', 'width=50px,height=50px,left=10px,top=20px,resize=0,scrolling=0');
						
						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
			
			//alert(req.responseText);
		//return resp;
		}
		
	}

	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{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
	}
	
	/////////////// onload
	
	function check_request() 
	{		
		strURL="process_request.php";
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					
						//document.getElementById(dv).innerHTML=req.responseText;	
						/////////////////////////start
						
						var strres=req.responseText;
					if(strres!=" ")
					{
				
		var arrres=strres.split('~~');

	 var cnt=arrres.length;
	

	 for (var x = 0; x < cnt; x++)
   {

  var prods=arrres[x];

   var prod=prods.split(',');
   
   var dv_id=prod[0].replace(/^\s+|\s+$/g,"");;

    var dv_resp=prod[1];
	
	////////////////////////////////////////////
	
	 var div_nm_chlng_rqst='div_chlng_rqst'+dv_id;
	 ////alert(div_nm_chlng);
	     document.getElementById(div_nm_chlng_rqst).innerHTML=dv_resp;	
	    var div_chlng="div_chlng_rqst"+dv_id;
                       var frmcheck="frmcheck"+dv_id;
						
						agewindow=dhtmlmodal.open('frmcheck', 'div',div_chlng, ' ', 'width=50px,height=50px,left=10px,top=20px,resize=0,scrolling=1');
						

   /////////////////////////////////////////////////


   }


   }
						
						/////////////////////////end
					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
	}
	
	///////////////DHTML.....
	
	function div_popup(cat_id){
var abc;
var div_chlng="div_chlng"+cat_id;
var frmcheck="frmcheck"+cat_id;


	agewindow=dhtmlmodal.open('frmcheck', 'div', div_chlng, 'popcorn', 'width=50px,height=50px,left=10px,top=100px,resize=0,scrolling=0')
}


	function menu_chlng(cat_id,sess_user_id,user_id,msg_text,sess_username,username){
var abc;
var div_chlng="div_chlng"+cat_id;
var frmcheck="frmcheck"+cat_id;

 var div_nm_chlng='div_chlng'+cat_id;
  
    
 

 check_chlng_status(div_nm_chlng,cat_id,sess_user_id,user_id,msg_text,sess_username,username);
}




//Function to run when buttons within modal window is clicked on. Directly embedded inside hidden DIV, bypassing "onclose" event:
function process_age(whichbutton){
	
	agewindow.hide();
}






function request_delete(uid) 
	{		
		strURL="process_delete.php?uid="+uid;
		//alert(strURL);
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					
					//alert(req.responseText);
						//document.getElementById(dv).innerHTML=req.responseText;	
						//alert('hi requst decline');
						return dhtmlwindow.close_div();
					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
	}
//////////////////


function request_decline() 
	{		
		strURL="process_decline.php";
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					
						//document.getElementById(dv).innerHTML=req.responseText;	
						//alert('hi requst decline');
						return dhtmlwindow.close_div();
					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
	}
	///////////request_pendding
	
	function request_reply()
 
	{		
		strURL="process_request_reply.php";
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					
						//document.getElementById(dv).innerHTML=req.responseText;	
						/////////////////////////start
						
						var strres=req.responseText;
					if(strres!=" ")
					{
				
		var arrres=strres.split('~~');

	 var cnt=arrres.length;
	

	 for (var x = 0; x < cnt; x++)
   {

  var prods=arrres[x];

   var prod=prods.split(',');
   
   var dv_id=prod[0].replace(/^\s+|\s+$/g,"");;

    var dv_resp=prod[1];
	
	////////////////////////////////////////////
	
	 var div_nm_chlng_rqst='div_chlng_rqst'+dv_id;
	 ////alert(div_nm_chlng);
	     document.getElementById(div_nm_chlng_rqst).innerHTML=dv_resp;	
	    var div_chlng="div_chlng_rqst"+dv_id;
                       var frmcheck="frmcheck"+dv_id;
						
						agewindow=dhtmlmodal.open('frmcheck', 'div',div_chlng, ' ', 'width=50px,height=50px,left=10px,top=20px,resize=0,scrolling=1');
						

   /////////////////////////////////////////////////


   }


   }
						
						/////////////////////////end
					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
	}
	
	