var xmlhttp;
var pBody;
pBody = document.all[0].innerHTML;
var newdiv = document.createElement('div');
var div;

function close()
{
	 //obj.style.display = 'normal';
 	var alpha = 10; //Set the initial value of alpha to 10 (Opaque)
	function f(){ //Internal function

 	 alpha--; //Decrement the alpha value
	 newdiv.style.opacity = alpha/10; //Set the opacity of our element to the specified alpha
	
	  if(alpha > -1){ //If alpha is still bigger than -1 then..
 	  setTimeout(f, 0.01); //..then call the function again after 100 milliseconds
 	 }
 	 
 	 if(alpha == 0)
	{
		document.body.removeChild(document.getElementById("box"));
	}
 	 
	}
	
	setTimeout(f, 5); //This is where we call the f() function for the first time

}


function fade(){
	newdiv.style.opacity = 0;
	document.body.appendChild(newdiv);
 	
 
 
	 //obj.style.display = 'normal';
 	var alpha = 0; //Set the initial value of alpha to 10 (Opaque)
	function f(){ //Internal function

 	 alpha++; //Decrement the alpha value
	 newdiv.style.opacity = alpha/10; //Set the opacity of our element to the specified alpha

	  if(alpha < 10){ //If alpha is still bigger than -1 then..
 	  setTimeout(f, 0.2); //..then call the function again after 100 milliseconds
 	 }
	}
	
	setTimeout(f, 5); //This is where we call the f() function for the first time
}

function base58(str)
{
 
 newdiv.setAttribute('id', 'box');
 newdiv.innerHTML = "<div id=\"box\" style=\"background: url(/black.png) repeat; text-align:center; width: 100%; height:100%; margin:0px; padding:0px; top:0px; left:0px; position:absolute; \"><div style=\"text-align:center; -webkit-box-shadow: 0px 1px 3px #111;-moz-box-shadow: 0px 1px 3px #111; font-family: 'Lucida Grande'; font-size: 14pt; margin:0px auto; margin-top: 120px; background:#fff; -webkit-border-radius:10px; padding: 20px; width:32px;\"><a href=\"javascript:close();\"><img style=\"position:absolute; margin-left:-35px; margin-top:-30px;\" src=\"/x.png\" /></a><center><img src=\"loading.gif\" /></center> </div></div>";
 
 fade();
  
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="/base58.php";
url=url+"?s="+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
	
	if (xmlhttp.readyState==4)
	{
		if(xmlhttp.responseText != '1')
		{
		  		newdiv.innerHTML = "<div id=\"box\" style=\"background: url(/black.png) repeat; text-align:center; width: 100%; height:100%; margin:0px; padding:0px; top:0px; left:0px; position:absolute; \"><div style=\"text-align:center; line-height:30px; -webkit-box-shadow: 0px 1px 3px #111;-moz-box-shadow: 0px 1px 3px #111; font-family: 'Lucida Grande'; font-size: 14pt; margin:0px auto; margin-top: 120px; background:#fff; -webkit-border-radius:10px; padding: 20px; width:350px;\"><a href=\"javascript:close();\"><img style=\"position:absolute; margin-left:-35px; margin-top:-30px;\" src=\"/x.png\" /></a><span style=\"color:green;\">Your short flic.kr url is ready!</span><br/><b>Visit you image here: <a href=\"http://www.flic.kr/"+xmlhttp.responseText+"\">www.flic.kr/p/"+xmlhttp.responseText+"</a></b></div></div>";
  		}
  		else
  		{	
  			newdiv.innerHTML = "<div id=\"box\" style=\"background: url(/black.png) repeat; text-align:center; width: 100%; height:100%; margin:0px; padding:0px; top:0px; left:0px; position:absolute; \"><div style=\"text-align:center; line-height:30px; -webkit-box-shadow: 0px 1px 3px #111;-moz-box-shadow: 0px 1px 3px #111; font-family: 'Lucida Grande'; font-size: 14pt; margin:0px auto; margin-top: 120px; background:#fff; -webkit-border-radius:10px; padding: 20px; width:550px;\"><a href=\"javascript:close();\"><img style=\"position:absolute; margin-left:-35px; margin-top:-30px;\" src=\"/x.png\" /></a><span style=\"color:red;\">There was an issue with the photo ID you provided.</span><br/><span style=\"font-size:10pt; line-height:12px;\">There is an example of a photo ID in a flick URL below.<br/>The photo ID is the bold intalic number in this example.</span><br/><a href=\"http://www.flickr.com/photos/tmdvs/4295516336/\">http://www.flickr.com/photos/tmdvs/<b><em>4295516336</em></b>/</a></div></div>";

  		}
	}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}