// JavaScript Document
var xmlHttp;
function createXMLHttpRequest() 
{ 
if(window.XMLHttpRequest) 
{ 
xmlHttp=new XMLHttpRequest();
}
else if(window.ActiveXObject) 
{ 
try
{ 
xmlHttp=new ActiveX0bject("Msxml2.XMLHTTP");
} 
catch(e) 
{} 
try
{ 
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{} 
if(!xmlHttp) 
{ 
window.alert("Can't create XMLHttpRequest"); 
return false; 
} 
} 
}
function startRequest(ID) 
{ 
createXMLHttpRequest();
xmlHttp.open("GET","show_album_info.php?id="+ID,true); 
xmlHttp.onreadystatechange=function() 
{ 
if(xmlHttp.readyState==4) 
{
if(xmlHttp.status==200) 
{   
  document.getElementById('album-info').innerHTML = xmlHttp.responseText; 
} 
} 
} 
xmlHttp.send(null); 
//startRequest2();
} 

function PostReview(album_ID,content,is_reply,reply_ID,UserID)
{ 
createXMLHttpRequest();
contentstr = "album_ID="+album_ID+"&content="+content+"&is_reply="+is_reply+"&reply_ID="+reply_ID+"&UserID="+UserID;
xmlHttp.open("POST","get_review.php",true); 
xmlHttp.setRequestHeader("Content-Length", contentstr.length);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(contentstr);
} 

function showElementById(id)
{
	document.getElementById(id).style.display="";
}

function Get_next_item()
{
   var Value = document.formatitem.format1.options[document.formatitem.format1.selectedIndex].text; 
   startRequest('/format-search/search.php?format1='+Value);
}

function Get_url()
{
   var Value = document.formatitem.format1.options[document.formatitem.format1.selectedIndex].text; 
   var Value2 = document.formatitem.format2.options[document.formatitem.format2.selectedIndex].text; 
   startRequest('/format-search/search.php?format1='+Value+'&format2='+Value2);
}

function ToPage()
{
   	var url = document.getElementById('url').value;
	var ID = document.getElementById('id').value;
	GoHit('/format-search/hit.php?id='+ID);	
	setTimeout("window.location.href = '"+url+"'",1000);
	return false;
}

function UrlEncode(str) 
{ 
return transform(str); 
} 
    
function transform(s) 
{ 
var hex=''    
var i,j,t 
    
j=0 
for (i=0; i<s.length; i++) 
{ 
t = hexfromdec( s.charCodeAt(i) ); 
if (t=='25') 
{ 
t=''; 
} 
hex += '%' + t; 
} 
return hex; 
} 
    
function hexfromdec(num) { 
if (num > 65535) { return ("err!") } 
first = Math.round(num/4096 - .5); 
temp1 = num - first * 4096; 
second = Math.round(temp1/256 -.5); 
temp2 = temp1 - second * 256; 
third = Math.round(temp2/16 - .5); 
fourth = temp2 - third * 16; 
return (""+getletter(third)+getletter(fourth)); 
} 
    
function getletter(num) { 
if (num < 10) { 
return num; 
} 
else { 
if (num == 10) { return "A" } 
if (num == 11) { return "B" } 
if (num == 12) { return "C" } 
if (num == 13) { return "D" } 
if (num == 14) { return "E" } 
if (num == 15) { return "F" } 
} 
} 

function show_reply(showid,total)
{
   for (i=0;i<total;i++)
   {
	  if (i == showid) 
	  {
	     document.getElementById('reply'+showid).style.display='';
	  }
	  else
	  {
	     document.getElementById('reply'+i).style.display='none';
	  }
   }
   document.getElementById('page').style.display='none';
}
