function LoginUser() {
var login = $('#login')[0].value;
var password = $('#password')[0].value;
if(login!='' && password!='')
{
$('#keyBtn')[0].onclick = null;
$('#keyBtn')[0].src = '/images/progress_active.gif';
$.post('/ajax/login',
{ login:login, password: password },
function(results) {
autorise(results);
}, 'json'
);
}
}
function setAutorisation(code, uni, sid)
{
var exdate = new Date();
exdate.setYear(2016);
document.cookie="uni="+uni+"; path=/; expires=" + exdate.toGMTString();
document.cookie="code="+code+"; path=/; expires=" + exdate.toGMTString();
document.cookie="sid="+sid+"; path=/; expires=" + exdate.toGMTString();
window.location.reload();
}
function authInfo(response) {
if (response.session) {
getInitData(response.session.sig);
} else {
}
}
function getInitData(sig) {
var code = 'return {';
code += 'me: API.getProfiles({uids: API.getVariable({key: 1280}), fields: "nickname, sex, bdate, city, country, photo, photo_medium, photo_big"})[0]';
code += ', user: API.getUserInfoEx({api_id: 2373677, sig: "'+sig+'", v: "2.0"})'
code += '};';
VK.Api.call('execute', {'code': code}, onGetInitData);
}
function onGetInitData(data) {
if (data.response) {
var id = 'VK_'+data.response.me.uid;
var firstName = data.response.me.first_name;
var nickName = data.response.me.nickname;
var lastName = data.response.me.last_name;
var avatar = data.response.me.photo_big;
var sex = data.response.me.sex-1;
var birsday = [0,0,0];
if (data.response.me.bdate > '') birsday = data.response.me.bdate.split(".");
$.post('/ajax/oauth', {id: id,
firstName: firstName,
nickName: nickName,
lastName: lastName,
birsday: birsday[2]+'-'+birsday[1]+'-'+birsday[0],
avatar: avatar,
sex: sex,
ref: ''}, function(data){
VK.Auth.logout(autorise(data));
}, 'json');
}
}
function autorise(data) {
if (data.result[0] == 'success') {
setAutorisation(data.result[1], data.result[2], data.result[3]);
} else {
switch (data.errors[0])
{
case 0:
$('#notifycontent').dialog('close');
$('#notifycontent').html('
'+
''+
'');
$('#notifycontent').dialog("option", "title", "").dialog('open');
break;
case 1:
$('#notifycontent').dialog('close');
$('#notifycontent').html(' '+data.errors[1]+'
'+
'');
$('#notifycontent').dialog("option", "title", "").dialog('open');
break;
default:
$('#passremind').show();
$('#messages').html('