function providerSelected(code, tp){
$('#send_smsArea').html('');
	val = $('#provider').val();
	data = $.ajax({
	 type: "GET",
	 url: "/os/sms/smspay-sendText/"+code+"/"+val+"/100/"+tp,
	 data: '',
	 async: false
	 }).responseText;
	 $('#send_smsArea').html(data);
}
function selectProvider(){
$('#providerArea').hide();
val = $('#sms_cntry').val();
if (val!=0){
	$("#provider").removeOption(/./);
	 data = $.ajax({
		 type: "GET",
		 url: "/os/sms/smspay-providers/"+val,
		 data: '',
		 async: false
	}).responseText;
	var str=data.split("|");
	pref = str[0];
	k=str.length-1;
	myOptions = new Array();
	myOptions[0]= '---выбрать---';

	for (i=1;i<k;i+=2){
		myOptions[str[i]]= str[i+1];

	}
	$('#provider').addOption(myOptions);
	$('#provider').val(pref);

	$('#providerArea').show();
}

}
setInterval('keepalive()', 60000);
//setInterval('changeLeader()', 15000);

function keepalive(){

data = jQuery.ajax({
	 type: "GET",
	 url: "/keepalive.php",
	 data: "",
	 async: true,
	 success: function(data) {
		ar = data.split(',');
		triggerBlock('lmu', ar[0], true);
		triggerBlock('gbu', ar[1], true);
		triggerBlock('blu', ar[2], true);
	 }
 });


}

function changeLeader(){
jQuery.ajax({
	 type: "GET",
	 url: "/os/leader-get/",
	 data: "",
	 async: true,
	 success: function(data) {
		$('#topLeader').slideUp();
		$('#topLeader').html(data);
		$('#topLeader').slideDown();
	 }
 });
}

function triggerBlock(name, count, showCount){
	if (count!='0'){
		jQuery('#'+name+'mes').attr('style', '');
		if (showCount){
			jQuery('#'+name+'count').html(count);
		}
	}else{
		jQuery('#'+name+'mes').attr('style', 'display:none');
	}

}

function showProfile(to, from){
 src = $('#'+from+'img').attr('src');
 $('#'+to+'img').attr('src', src);
 text = $('#'+from).html();
 $('#'+to).html(text);
 link= $('#'+from+'lnk').attr('href');
 $('#'+to+'imglnk').attr('href', link );
}

function hideLPanel(){
$('#leftPanelB').toggle('slow');
$('#leftPanelS').toggle('slow');
jQuery.ajax({
	 type: "GET",
	 url: "/os/ui-toggleLeft",
	 data: ""
	 });
}
function showLPanel(){
jQuery.ajax({
	 type: "GET",
	 url: "/os/ui-toggleLeft",
	 data: "",
	 success: function(data) {
		document.location.reload();
	 }
	});

}

function showUPhoto(imgLink){
	if (imgLink!=''){
	 $('#usrphoto').attr('src', imgLink);
	}
}

function chatIcons(){
 $('div[@class=i]').each(function(){
	icon = $(this).html();
	if (icon=='in' || icon=='out'){
		$(this).html('<img src="/images/pm/'+icon+'.gif">');
	}
	if(icon=='f') {
		$(this).html('<img src="/images/common/click_me.gif">');
	}

});
}

function chatWindow(){
window.open('/os/Chat-pop','history','resizable=yes,location=no,toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,height=600,width=620,left=250,top=0');
}
changeFunc = function(){
	var country = $("select#country");
	var city = $("select#city");
	var region = $("select#region");

	selectText = this.options[0].text;
	//$("select#city").removeAttr("disabled")
	city.attr("disabled","disabled");
	city.attr("length","1");
	var type = 'region';
	if ($(this).attr('id')=='region'){
		type = 'city';
	}else{
		region.attr("disabled","disabled");
		region.attr("length","1");
	}
	selId = $(this).val();
	tmpStr = grabList(type, selId);
	if (type=='city'){
		city.html(tmpStr);
		city.val(0);
		city.removeAttr('disabled');
	}else{
		if (tmpStr==''){
			tmpStr = grabList('city2', selId);
			city.html(tmpStr);
			city.val(0);
			city.removeAttr('disabled');
		}else{
			region.html(tmpStr);
			region.val(0);
			region.removeAttr('disabled');
		}

	}

}
function grabList(type, selId){
	data = $.ajax({
	 type: "GET",
	 url: "/grab.php",
	 data: "type="+type+"&num="+selId,
	 async: false
	}).responseText;
	var str=data.split(",");
	k=str.length-1;
	tmpStr = '<option value="0" selected>'+selectText+'</option>';
	for (i=0;i<k;i+=2){
		 tmpStr = tmpStr+'<option value="'+str[i]+'">'+str[i+1]+'</option>';
		 //AddOption(str[i], str[i+1], ne);
	}
	if (k==0) return '';
	return tmpStr;
}
