/* -------------------------- */
/*   XMLHTTPRequest Enable    */
/* -------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
} else {
request_type = new XMLHttpRequest();
}
return request_type;
}
var http = createObject();


function mesAdd(a)
{var parts = a.split(/\=/);var text=document.getElementById("textmes").value;if(parts[0]!='fullprognoz'){$.post("/engine/ajax/prognozfree/comments.php", {messadd:''+a+'',messtext:''+text+''},function(b){$("#commenty").html(b)});}else {$.post("/engine/ajax/prognozfree/comments.php", {prognoz_id:parts[1],messtext:''+text+''},function(b){$("#commenty").html(b)});}}

function showAdmes(){setTimeout(function(){$("#newmes").show("blind",{},1500)},700);}

function showMesEdit(a){document.getElementById("redmes"+a).style.display='block';}

function mesEdit(a)
{var chast = a.split(/\=/);if(chast[0]!='fullprognoz'){var parts = a.split(/\|/);var text=document.getElementById("redtextmes"+a).value;$.post("/engine/ajax/prognozfree/comments.php", {mesidred:parts[0],translation:parts[1],comenttext:''+text+''},function(b){$("#commenty").html(b)});}else{var parts = chast[1].split(/\|/);var text=document.getElementById("redtextmes"+chast[1]).value;$.post("/engine/ajax/prognozfree/comments.php", {mesidred:parts[0],prognoz_id:parts[1],comenttext:''+text+''},function(b){$("#commenty").html(b)});}}

function mesDel(a)
{if(confirm('Вы действительно хотите безвозвратно удалить данный комментарий?\nДанная операция необратима')){var chast = a.split(/\=/);if(chast[0]!='fullprognoz'){var parts = a.split(/\|/);$.post("/engine/ajax/prognozfree/comments.php", {mesiddel:parts[0],translation:parts[1]},function(b){$("#commenty").html(b)});}else{var parts = chast[1].split(/\|/);$.post("/engine/ajax/prognozfree/comments.php", {mesiddel:parts[0],prognoz_id:parts[1]},function(b){$("#commenty").html(b)});}}}


function PrognozDel(a)
{if(confirm('Вы действительно хотите безвозвратно удалить данный прогноз?\nДанная операция необратима')){var parts = a.split(/\|/);var app=(parts[4])? parts[4] : "";var ordavt=(parts[5])? parts[5] : "";var ordrat=(parts[6])? parts[6] : "";var ordcst=(parts[7])? parts[7] : "";$.post("/engine/ajax/prognozfree/prognozfree.php", {prognozdel:parts[0],avtor:parts[1],limit:parts[2],execut:parts[3],app:app,ordavt:ordavt,ordrat:ordrat,ordcst:ordcst},function(b){$("#prognozy").html(b)});}}
/* -------------------------- */
/*    ShowAddEditPrognoz(a)   */
/* -------------------------- */
function ShowAddEditPrognoz(a)
{var parts = a.split(/\|/);var ordavt=(parts[2])? parts[2] : "";var app=(parts[3])? parts[3] : "";var ordrat=(parts[4])? parts[4] : "";var ordcst=(parts[5])? parts[5] : "";$.post("/engine/ajax/prognozfree/prognozfree.php", {showaddeditprognoz:true,limit:parts[0],execut:parts[1],ordavt:ordavt,app:app,ordrat:ordrat,ordcst:ordcst},function(b){window.opener.document.getElementById("prognozy").innerHTML=b;window.close();
																																																																																																								 });}

/* -------------------------- */
/*    ShowFullPrognoz(a)   */
/* -------------------------- */
function ShowFullPrognoz(a)
{$.post("/engine/ajax/prognozfree/prognozfree.php", {showfullprognoz:a},function(b){$("#prognozfull").html(b)});}

function PrognozFullDel(a)
{if(confirm('Вы действительно хотите безвозвратно удалить данный прогноз?\nВсе комменты к данному прогнозу будут удалены тоже.\nДанная операция необратима')){var parts = a.split(/\|/);$.post("/engine/ajax/prognozfree/prognozfree.php", {prognozdel:parts[0],avtor:parts[1],limit:0,execut:10},function(){document.location.href='/index.php?do=prognozfree';});}}


function OrderChemp()
{
var ordChemp=document.getElementById("chemp").value;
var ordTour=document.getElementById("tour").value;
var ordChempyear=document.getElementById("chempyear").value;
var category=(ordChemp=='') ? "" : "&category="+ordChemp;
var year=(ordChempyear=='') ? "" : "&year="+ordChempyear;
var tour=(ordTour=='') ? "" : "&tour="+ordTour;
location.href="/index.php?do=archiv_video"+year+tour+category;
}

function ReplaceComa(a){
a.value=a.value.replace(/,/g,'.');	
}

function NewWM(a){
wm=window.open(a, 'WM', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=600, height=370'); 
wm.focus();	
}

function JJandTwitter(a){
nocache = Math.random();
var parts = a.split(/\|/);
var id=parts[0]; 
var public=parts[1];
http.open('get', 'http://totbet.net/engine/modules/viksoft_ajax/ajax.php?jjtwitter='+id+'&public='+public+'&nocache ='+nocache);
http.send(null);
}

function VKontakte(id){
$.post("/engine/ajax/vkontakte_poster.php", {news_id:id});
}


function RassylkaPR(){
	nocache = Math.random();
	http.open('get', '/engine/modules/viksoft_ajax/ajax.php?rassylka&nocache ='+nocache);
	http.onreadystatechange = RASrez;
	http.send(null);
}

function RASrez() 
{
	if(http.readyState == 4) 
	{
	var response = http.responseText;
	document.getElementById("rassylka").innerHTML=response;
	//document.getElementById("timer").style.display='block';
	}
}
function rezOpl(a) 
{
	a.value=a.value.replace(/[^0-9]/gi,""); // удаляем все символы кроме цифр
	var b=parseInt(a.value); // приводим к целому числу
	if (isNaN(b))  b=0; // если нет чисел
	if (b<0)  b=0; // если отрицательное число
	
	var rez=b*costRassVV*100;
	rez=(Math.round(rez))/100;
	document.getElementById("payRas").innerHTML='<b>'+rez+'</b>';
}
function doOPLata() 
{
	var a =document.getElementById("daysRas").value;
	var m =document.getElementById("mailRas").value;
	a=a.replace(/[^0-9]/gi,""); // удаляем все символы кроме цифр
	var b=parseInt(a); // приводим к целому числу
	if (isNaN(b))  {alert('Вы не ввели количество дней'); return;} // если нет чисел
	if (b<=0)  {alert('Недопустимое значение "количество дней"'); return;} // если отрицательное число
	if (!m || m.search(/[^A-z-_0-9@\.]/)!=-1)  {alert('Недопустимое значение "почтовый ящик для рассылки"'); return;} // если отрицательное число
	nocache = Math.random();
	m=encodeURIComponent(m);
	http.open('get', '/engine/modules/viksoft_ajax/ajax.php?dorassylka='+b+'&mail='+m+'&nocache ='+nocache);
	http.onreadystatechange = doRASrez;
	http.send(null);
}

function doRASrez() 
{
	if(http.readyState == 4) 
	{
	var response = http.responseText;
	document.getElementById("rassylka").innerHTML=response;
	}
}
function editMail() 
{
	var m =document.getElementById("mailRas").value;
	if (!m || m.search(/[^A-z-_0-9@\.]/)!=-1)  {alert('Недопустимое значение "почтовый ящик для рассылки"'); return;} // если отрицательное число
	nocache = Math.random();
	m=encodeURIComponent(m);
	http.open('get', '/engine/modules/viksoft_ajax/ajax.php?editmail='+m+'&nocache ='+nocache);
	http.onreadystatechange = doRASrez;
	http.send(null);
}
function ShowAdminprognoz()
{
window.opener.document.location.href="http://totbet.net/index.php?do=agregator";
window.close();
}

function editMailProfile() 
{
	var m =document.getElementById("mailRas").value;
	if (!m || m.search(/[^A-z-_0-9@\.]/)!=-1)  {alert('Недопустимое значение "почтовый ящик для рассылки"'); return;} // если отрицательное число
	nocache = Math.random();
	m=encodeURIComponent(m);
	http.open('get', '/engine/modules/viksoft_ajax/ajax.php?editmail='+m+'&nocache ='+nocache);
	http.onreadystatechange = EMPrez;
	http.send(null);
}
function EMPrez()
{
document.getElementById("mesmailedit").innerHTML="<span id='mesmailedit' style='color:green'>Ваш email для рассылки успешно изменен!</span>";
}

function fulltime ()   {
var time=new Date();
var totalRemains=(newDate.getTime()-time.getTime());

if (totalRemains>1){
var RemainsSec = (parseInt(totalRemains/1000));
var RemainsFullDays=(parseInt(RemainsSec/(24*60*60)));
var secInLastDay=RemainsSec-RemainsFullDays*24*3600;
var RemainsFullHours=(parseInt(secInLastDay/3600));
if (RemainsFullHours<10){RemainsFullHours="0"+RemainsFullHours};
var secInLastHour=secInLastDay-RemainsFullHours*3600;
var RemainsMinutes=(parseInt(secInLastHour/60));
if (RemainsMinutes<10){RemainsMinutes="0"+RemainsMinutes};
var lastSec=secInLastHour-RemainsMinutes*60;
if (lastSec<10){lastSec="0"+lastSec};

document.getElementById("RemainsFullDays").innerHTML=RemainsFullDays;
document.getElementById("RemainsFullHours").innerHTML=RemainsFullHours;
document.getElementById("RemainsMinutes").innerHTML=RemainsMinutes;
document.getElementById("lastSec").innerHTML=lastSec;
setTimeout('fulltime()',10)  
}

}


function OptionBan(a){
document.getElementById("banlist"+a).style.display='block';
document.getElementById("banlist"+a+"top").style.display='block';

document.getElementById("banlist"+a).style.width=document.documentElement.clientWidth+'px';
document.getElementById("banlist"+a).style.height=document.documentElement.clientHeight+'px';

document.getElementById("banlist"+a+"top").style.width=document.documentElement.clientWidth+'px';
document.getElementById("banlist"+a+"top").style.height=document.documentElement.clientHeight+'px';
document.getElementById("banlist"+a+"top").style.marginTop='-'+document.documentElement.clientHeight+'px';
}

function UserBan(id) 
{
ban=window.open(dle_root+dle_admin+'?mod=editusers&action=edituser&id='+id, 'BanWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=640, height=535, left=100, top=100');  
ban.focus();
}
function CommentsDel(a) 
{
	nocache = Math.random();
	var parts=a.split(/\|/);
	userid=parts[0]; name=parts[1];
	if(confirm('Вы действительно хотите удалить все комментарии  пользователя '+name+' ?')){
	http.open('get', '/engine/modules/viksoft_ajax/ajax.php?delcomments_user='+userid+'&nocache ='+nocache);
	http.onreadystatechange = ComDelRez;
	http.send(null);
	}
}
function ComDelRez() 
{
	if(http.readyState == 4) 
	{
	var response = http.responseText;	
	alert('Все комментарии пользователя '+response+' были удалены!');
	document.location.reload();
	}
}
function PmDel(a) 
{
	nocache = Math.random();
	var parts=a.split(/\|/);
	userid=parts[0]; name=parts[1];
	if(confirm('Вы действительно хотите удалить все сообщения  пользователя '+name+' ?')){
	http.open('get', '/engine/modules/viksoft_ajax/ajax.php?delpm_user='+userid+'&nocache ='+nocache);
	http.onreadystatechange = PmDelRez;
	http.send(null);
	}
}
function PmDelRez() 
{
	if(http.readyState == 4) 
	{
	var response = http.responseText;	
	alert('Все личные сообщения пользователя '+response+' были удалены!');
	}
}
function MenuBanBuild(name,id){
var user_ban  = 'Добавить пользователя в БАН - лист';
var del_comment  = 'Удалить все комментарии пользователя';
var del_pm  = 'Удалить все сообщения пользователя';
var b=[];
b[0]="<a href=\"\" onClick=\"CommentsDel('"+id+"|"+name+"'); return false;\">"+del_comment+"</a>";
if(dle_admin!="")b[1]="<a href=\"\" onClick=\"UserBan('"+id+"'); return false;\">"+user_ban+"</a>";
b[2]="<a href=\"\" onClick=\"PmDel('"+id+"|"+name+"'); return false;\">"+del_pm+"</a>";return b};




