
/*	--					Check For New Zaks						-- */
var request84637 = createRequest(); // Update request for the Update Timestamp function
var request7323 = createRequest(); // Inform the db that the zak has been checked

function Insert_Content_Within_popupZak_Alert () {

  var form = document.getElementById("popupZak_Alert");
	  Close_Link = "<a href = \"javascript:popupZak_Alert('I_Read_My_Zak');\">close</a>";
	  Zakbook_Link = "<a href = \"Zakbook.php\">check</a> - ";	  
	  form.innerHTML = "You have received a new message in your zakbook. " + Zakbook_Link + Close_Link; 

} // Insert content within the "popupZak_Alert" DIV [ Insert Content Within popupZak Alert ]			

function Update_Timestamp_For_Active_User() {
/* 	-- 		Send the AJAX request		-- 		*/	
var url = "Update_Timestamp_For_Active_User.php?Action=Update_Time";
	
	 request84637.open("GET", url, true); /* this line initiates the connection */
	 request84637.onreadystatechange = Check_if_New_Zak_Arrived; /* when the server returns data, function updatepage is called */	 
     request84637.send(null); /* this sends the request (with zero data) */
	 	 	
	setTimeout('Update_Timestamp_For_Active_User()',60000);
	//^ Reload the function

//request84637.createRequest();	
} // Alert Shuzak that the user is still online. The user will be shown online as long as this function is running [ Update Timestamp For Active User ]

function Check_if_New_Zak_Arrived () {

    if (request84637.readyState == 4) {
		if (request84637.status == 200) {		
	
			var Alert = request84637.responseText; 	
			if (Alert == "Yes") {
				popupZak_Alert ('show');
			}
			else if (Alert == "No") {
	  			if (document.getElementById("popupZak_Alert")) {			
				//^ If the login popup is already visisble
					popupZak_Alert ('hide');			
				}
			}

  		}
		//request84637.createRequest();    	
	}

} // This function checks if a new zak has arrived. If yes, it activates the popupZak Alert function [ Check if New Zak Arrived ]

function popupZak_Alert(showhide){
  <!-- http://forums.tizag.com/showthread.php?p=4928 -->
    if(showhide == "show"){
        document.getElementById('popupZak_Alert').style.visibility="visible"; /* If the function is called with the variable 'show', show the login box */
    }
	else if(showhide == "hide"){
        document.getElementById('popupZak_Alert').style.visibility="hidden"; /* If the function is called with the variable 'hide', hide the login box */
    }
	else if(showhide == "I_Read_My_Zak"){
        document.getElementById('popupZak_Alert').style.visibility="hidden"; /* Renders Any_New_Zaks = No so that the db doesn't keep popping up the zak alert*/

		/* 	-- 		Send the AJAX request		-- 		*/	
		var url = "Update_Timestamp_For_Active_User.php?Action=I_Read_My_Zak";
			
			 request7323.open("GET", url, true); /* this line initiates the connection */
			 request7323.send(null); /* this sends the request (with zero data) */
		
    }
} // Show the popup Alert when a new zak arrives [ popupZak Alert ]
/*  -------------------------------------------------------------------------  */