﻿hs.outlineType = null;
hs.showCredits = false;
hs.graphicsDir = 'graphics/';
hs.skin = { contentWrapper: '<div class="highslide-body"></div>' };
hs.cacheAjax = false;
var basketpos = 1;
var basketcontent = '';
var basketdiv = null;
var livecontent = '';
var basketIntervalID;
window.setInterval(UpdateLeftLive, 13000);
window.setInterval(MoveMenu, 300);

function WebForm_MyDoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) {
	var postData = "__EVENTTARGET=" + "&__EVENTARGUMENT=" +
				"&__CALLBACKID=" + WebForm_EncodeCallback(eventTarget) +
				"&__CALLBACKPARAM=" + WebForm_EncodeCallback(eventArgument);
	var xmlRequest, e;
	try {
		xmlRequest = new XMLHttpRequest();
	}
	catch (e) {
		try {
			xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) { }
	}
	var callback = new Object();
	callback.eventCallback = eventCallback;
	callback.context = context;
	callback.errorCallback = errorCallback;
	callback.async = useAsync;
	callback.xmlRequest = xmlRequest;
	WebForm_FillFirstAvailableSlot(__pendingCallbacks, callback);
	xmlRequest.onreadystatechange = WebForm_CallbackComplete;
	xmlRequest.open("POST", theForm.action + (theForm.action.indexOf("?") != -1 ? "&r=" : "?r=") + Math.random(), true);
	xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
	xmlRequest.send(postData);
}

function hl1(cell) {
	cell = cell.toElement || cell.target;
	if (cell && cell.tagName == "TD" && (cell.className == "coef" || cell.className == "coef40" || cell.className == "cf" || cell.className == "cu" || cell.className == "cd" || cell.className == "c1" || cell.className == "c2"))
		cell.style.backgroundColor = '#82c777';
	if (cell && cell.tagName == "SPAN" && cell.className == "coef")
		cell.style.color = '#00b04b';
}

function hl2(cell) {
	cell = cell.fromElement || cell.target;
	if (cell && cell.tagName == "TD" && (cell.className == "coef" || cell.className == "coef40" || cell.className == "cf" || cell.className == "cu" || cell.className == "cd" || cell.className == "c1" || cell.className == "c2"))
		cell.style.backgroundColor = cell.parentNode.style.backgroundColor;
	if (cell && cell.tagName == "SPAN" && cell.className == "coef")
		cell.style.color = '#26559b';
}

function highlight(cell, dir) {
	if (dir)
		cell.style.backgroundColor = '#82c777';
	else
		cell.style.backgroundColor = cell.parentNode.style.backgroundColor;
}

function frombasket(coef) {
	WebForm_MyDoCallback('Left1', '0|' + coef, RedrawBasket, null, null, true);
}

function getBodyScrollTop() {
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function tobasket(cell) {
	if (!cell.tagName) {
		cell = cell.srcElement || cell.target;
	}
	if (!cell || cell.onclick || (cell.className != "coef" && cell.className != "coef40" && cell.className != "cf" && cell.className != "cu" && cell.className != "cd"))
		return;
	MoveMenu2();
	WebForm_MyDoCallback('Left1', '1|' + cell.id, RedrawBasket, null, null, true);
	var coefrect = cell.getClientRects()[0];
	var baskettd = document.getElementById('baskettd');
	baskettd.innerHTML = cell.innerHTML;
	baskettd.style.width = (coefrect.right - coefrect.left - 5) + 'px';

	basketdiv = document.getElementById('basketdiv');
	basketdiv.style.display = '';
	basketdiv.style.left = coefrect.left + 'px';
	basketdiv.style.top = (coefrect.top + getBodyScrollTop()) + 'px';
	basketpos = coefrect.left;
	window.clearInterval(basketIntervalID);
	basketIntervalID = window.setInterval(moving, 1);
}

function tosumm(val) {
	var summ = document.getElementById('summ');
	if (val >= 5000)
		summ.value = val;
	else
		summ.value = summ.value * 1 + val;
}

function acceptbet() {
	document.getElementById('ButtonBet').disabled = 'disabled';
	document.getElementById('ButtonBet').value = document.getElementById('processing').value;
	var summ = document.getElementById('summ').value;
	var accepted = document.getElementById('accepted').checked;
	WebForm_MyDoCallback('Left1', '10|' + accepted + '|' + summ, RedrawBasket1, null, null, true);
}

function openlive(event) {
	if (document.getElementById('livediv') == null)
		__doPostBack(event, '');
	else {
		livecontent = '1';
		WebForm_MyDoCallback('Left1', '4|' + event, RedrawLive, null, null, true);
	}
}

function openall(event) {
	if (document.getElementById('livediv') == null)
		__doPostBack(event, '');
	else {
		livecontent = '1';
		WebForm_MyDoCallback('Left1', '8|' + event, RedrawLive, null, null, true);
	}
}

function openwindow(p1, p2, p3) {
	return hs.htmlExpand(p1, { objectType: 'ajax', width: p3, src: p2 + "&r=" + Math.random() + '#aaa' });
}

function moving() {
	if (basketpos > 10) {
		basketdiv.style.left = basketpos + 'px';
		basketpos -= 40;
	}
	else {
		window.clearInterval(basketIntervalID);
		var basketdiv1 = document.getElementById('basketdiv');
		if (basketdiv1)
			basketdiv1.style.display = 'none';
		if (basketcontent.length > 0) {
			document.getElementById('Left1_tabletrashdiv').innerHTML = basketcontent;
			basketcontent = '';
		}
	}
}

function RedrawBasket(result, context) {
	basketcontent = result;
	if (basketpos <= 10) {
		document.getElementById('Left1_tabletrashdiv').innerHTML = basketcontent;
		basketcontent = '';
	}
}

function RedrawBasket1(result, context) {
	RedrawBasket(result, context);
	window.setTimeout(function () {
		WebForm_MyDoCallback('Left1', '9|', UpdateLeftLogin, null, null, true);
	}, 10);
}

function UpdateLeftLive() {
	if (document.getElementById('Left1_tablelivediv'))
		WebForm_MyDoCallback('Left1', '2|', RedrawLeftLive, null, null, true);
}

function RedrawLeftLive(result, context) {
	if (result.length > 0)
		document.getElementById('Left1_tablelivediv').innerHTML = result;
}

function UpdateLeftLogin(result, context) {
	if (result.length > 0) {
		document.getElementById('Left1_tablelogindiv').innerHTML = result;
	}
}

function MoveMenu() {
	if (document.getElementById('rightnews')) {
		if (document.body.offsetWidth < 1100 && !news) {
			document.getElementById('rightnews').style.display = 'none';
			document.getElementById('ccolumn').style.marginRight = '10px';
		}
		else {
			document.getElementById('rightnews').style.display = '';
			document.getElementById('ccolumn').style.marginRight = '230px';
		}
	}
	if (document.getElementById('Div1')) {
		if (document.getElementById('Div1').style.height.replace('px', '') > getBodyScrollTop() - 225)
			document.getElementById('Div1').style.height = getBodyScrollTop() < 225 ? '0px' : ((getBodyScrollTop() - 225) + 'px');
		document.getElementById('Div1').style.display = document.getElementById('Div1').style.height.replace('px', '') <= 0 ? 'none' : '';
	}
}

function MoveMenu2() {
	document.getElementById('Div1').style.height = getBodyScrollTop() < 225 ? '0px' : ((getBodyScrollTop() - 225) + 'px');
}

/*function RedrawAll(result, context) {
	var params = result.split('|');
	document.getElementById('Left1_tabletrashdiv').innerHTML = params[0];
//	if (params[1].length > 0)
	document.getElementById('Left1_tablelivediv').innerHTML = params[1];
	document.getElementById('Left1_tablesportdiv').innerHTML = params[2];
}*/

var liveIntervalId=window.setInterval(UpdateLive, 3000);
//window.setInterval(RunCounter, 1000);
var chatIntervalId;
var chatsize=100;
var chatsize1=100;
var chatevent='';
var chatdiv='';
var da=[,,];
var da2=[,,];
var chatdivs=[,,];
var news=true;
var chatresult='';
function RunCounter() {
	for (var i = 0; ; i++) {
		da[i] = null;
		if (document.getElementById('counter' + (i + 1).toString()) != null && da[i] != null) {
			da[i].setSeconds(da[i].getSeconds() + 1);
			if (da2[i] == 0)
				document.getElementById('counter' + (i + 1).toString()).innerHTML = (da[i].getHours() * 60 + da[i].getMinutes()) + ':' + (da[i].getSeconds() < 10 ? '0' : '') + da[i].getSeconds();
			else
				document.getElementById('counter' + (i + 1).toString()).innerHTML = da[i].getHours() + ':' + (da[i].getMinutes() < 10 ? '0' : '') + da[i].getMinutes() + ':' + (da[i].getSeconds() < 10 ? '0' : '') + da[i].getSeconds();
		}
		if (da[i] == null)
			break;
	}
}
function getCaretPosition(ctrl) {
	if (document.hasFocus && !document.hasFocus())
		return 0;
	var CaretPos = 0;
	// IE Support
	if (document.selection) {
		ctrl.focus();
		var Sel = document.selection.createRange();
		Sel.moveStart('character', -ctrl.value.length);
		CaretPos = Sel.text.length;
	}
	// Firefox support
	else if (ctrl.selectionStart || ctrl.selectionStart == '0')
		CaretPos = ctrl.selectionStart;
	return CaretPos;
}
function setCaretPosition(ctrl, pos) {
	if (document.hasFocus && !document.hasFocus())
		return;
	if (ctrl.setSelectionRange) {
		ctrl.focus();
		ctrl.setSelectionRange(pos, pos);
	}
	else if (ctrl.createTextRange) {
		var range = ctrl.createTextRange();
		range.collapse(true);
		range.moveEnd('character', pos);
		range.moveStart('character', pos);
		range.select();
	}
}
function SetDivsScroll() {
	for (var i = 1; ; i++) {
		var div = document.getElementById("chatdiv" + i);
		if (!div)
			break;
		if (chatdivs[i] != null && chatdivs[i] != -1)
			div.scrollTop = chatdivs[i];
		else
			div.scrollTop = div.scrollHeight;
	}
}
function LiveReady() {
	$('.button2').click(function () {
		sendmessage($(this).parent().parent().attr("id").substr(4), $(this).parent().parent().prev().find('div').attr('id'), $(this).prev());
	});
	$('.msg').keypress(function (e) {
		if (e.keyCode == 13) {
			$(this).next().click();
			return false;
		}
//		WebForm_FireDefaultButton(e, 'msgbtn' + $(this).attr("id").substr(3)); //return
	});
	$('.c1').click(function (e) {
		openchat('chat' + $(this).parent().attr("id").substr(4), $(this).parent().prev().find('div').attr('id'), e.target); //return
	});
	$('.c2').click(function (e) {
		openwindow(e.target, 'ChatHistory.aspx?id=' + $(this).parent().attr("id").substr(4), 400); //return
	});
}

function RedrawLive2(result, context) {
	for (var i = 1; ; i++) {
		var div = document.getElementById("chatdiv" + i);
		if (!div)
			break;
		chatdivs[i] = -1;
		if (div.scrollTop < div.scrollHeight - 100)
			chatdivs[i] = div.scrollTop;
	}
	livecontent = '';
	var id = null;
	var tmp = '';
	var pos = 0;
	if (document.activeElement) {
		id = document.activeElement.id;
		if (id && id.substr(0, 3) == 'msg' && document.getElementById(id)) {
			tmp = document.getElementById(id).value;
			pos = getCaretPosition(document.getElementById(id));
		}
	}
	document.getElementById('livediv').innerHTML = result;
	if (id && id.substr(0, 3) == 'msg' && document.getElementById(id)) {
		document.getElementById(id).value = tmp;
		setCaretPosition(document.getElementById(id), pos);
	}
	SetDivsScroll();
	news = false;
	LiveReady();
}
function RedrawLive(result, context) {
	if (chatsize >= 100 && chatsize1 >= 100 && livecontent == '1') {
		if (result.length > 0 && document.getElementById('livediv'))
			RedrawLive2(result, context);
	}
	else {
		chatresult = result;
	}
}
function UpdateLive() {
	if (chatsize >= 100 && chatsize1 >= 100) {
		if (document.getElementById('livediv')) {
			livecontent = '1';
			WebForm_MyDoCallback('Left1', '5|', RedrawLive, null, null, true);
		}
	}
}
function openchat(event, div, cell) {
	if (chatsize < 100 || chatsize1 < 100)
		return;
	if (cell)
		highlight(cell, false);
	window.clearInterval(liveIntervalId);
	livecontent = '';
	if (document.getElementById(event).style.display == 'none') {
		chatdiv = div;
		chatsize = 1;
		WebForm_MyDoCallback('Left1', '6|' + event, RedrawLive, null, null, true);
		chatevent = event;
		document.getElementById(chatdiv).style.height = chatsize + 'px';
		document.getElementById(chatevent).style.display = '';
	}
	else {
		chatdiv = div;
		chatsize1 = 1;
		WebForm_MyDoCallback('Left1', '7|' + event, RedrawLive, null, null, true);
		chatevent = event;
	}
	window.clearInterval(chatIntervalId);
	chatIntervalId = window.setInterval(grawchat, 1);
}
function grawchat() {
	if (chatsize < 100) {
		var delta = chatsize < 50 ? chatsize / 5 : ((100 - chatsize) / 5);
		if (delta < 2) delta = 2;
		chatsize += delta;
		document.getElementById(chatdiv).style.height = chatsize + 'px';
		document.getElementById(chatdiv).scrollTop = 1000000;
	}
	else if (chatsize1 < 100) {
		var delta = chatsize1 < 50 ? chatsize1 / 5 : ((100 - chatsize1) / 5);
		if (delta < 2) delta = 2;
		chatsize1 += delta;
		document.getElementById(chatdiv).style.height = (100 - chatsize1) + 'px';
		if (chatsize1 >= 100)
			document.getElementById(chatevent).style.display = 'none';
		document.getElementById(chatdiv).scrollTop = 1000000;
	}
	else {
		window.clearInterval(chatIntervalId);
		if (chatresult.length > 0)
			RedrawLive2(chatresult, '');
		chatresult = '';
		liveIntervalId = window.setInterval(UpdateLive, 3000);
	}
}
function sendmessage(id, div, value) {
	if (value.attr('value').length > 0) {
		livecontent = '1';
		WebForm_MyDoCallback('Left1', '11|' + id + "|" + value.attr('value'), null, null, null, true);
		value.attr('value', '');
		if (document.getElementById('chat' + id).style.display == 'none')
			openchat('chat' + id, div);
	}
}
function PreShowAddCoefs(addrow) {
	if (document.getElementById('addrow' + addrow).style.display == 'none') {
		document.getElementById('add' + addrow).innerHTML = document.getElementById('add' + addrow).innerHTML.replace('+', '-');
		document.getElementById('addrow' + addrow).style.display = '';
	}
	else {
		document.getElementById('add' + addrow).innerHTML = document.getElementById('add' + addrow).innerHTML.replace('-', '+');
		document.getElementById('addrow' + addrow).style.display = 'none';
	}
	WebForm_MyDoCallback('__page', addrow, ShowAddCoefs, null, null, true);
}
function ShowAddCoefs(result, context) {
	var params = result.split('|');
	document.getElementById('addtd' + params[0]).innerHTML = params[1];
}

function login1() {
	WebForm_MyDoCallback('Top1', '1|' + document.getElementById('Top1_TextBoxLogin').value + '|' + document.getElementById('Top1_TextBoxPwd').value, UpdateLogin, null, null, true);
}
function UpdateLogin(result, context) {
	if (result.length > 1) {
		document.getElementById('Top1_logintablediv').innerHTML = result;
		window.setTimeout(function () {
			WebForm_MyDoCallback('Left1', '9|', UpdateLeftLogin, null, null, true);
			WebForm_MyDoCallback('Left1', '0|coef0', RedrawBasket, null, null, true);
			if (document.getElementById('totaacceptbet'))
				WebForm_MyDoCallback('__page', '9|', UpdateTotaAccept, null, null, true);
			if (document.getElementById('livediv')) {
				livecontent = '1';
				WebForm_MyDoCallback('Left1', '5|', RedrawLive, null, null, true);
			}
		}, 10);
	}
	else if (result == '1') {
		document.getElementById('Top1_errortablediv').style.display = '';
	}
	else if (result == '2') {
		document.getElementById('Top1_errortablediv2').style.display = '';
	}
	if (detectIE6()) pngfix();
}
function UpdateTotaAccept(result, context) {
	document.getElementById('totaacceptbet').innerHTML = result;
}

(function ($) {
	$.fn.dropDownBlock = function (options) {
		var defaults = {
			speed: 'fast',
			top: $(this).height(),
			left: 100
		},
		opts = $.extend(defaults, options),
		toggler = $(this),
		block = $(this).next("div");
		toggler.css({ 'outline': 'none' })

		$(document).click(function (e) {
			if (!$(e.target).hasClass("toggler") && !$(e.target).hasClass("paysys"))
				block.fadeOut(opts['speed']);
		});
		toggler.click(function (e) {
			e.preventDefault();
			if (block.is(':visible')) block.fadeOut(opts['speed']);
			else {
				var left = $(this).offset().left + $(this).width();
				if (left + $(this).next("div").width() > $(document).width() - 30)
					left = $(document).width() - 30 - $(this).next("div").width();
				$(this).next("div").css({
					'position': 'absolute',
					'top': ($(this).offset().top + $(this).height()),
					'left': left
				});
				$(this).next("div").fadeIn(opts['speed']);
			}
			this.focus();
		});
		$('.paysys').click(function () {
			block.fadeOut('fast');
		});
	};
})(jQuery);

function Addresses() {
	$('.toggler').dropDownBlock();
	$('.paysys').hover(function () {
		$(this).css('background', 'url(images/green-bg.png) repeat-x bottom #57bd4d');
		$(this).css('color', 'white');
	}, function () {
		$(this).css('background', '');
		$(this).css('color', '');
	});
}

function fixPNG(element) {
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
		var src;

		if (element.tagName == 'IMG') {
			if (/\.png$/.test(element.src)) {
				src = element.src;
				element.src = "/img/blank.gif";
			}
		}
		else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
			if (src) {
				src = src[1];
				element.runtimeStyle.backgroundImage = "none";
			}
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}

function pwdchange() {
	if (document.getElementById('Top1_TextBoxPwd').value.length > 0 && document.getElementById('in'))
		document.getElementById('in').id = 'in1';
	if (document.getElementById('Top1_TextBoxPwd').value.length == 0 && document.getElementById('in1'))
		document.getElementById('in1').id = 'in';
}
function namefocus(dir) {
	if (dir && document.getElementById('Top1_TextBoxLogin').value == document.getElementById('Top1_usernametext').value)
		document.getElementById('Top1_TextBoxLogin').value = '';
	if (!dir && document.getElementById('Top1_TextBoxLogin').value == '')
		document.getElementById('Top1_TextBoxLogin').value = document.getElementById('Top1_usernametext').value;
}
function passfocus(dir) {
	if (dir) {
		document.getElementById('Top1_TextBoxPwd1').style.display = 'none';
		document.getElementById('Top1_TextBoxPwd').style.display = '';
		document.getElementById('Top1_TextBoxPwd').focus();
	}
	if (!dir && document.getElementById('Top1_TextBoxPwd').value == '') {
		document.getElementById('Top1_TextBoxPwd').style.display = 'none';
		document.getElementById('Top1_TextBoxPwd1').style.display = '';
	}
}

function totaselectint(cell, val) {
	if (val) {
		cell.className = 'tot_ch';
		var nums = cell.id.substr(4).split('_');
		var str = document.getElementById('SelectedEvents').value;
		var pos = Number(nums[0]) * 3 + Number(nums[1]);
		str = str.substr(0, pos - 1) + 'v' + str.substr(pos, str.length - pos);
		document.getElementById('SelectedEvents').value = str;
	}
	else {
		cell.className = 'tot';
		var nums = cell.id.substr(4).split('_');
		var str = document.getElementById('SelectedEvents').value;
		var pos = Number(nums[0]) * 3 + Number(nums[1]);
		str = str.substr(0, pos - 1) + ' ' + str.substr(pos, str.length - pos);
		document.getElementById('SelectedEvents').value = str;
	}
}
function totaselect(cell) {
	if (cell.className != 'tot_ch') {
		totaselectint(cell, true);
	}
	else {
		totaselectint(cell, false);
	}
	calculatevariants();
}
function calculatevariants() {
	var str = document.getElementById('SelectedEvents').value;
	var n = 1;
	for (var i = 0; i < str.length; i += 3) {
		var k = 0;
		if (str.charAt(i) == 'v') k++;
		if (str.charAt(i + 1) == 'v') k++;
		if (str.charAt(i + 2) == 'v') k++;
		n *= k;
	}
	document.getElementById('variants').innerHTML = n;
	document.getElementById('minsum').innerHTML = n * 30;
}
function randomselect() {
	for (var i = 0; i < 15; i++) {
		var rnd = Math.floor(Math.random() * 3) + 1;
		for (var k = 1; k <= 3; k++) {
			var cell = document.getElementById("cell" + i + "_" + k)
			totaselectint(cell, k == rnd);
		}
	}
	calculatevariants();
}
function accepttotabet() {
	document.getElementById('button1').disabled = 'disabled';
	document.getElementById('button1').value = document.getElementById('processing').value;
	__doPostBack('button1', '');
}

function detectIE6() {
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		var b_version = navigator.appVersion;
		var re = /\MSIE\s+(\d\.\d\b)/;
		var res = b_version.match(re);
		if (res[1] <= 6)
			return true;
	}
	return false;
}

function pngfix() { var els = document.getElementsByTagName('*'), ip = /\.png/i, al = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='", i = els.length, uels = new Array(), c = 0; while (i-- > 0) { if (els[i].className.match(/unitPng/)) { uels[c] = els[i]; c++; } } if (uels.length == 0) pfx(els); else pfx(uels); function pfx(els) { i = els.length; while (i-- > 0) { var el = els[i], es = el.style, elc = el.currentStyle, elb = elc.backgroundImage; if (el.src && el.src.match(ip) && !es.filter) { es.height = el.height; es.width = el.width; es.filter = al + el.src + "',sizingMethod='crop')"; el.src = clear; } else { if (elb.match(ip)) { var path = elb.split('"'), rep = (elc.backgroundRepeat == 'no-repeat') ? 'crop' : 'scale', elkids = el.getElementsByTagName('*'), j = elkids.length; es.filter = al + path[1] + "',sizingMethod='" + rep + "')"; es.height = el.clientHeight + 'px'; es.backgroundImage = 'none'; if (j != 0) { if (elc.position != "absolute") es.position = 'static'; while (j-- > 0) if (!elkids[j].style.position) elkids[j].style.position = "relative"; } } } } }; };

if (detectIE6()) {
	var clear = "images/clear.gif"; //path to clear.gif
	document.write('<script type="text/javascript" id="ct" defer="defer" src="javascript:void(0)"><\/script>'); var ct = document.getElementById("ct"); ct.onreadystatechange = function () { pngfix() };
}

$(document).ready(function () {
	$(".fade").fadeTo("slow", 0.6);
	$(".fade").hover(function () {
		$(this).fadeTo("slow", 1.0);
	}, function () {
		$(this).fadeTo("slow", 0.6);
	});
});

function check_all(field) {
	for (i = 0; i < field.length; i++) {
		if (field[i].id.substring(0, 3) != 'cbl') {
			if (document.forms['form1'].elements['all'].checked)
				field[i].checked = true;
			else
				field[i].checked = false;
		}
	}
}

function check_all2(field, direction, folder) {
	for (i = 0; i < field.length; i++) {
		if (field[i].id.substring(0, folder.length) == folder) {
			if (direction)
				field[i].checked = true;
			else
				field[i].checked = false;
		}
	}
}
function SelectInterval(select) {
	var height = document.getElementById('GroupsHolder').offsetHeight;
	document.getElementById('GroupsHolder').style.height = height + 'px';
	document.getElementById('GroupsHolder').innerHTML = '<br/>' + document.getElementById('loading').value + '...';
	document.getElementById('all').checked = false;
	WebForm_MyDoCallback('__page', '1|' + document.getElementById(select).value, UpdateLineMenu, null, null, true);
}
function SelectInterval2(select) {
	if (document.getElementById(select).value != '0')
		SelectInterval(select);
}
function UpdateLineMenu(result, context) {
	document.getElementById('GroupsHolder').style.height = '';
	document.getElementById('GroupsHolder').innerHTML = result;
	document.body.style.height = '100%';
}

var savedvalidation = null, currentvalidation = null;
function RegisterValidation() {
	$('.ph_close').click(function () {
		CloseValidation();
	});
	$(window).resize(function () {
		PositionValidation();
	});
	$(window).scroll(function () {
		PositionValidation();
	});
	PositionValidation();
}
function PositionValidation() {
	if ($('.phwrap').is(':visible')) {
		$('.phwrap').css({
			'position': 'absolute',
			'top': 0,
			'left': 0,
			'width': $('.wrapper').width(),
			'height': $('.wrapper').height()
		});
		$('.ph_change').css({
			'position': 'absolute',
			'top': ($(window).height() - $('.ph_change').height() - 50) / 2 + $(document).scrollTop(),
			'left': ($(window).width() - $('.ph_change').width() - 50) / 2 + $(document).scrollLeft()
		});
	}
}
function SavePhone() {
	currentvalidation = 1;
	$('#changephone').css({ 'display': '' });
	$('#changesmson').css({ 'display': 'none' });
	$('#changesmsoff').css({ 'display': 'none' });
	$('#phoneinvalid').css({ 'display': 'none' });
	$('#phonesaved').css({ 'display': 'none' });
	WebForm_MyDoCallback('__page', '1|' + $('#phoneprofile').attr('value') + '|', SMSSent, null, null, true);
	return false;
}
function SaveValidation() {
	currentvalidation = 2;
	savedvalidation = $('#smsvalidationprofile').attr('checked') == true ? false : true;
	$('#changephone').css({ 'display': 'none' });
	$('#changesmson').css({ 'display': savedvalidation ? 'none' : '' });
	$('#changesmsoff').css({ 'display': savedvalidation ? '' : 'none' });
	$('#smsinvalid').css({ 'display': 'none' });
	$('#smssaved').css({ 'display': 'none' });
	$('#phoneinvalid').css({ 'display': 'none' });
	$('#phonesaved').css({ 'display': 'none' });
	WebForm_MyDoCallback('__page', '2|' + $('#smsvalidationprofile').attr('checked') + '|' + $('#phoneprofile').attr('value'), SMSSent, null, null, true);
	return false;
}
function SMSSent(result, context) {
	var params = result.split('|');
	if (params[1])
		$('#' + params[1]).css({ 'display': '' });
	if (params[2])
		$('#' + params[2]).css({ 'display': '' });
	if (params[0] != '1') {
		if (params[0] == '2' && savedvalidation != null) {
			$('#smsvalidationprofile').attr('checked', savedvalidation);
			savedvalidation = null;
		}
		return;
	}
	$('.phwrap').css({'display': ''});
	PositionValidation();
}
function ShowValidation(id) {
	$('#idtovalidate').attr('value', id);
	$('.phwrap').css({ 'display': '' });
	PositionValidation();
}
function SendValidation() {
	var exch = '', current = '';
	if ($('#idtovalidate').length > 0)
		exch = $('#idtovalidate').attr('value');
	if (currentvalidation != null)
		current = currentvalidation;
	WebForm_MyDoCallback('__page', '3|' + $('#validationcode').attr('value') + '|' + exch + '|' + current, ValidationDone, null, null, true);
	return false;
}
function ValidationDone(result, context) {
	var params = result.split('|');
	if (params[0] != '1') {
		$('.ph_err').css({ 'display': '' });
		return;
	}
	savedvalidation = null;
	if (params[1]) {
		$('#' + params[1]).css({ 'display': '' });
		if (params[1] == 'phonesaved')
			savedvalidation = false;
	}
	if ($('#idtovalidate').length > 0) {
		var exch = $('#idtovalidate').attr('value');
		$('#phone' + exch).html('');
	}
	CloseValidation();
}
function CloseValidation() {
	$('.phwrap').css({ 'display': 'none' });
	$('.ph_err').css({ 'display': 'none' });
	if (savedvalidation != null) {
		$('#smsvalidationprofile').attr('checked', savedvalidation);
		savedvalidation = null;
	}
}
