function displayBlock(ID,instruction){
	if(instruction){
		document.getElementById(ID).style.display = instruction;
	}else{
		if(document.getElementById(ID).style.display == "none"){
			document.getElementById(ID).style.display = "block";
		}else{
			document.getElementById(ID).style.display = "none";
		}
	}
	return;
}

function displayRow(ID,instruction){//a function to amend the visibility of table rows
	if(instruction){
		document.getElementById(ID).style.visibility = instruction;
	}else{
		if(document.getElementById(ID).style.visibility == "collapse"){
			document.getElementById(ID).style.visibility = "visible";
		}else{
			document.getElementById(ID).style.visibility = "collapse";
		}
	}
	return;
}

function displayOther(ID,instruction){
	
	if(instruction == "none"){
		document.getElementById(ID).style.display = "none";
		document.getElementById(ID).value = "";
	}else{
		document.getElementById(ID).style.display = "inline";
	}
	
	/*
	if(document.getElementById(ID).style.display == "none"){
		document.getElementById(ID).style.display = "inline";
	}else{
		document.getElementById(ID).style.display = "none";
		document.getElementById(ID).value = "";
	}
	*/
	return;
}

function displayRelevant(ID,otherID){
	
	if(document.getElementById(ID).style.display == "none"){
		document.getElementById(ID).style.display = "inline";
	}else{
		document.getElementById(ID).style.display = "none";
		document.getElementById(otherID).value = "";
	}
	
	return;
}
		
function popUp(destination,width_measure,height_measure){
	var newWin = window.open(destination, 'popup', 'status=no,width='+width_measure+',height='+height_measure+',resizable=yes');
}

function closeMe(){
		opener.location.reload(true);
		self.close();
	}

function updateHidden(fieldName,content,value){
	if(value){
		document.getElementById(fieldName).value = content;
	}else{
		document.getElementById(fieldName).value = '';
	}
}


function set_styles(current, previous){
	//alert("flib");
	if(!current && !previous){
		current = 1;
		previous = 0;
	}
	var currentID = "pb"+current;
	var previousID = "pb"+previous;
	var current_linkID = "link"+current;
	var previous_linkID = "link"+previous;

	//alert("current: "+current+"\nprevious: "+previous+"\ncurrentID: "+currentID+"\npreviousID: "+previousID+"\ncurrent_linkID: "+current_linkID+"\nprevious_linkID: "+previous_linkID);

	//blocks of text...
	document.getElementById(currentID).style.display = "block";
	if(previous && previous != current){
		document.getElementById(previousID).style.display = "none";
	}

	//links...
	document.getElementById(current_linkID).style.textDecoration = "underline";
	if(previous){
		document.getElementById(previous_linkID).style.textDecoration = "none";
	}
	
	prev = current;

}

function show_all_parts(number_of_blocks){
	for(i=1;1<=number_of_blocks;i++){
		var currentID = "pb"+i;
		document.getElementById(currentID).style.display = "block";
	}
}

/////////////////////////////
//pd_admin functions
/////////////////////////////

function deleteCompanyRecord(comp_name,comp_hash){
	if(confirm("Are you sure you want to delete '"+comp_name+"' from the Provider Directory Database? This action cannot be undone.")){
		document.location = "./index.php?action=delete&comp_hash="+comp_hash;
	}
}


function shownews(){
	if(document.implementation && document.implementation.createDocument){
		// Mozilla

		var xsltProcessor = new XSLTProcessor();
		
		// load the xslt file
		var myXMLHTTPRequest = new XMLHttpRequest();
		myXMLHTTPRequest.open("GET", "http://www.thecro.com/crr.xsl", false);
		myXMLHTTPRequest.send(null);
		
		// get the XML document
		xslStylesheet = myXMLHTTPRequest.responseXML;
		xsltProcessor.importStylesheet(xslStylesheet);
		
		// load the xml file
		myXMLHTTPRequest = new XMLHttpRequest();
		myXMLHTTPRequest.open("GET", "http://www.corporateregister.com/feeds/CROMembers.xml", false);
		myXMLHTTPRequest.send(null);
		
		var xmlSource = myXMLHTTPRequest.responseXML;
		
		//transform
		 var resultDocument = xsltProcessor.transformToFragment(xmlSource, document);
		document.getElementById(xslfile).appendChild(resultDocument);
		
	}else if(window.ActiveXObject){
		// IE
		
		// Load XML
		xml = new ActiveXObject("MSXML2.DOMDocument");
		xml.async = false
		xml.load("http://www.corporateregister.com/feeds/CROMembers.xml")
		
		// Load XSL
		xsl = new ActiveXObject("MSXML2.DOMDocument");
		xsl.async = false
		xsl.load("http://www.thecro.com/crr.xsl")
		
	
		// Transform
		document.getElementById(xslfile).innerHTML=xml.transformNode(xsl);
		
		
		
	}else{
		// Browser unknown
		alert("Browser unknown");
	}

}
