// JavaScript Document
function clearText(target, text)
{
	document.getElementById(target).style.color = '#000';
	document.getElementById(target).style.fontStyle = 'normal';
	var x = document.getElementById(target).value;
	if( x == text)
	{
		document.getElementById(target).value = '';
	}
}
function checkValues(id, id2, target)
{
	var str1 = document.getElementById(id).value;
	var str2 = document.getElementById(id2).value;
	if( str1 == str2)
	{
		document.getElementById(target).innerHTML = '<p class="description">&nbsp;</p>';
	} else {
		document.getElementById(target).innerHTML = '<p class="description">De indtastede kodeord er ikke ens</p>';
	}
}
function clearTextarea(target, text)
{
	document.getElementById(target).style.color = '#000';
	document.getElementById(target).style.fontStyle = 'normal';
	var x = document.getElementById(target).innerHTML;
	if( x == text)
	{
		document.getElementById(target).innerHTML = '';
	}
}
function toggleID(id)
{
	status = document.getElementById(id).style.display;
	if( status == 'none')
	{
		document.getElementById(id).style.display = 'block';
	} else
	{
		document.getElementById(id).style.display = 'none';
	}
}
function hideID(id)
{
	document.getElementById(id).style.display = 'none';
}

var xmlHttp

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 sendJot()
{
		var jotnote = document.getElementById('jotnote').value;
	alert(jotnote);
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  } 
		xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
			xhtml = '<p>'+xmlHttp.responseText+'</p>';
		  	document.getElementById('my_jots').innerHTML = xhtml;
		  }
		}
		
		xmlHttp.open("GET","/inc/applets/googlerank/jotter.php?action=update&note="+encodeURIComponent(jotnote),true);
		xmlHttp.send(null);
		document.getElementById('jotnote').innerHTML = '';
}
function addComment(id)
{
		var comment = document.getElementById('comment').value;
		var headline = document.getElementById('headline').value;
		var username = document.getElementById('username').value;
		var email = document.getElementById('email').value;
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  } 
		xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
		  	document.getElementById('commentbox').innerHTML = xmlHttp.responseText;
			showComments(id);
			//alert(url);
		  }
		}
		var url="/inc/applets/comments/comments.php";
		url=url+"?action=put";
		url=url+"&username="+ encodeURIComponent(username);
		url=url+"&headline="+ encodeURIComponent(headline);
		url=url+"&comment="+ encodeURIComponent(comment);
		url=url+"&email="+ encodeURIComponent(email);
		url=url+"&id="+id;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}
function showComments(id)
{
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  } 
		xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		  {
		  	document.getElementById('comments').innerHTML = xmlHttp.responseText;
		  }
		}
		xmlHttp.open("GET","/inc/applets/comments/comments.php?action=get&id="+id,true);
		xmlHttp.send(null);
}

var runOnLoad = new Array();
window.onload = function() {
	for(var i = 0; i < runOnLoad.length; i++) runOnLoad[i]() 
}
if(document.getElementsByTagName)
for(var i in a = document.getElementsByTagName('a')) {
	a[i].onmousedown = function() { 
		this.blur();                 // most browsers 
		this.hideFocus = true;       // internet explorer
		this.style.outline = 'none'; // mozilla
	}   
	a[i].onmouseout = a[i].onmouseup = function() { 
		this.blur();                 // most browsers 
		this.hideFocus = false;      // internet explorer    
		this.style.outline = null;   // mozilla 
	}
}

