var xmlHttp;

var topic_id;

var item_id;



function favorite_click(topicid)

{

	var answer = confirm("Would you like to add this topic to your favorites?")

	if (answer){

		xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request");

			return;

		}

		var url="addfav.php";

		url=url+"?topicid="+topicid;

		xmlHttp.onreadystatechange=addFavorite;

		xmlHttp.open("GET",url,true);

		xmlHttp.send(null);

	}

	else{



	}

}



function addFavorite()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

 	alert(xmlHttp.responseText);

 } 

}



function flag_click(topicid)

{

	var answer = confirm("Would you like to flag this topic as inappropriate?")

	if (answer){

		xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request");

			return;

		}

		var url="addflag.php";

		url=url+"?topicid="+topicid;

		xmlHttp.onreadystatechange=addFlag;

		xmlHttp.open("GET",url,true);

		xmlHttp.send(null);

	}

	else{



	}

}



function addFlag()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

 	alert(xmlHttp.responseText);

 } 

}



function nsfw_click(topicid)

{

	var answer = confirm("Would you like to label this topic as NSFW?")

	if (answer){

		xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request");

			return;

		}

		var url="addnsfw.php";

		url=url+"?topicid="+topicid;

		xmlHttp.onreadystatechange=addNsfw;

		xmlHttp.open("GET",url,true);

		xmlHttp.send(null);

	}

	else{



	}

}



function addNsfw()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

 	alert(xmlHttp.responseText);

 } 

}



function deleteItem(id)

{



if (confirm("Are you sure you want to delete this item?"))

{

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)

 {

 alert ("Browser does not support HTTP Request");

 return;

 }

var url="deleteitem.php";

url=url+"?id="+id;

xmlHttp.onreadystatechange=itemDeleted;

xmlHttp.open("GET",url,true);

xmlHttp.send(null);

}



}



function itemDeleted()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

 	location.href=location.href;

 } 

}



function deleteTopic(id)

{



if (confirm("Are you sure you want to delete this topic?"))

{

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)

 {

 alert ("Browser does not support HTTP Request");

 return;

 }

var url="delete.php";

url=url+"?id="+id;

xmlHttp.onreadystatechange=topicDeleted;

xmlHttp.open("GET",url,true);

xmlHttp.send(null);

}



}



function topicDeleted()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

 	location.href=location.href;

 } 

}



function voteTopic(id,user,val)

{ 

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)

 {

 alert ("Browser does not support HTTP Request");

 return;

 }

var url="vote.php";

url=url+"?id="+id;

url=url+"&user="+user;

url=url+"&val="+val;

topic_id=id;

xmlHttp.onreadystatechange=stateChanged;

xmlHttp.open("GET",url,true);

xmlHttp.send(null);

}



function stateChanged() 

{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

 document.getElementById("numvotes_"+topic_id).innerHTML=xmlHttp.responseText;

 } 

}



function voteItem(id,user,val)

{ 

xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)

 {

 alert ("Browser does not support HTTP Request");

 return;

 }

var url="voteitem.php";

url=url+"?id="+id;

url=url+"&user="+user;

url=url+"&val="+val;

item_id=id;

xmlHttp.onreadystatechange=stateChangedItem;

xmlHttp.open("GET",url,true);

xmlHttp.send(null);

}



function stateChangedItem() 

{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

 { 

 document.getElementById("itemvotes_"+item_id).innerHTML=xmlHttp.responseText;

 } 

}function GetXmlHttpObject()

{

var xmlHttp=null;

try

 {

 // Firefox, Opera 8.0+, Safari

 xmlHttp=new XMLHttpRequest();

 }

catch (e)

 {

 //Internet Explorer

 try

  {

  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

  }

 catch (e)

  {

  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

 }

return xmlHttp;

}



function showPicture(pic, caption)

{

	picImg2 = document.getElementById('picImg');

	picImg2.src = pic;
	
	picCaption2 = document.getElementById('picCaption');

	picCaption2.innerHTML = caption;



      document.getElementById('picDivUnder').style.visibility = 'visible';

      document.getElementById('picDiv').style.visibility = 'visible';

      document.getElementById('picDivUnder').style.display = 'block';

      document.getElementById('picDiv').style.display = 'block';
	  

}


function showEmailSuccess()

{
      document.getElementById('notificationDivUnder').style.visibility = 'visible';

      document.getElementById('notificationDiv').style.visibility = 'visible';

      document.getElementById('notificationDivUnder').style.display = 'block';

      document.getElementById('notificationDiv').style.display = 'block';
	  

}


function killNotification()

{
      document.getElementById('notificationDivUnder').style.visibility = 'hidden';

      document.getElementById('notificationDiv').style.visibility = 'hidden';

      document.getElementById('notificationDivUnder').style.display = 'none';

      document.getElementById('notificationDiv').style.display = 'none';

}


function killPic()

{
	picImg2 = document.getElementById('picImg');

	picImg2.src = '';

      document.getElementById('picDivUnder').style.visibility = 'hidden';

      document.getElementById('picDiv').style.visibility = 'hidden';

      document.getElementById('picDivUnder').style.display = 'none';

      document.getElementById('picDiv').style.display = 'none';

}