var serv = new Service();
var serv_2 = new Service();
var loading_h=0;
var current_dir=0;
var selected_dir=0;
var selected_mpanel=0;
var selected_cost = 0;
var current_order_id = 0;

// EXAMPLE: send post and get result
function testobj(){
	serv.send('handlers.php?h=test','a=2',htest);
}

function htest(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			alert(serv.getXhtmlText());
		}
	}
	
}

function setLang(lang){
	serv.send('/handlers.php?h=setlang','lang='+lang,handleReloadPage);
}

function userLogin(){
	ul = document.getElementById('wlogin').value;
	up = document.getElementById('wpass').value;
	ur = document.getElementById('remember').checked?1:0;
	serv.send('/handlers.php?h=login','login='+ul+'&pass='+up+'&remember='+ur,handleReloadPage);
}

function userLogout(){
	serv.send('/handlers.php?h=logout','',handleReloadPage);
}

function handleReloadPage(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			document.getElementById('reloadpage').submit();
		}
	}
}

function loading(id){
	h = document.getElementById(id).parentNode.offsetHeight;
	r=document.getElementById('loading');
	if(id=='filelist'){
		if(!loading_h){
			loading_h = Math.round(h/2);
		}
		document.getElementById(id).style.height = loading_h+'px';
	}
	//r.style.height = h+'px';

	document.getElementById(id).innerHTML=r.innerHTML;

}

function deleteFile(fid){
	loading('filelist');
	loading('pagelist');
	serv.send('handlers.php?h=deletefile','fid='+fid,handleViewPage);
}

function lockFile(fid){
	loading('filelist');
	loading('pagelist');
	serv.send('handlers.php?h=lockfile','fid='+fid,handleViewPage);
}

function unlockFile(fid){
	loading('filelist');
	loading('pagelist');
	serv.send('handlers.php?h=unlockfile','fid='+fid,handleViewPage);
}


function viewPage(sval){
	loading('filelist');
	loading('pagelist');
	serv.send('handlers.php?h=viewpage','sp='+sval,handleViewPage);
}

function setSort(column){
	loading('filelist');
	loading('pagelist');
	serv.send('handlers.php?h=sortfilelist','column='+column,handleViewPage);
}

function perPage(pp){
	loading('filelist');
	loading('pagelist');
	serv.send('handlers.php?h=perpage','pp='+pp,handleReloadPage);
}

function handleViewPage(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			document.getElementById('filelist').innerHTML = serv.getXhtmlText();
			updatePageList();
		}
	}
}

function updatePageList(){
	serv_2.send('handlers.php?h=updatepagelist','',handleUpdatePageList);	
}

function handleUpdatePageList(){
	if(serv_2.getState() == 4){
		if(serv_2.getStatus() == 200){
			document.getElementById('pagelist').innerHTML = serv_2.getXhtmlText();
		}
	}
}

function handleNull(){
	
}

function showLogin(stat){
	document.getElementById('login_form').style.display = (stat?'':'none');	
}

function advLoad(){
	
	r = document.getElementById('right_adv');
    l = document.getElementById('left_adv');
    t = document.getElementById('top_adv');
    b = document.getElementById('bottom_adv');
    u = document.getElementById('under_news_adv');
	c = document.getElementById('center_adv');
    
	
	
                if(document.getElementById('adv_right')){                      
                        document.getElementById('adv_right').appendChild(r);
                        $('#right_adv').slideDown('slow');
                }

                if(document.getElementById('adv_left')){                        
                        document.getElementById('adv_left').appendChild(l);
                        $('#left_adv').slideDown('slow');
                }

                if(document.getElementById('adv_top')){                      
                        document.getElementById('adv_top').appendChild(t);
                        $('#top_adv').slideDown('slow');
                }

                if(document.getElementById('adv_bottom')){                       
                        document.getElementById('adv_bottom').appendChild(b);
                        $('#bottom_adv').slideDown('slow');
                }

                if(document.getElementById('adv_under_news')){
                        document.getElementById('adv_under_news').appendChild(u);
                        $('#under_news_adv').slideDown('slow');
                }
				
                if(document.getElementById('adv_center')){
                        document.getElementById('adv_center').appendChild(c);
                        $('#center_adv').slideDown('slow');
                }
				if(document.getElementById('download_area')){
					waitLast(30);
					setTimeout("download_area()",30000);
				}
}

function waitLast(sec){
	if(sec>0){
		document.getElementById('waits').value = sec;
		setTimeout('waitLast('+(sec-1)+')',1000);
	}
}

function advLoadGde(){
	/*
	g = document.getElementById('gde_adv');
	if(document.getElementById('adv_gde')){                       
        //document.getElementById('adv_gde').appendChild(g);
		//$('#gde_adv').slideDown('slow');
    }
	*/
}

function download_area(hash){
	if(document.getElementById('download_area')){
		load_adv_ajax(hash,'waiter');
		document.getElementById('waiting').style.display='none';
		$('#download_area').slideDown('slow');
        load_download_area();
		$('#download_adv_area').slideDown('slow');
		$('#download_adv_area2').slideDown('slow');
				
	}
}

function hover(el,chover){
	el.className = chover;
}

function fileGetLink(fid){
	document.getElementById('uniqlink').value = document.getElementById('download_'+fid).value;
}

function godownload(code){
	if(document.getElementById('captcha')){
		codes = document.getElementById('captcha').value;
	}else{
		codes ='0';
	}
	serv.send('/handlers.php?h=godownl','hash='+code+'&captcha='+codes,handleReloadPage);
}

function startUpload(){
	if(document.getElementById('myfile').value!=""){
	document.getElementById('f_status').style.display = 'inline';
	document.getElementById('f_upload').style.display = 'none';
	document.getElementById('f_button').style.display = 'none';
	if(document.getElementById('ftp_acc')){
		document.getElementById('ftp_acc').style.display = 'none';
		document.getElementById('ftp_head').style.display = 'none';
	}
	
	
	if(document.getElementById('upl_head')){
		document.getElementById('upl_head').style.display = 'none';
	}
	
	
	code = document.getElementById('tmp_prefix').value;
	serv.send('handlers.php?h=start_upload','code='+code,handleStartUpload);
	return true;
	}else{
	return false;
	}
}

function handleStartUpload(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			processing();
		}
	}
}

function processing(){
	serv.send('/handlers.php?h=process','',handleProcessing);
}

function handleProcessing(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			var xdoc = serv.getXhtmlXML();
			
			var selectNodes = xdoc.getElementsByTagName('info')[0];
			
			var process 	= selectNodes.getElementsByTagName('fsize')[0].childNodes[0].nodeValue;
			var status 		= selectNodes.getElementsByTagName('status')[0].childNodes[0].nodeValue;
			var url 		= selectNodes.getElementsByTagName('url')[0].childNodes[0].nodeValue;
			var perc 		= selectNodes.getElementsByTagName('percent')[0].childNodes[0].nodeValue;
			var speed 		= selectNodes.getElementsByTagName('speed')[0].childNodes[0].nodeValue;
			var fsize 		= selectNodes.getElementsByTagName('filesize')[0].childNodes[0].nodeValue;
			var active 		= selectNodes.getElementsByTagName('active')[0].childNodes[0].nodeValue;
			
			
			if(url!='###'){
				window.location = url;
			}else{
				document.getElementById('f_process').innerHTML = process;
				document.getElementById('f_percent').innerHTML = perc+'%';
				document.getElementById('f_speed').innerHTML = speed;
				document.getElementById('f_maxsize').innerHTML = fsize;
				
				
				//
				//document.getElementById('progressbar').style.width = perc*3+'px';
				var prbar = '';
				for(i=0;i<20;i++){
					if(i<active){
						if (i%2==0)	prbar += '<div class="upload_1"></div>';
						else prbar += '<div class="upload_2"></div>';
					}else{
						prbar += '';
					}
				}
				document.getElementById('progressbar').innerHTML = prbar;
				setTimeout("processing()",500);
			}
		}
	}
}

function terminateUpload(){
	serv_2.send('handlers.php?h=terminate_upload','',handleNull);
}

function stopUpload(url){
	serv.send('/handlers.php?h=stop_upload','url='+url,handleNull);
}

function lockButton(obj,status){

}

function startFarUpload(){
	var link = document.getElementById('far_url').value;
	if(link!=''){
		document.getElementById('far_start_btn').disabled = true;
		//document.getElementById('farlink').style.display = 'none';
		//document.getElementById('farproccess').style.display = 'inline';
		//document.getElementById('farlink').style.display = 'none';
		//document.getElementById('faruplbtn').style.display = 'none';
		serv.send('handlers.php?h=run_far','link='+link,handleStartFarUpload);//handleStartFarUpload
	}
}

function startFarUpload2(){
	var link = document.getElementById('far_url').value;
	var fname = document.getElementById('far_name').value;
	if(link!=''){
		document.getElementById('farlink').style.display = 'none';
		document.getElementById('farproccess').style.display = 'inline';
		document.getElementById('farlink').style.display = 'none';
		document.getElementById('faruplbtn').style.display = 'none';
		serv.send('handlers.php?h=run_far','link='+link+'&fname='+fname,handleStartFarUpload);
	}
	/*
	var link = '';
	var fname = '';
	if(document.getElementById('myfile_f')){
		link=document.getElementById('myfile_f').value;
	}
	
	if(document.getElementById('myfile_name')){
		fname=document.getElementById('myfile_name').value;
	}
	if(trim(link)!='' && trim(fname)!=''){
		document.getElementById('f1_upload_form_far').style.display = 'none';
		document.getElementById('upload_btn_far').style.display = 'none';
		document.getElementById('f1_upload_process_far').style.display = 'block';
		serv.send('uploadbylink.php','link='+link+'&fname='+fname,handleStartFarUpload);
	}else{
		alert(msg);
	}
	*/
}

function handleStartFarUpload(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			setTimeout("far_processing()",4000);//handleReloadPage()
		}
	}
}

function far_processing(){
	serv.send('handlers.php?h=process_far','',handleFarProcessing);
}

function handleFarProcessing(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			
			if(serv.getXhtmlText()!=-1){
				document.getElementById('farlink').style.display = 'none';
				//document.getElementById('faruplbtn').style.display = 'none';
				document.getElementById('farproccess').style.display = 'inline';
				document.getElementById('progressbarfar').style.display = 'inline';
				document.getElementById('progressbarfar').innerHTML = serv.getXhtmlText();
				setTimeout("far_processing()",1000);
			}else{
				document.getElementById('farlink').style.display = 'block';
				//document.getElementById('faruplbtn').style.display = 'inline';
				document.getElementById('progressbarfar').style.display = 'none';
				document.getElementById('farproccess').style.display = 'none';
				document.getElementById('far_start_btn').disabled = false;
			}
			
			
		}
	}
}

function showAbouts(show){
	if(document.getElementById('about_vip').style.display=='none'){
		document.getElementById('about_vi').style.backgroundPosition="0px -143px";
		$('#about_vip').show('slow');
	}else{
		document.getElementById('about_vi').style.backgroundPosition="-9px -143px";
		$('#about_vip').hide('slow');
	}
}

function moveFiles(){
	document.getElementById('movefileftp').disabled=true;
	serv.send('handlers.php?h=move_ftp','',handleReloadPage);//handleReloadPage
}

function moveFiles2(){
    document.getElementById('movefileftp2').disabled=true;
    serv.send('handlers.php?h=move_ftp2','',handleReloadPage);//handleReloadPage
}

function handleAlert(){
    if(serv.getState() == 4){
        if(serv.getStatus() == 200){
            alert(serv.getXhtmlText());
        }
    }
}

function getFtpAccount(){
	document.getElementById('getftp').enabled=false;
	serv.send('handlers.php?h=create_ftp','',handleReloadPage);
}

function iframedestroy(){
	if (window.top != window) {
		window.top.location = window.location;
	}
}

function sms_hideAll(classname)
{
	var allDivs = document.getElementsByTagName('div');
	for (var div in allDivs) {
		if (allDivs[div].className == classname) {
			allDivs[div].style.display = 'none';
		}
	}
}

function sms_showTip(current){
	sms_hideAll('infodiv');
	sms_hideAll('infodiv7');
	sms_hideAll('infodiv3');
	//current++;
	if(document.getElementById('op_'+current)) document.getElementById('op_'+current).style.display='block';
	if(document.getElementById('op7_'+current)) document.getElementById('op7_'+current).style.display='block';
	if(document.getElementById('op3_'+current)) document.getElementById('op3_'+current).style.display='block';
	
}

function sms_showTip2(current){
	sms_hideAll('infodiv2');
	if(document.getElementById('info_'+current)) document.getElementById('info_'+current).style.display='block';
}

function sms_checkcode(){
	if(document.getElementById('s_pair')){
		var code = document.getElementById('s_pair').value;
		serv.send('/handlers.php?h=checksmscode','code='+code,handleReloadPage); 
	}
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function setStatType(statistic_type){
 serv.send('/handlers.php?h=statistic','type='+statistic_type,handleReloadPage);
}
function setStatSort(sort){
 serv.send('/handlers.php?h=setstatsort','statsort='+sort,handleReloadPage);
}

function initTree(){
	$(document).ready(function(){
		$("#browser").treeview({
			toggle: function() {
				
			}
		});
	});
}

function selectedNode(id){
	var allDivs = document.getElementsByTagName('span');
	for (var div in allDivs) {
		if(allDivs[div])
		if (allDivs[div].className == 'txt_sel') {
			allDivs[div].style.backgroundColor = '#FFFFFF';
		}
	}
	current_dir = id;
	document.getElementById('txt_'+id).style.backgroundColor='#5AAF04';
	document.getElementById('dir_id').value=id;
	serv.send('handlers.php?h=changedir','dir='+id,handleViewPage);
	
}

function selectDir(id){
	selected_dir=id;
}

function moveFile(fid){
	serv.send('handlers.php?h=movefile','dir='+selected_dir+'&file_id='+fid,handleViewPage);
}

function addDirForm(){
	
	document.getElementById('add_h').style.display='block';
	document.getElementById('ren_h').style.display='none';
	document.getElementById('dir_name').value='';
	$('#move_file').hide('slow');
	$('#add_dir').slideDown('slow');
	document.getElementById('oper').value=0;
}

function renDirForm(){
	if(current_dir!=0){
	if(document.getElementById('txt_'+current_dir)){
		document.getElementById('add_h').style.display='none';
		document.getElementById('ren_h').style.display='block';
		document.getElementById('dir_name').value=document.getElementById('txt_'+current_dir).innerHTML;
		$('#move_file').hide('slow');
		$('#add_dir').slideDown('slow');
		document.getElementById('oper').value=1;
	}
	}
}

function moveFileForm(){
	cancelForm('add_dir');
}



function addDir(){
	if(trim(document.getElementById('dir_name').value)!='')
	if(document.getElementById('oper').value==0){
		//new
		serv.send('handlers.php?h=adddir','id='+document.getElementById('dir_id').value+'&name='+trim(document.getElementById('dir_name').value),handleDir);
	}else{
		//edit
		serv.send('handlers.php?h=rendir','id='+document.getElementById('dir_id').value+'&name='+trim(document.getElementById('dir_name').value),handleDir);
	}
}

function delDir(){
	if(current_dir!=0){
		serv.send('handlers.php?h=deldir','id='+current_dir,handleDir);
	}
}

function handleDir(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			document.getElementById('treeview').innerHTML = serv.getXhtmlText();
			cancelForm('add_dir');
			initTree();
			updateDirList();
		}
	}
}

function allFiles(){
	serv.send('handlers.php?h=allfiles','',handleReloadPage);
}

function byDir(){
	serv.send('handlers.php?h=bydir','',handleReloadPage);
}

function cancelForm(id){
	$('#'+id).hide('slow');
	$('#move_file').slideDown('slow');
}

function updateDirList(){
	serv_2.send('handlers.php?h=updatedirs','',handleUpdateDirList);
}

function handleUpdateDirList(){
	if(serv_2.getState() == 4){
		if(serv_2.getStatus() == 200){
			document.getElementById('dirlist').innerHTML = serv_2.getXhtmlText();
		}
	}
}

function editForm(id){
	var edit_form = document.getElementById('edit_form').innerHTML;
	var edit_filename = document.getElementById('file_'+id).value;
	var allDivs = document.getElementsByTagName('div');
	for (var div in allDivs) {
		if(allDivs[div])
		if (allDivs[div].className == 'table_line') {
			var isfile = allDivs[div].id.split('_');
			if(isfile[0]=='filen'){
				document.getElementById(allDivs[div].id).innerHTML=document.getElementById('file_'+isfile[1]).value;
			}
		}
	}
	
	document.getElementById('filen_'+id).innerHTML = edit_form;
	document.getElementById('filename').value=edit_filename;
	document.getElementById('fileid').value=id;
}

function editFilename(){
	serv.send('handlers.php?h=editfilename','fname='+document.getElementById('edit_filename').value+'&fid='+document.getElementById('fileid').value,handleViewPage);
}

function getMoneyPanel(sms_id){
	if(document.getElementById('sms_'+selected_mpanel)){
		//document.getElementById('sms_'+selected_mpanel).style.display='none';
		document.getElementById('sms_'+selected_mpanel).innerHTML = '';
	}
	if(document.getElementById('price_'+selected_mpanel)){
		document.getElementById('price_'+selected_mpanel).style.display='inline';
	}
	if(document.getElementById('sms_'+sms_id)){
		//document.getElementById('sms_'+sms_id).style.display='inline';
		document.getElementById('price_'+sms_id).style.display='none';
		document.getElementById('sms_'+sms_id).innerHTML = document.getElementById('money_panel').innerHTML;
		
	}
	if(document.getElementById('price_'+sms_id)){
		document.getElementById('price_'+sms_id).style.display='none';
		//document.getElementById('sms_'+sms_id).innerHTML = '';
	}
	selected_mpanel = sms_id;
	selected_cost = 0;
}

function setCurrentCost(cost){
	selected_cost = cost;
}

function setMoney(){
	if(document.getElementById('sms_'+selected_mpanel)){
		document.getElementById('sms_'+selected_mpanel).innerHTML = '';
		serv.send('handlers.php?h=setmoneysms','id='+selected_mpanel+'&cost='+selected_cost,handleSetMoney);
	}
}

function handleSetMoney(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			document.getElementById('price_'+selected_mpanel).innerHTML = '('+serv.getXhtmlText()+')';
			document.getElementById('price_'+selected_mpanel).style.display='inline';
		}
	}
}

function selectAll(status){
	var inp_check = document.getElementsByTagName('input');
	for(var inp in inp_check){
		if(inp_check[inp])
		if(inp_check[inp].id)
		if(inp_check[inp].id.substr(0,6)=='fileid'){
			inp_check[inp].checked = status;
		}
		
	}
}

function getCheckedId(){
	var check_arr = new Array();
	var check_ind = 0;
	var inp_check = document.getElementsByTagName('input');
	for(var inp in inp_check){
		if(inp_check[inp])
		if(inp_check[inp].id)
		if(inp_check[inp].id.substr(0,6)=='fileid')
		if(inp_check[inp].checked)
		{
			if(inp_check[inp].id.substr(7,inp_check[inp].id.length)!=''){
			check_arr[check_ind] = inp_check[inp].id.substr(7,inp_check[inp].id.length);
			check_ind++;
			}
		}
		
	}
	return check_arr;
}

function selectDelete(){
	var l_id_list = getCheckedId();
	var id_str='';
	for(var i in l_id_list){
		id_str+=l_id_list[i]+':';
	}
	id_str = id_str.substr(0,(id_str.length-1));
	serv.send('handlers.php?h=selecteddelete','id_list='+id_str,handleViewPage); 
}

function selectLock(){
	var l_id_list = getCheckedId();
	var id_str='';
	for(var i in l_id_list){
		id_str+=l_id_list[i]+':';
	}
	id_str = id_str.substr(0,(id_str.length-1));
	serv.send('handlers.php?h=selectedlock','id_list='+id_str,handleViewPage); 
	
}

function selectUnlock(){
	
	var l_id_list = getCheckedId();
	var id_str='';
	for(var i in l_id_list){
		id_str+=l_id_list[i]+':';
	}
	id_str = id_str.substr(0,(id_str.length-1));
	serv.send('handlers.php?h=selectedunlock','id_list='+id_str,handleViewPage);//handleReloadPage
	
}

function selectMoveToDir(){
	var l_id_list = getCheckedId();
	var id_str='';
	for(var i in l_id_list){
		id_str+=l_id_list[i]+':';
	}
	id_str = id_str.substr(0,(id_str.length-1));
	serv.send('handlers.php?h=selectedmovefile','id_list='+id_str+'&dir_id='+selected_dir,handleViewPage);//
}

function checkPayment(order_id){
	current_order_id = order_id;
	serv.send('handlers.php?h=getpaystat','key='+order_id,handleCheckPayment);//
}

function handleCheckPayment(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			if(serv.getXhtmlText()=='1'){
				document.getElementById('reloadpage').submit();
			}else{
				setTimeout('checkPayment('+current_order_id+')',2000);
			}
			//document.getElementById('price_'+selected_mpanel).innerHTML = '('+serv.getXhtmlText()+')';
			//document.getElementById('price_'+selected_mpanel).style.display='inline';
		}
	}
}

function selectGetLinks(){
	var l_id_list = getCheckedId();
	var id_str='';
	var id_arr=[];
	for(var i in l_id_list){
		//id_str+=document.getElementById('download_'+l_id_list[i]).value+'\n';//l_id_list[i]+':';
		id_arr[l_id_list[i]] = document.getElementById('download_'+l_id_list[i]).value;
	}
	for(var i in id_arr){
		id_str+=id_arr[i]+'\n';
	}
	document.getElementById('uniqlink').value = id_str;
} 

function selectSmsSetMoney(){

}

function getDownloadAdv(hash){
    window.open('/html/index3.php?hash='+hash);
	//window.open('/html/index4.html');
}
function getDownloadAdv2(hash){
    window.open('/html/index.php?hash='+hash);
	//window.open('/html/index4.html');
}
function getDownloadAdvEn(id){
    window.open('/html/ad_wait'+id+'.html');
	//window.open('/html/index4.html');
}

function showEditForm(status){
	if(status){
		$('#fileedit').show('slow');
		$('#filelist').hide();
		$('#toppanel').hide();
		$('#bottompanel').hide();
		$('#pagelist').hide();
		$('#linksfield').hide();
		$('#byview').hide();
	}else{
		$('#fileedit').hide();
		$('#filelist').show('slow');
		$('#toppanel').show();
		$('#bottompanel').show();
		$('#pagelist').show();
		$('#linksfield').show();
		$('#byview').show();
	}
}

function setDescription(){
	var fname 	= document.getElementById('filename').value;
	var fkey 	= document.getElementById('keywords').value;
	var fdescr 	= document.getElementById('descr').value;
	var fid		= document.getElementById('file_id').value;
	serv.send('handlers.php?h=setdescr','name='+fname+'&keywords='+fkey+'&descr='+fdescr+'&id='+fid,handleSetDescription);
}

function getFileInfo(id){
	serv.send('handlers.php?h=getfileinfo','id='+id,handleGetFileInfo);
}

function handleSetDescription(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			showEditForm(false);
		}
	}
}

function handleGetFileInfo(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			xdoc = serv.getXhtmlXML();
						
			var selectNodes = xdoc.getElementsByTagName('response')[0];
			var id 	= selectNodes.getElementsByTagName('id')[0].childNodes[0].nodeValue;
			var rname 	= selectNodes.getElementsByTagName('name')[0].childNodes[0].nodeValue;
			var keyw 	= selectNodes.getElementsByTagName('keywords')[0].childNodes[0].nodeValue;
			var descr 	= selectNodes.getElementsByTagName('description')[0].childNodes[0].nodeValue;
						
			document.getElementById('file_id').value=id;
			document.getElementById('filename').value=rname;
			document.getElementById('keywords').value=keyw;
			document.getElementById('descr').value=descr;
			showEditForm(true);
		}
	}
}

function handleSaveFileInfo(){
	if(serv.getState() == 4){
		if(serv.getStatus() == 200){
			
			showEditForm(false);
		}
	}
}

function setSearchPage(page){
    document.getElementById('search_page').value=page;
    document.getElementById('search_form').submit();
}

function load_adv_ajax(hash,advname){ 
    serv_2.send('/handlers.php?h=loadiframe','hash='+hash+'&advname='+advname,handleNull);
}

function load_download_area(){
    serv.send('/handlers.php?h=getdownloadarea','',handleLoadDA);
}

function handleLoadDA(){
    if(serv.getState() == 4){
	if(serv.getStatus() == 200){
            document.getElementById('download_area').innerHTML = serv.getXhtmlText();
			
        }
    }
}

function adv_is_show(adv_id){ 
    serv_2.send('/handlers.php?h=adv_show_block','adv_id='+adv_id,handleNull);
}

function showBlock(id,status){
	if(status){
		$('#'+id).show('slow');
	}else{
		$('#'+id).hide('slow');
	}
}

function show_quickform_buy(idform){
	document.getElementById('form_sms').style.display='none';
	document.getElementById('form_pp').style.display='none';
	document.getElementById('form_cc').style.display='none';
	if (idform=='form_sms') document.getElementById('form_sms').style.display='block';
	if (idform=='form_pp') document.getElementById('form_pp').style.display='block';
	if (idform=='form_cc') document.getElementById('form_cc').style.display='block';
}
