function gete(i){
	return document.getElementById(i);
}

var progress_checked_domain={count:0};

function dtSubmit(o,s){
	progress_checked_domain={count:0};
	var cback=function(r){
		if(r.substr(0,9)=='redirect:'){
			location.href=r.substr(9).replace('&amp;','&');
			return;
		}
		if(r.substr(0,6)=='login:'){
			r=r.substr(6);
			var i,d=document.getElementsByTagName('DIV');
			for(i=0;i<d.length;i++){
				if(d[i].id.substr(0,8)=='o_login_'){
					d[i].style.padding='0px';
					d[i].style.border='2px solid #FF0000';
				}
			}
		}
		gete('dtRefresh').innerHTML=r;
		if(o)o.id='A0';
	}
	var t=''
	if(o){
		var i,n,e=o.form.elements;
		for(i=0;i<e.length;i++){
			n=e[i].name.split('[');
			if(n[0]==s){
				t+='&'+e[i].name+'='+e[i].value;
				switch(e[i].type){
					case 'checkbox':
						t+='&'+e[i].name+'='+(e[i].checked ? e[i].value:'');
						break;
					default:
						t+='&'+urlencode(e[i].name)+'='+urlencode(e[i].value);
						break;
				}
			}
		}
	}
	if(gete('dpopupPopupID').style.display==''){
		dpopupHelp();
		dpopupPopup(gete('IMAGE1'));
	}
	ajaxCall(cback,'index.php','MDL=ajax&f=getObject&object=domain_transfer&step='+s+t+helpVisible());
}

function makeImages(){
	var i,m=document.getElementsByTagName('img');
	for(i=0;i<m.length;i++){
		if(m[i].id.split('[')[0]=='arrow' && m[i].src.split(dpopupSrcDown).length==2){
			m[i].src=dpopupSrcRight;
		}
	}
}

function dtContainer(i,c){
	var b=gete('BODY'+i);
	if(!b){
		return false;
	}
	b=b.style
	var m=gete('IMAGE'+i);
	if(gete('dpopupPopupID').style.display==''){
		dpopupHelp();
		dpopupPopup(m);
	}
	if(c || b.display==''){
		b.display='none';
		m.src=dpopupSrcRight;
	}else{
		b.display='';
		m.src=dpopupSrcDown;
	}
	return true;
}

function dtShow(o,i){
	var j,d,t,c=0;
	for(j=1;d=gete('DOMAIN'+j);j++){
		if((t=gete(i+'['+d.title+']')) && !document.getElementsByName('confirm[domain]['+d.title+']['+i+']')[0].disabled){
			if(c){
				t.style.display=o.checked?'none':'';
			}else{
				c=1;
			}
		}
	}
}

function helpVisible(){
	return '&HELP_VISIBLE='+(gete('HELP_VISIBLE_ID').checked?1:0);
}

function helpVisibleSave(){
	var cback=function(r){}
	var h=gete('HELP_VISIBLE_ID').checked?1:0;
	gete('onlinehelp').style.display=h?'':'none';
	ajaxCall(cback,'index.php','MDL=ajax&f=getObject&object=domain_transfer&helpVisibleSave='+h);
}

function dtPrice(i){
	var i,c,v,l,a;
	event.cancelBubble=true;
	if((c=gete('check_'+i)) && (v=gete('Vat_'+i)) && (l=gete('Last_'+i)) && (a=gete('Amounts_'+i))){
		a=a.innerHTML.split('/');
		if(a[0]!=a[1]){
			v.innerHTML=c.checked && a[0] ? currencyFormat(a[0],1,1)+'<br>':'&nbsp;';
		}
		l.innerHTML=c.checked && a[0] ? currencyFormat(a[0],0,1):'&nbsp;';
	}
	v=l=0;
	for(i=1;(a=gete('Amounts_'+i)) && (c=gete('check_'+i));i++){
		if(c.checked){
			a=a.innerHTML.split('/');
			v+=1*a[0];
			l+=1*a[1];
		}
	}
	if((!v || v!=l) && (a=gete('Vat_total'))){
		a.innerHTML=v?currencyFormat(v,1,1)+'<br>':'&nbsp;';
	}
	a=gete('Last_total');
	a.innerHTML=l?currencyFormat(l,0,1):'&nbsp;';
}

function progress_check_domain(d,c){
	if(progress_checked_domain[d])return;
	progress_checked_domain[d]=1;
	var cback=function(r){
		d=gete('progress_td_'+d);
		d.className='progress';
		d.innerHTML=r;
		++progress_checked_domain['count'];
		if(progress_checked_domain['count']==c){
			var cbackcheck=function(r){
				gete('dtRefresh').innerHTML=r;
			}
			ajaxCall(cbackcheck,'index.php','MDL=ajax&f=getObject&object=domain_transfer&step=check');
		}
	}
	ajaxCall(cback,'index.php','MDL=ajax&f=getObject&object=domain_transfer&progress_check_domain='+d);
}

function select_line_clicked(c){
	var p=document.getElementById('check_'+c);
	p.checked=p.checked?false:true;
	dtPrice(c);
}

function domain_whois(d){
	var o=document.getElementById('div_whois_'+d);
	var a=document.getElementById('pre_whois_'+d);
	if(a){
		o.style.display=o.style.display==''?'none':'';
		return;
	}
	o.style.display='';
	var cback=function(r){
		o.innerHTML='<div id="pre_whois_'+d+'">'+r+'</div>';
	}
	ajaxCall(cback,'index.php','MDL=ajax&f=getObject&object=domain_transfer&domain_whois='+d);
}

function dtHemlpme(){
	var cback=function(r){
		var s=window_size();
		var a='<div style="width:'+(s.w-20)+';height:'+(s.h-20)+';overflow:auto"><table bgcolor=#FFFFFF width=100% height=100% cellspacing=10 cellpadding=0 border=0 style="border:1px solid #000000"><tr><td valign=top>';
		a+=r;
		a+='</td></tr></table></div>';
		var d=document.createElement('DIV');
		d.innerHTML=a;
		var m=d.getElementsByTagName('IMG');
		var i,n;
		for(i=0;i<m.length;i++){
			if(m[i].id=='fullscreenimg'){
				m[i].style.display='none';
			}else if(m[i].src.indexOf('_small')>-1){
				n=document.createElement('IMG');
				n.src=m[i].src.replace('_small','_large');
				n.align='left'
				n.style.marginRight='10px';
				m[i].parentNode.replaceChild(n,m[i]);
			}
		}
		a='<div id=domainTransferHelp>'+d.innerHTML+'</div>';
		zoom_image('html',a,s.w-20,s.h-20);
	}
	ajaxCall(cback,'index.php','MDL=ajax&f=getAlias&getAlias=DOMAINS_TRANSFER_HELPME');
}
function PrintContents(){
	var d=document.getElementById('domainTransferHelpDiv');
	if(!d){
		var cback=function(r){
			d=document.createElement('DIV');
			d.id='domainTransferHelpDiv';
			d.style.display='none';
			d.innerHTML='';
			var a=document.getElementById('top_logo'),b=document.getElementById('top_image');
			if(a||b){
				d.innerHTML='<div style="text-align:center" nowrap>'+(a?'<i'+'mg src="'+a.src+'" border=0>':'')+(b?'<i'+'mg src="'+b.src+'" border=0></div>':'');
			}
			d.innerHTML+=r;
			var m=d.getElementsByTagName('IMG');
			var i,n;
			for(i=0;i<m.length;i++){
				if(m[i].src.indexOf('_small')>-1||m[i].src.indexOf('_large')>-1){
					n=document.createElement('DIV');
					n.style.textAlign='center';
					n.innerHTML='<i'+'mg src="'+m[i].src.replace('_small','_large')+'" border=0><br><br>';
					m[i].parentNode.replaceChild(n,m[i]);
				}
			}
			document.body.appendChild(d);
			window.open('?MDL=s_print&NO_SAVE_SCREEN=1&area=domainTransferHelpDiv','','top='+((screen.height-105)/4)+',left='+((screen.width-130)/4)+',status=0,width=160,height=105').focus();
		}
		ajaxCall(cback,'index.php','MDL=ajax&f=getAlias&getAlias=DOMAINS_TRANSFER_HELPME');
	}else{
		window.open('?MDL=s_print&NO_SAVE_SCREEN=1&area=domainTransferHelpDiv','','top='+((screen.height-105)/4)+',left='+((screen.width-130)/4)+',status=0,width=160,height=105').focus();
	}
}

