
function menu_popup1(i){

	//alert(123);
//	var hd_count=document.getElementById('hd_count').value;
	//var x;
	alert(i);


}
function menu_popup(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="block";
   document.getElementById(div_nm_chlng).style.display="none";
   }
   else
   {
   var div_nm='div_popup'+x;
   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_chlng'+x;
      
   document.getElementById(div_nm_chlng).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;

	//	alert(strURL);
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
						resp=req.responseText;
 						document.getElementById(dv).innerHTML=req.responseText;						
 						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);
			
		 
		}
		
}














	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(){
	//	alert('asdf');
		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_rqst)
	document.getElementById(div_nm_chlng_rqst).style.display="block";
	
		 
		  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){

	//alert("hello");
	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_block(uid){		
		strURL="process_block.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');
						request_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_block_direct(uid){		
		strURL="process_block.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');
						
						
					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
	}

function request_unblock_direct(uid){		
		strURL="process_unblock.php?uid="+uid;
		
	
		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');
						
						
					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
	}

function request_blocklink(uid)	{		
		strURL="process_blocklink.php?uid="+uid;
		
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					

						document.getElementById('dv_blocklink').innerHTML=req.responseText;	
						//alert('hi requst decline');
						
						
					
					} 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 accept
	
	function request_accept(filename) 
	{		
	
	 	strURL="process_accept.php?tpc="+filename;
		
		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
												/*alert('hi requst Accepted');
												alert(""+req.responseText+".");
												alert(strURL);*/
												return dhtmlwindow.close_accept_div(filename);
 					} 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);
		}
		
	}
	///////////////accept reply
	
	function request_accept_reply()
 	{		
		
		 strURL="process_accept_reply.php";
		
		 //alert(strURL);

		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);
		}
		
	}
	
	function request_debate(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_accept_confirm(filename) 
	{		
	
			strURL="process_accept_confirm.php?tpc="+filename;
		
			var req = getXMLHTTP();
			
			if (req) {
				
				req.onreadystatechange = function() {
					if (req.readyState == 4) { 
						// only if "OK"
						if (req.status == 200) {	
						
							//document.getElementById(dv).innerHTML=	
							////alert('hi requst decline');
						//alert(req.responseText);
							return dhtmlwindow.close_accept_div(filename);
						
						} else {
							alert("There was a problem while using XMLHTTP:\n" + req.statusText);
						}
					}				
				}			
				req.open("GET", strURL, true);
				req.send(null);
			}
		
	}
	
	//////////////////
	
	function request_channel()
 	{		
		strURL="process_channel.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_debate='div_debate'+dv_id;
	 ////alert(div_nm_chlng);
	// alert("123");
 				div_nm_debate=dv_resp;
				
				//change by abid
 		     //document.getElementById(div_nm_debate).innerHTML=dv_resp;	
	
						
						
						

   /////////////////////////////////////////////////


   }


   }
						
						/////////////////////////end
					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
	}

	function hide_dv_profile()
	{


var div_nm='dv_list';
 
	document.getElementById(div_nm).style.display="none";
	
}

	function show_dv_profile(uid)
	{

	var div_nm='dv_list';
 
	if(document.getElementById(div_nm).style.display=="none")
	
	{
    document.getElementById(div_nm).style.display="block";
	strURL="process_profile.php?uid="+uid;
		//alert(strURL);
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	

						document.getElementById(div_nm).innerHTML=req.responseText;
					
					} else {
						
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
		
		
	
	
	
	
	
	
	
	
	
	}
	else
		{
			
			document.getElementById(div_nm).style.display="none";
			
			strURL="process_profile.php?uid="+uid;
			var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	

						document.getElementById(div_nm).innerHTML=req.responseText;
					
					} else {
						
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
			
			document.getElementById(div_nm).style.display="block";
			
			}
	}

	
	function show_dv_profile_parent(uid)
	{

	var div_nm='dv_list';
 
	if(document.getElementById(div_nm).style.display=="none")
	
	{
    document.getElementById(div_nm).style.display="block";
	strURL="process_profile.php?uid="+uid;
		//alert(strURL);
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	

						document.getElementById(div_nm).innerHTML=req.responseText;
					
					} else {
						
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
		
		
	
	
	
	
	
	
	
	
	
	}
	else
		{
			
			document.getElementById(div_nm).style.display="none";
			
			strURL="process_profile.php?uid="+uid;
			var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	

						document.getElementById(div_nm).innerHTML=req.responseText;
					
					} else {
						
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
			
			document.getElementById(div_nm).style.display="block";
			
			}
	}





	function request_userlist() 
	{		
		strURL="process_userlist.php";
		//alert(strURL);
	
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	

						document.getElementById('dv_ulist').innerHTML=req.responseText;
					
					} else {
						
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
		
	}
