function showpics(num,name){	
  displaypic('upload.php?gp=1&name='+name+'&num='+num, 'result');
}
var iloadnow = 0;
function iloading(){
	iloadnow ++;
	if(iloadnow > 3)
		iloadnow = 0;
	//var icon = new Array('\\','-','/','|');
	var icon = new Array('.','..','...','....');
	document.getElementById('iload').innerHTML = icon[iloadnow];
	setTimeout('iloading();',160);
}

function upload(){					
	document.getElementById('player_mc').uploadpics();	
}
function loading(){
  document.getElementById('loading').innerHTML = 'RockMe.Ws - Uploading..<span id="iload"></span>';
  iloading();
}
function responseStatus(msg){
   document.getElementById('loading').innerHTML = msg;
   if(msg == 'Done!')
   	document.getElementById('getcode').style.display = 'block';
}
function clearlist(){
   document.getElementById('result').innerHTML = "";
}
function showcode(type){
	var code = new Array();
	if(type == 'html'){
		
		code[0] = '&lt;img src="';
		code[1]	= '"&gt;';
	}else{
		code[0] = '[IMG]';
		code[1]	= '[/IMG]';
	}	
	
	content = document.getElementById('result').innerHTML;
	ex = content.split('</div>');
	var html = '';
	for(i in ex){
			html += code[0] + ex[i].replace('<div>','') + code[1] + "\n";	
	}
	html = html.replace(code[0]+code[1],'');
	document.getElementById('showcode').innerHTML = html;
}
function transfer(){
	clearlist();
	listUrl = document.getElementById('listurl').value;
	ex = listUrl.split("\n");
	for(i in ex){
		transferUrl(ex[i],'result',i,ex.length);	
	}
	
}
function transferUrl(url,id,num,count){
	loading();
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return;
	}
	xmlHttp.onreadystatechange=function(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		if(xmlHttp.responseText) exist = 1;
			if(id){
				var up = document.getElementById(id);
				var dv = document.createElement("div");
				dv.innerHTML = xmlHttp.responseText;
				up.appendChild(dv);
				if(num==count-1)
					responseStatus("Done!");
			}
		}
	}
	url = 'url='+encodeURI(url)+'&sid='+ Math.random();
	xmlHttp.open('POST', 'upload.php', true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", url.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(url);
}
function displaypic(url, id){
   var xmlHttp = GetXmlHttpObject();
  if (xmlHttp==null){
    alert ("Browser does not support HTTP Request")
    return;
  }
  
  xmlHttp.onreadystatechange=function(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    	if(xmlHttp.responseText) exist = 1;
    	if(id){
			var up = document.getElementById(id);
			var dv = document.createElement("div");
			dv.innerHTML = xmlHttp.responseText;
			up.appendChild(dv);
    	}
    }
  }
  url = decodeURIComponent(url);
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}


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;
}