function pop_game()
{
	var x="noParking.php";
	testwindow= window.open (x, "mywindow", "width=800,height=600");
	testwindow.moveTo(50,50);
};

 
function check()
{
if(flag)
	{
	document.lstmail.CheckAll_intId.checked=false;
	flag=false;
	}
else
	{
	document.lstmail.CheckAll_intId.checked=true;
	flag=true;
	}	
}
	
function deletedata(frm,tid)
{
	var flag;
	flag = false;
	for(var i=0;i<frm.elements.length;i++)
	{
		if(frm.elements[i].type=="checkbox" && frm.elements[i].name.substr(0,5)=="intId")
		{
			if(frm.elements[i].checked)
			{
				flag = true;
			}
		}
	}
	if (flag==false)
	{
		alert("Please select atlest one message !");
	}
	else
	{
		if(confirm("Are you sure you want to delete this message?"))
		{
			//frm.hdnoperationstatus.value = "delete";
			frm.action = "team-nook-mail.php?tid="+tid+"&action=delete";
			frm.method = "post";
			frm.submit ();
		}
	}
	
}

function chngtrcolor(cid,cstatus)
{
	temp="111";
	//alert(cstatus);
	//if(cstatus)
		//document.getElementById("tr"+cid).bgColor = "#F0F0f0";
	//else
		//document.getElementById("tr"+cid).bgColor = "white";
}
		
function pop_game1()
{
	var x="noParking1.php";
	testwindow= window.open (x, "mywindow", "width=800,height=600");
	testwindow.moveTo(50,50);
};

function conf_delete(x) 
{
	var answer = confirm("Are you sure you want to delete this friend from the list?");	
	if (answer)
	{
		window.location='x';		
	}
}

function MM_OpenBrWindow(url, name, status)		// added on 30-jul-2007
{
	window.open(url, name, status); 
}

function edit_profile()
{
	document.edit_form.submit();
}

function search()
{
	document.search_form.search.value = 1;		// added on 26-Jul-07
	document.search_form.submit();
}

function invite()								// created on 26-Jul-07
{
	document.search_form.invite.value = 1;
	document.search_form.submit();
}

function reg_submit()
{
	document.thisform.submit();
}

//-----------added on 2nd aug 07
// to enable checkbox click function properly in uniform manner

function CheckUncheckAll(frm,chk)
{
	if(chk.name.substr(0,5) == "intId")
		{chngtrcolor(chk.id,chk.checked)}
	if(chk.name.substr(0,8)!="CheckAll")
	{
		
		CheckName = chk.name.substr(0,5);
		MyChecked	= true;

		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].name.substr(0,5)==CheckName && frm.elements[i].checked==false)
				
				MyChecked=false;
		}

		CheckAll = eval("frm.CheckAll_"+CheckName.substr(0,5));
		CheckAll.checked=MyChecked;
	}		
	else
	{
		
		CheckName = chk.name.substr(9,chk.name.length);
		if(chk.checked==true)
			AllChecked = true;
		else
			AllChecked = false;
		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].type == "checkbox" && frm.elements[i].name.substr(0,5)==CheckName)
			{
				
				frm.elements[i].checked=AllChecked;	
				
				if(frm.elements[i].name.substr(0,5) == "intId"){chngtrcolor(frm.elements[i].id,frm.elements[i].checked);}
			}
		}
	}
}

// --------- start: Added for My Nook Mail page on 6-Aug-2007
function select_deselect(x, section)
{
	var frm = document.frm_nookmail;
	if(x == 1)
	{
		for(i=0; i<frm.elements.length; i++)
		{
			if(frm.elements[i].type == "checkbox" && frm.elements[i].name == "chkdelete_"+section+"[]")
				frm.elements[i].checked = true;
		}
	}
	else
	{
		for(i=0; i<frm.elements.length; i++)
		{
			if(frm.elements[i].type == "checkbox" && frm.elements[i].name == "chkdelete_"+section+"[]")
				frm.elements[i].checked = false;
		}
	}
}

function delete_all(section, id, cpub, cpvt)
{
	var frm = document.frm_nookmail;
	var item_checked = 0;
	for( x=0; x<frm.elements.length; x++ ) 
	{
		var e = frm.elements[x];
		if ( e.name == "chkdelete_"+section+"[]" && e.checked == true ) 
			item_checked++;
	}
	if ( item_checked == 0 )
		alert("You must select atleast one message to delete.");
	else 
	{
		if ( confirm("Are you sure you want to delete the selected message(s)?") ) 
		{
			frm.action = "my-nook-mail.php?user_id=" + id + "&cpub=" + cpub + "&cpvt=" + cpvt + "&action=deleteall#" + section;
			//frm.action = "my-nook-mail.php?user_id=" + "<?=$id?>" + "&action=deleteall#" + section;
			frm.submit();
		}
	}
}

function delete_message(x, section, id, cpub, cpvt)
{
	var frm = document.frm_nookmail;
	if ( confirm("Are you sure you want to delete this message?") ) 
	{
		frm.action = "my-nook-mail.php?user_id=" + id + "&cpub=" + cpub + "&cpvt=" + cpvt + "&action=delete&did=" + x + "#" + section;
		frm.submit();
	}
}

function post_msg(id, cpub, cpvt)
{
	var frm = document.frm_nookmail;
	//frm.post_public.value = 1;
	frm.action = "my-nook-mail.php?user_id=" + id + "&cpub=" + cpub + "&cpvt=" + cpvt + "&post_public=1";
	frm.submit();
}

var flag;
function xmlHTTPFunction()
{
	var xmlHttp;
	try
	  {  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	  }
	catch (e)
	  {  // Internet Explorer  
		  try
			{    
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
			}
	  	  catch (e)
			{    
				try
		  		{      
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}
				catch (e)
		  		{      
					alert("Your browser does not support AJAX!");      
					return false;      
				}    
			}  
	 }
	 return xmlHttp;
 }

function post_reply_msg(receiverid, msg, table_flag, id)
{
	var xmlHTTPobj=xmlHTTPFunction();
	/*var frm = document.frm_nookmail;
	//frm.post_public.value = 1;
	frm.action = "my-nook-mail.php?user_id=" + id + "&action=reply" + "&msgid=" + msg_id ;
	frm.submit();*/
	 xmlHTTPobj.onreadystatechange=function()
		{
		if(xmlHTTPobj.readyState==4)
		  {
			  if(isNaN(xmlHTTPobj.responseText)){
		  		document.getElementById('result'+id).innerHTML=xmlHTTPobj.responseText;
			  }
			  else{
				document.getElementById('result'+id).innerHTML="Your reply was successfully posted.";
			  }
		  }
		}
	  xmlHTTPobj.open("GET","insert_reply_msg.php?receiver_id="+receiverid+"&msg="+msg+"&table="+table_flag,true);
	  xmlHTTPobj.send(null);  
	document.getElementById('reply'+id).style.display=	'block';
	document.getElementById('replymsgcnt'+id).style.display='none';
}

function changepage(x, section, id, cpub, cpvt)
{
	var frm = document.frm_nookmail;
	//eval("frm.currentPage_"+section+".value = x;");
	
/*	if(section == "pub")
		cpub = x;
	else
		cpub = '<?=$currentPage_pub?>';
	if(section == "pvt")
		cpvt = x;
	else
		cpvt = '<?=$currentPage_pvt?>';	*/
	if(section == "pub")
		cpub = x;
	if(section == "pvt")
		cpvt = x;
	
	frm.action = "my-nook-mail.php?user_id=" + id + "&cpub=" + cpub + "&cpvt=" + cpvt + "#" + section;
	frm.submit();	
}
// --------- end: Added for My Nook Mail page on 6-Aug-2007

