var xmlhttp = false;		// we will use this boolean to check for the presence of Internet Explorer
var usingIE = true;			// true if using some version of Internet Explorer, false if using a non-IE browser such as Firefox or Netscape

/**************** BEGIN AJAX INIT ********************/
// check if we are using IE
try
{
	// if the JavaScript version is greater than 5
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
	// if not, then try to use the older ActiveX object
	try
	{
		// if we are using IE
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(E)
	{
		// else we must be using a non-IE browser, like Firefox or Netscape
		xmlhttp = false;
		usingIE = false;
	}
}

// if we are using a non-IE browser, create a JavaScript instance of the object
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
	xmlhttp = new XMLHttpRequest();
}
/**************** END AJAX INIT ********************/

// request serverPage from the server and load the results into objID
function makeRequest (serverPage, objID)
{
	var obj = document.getElementById(objID);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

// show or hide the news item
var showTheNews1 = true;	// a variable used to distinguish whether to open or close the news item
var showTheNews2 = true;	// a variable used to distinguish whether to open or close the news item
var showTheNews3 = true;	// a variable used to distinguish whether to open or close the news item
var showTheNews4 = true;	// a variable used to distinguish whether to open or close the news item
var showMoreLess = true;		// expand the news box or not?
function showHideNews (the_news)
{
	var objID;

	// the location we are loading the news into
	if (the_news == 1) objID = "news1";
	if (the_news == 2) objID = "news2";
	if (the_news == 3) objID = "news3";
	if (the_news == 4) objID = "news4";
	
	// change the current image of the plus or minus
	if (the_news == 1)
	{
		if (showTheNews1 == true)
		{
			document.getElementById("opencloseimg1").src = "images/minus.gif";	
			showTheNews1 = false;
			
			document.getElementById(objID).innerHTML = '<a href="javascript:showHideNews(1)" class="newstext"><img id="opencloseimg1" src="images/minus.gif" alt="" title="" style="border:none; width:9px; height:9px;" /> </a><a href="javascript:showHideNews(1)" class="newstext">July 7, 2007: Private Pix 3.1 released!</a> loading, please wait...';
			makeRequest("news/news.php?thenews=1", objID);
		}
		else
		{
			document.getElementById("opencloseimg1").src = "images/plus.gif";	
			showTheNews1 = true;
			
			document.getElementById(objID).innerHTML = '<a href="javascript:showHideNews(1)" class="newstext"><img id="opencloseimg1" src="images/plus.gif" alt="" title="" style="border:none; width:9px; height:9px;" /> </a><a href="javascript:showHideNews(1)" class="newstext">July 7, 2007: Private Pix 3.1 released!</a>';
		}
	}

	if (the_news == 2)
	{	
		if (showTheNews2 == true)
		{
			document.getElementById("opencloseimg2").src = "images/minus.gif";	
			showTheNews2 = false;
			
			document.getElementById(objID).innerHTML = '<a href="javascript:showHideNews(2)" class="newstext"><img id="opencloseimg2" src="images/minus.gif" alt="" title="" style="border:none; width:9px; height:9px;" /> </a><a href="javascript:showHideNews(2)" class="newstext">July 11, 2007: Windows Vista concerns</a> loading, please wait...';
			makeRequest("news/news.php?thenews=2", objID);
		}
		else
		{
			document.getElementById("opencloseimg2").src = "images/plus.gif";	
			showTheNews2 = true;
			
			document.getElementById(objID).innerHTML = '<a href="javascript:showHideNews(2)" class="newstext"><img id="opencloseimg2" src="images/plus.gif" alt="" title="" style="border:none; width:9px; height:9px;" /> </a><a href="javascript:showHideNews(2)" class="newstext">July 11, 2007: Windows Vista concerns</a>';
		}
	}
	
	if (the_news == 3)
	{	
		if (showTheNews3 == true)
		{
			document.getElementById("opencloseimg3").src = "images/minus.gif";	
			showTheNews3 = false;
			
			document.getElementById(objID).innerHTML = '<a href="javascript:showHideNews(3)" class="newstext"><img id="opencloseimg3" src="images/minus.gif" alt="" title="" style="border:none; width:9px; height:9px;" /> </a><a href="javascript:showHideNews(3)" class="newstext">July 21, 2007: Private Encryptor 6.4 released!</a> loading, please wait...';
			makeRequest("news/news.php?thenews=3", objID);
		}
		else
		{
			document.getElementById("opencloseimg3").src = "images/plus.gif";	
			showTheNews3 = true;
			
			document.getElementById(objID).innerHTML = '<a href="javascript:showHideNews(3)" class="newstext"><img id="opencloseimg3" src="images/plus.gif" alt="" title="" style="border:none; width:9px; height:9px;" /> </a><a href="javascript:showHideNews(3)" class="newstext">July 21, 2007: Private Encryptor 6.4 released!</a>';
		}
	}
	
	if (the_news == 4)
	{	
		if (showTheNews4 == true)
		{
			document.getElementById("opencloseimg4").src = "images/minus.gif";	
			showTheNews4 = false;
			
			document.getElementById(objID).innerHTML = '<a href="javascript:showHideNews(4)" class="newstext"><img id="opencloseimg4" src="images/minus.gif" alt="" title="" style="border:none; width:9px; height:9px;" /> </a><a href="javascript:showHideNews(4)" class="newstext">Nov. 1, 2007: Private Encryptor 7.0 released!</a> loading, please wait...';
			makeRequest("news/news.php?thenews=4", objID);
		}
		else
		{
			document.getElementById("opencloseimg4").src = "images/plus.gif";	
			showTheNews4 = true;
			
			document.getElementById(objID).innerHTML = '<a href="javascript:showHideNews(4)" class="newstext"><img id="opencloseimg4" src="images/plus.gif" alt="" title="" style="border:none; width:9px; height:9px;" /> </a><a href="javascript:showHideNews(4)" class="newstext">Nov. 1, 2007: Private Encryptor 7.0 released!</a>';
		}
	}
}

function showMore ()
{
	var objID = "more";			// the location we are loading the news into
	var linkID = "more_link";
	
	// expand or contract the news box
	if (showMoreLess == true)
	{
		//document.getElementById("opencloseimg1").src = "images/minus.gif";	
		showMoreLess = false;
		
		document.getElementById(objID).innerHTML = 'loading, please wait...';
		document.getElementById(linkID).innerHTML = '<img border="0" src="images/less.gif" width="12" height="12"> less news';
		makeRequest("news/news.php?thenews=0", objID);
	}
	else
	{
		//document.getElementById("opencloseimg1").src = "images/plus.gif";	
		showMoreLess = true;
		showTheNews1 = true;
		showTheNews2 = true;
		showTheNews3 = true;
		
		document.getElementById(objID).innerHTML = '';
		document.getElementById(linkID).innerHTML = '<img border="0" src="images/more.gif" width="12" height="12"> more news';
	}
}


