// 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 GoHit(url)
{ 
createXMLHttpRequest();
xmlHttp.open("GET",url,true); 
xmlHttp.send(null);
} 



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 showElementById(id)
{
	document.getElementById(id).style.display="";
}

function hideElementById(id)
{
	document.getElementById(id).style.display="none";
}

/****comment.php*****/
function ltrim(s){
    return s.replace( /^\s*/,"");
}

function rtrim(s){
    return s.replace( /\s*$/,"");
}

function trim(s){
    return ltrim(rtrim(s));
}

function check_comment()
{	   
   //var Value = document.form1.title.options[document.form1.title.selectedIndex].text;  
   if (trim(document.form1.comments.value)=='')
   {
	   alert ('Required:Your Comments');
	   document.form1.comments.focus();
	   return false;	     
   }
   if (document.form1.code_y.value!=document.form1.code.value)
   {
        alert ('Please input your valid Anti-SPAM protection number.');
		document.form1.code_y.focus();
		return false;
   }
	  
}

function check_upload()
{
   if (trim(document.getElementById('album_name').value)=="")
   {
 	   alert ('Required:Album Name');
	   document.getElementById('album_name').focus();
	   return false;	          
   }
   
   if (trim(document.getElementById('tag').value)=="" || trim(document.getElementById('tag').value)=="tag1,tag2" || trim(document.getElementById('tag').value)==","|| trim(document.getElementById('tag').value)=="tag1," || trim(document.getElementById('tag').value)=="tag1" || trim(document.getElementById('tag').value)==",tag2" || trim(document.getElementById('tag').value)=="tag2")
   {
 	   alert ('Required:Your Album Tag');
	   document.getElementById('tag').focus();
	   return false;	          
   }   
}