var doc = null;

function ajax() {
	// Make a new XMLHttp object
	if (typeof window.ActiveXObject != 'undefined' ) doc = new ActiveXObject("Microsoft.XMLHTTP");
	else doc = new XMLHttpRequest();
}

function CheckLogin(section, login, destination, id){
    if (login != '') {
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	    	destination.innerHTML = "<font class='text'>Loading data...</font>";
	    	doc.onreadystatechange = function() {
				if (doc.readyState == 4) {
					destination.innerHTML = doc.responseText;
				}
	   		}
	       	if (id!=0){
	       		doc.onreadystatechange = function() {
					if (doc.readyState == 4) {
						destination.innerHTML = doc.responseText;
					}
	    		}	
	       		doc.open("GET", "check_login.php?sec=" + section + "&" + section + "=" + login + "&id=" + id, false);
	       		doc.send(null);
	    		// Write the response to the div	    	
	       	}else{
	       		doc.onreadystatechange = function() {
					if (doc.readyState == 4) {
						destination.innerHTML = doc.responseText;
					}
	    		}
	       		doc.open("GET", "check_login.php?sec=" + section + "&" + section + "=" + login, false);
	       		doc.send(null);
	    		// Write the response to the div	
			}  
			doc.onreadystatechange = function() {
				if (doc.readyState == 4) {
					destination.innerHTML = doc.responseText;
				}
	   		}  	
	    }
	    else{
	      
	       destination.innerHTML = 'Browser unable to create XMLHttp Object';
	    }        
    }
    else {
    	destination.innerHTML = "Nick is empty";
    }

}

function ViewDetails(id,destination){
	if(destination.style.display == "block"){
		destination.style.display = "none";
	}
	else{
		destination.style.display = "block";	
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	    	destination.innerHTML = "Loading data...";
	    	doc.onreadystatechange = function() {
				if (doc.readyState == 4) {
					destination.innerHTML = doc.responseText;
				}
	   		}
       		doc.onreadystatechange = function() {
				if (doc.readyState == 4) {
					destination.innerHTML = doc.responseText;
				}
       		}
       		doc.open("GET", "details.php?id=" + id, false);
	    	doc.send(null);
	    	
			doc.onreadystatechange = function() {
				if (doc.readyState == 4) {
					destination.innerHTML = doc.responseText;
				}
	   		}  	
	    }
	    else{
	      
	       destination.innerHTML = 'Browser unable to create XMLHttp Object';
	    }   
	}     
}

function ViewLibrary(id){
	if (id.style.display == "none"){
		id.style.display = "block";
	}else if (id.style.display == "block"){
		id.style.display = "none";
	}
}