function callDDiv(atobj, dom_id, detailed,cl){
	self.onclick=null;
	var oDiv = document.getElementById('contdiv');
	oDiv.style.visibility = 'visible';
	var oAtobj = document.getElementById(atobj);
	oDiv.style.left = GetXof(oAtobj);
	oDiv.style.top = GetYof(oAtobj);
	ajaxDo('/admoutputonly.php?act=informer&op=domain&closecode='+encodeURIComponent('hideCDiv()')+'&dom_id='+dom_id+'&cl='+cl+'&dshow='+detailed,'contdiv','GET',0,0);
	//self.onclick=hideCDiv;
}
function callCDiv(atobj, cname){
	self.onclick=null;
	var oDiv = document.getElementById('contdiv');
	oDiv.style.visibility = 'visible';
	var oAtobj = document.getElementById(atobj);
	oDiv.style.left = GetXof(oAtobj);
	oDiv.style.top = GetYof(oAtobj);
	ajaxDo('/admoutputonly.php?act=informer&op=contact&closecode='+encodeURIComponent('hideCDiv()')+'&cont='+cname,'contdiv','GET',0,0);
	self.onclick=hideCDiv;
}
function hideCDiv(){
	self.onclick=null;
	var oDiv = document.getElementById('contdiv');
	oDiv.style.visibility = 'hidden';
}

function translitToEn(h){
	var tr = {'А':'A','Б':'B','В':'V','Г':'G','Д':'D','Е':'E','Ё':'E','Ж':'Zh','З':'Z','И':'I','Й':'J','К':'K','Л':'L','М':'M','Н':'N','О':'O','П':'P','Р':'R','С':'S','Т':'T','У':'U','Ф':'F','Х':'KH','Ц':'C','Ч':'CH','Ш':'Sh','Щ':'Sh','Ъ':'','Ы':'Y','Ь':'','Э':'E','Ю':'U','Я':'Ya','а':'a','б':'b','в':'v','г':'g','д':'d','е':'e','ё':'e','ж':'zh','з':'z','и':'i','й':'j','к':'k','л':'l','м':'m','н':'n','о':'o','п':'p','р':'r','с':'s','т':'t','у':'u','ф':'f','х':'kh','ц':'c','ч':'ch','ш':'sh','щ':'sh','ъ':'','ы':'y','ь':'','э':'e','ю':'u','я':'ya'};
	var p;do{p=h;for(var x in tr)h=h.replace(x,tr[x]);}while(p!=h);return h;
}
function processPhone(h){
	if(!h)h='';
	h=h.replace(/[^+0-9\.]/gi,'');
	if(h.substr(0,1)!='+')
		h = '+'+h;
	return h;
}
function rexpValidate(o,re){
	var chkre = re.test($(o).attr('value'));
    cfSetFlag(o,chkre);
}
function cfSetFlag(o,r){
    $(o).css({'background-image':'url(/images/'+(r ? 'aff_tick.gif' : 'aff_cross.gif')+')', 'background-repeat':'no-repeat', 'background-position':'right center'});
}
function cfCheckLogin(){
	this.value=translitToEn(this.value);
	rexpValidate(this, /^[a-z][0-9a-z]{5,11}$/i );	
}
function cfCheckPw(){
	rexpValidate(this, /^.{6,}$/ );	
}
function cfCheckPw2(){
	var eq = true, et = false;

	$(this).parents('form').find('input[type="password"]').each(function(){ 
		var v=$(this).attr('value');
		if(et===false)et=v;
		else 
			if(v!=et||v===''||et===''){eq=false; return false; }
	});
	cfSetFlag(this,eq);
}
function cfCheckPhone(){
	this.value=processPhone(this.value);
	rexpValidate(this, /^\+[0-9]{1,3}\.[0-9]{10,19}$/ );
}
function cfCheckPhoneE(){
	rexpValidate(this, /^(\+[0-9]{1,3}\.[0-9]{10,19}){0,1}$/ );
}
function cfCheckName(){
	this.value=translitToEn(this.value);
	rexpValidate(this, /^([_0-9A-Za-z,\.\"`\/\'-]+[ ]+)+([_0-9A-Za-z,\.\"`\/\'-]+)[ ]*$/ );
}
function cfCheckAlfaNE(){
	this.value=translitToEn(this.value);
	rexpValidate(this, /^([_0-9A-Za-z,\.\"`\/\'-]+)([_0-9A-Za-z,\.\"`\/\' -]*)$/ );
}
function cfCheckAlfaE(){
	this.value=translitToEn(this.value);
	rexpValidate(this, /^[_0-9a-z,\.\"`\/\' -]*$/i );
}
function cfCheckNumNE(){
	rexpValidate(this, /^[0-9]+$/ );
}
function cfCheckNumE(){
	rexpValidate(this, /^[0-9]*$/ );
}
function cfCheckAlfaNEru(){
	rexpValidate(this, /^([_0-9A-Za-zА-Яа-я,\.\"`\/\'-]+[ ]+)+([_0-9A-Za-zА-Яа-я,\.\"`\/\'-]+)[ ]*$/ );
}
function cfCheckAlfaEru(){
	rexpValidate(this, /^[_0-9A-Za-zА-Яа-я,\.\"`\/\' -]*$/ );
}
var cfEmailcheckers={};
function cfCheckEmail(){
	var re = /^[_0-9a-z\.-]+@[_0-9a-z\.-]+\.[_0-9a-z\.-]{2,}$/i , v = $(this).attr('value'), r = $(this).attr('rel'), chkre = re.test(v);
	
	if($(this).attr('old')==v) return;
	$('#confitemaux'+r).html('');
	if(chkre){
		if(cfEmailcheckers[r]){
			window.clearTimeout(cfEmailcheckers[r].to);
		}else{
			cfEmailcheckers[r] = {to:false};
		}
		var me = this;
		cfEmailcheckers[r].to = window.setTimeout(function(){cfCheckEmailLaunch(me);},500);
	}else
		cfSetFlag(this,chkre);
}
function cfCheckEmailLaunch(o){
	$(o).attr('disabled',true);
	$(o).attr('old',$(o).attr('value'));
	$.ajax({ 
		method:'POST',url:'//www.dnr.kz/my/?rootact=evrfy', 
		data:{'e': $(o).attr('value') }, 
		dataType:'json', 
		success:cfCheckEmailCB, 
		error:comctlAjaxErr, 
		context: o, 
		cache: false });
}
function comctlAjaxErr(data){
	$(this).attr('disabled',false);
	alert('Request error');
}
function cfCheckEmailCB(data){
	if( $(this).attr('value') == data.vrfy ){
		$(this).attr('disabled',false);
		$('#confitemaux'+$(this).attr('rel')).css({'display':'block','color':data.color}).html('<small>'+data.msg+'</small>');
		cfSetFlag(this,data.good);
	}
}

function cfAreaChange(ogID){
	oinp = document.getElementById('confitem'+ogID);
	if(oinp.options[oinp.selectedIndex].value){
		oinpa = document.getElementById('confitem'+(ogID-1));
		for (var loop=oinpa.options.length-1; loop >=0 ; loop--) {
			 // remove the option
			 oinpa.options[loop] = null;
		}
		oinpa.options[0] = new Option('Loading...','0');
		ajaxDoExec('//www.dnr.kz/my/?rootact=getarea&id='+ogID+'&cc='+oinp.options[oinp.selectedIndex].value,'POST');
	}else alert('no value');
}

function cfVerifyEmail(ogID){ 
	return;
	var re = /^[_0-9A-Za-z\.-]+@[_0-9A-Za-z\.-]+\.[_0-9A-Za-z\.-]{2,}$/
	oinp = document.getElementById('confitem'+ogID);
	if(re.test(oinp.value))
		ajaxDoExecProgress('//www.dnr.kz/my/?rootact=evrfy&id='+ogID+'&e='+oinp.value,'POST','confitemaux'+ogID);
	else{
		var result = re.test(oinp.value) ? 'aff_tick.gif' : 'aff_cross.gif';
		oinp.style.backgroundImage='url(/images/'+result+')';
		oinp.style.backgroundRepeat='no-repeat';
		oinp.style.backgroundPosition='right center';		
	}
}

//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//		Transliteration
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////


var abc1 = new Array();
abc1['а'] = 'a';
abc1['б'] = 'b';
abc1['в'] = 'v';
abc1['г'] = 'g';
abc1['д'] = 'd';
abc1['е'] = 'e';
abc1['ё'] = 'jo';
abc1['ж'] = 'zh';
abc1['з'] = 'z';
abc1['и'] = 'i';
abc1['й'] = 'j';
abc1['к'] = 'k';
abc1['л'] = 'l';
abc1['м'] = 'm';
abc1['н'] = 'n';
abc1['о'] = 'o';
abc1['п'] = 'p';
abc1['р'] = 'r';
abc1['с'] = 's';
abc1['т'] = 't';
abc1['у'] = 'u';
abc1['ф'] = 'f';
abc1['х'] = 'h';
abc1['ц'] = 'c';
abc1['ч'] = 'ch';
abc1['ш'] = 'sh';
abc1['щ'] = 'w';
abc1['ъ'] = '#';
abc1['ы'] = 'y';
abc1['ь'] = '\'';
abc1['э'] = 'je';
abc1['ю'] = 'ju';
abc1['я'] = 'ja';
abc1['А'] = 'A';
abc1['Б'] = 'B';
abc1['В'] = 'V';
abc1['Г'] = 'G';
abc1['Д'] = 'D';
abc1['Е'] = 'E';
abc1['Ё'] = 'JO';
abc1['Ж'] = 'ZH';
abc1['З'] = 'Z';
abc1['И'] = 'I';
abc1['Й'] = 'J';
abc1['К'] = 'K';
abc1['Л'] = 'L';
abc1['М'] = 'M';
abc1['Н'] = 'N';
abc1['О'] = 'O';
abc1['П'] = 'P';
abc1['Р'] = 'R';
abc1['С'] = 'S';
abc1['Т'] = 'T';
abc1['У'] = 'U';
abc1['Ф'] = 'F';
abc1['Х'] = 'H';
abc1['Ц'] = 'C';
abc1['Ч'] = 'CH';
abc1['Ш'] = 'SH';
abc1['Щ'] = 'W';
abc1['Ъ'] = '##';
abc1['Ы'] = 'Y';
abc1['Ь'] = '\'\'';
abc1['Э'] = 'JE';
abc1['Ю'] = 'JU';
abc1['Я'] = 'JA';

function translatechartolatin(symb)
{
	return abc1[symb]?abc1[symb]:symb;
}
function translateStringtoLatin(txt)
{
	txtnew="";
	var symb = "";
	for (kk=0;kk<txt.length;kk++)
	{
		symb = translatechartolatin(txt.substr(kk,1));
		txtnew = txtnew.substr(0,txtnew.length) + symb;
	}
	return txtnew;
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function rfcSwitch(rfcid,swid){
	var orfc = document.getElementById(rfcid);
	var osw = document.getElementById(swid);
	if(!orfc || !osw) alert(orfc +' + '+osw);
	if(osw.checked)
		orfc.style.display = 'block';
	else
		orfc.style.display = 'none';
}
