

        function makeUserSubscribe(userid) {
            var selected = new Array();
            var checkList = 'sub_topics';

            jQuery("input[name=" + checkList + "]:checked").each(function() {
                selected.push(jQuery(this).val());
            });

            var user_subs = selected.toString();


            var selected1 = new Array();

            jQuery("input[name=" + checkList + "]").each(function() {
                selected1.push(jQuery(this).val());
            });

            var all_subs = selected1.toString();


            xmlHttp=GetXmlHttpObject();
            if (xmlHttp==null)   {
                alert ("Your browser does not support AJAX!");
                return;
            }

            var variations = "userid=" + userid;
                variations = variations + "&user_subs=" + user_subs;
                variations = variations + "&all_subs=" + all_subs;
            var contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
            var url = 'makeUserSubscribe.php';

            xmlHttp.onreadystatechange = makeUserSubscribe_ready;
            xmlHttp.open("POST", url, true);
            xmlHttp.setRequestHeader("Content-Type", contentType);
            xmlHttp.send(variations);
        }

        function makeUserSubscribe_ready() {
            if (xmlHttp.readyState==4) {
            //    document.getElementById('userlist').innerHTML = xmlHttp.responseText;
                alert(xmlHttp.responseText);
            }
        }


	
	function trim(string)  {
		return string.replace(/(^\s+)|(\s+$)/g, "");  
	} // end of function
	
	
	function GetXmlHttpObject() {
		var xmlHttp=null;
		try {
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e) {
			// Internet Explorer
			try	{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}
	
	function changeCountry_New(press_ok,user_agreement) {
		var country_value = document.getElementById('country').value;
		var region = document.getElementById('region');
		var city = document.getElementById('city');

		if (country_value != '-1') {
                        if (country_value == 1) document.getElementById('useragreement').innerHTML = press_ok + '<br><a target=\'_blank\' href=\'index.php?option=com_content&view=article&id=127\'>' + user_agreement + '</a>';
                        else document.getElementById('useragreement').innerHTML = press_ok + '<br><a target=\'_blank\' href=\'index.php?option=com_content&view=article&id=85\'>' + user_agreement + '</a>';
                        
			var countryval='id='+country_value;
			var status = false;
			var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
			var url="custom_files/ajax/getregionlist.php";
			
			xmlHttpc=GetXmlHttpObject();
			if (xmlHttpc==null)   {
				alert ("Your browser does not support AJAX!");
				return;
			}
			xmlHttpc.onreadystatechange=countryChanged_New;
			xmlHttpc.open("post", url, true);
			xmlHttpc.setRequestHeader("Content-Type", contentType);
			xmlHttpc.send(countryval);
			
			document.getElementById('city_row').style.display = 'none';
			document.getElementById('othercity').value = '';
			document.getElementById('hidden_row').style.display = 'table-row';
		}
		else {
                        document.getElementById('useragreement').innerHTML = '';
                        
			region.disabled = 1;
			city.disabled = 1;
			document.getElementById('city_row').style.display = 'none';
			document.getElementById('othercity').value = '';
			document.getElementById('hidden_row').style.display = 'table-row';
		}
	}
	
	function countryChanged_New() {
		var region = document.getElementById('region');
		var city = document.getElementById('city');
		if (xmlHttpc.readyState==4) { 
			region.disabled = 0;
			city.disabled = 1;
			document.getElementById('region_list').innerHTML=xmlHttpc.responseText;
		}
	}

        function set_cookie(name, value, expires)
        {
            if (!expires)
            {
                expires = new Date();
            }
            document.cookie = name + "=" + escape(value) + "; expires=" + expires.toUTCString() + "; path=/";
        }

        function parseGET(){
            str=location.href;
            var GET = Array();
            str = str.split('?');
            str = str[1];
            if (str!=undefined)
            {
                params = str.split('&');
                for (i=0; i<params.length; i++)
                {
                    var keyval = params[i].split('=');
                    GET[keyval[0]]=keyval[1];
                }
                if (GET['ref']==undefined) return ""; else return GET['ref'];
            }
            else return "";
        }

        function ifexistsreferal()
        {
            var ref=parseGET();
            expires = new Date();
            expires.setTime(expires.getTime() + (1000 * 86400));
            if (ref!="") set_cookie('referal', ref, expires);
        }
	
	function changeRegion_New() {
		var region_value = document.getElementById('region').value;
	//	var region = document.getElementById('region');
		var city = document.getElementById('city');
		if (region_value != '-1') {	
			var regionval='id='+region_value;
			var status = false;
			var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
			var url="custom_files/ajax/getcitieslist.php";
			
			xmlHttpc=GetXmlHttpObject();
			if (xmlHttpc==null)   {
				alert ("Your browser does not support AJAX!");
				return;
			}
			xmlHttpc.onreadystatechange=regionChanged_New;
			xmlHttpc.open("post", url, true);
			xmlHttpc.setRequestHeader("Content-Type", contentType);
			xmlHttpc.send(regionval);		
			document.getElementById('city_row').style.display = 'none';
			document.getElementById('othercity').value = '';
			document.getElementById('hidden_row').style.display = 'table-row';
		}
		else {
	//		region.disabled = 1;
			city.disabled = 1;
			document.getElementById('city_row').style.display = 'none';
			document.getElementById('othercity').value = '';
			document.getElementById('hidden_row').style.display = 'table-row';
		}
	}
	
	function regionChanged_New() {
	//	var region = document.getElementById('region');
		if (xmlHttpc.readyState==4) { 
	//		region.disabled = 0;
			document.getElementById('city_list').innerHTML=xmlHttpc.responseText;
		}
	}
	
	function changeCity_New() {
		var city_value = document.getElementById('city').value;
		if (city_value == 'other') {
			document.getElementById('city_row').style.display = 'table-row';
			document.getElementById('hidden_row').style.display = 'none';
		}
		else {
			document.getElementById('city_row').style.display = 'none';
			document.getElementById('othercity').value = '';
			document.getElementById('hidden_row').style.display = 'table-row';		
		}
	}


        function checkLeaderRegisterInputs() {

            var LANG = Get_Cookie('language');
            if (LANG != 'ru' && LANG != 'en') {LANG = 'ru';}

            if (LANG == 'ru') {
                var T_pwd_length = 'Длина пароля должна быть более 5-ти символов';
                var T_pwds_not_match = 'Введённые пароли не совпадают';
                var T_not_city_name = 'Вы не ввели название города';
                var T_not_city = 'Вы не выбрали город';
                var T_not_region = 'Вы не выбрали регион';
                var T_not_country = 'Вы не выбрали страну';
                var T_not_all_fields = 'Вы заполнили не все обязательные поля';
            }
            if (LANG == 'en') {
                var T_pwd_length = 'Your password should be more than 5 characters';
                var T_pwds_not_match = 'Provided passwords does not match';
                var T_not_city_name = 'You did not enter the city name';
                var T_not_city = 'You did not select the city';
                var T_not_region = 'You did not select the region';
                var T_not_country = 'You did not select the country';
                var T_not_all_fields = 'You have not filled all required fields';
            }

		var fio = trim(document.getElementById('fio').value);
		var country = trim(document.getElementById('country').value);
		var region = trim(document.getElementById('region').value);
		var city = trim(document.getElementById('city').value);
		var phone = trim(document.getElementById('phone').value);
		var mail = trim(document.getElementById('mail').value);
	//	var pwd = document.getElementById('pwd').value;
	//	var pwd2 = document.getElementById('pwd2').value;
		var othercity = trim(document.getElementById('othercity').value);
                var currentlogin = trim(document.getElementById('currentlogin').value);
		var code = trim(document.getElementById('code').value);
		var position = trim(document.getElementById('position').value);
		var company = trim(document.getElementById('company').value);
		var actiontype = trim(document.getElementById('actiontype').value);
		var site = trim(document.getElementById('site').value);

		if (fio != '' && phone != '' && mail != '' && code != '') {
			if (country != '-1') {
				if (region != '-1') {
					if (city != '-1') {
						if (city == 'other') {
							if (othercity != '') {
		
								registerNewColeader_New(fio, country, region, city, phone, mail, othercity, code, position, company, actiontype, site, currentlogin);
		
							}
							else {
								alert(T_not_city_name+'!');
							}
						}
						else {

							registerNewColeader_New(fio, country, region, city, phone, mail, othercity, code, position, company, actiontype, site, currentlogin);
		
						}
					} else {
						alert(T_not_city+'!');
					}
				}
				else {
					alert(T_not_region+'!');
				}
			}
			else {
				alert(T_not_country+'!');
			}
		} else {
			alert(T_not_all_fields+'!');
		}
        }

	
	function checkRegisterInputs() {

            var LANG = Get_Cookie('language');
            if (LANG != 'ru' && LANG != 'en') {LANG = 'ru';}

            if (LANG == 'ru') {
                var T_pwd_length = 'Длина пароля должна быть более 5-ти символов';
                var T_pwds_not_match = 'Введённые пароли не совпадают';
                var T_not_city_name = 'Вы не ввели название города';
                var T_not_city = 'Вы не выбрали город';
                var T_not_region = 'Вы не выбрали регион';
                var T_not_country = 'Вы не выбрали страну';
                var T_not_all_fields = 'Вы заполнили не все обязательные поля';
            }
            if (LANG == 'en') {
                var T_pwd_length = 'Your password should be more than 5 characters';
                var T_pwds_not_match = 'Provided passwords does not match';
                var T_not_city_name = 'You did not enter the city name';
                var T_not_city = 'You did not select the city';
                var T_not_region = 'You did not select the region';
                var T_not_country = 'You did not select the country';
                var T_not_all_fields = 'You have not filled all required fields';
            }

		var fio = trim(document.getElementById('fio').value);
		var country = trim(document.getElementById('country').value);
		var region = trim(document.getElementById('region').value);
		var city = trim(document.getElementById('city').value);
		var phone = trim(document.getElementById('phone').value);
		var mail = trim(document.getElementById('mail').value);
		var pwd = document.getElementById('pwd').value;
		var pwd2 = document.getElementById('pwd2').value;
		var othercity = trim(document.getElementById('othercity').value);
		var code = trim(document.getElementById('code').value);
		var position = trim(document.getElementById('position').value);
		var company = trim(document.getElementById('company').value);
		var actiontype = trim(document.getElementById('actiontype').value);
		var site = trim(document.getElementById('site').value);
		
		if (fio != '' && phone != '' && mail != '' && pwd != '' && pwd2 != '' && code != '') {
			if (country != '-1') {
				if (region != '-1') {
					if (city != '-1') {
						if (city == 'other') {
							if (othercity != '') {
								if (pwd == pwd2) {
									if (pwd.length > 5) {
								//		return true;
								//		alert('Good!');
										registerNewUser_New(fio, country, region, city, phone, mail, pwd, othercity, code, position, company, actiontype, site);
									}
									else {
										alert(T_pwd_length+'!');
									}
								}
								else {
									alert(T_pwds_not_match+'!');
								}
							}
							else {
								alert(T_not_city_name+'!');
							}
						}
						else {
							if (pwd == pwd2) {
								if (pwd.length > 5) {
							//		return true;
							//		alert('Good!');
									registerNewUser_New(fio, country, region, city, phone, mail, pwd, othercity, code, position, company, actiontype, site);
								}
								else {
									alert(T_pwd_length+'!');
								}
							}
							else {
								alert(T_pwds_not_match+'!');
							}
						}
					} else {
						alert(T_not_city+'!');
					}								
				}
				else {
					alert(T_not_region+'!');
				}
			}
			else {
				alert(T_not_country+'!');
			}
		} else {
			alert(T_not_all_fields+'!');
		}
	}

        function registerNewColeader_New(fio, country, region, city, phone, mail, othercity, code, position, company, actiontype, site, currentlogin) {
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)   {
			alert ("Your browser does not support AJAX!");
			return;
		}

		var url="custom_files/ajax/registerColeader.php";
		url=url+"?fio="+fio;
		url=url+"&country="+country;
		url=url+"&region="+region;
		url=url+"&city="+city;
		url=url+"&phone="+phone;
		url=url+"&mail="+mail;
		url=url+"&othercity="+othercity;
		url=url+"&code="+code;
		url=url+"&position="+position;
		url=url+"&company="+company;
		url=url+"&actiontype="+actiontype;
                url=url+"&currentlogin="+currentlogin;
		url=url+"&site="+site;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=getRegisteredColeader_New;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	
	function registerNewUser_New(fio, country, region, city, phone, mail, pwd, othercity, code, position, company, actiontype, site) {
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)   {
			alert ("Your browser does not support AJAX!");
			return;
		} 
	
		var path="custom_files/ajax/register.php";
		var url="fio="+fio;
		url=url+"&country="+country;
		url=url+"&region="+region;
		url=url+"&city="+city;
		url=url+"&phone="+phone;
		url=url+"&mail="+mail;
		url=url+"&pwd="+pwd;
		url=url+"&othercity="+othercity;
		url=url+"&code="+code;
		url=url+"&position="+position;
		url=url+"&company="+company;
		url=url+"&actiontype="+actiontype;
		url=url+"&site="+site;
		url=url+"&sid="+Math.random();
		var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
		xmlHttp.onreadystatechange=getRegistered_New;
		xmlHttp.open("POST",path,true);
		xmlHttp.setRequestHeader("Content-Type", contentType);
		xmlHttp.send(url);
	}

        function getRegisteredColeader_New() {

       //     alert(xmlHttp.responseText);

            var LANG = Get_Cookie('language');
            if (LANG == null) {LANG = 'ru';}
            if (LANG == 'ru') {
                var T_busy_email = "<div style='color:red;'>Выбраный e-mail занят</div>";
                var T_incorect_pwd = "<div style='color:red;'>Недопустимые символы в строке пароля</div>";
                var T_wrong_code = "<div style='color:red;'>Неверная сумма чисел</div>";
                var T_wrong_email = "<div style='color:red;'>Неверный формат e-mail</div>";

            }
            if (LANG == 'en') {
                var T_busy_email = "<div style='color:red;'>Provided email already exists</div>";
                var T_incorect_pwd = "<div style='color:red;'>Invalid characters in the password prompt</div>";
                var T_wrong_code = "<div style='color:red;'>Wrong verification code</div>";
                var T_wrong_email = "<div style='color:red;'>Wrong e-mail</div>";

            }

		if (xmlHttp.readyState==4) {
			//alert (xmlHttp.responseText);
			//document.getElementById("formreg").innerHTML=xmlHttp.responseText;
			if (xmlHttp.responseText == "4") {
				document.getElementById('mail_check').innerHTML = T_wrong_email;
				document.getElementById('code_check').innerHTML = '';
			//	document.getElementById('pwd_check').innerHTML = '';
			}
			if (xmlHttp.responseText == "3") {
				document.getElementById('code_check').innerHTML = T_wrong_code;
				document.getElementById('mail_check').innerHTML = '';
			//	document.getElementById('pwd_check').innerHTML = '';
			}
			if (xmlHttp.responseText == "1") {
				document.getElementById('mail_check').innerHTML = T_busy_email;
				document.getElementById('code_check').innerHTML = '';
			//	document.getElementById('pwd_check').innerHTML = '';
			}
			if (xmlHttp.responseText.length > 100) {
				document.getElementById('mail_check').innerHTML = '';
				document.getElementById('code_check').innerHTML = '';
			//	document.getElementById('pwd_check').innerHTML = '';
				document.getElementById('main_register_block').innerHTML = xmlHttp.responseText;
			}
			if (xmlHttp.responseText == "2") {
			//	document.getElementById('pwd_check').innerHTML = T_incorect_pwd;
				document.getElementById('mail_check').innerHTML = '';
				document.getElementById('code_check').innerHTML = '';
			}
		}
	}
	
	function getRegistered_New() {

            //alert(mail);

            var LANG = Get_Cookie('language');
            if (LANG == null) {LANG = 'ru';}
            if (LANG == 'ru') {
                var T_busy_email = "<div style='color:red;'>Выбраный e-mail занят</div>";
                var T_incorect_pwd = "<div style='color:red;'>Недопустимые символы в строке пароля</div>";
                var T_wrong_code = "<div style='color:red;'>Неверная сумма чисел</div>";
                var T_wrong_email = "<div style='color:red;'>Неверный формат e-mail</div>";

            }
            if (LANG == 'en') {
                var T_busy_email = "<div style='color:red;'>Provided email already exists</div>";
                var T_incorect_pwd = "<div style='color:red;'>Invalid characters in the password prompt</div>";
                var T_wrong_code = "<div style='color:red;'>Wrong verification code</div>";
                var T_wrong_email = "<div style='color:red;'>Wrong e-mail</div>";

            }

		if (xmlHttp.readyState==4) { 
			//alert (xmlHttp.responseText);
			//document.getElementById("formreg").innerHTML=xmlHttp.responseText;
			if (xmlHttp.responseText == "d") {
				document.getElementById('mail_check').innerHTML = T_wrong_email;
				document.getElementById('code_check').innerHTML = '';
				document.getElementById('pwd_check').innerHTML = '';
			}
			if (xmlHttp.responseText == "c") {
				document.getElementById('code_check').innerHTML = T_wrong_code;
				document.getElementById('mail_check').innerHTML = '';
				document.getElementById('pwd_check').innerHTML = '';
			}
			if (xmlHttp.responseText == "a") {
				document.getElementById('mail_check').innerHTML = T_busy_email;
				document.getElementById('code_check').innerHTML = '';
				document.getElementById('pwd_check').innerHTML = '';
			}
			if (xmlHttp.responseText!="a" && xmlHttp.responseText!="b" && xmlHttp.responseText!="c" && xmlHttp.responseText!="d") {
				document.getElementById('mail_check').innerHTML = '';
				document.getElementById('code_check').innerHTML = '';
				document.getElementById('pwd_check').innerHTML = '';
				//document.getElementById('main_register_block').innerHTML = xmlHttp.responseText;
				setCookie('registered',xmlHttp.responseText,{expires:1000});
				document.location.href="index.php?option=com_content&id=135&lang=ru";
			}
			if (xmlHttp.responseText == "b") {
				document.getElementById('pwd_check').innerHTML = T_incorect_pwd;
				document.getElementById('mail_check').innerHTML = '';
				document.getElementById('code_check').innerHTML = '';
			}
		}
	}

        function login_new () {

            var LANG = Get_Cookie('language');
            if (LANG == null) {LANG = 'ru';}
            if (LANG == 'ru') {
                var T_empty_login = 'Логин и пароль не могут быть пустыми';
            }
            if (LANG == 'en') {
                var T_empty_login = 'Login and password could not be empty';
            }

		var wlogin=document.getElementById("flogin").value;
		var wpwd=document.getElementById("fpwd").value;
		var wrem=document.getElementById("rem_pwd");
		if (wlogin=='' || wpwd=='') {
			alert (T_empty_login+"!");
		}
		else {
			if (wrem.checked==true) {
				me=1;
				Set_Cookie('login', wlogin, 30, '/', '', '' );
				Set_Cookie('pwd', wpwd, 30, '/', '', '' );
			} // end if
			else {
				me=0;
                                deleteCookie('login');
				deleteCookie('pwd');
			} // end else
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)   {
				alert ("Your browser does not support AJAX!");
				return;
			}
			var url="login.php";
			url=url+"?login="+wlogin;
			url=url+"&pwd="+wpwd;
			url=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange=logged_new;
			xmlHttp.open("GET",url , true);
			xmlHttp.send(null);
		} // end else when login and password are not empty
	}
	
	function logged_new () {

            var LANG = Get_Cookie('language');
            if (LANG == null) {LANG = 'ru';}
            if (LANG == 'ru') {
                var T_wrong = 'Логин или пароль неверны';
            }
            if (LANG == 'en') {
                var T_wrong = 'Wrong login or password';
            }

		var el2=document.getElementById("exit_btn");
		if (xmlHttp.readyState==4) {
			var loged=xmlHttp.responseText;
		//	alert('loged: '+loged);
			loged=trim(loged);                        
			if (loged!=0 || loged=="admin") {
			//	alert(loged);
				if (loged=="admin")	 {
				 //alert ('Inside 2-nd div!');
				//	$('#fpwd').unbind();
				//	$('#flogin').unbind();
                                        loged = SHA1(loged);
                                        setCookie("webinary_username", loged, {expires: 36000});
                                        setCookie("webinary_status", "1", {expires: 36000});
					url="index.php?option=com_content&view=article&id=91&Itemid=84";
					document.location.replace(url);
					el2.style.display="block";
				} // end if loged=="admin"
				else {
                                //        setCookie("name", "123", { expires: 120} )
                                        loged = SHA1(loged);
                                        setCookie("webinary_username", loged, {expires: 36000});
                                        setCookie("webinary_status", "1", {expires: 36000});
					url="index.php?option=com_content&view=article&id=90&Itemid=86";
					document.location.replace(url);
					el2.style.display="block";
				} // end else
			} // end if loged!=0
			else {
				alert (T_wrong+'!');
			}
		} // end if	xmlHttp.readyState==4
	} // end of function
	
		
	function setCookie(name, value, props) {
	    props = props || {};
	    var exp = props.expires;
	    if (typeof exp == "number" && exp) {
	        var d = new Date();
	        d.setTime(d.getTime() + exp*1000);
	        exp = props.expires = d;
	    }
	    if(exp && exp.toUTCString) {props.expires = exp.toUTCString();}

	    value = encodeURIComponent(value);
	    var updatedCookie = name + "=" + value;
	    for(var propName in props){
	        updatedCookie += "; " + propName;
	        var propValue = props[propName];
	        if(propValue !== true){updatedCookie += "=" + propValue;}
	    }
	    document.cookie = updatedCookie;
	}

        function deleteCookie(name) {
	    setCookie(name, null, {expires: -1});
	}

        function Get_Cookie( check_name ) {

			// first we'll split this cookie up into name/value pairs
			// note: document.cookie only returns name=value, not the other components
			var a_all_cookies = document.cookie.split( ';' );
			var a_temp_cookie = '';
			var cookie_name = '';
			var cookie_value = '';
			var b_cookie_found = false; // set boolean t/f default f

			for ( i = 0; i < a_all_cookies.length; i++ ) 	{

				// now we'll split apart each name=value pair
				a_temp_cookie = a_all_cookies[i].split( '=' );


				// and trim left/right whitespace while we're at it
				cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

				// if the extracted name matches passed check_name
				if ( cookie_name == check_name )
				{
					b_cookie_found = true;
					// we need to handle case where cookie has no value but exists (no = sign, that is):
					if ( a_temp_cookie.length > 1 )
					{
						cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
					}
					// note that in cases where cookie is initialized but no value, null is returned
					return cookie_value;
					break;
				}
				a_temp_cookie = null;
				cookie_name = '';
			}
			if ( !b_cookie_found ) 	{

			return null;

			} // end if

		    } // end of function





                function Exit_new () {

		//alert ('ok');
                var LANG = Get_Cookie('language');
                if (LANG != 'ru' && LANG != 'en') {
                    LANG = 'ru';
                }
                if (LANG == 'ru') {
                    var T_shure = 'Вы уверены';
                }
                if (LANG == 'en') {
                    var T_shure = 'Are you sure';
                }

		if (confirm(T_shure+"?")) {


                    deleteCookie('webinary_username');
                    deleteCookie('webinary_status');
                    url="index.php";
                    document.location.replace(url);

	/*	xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)   {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }


		var url="custom_files/ajax/logout.php";
		url=url+"?sid="+Math.random();
		xmlHttp.onreadystatechange=out_new;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);

*/
		} // end if

		} // end of function


/*		function out_new () {

		if (xmlHttp.readyState==4) {

		  url="http://joomla/index.php";
		  document.location.replace(url);

		} // end if */


       function updateUserDataFromCabinet() {
           var id = document.getElementById('id').value;
           var fio = document.getElementById('fio').value;
     //      var city = document.getElementById('city').value;
           var company = document.getElementById('company').value;
           var position = document.getElementById('position').value;
           var phone = document.getElementById('phone').value;
           var payprops = document.getElementById('payprops').value;
           var pwd1 = document.getElementById('pwd1').value;
           var pwd2 = document.getElementById('pwd2').value;




           xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)   {
				alert ("Your browser does not support AJAX!");
				return;
                        }
            var url="id="+id;
		url=url+"&fio="+fio;
       //         url=url+"&city="+city;
                url=url+"&company="+company;
                url=url+"&position="+position;
                url=url+"&phone="+phone;
                url=url+"&payprops="+payprops;
                url=url+"&pwd1="+pwd1;
                url=url+"&pwd2="+pwd2;
		url=url+"&sid="+Math.random();
                var status = false;
                var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
                var path="updateuserdatafromcabinet.php";

		xmlHttp.onreadystatechange=updateuserdatafromcabinet_ready;
		xmlHttp.open("post", path , true);
                xmlHttp.setRequestHeader("Content-Type", contentType);
		xmlHttp.send(url);
       }

            function updateuserdatafromcabinet_ready() {
                if (xmlHttp.readyState==4) {
             //       alert(xmlHttp.responseText);
                    if (xmlHttp.responseText == "Данные успешно изменены!") {
                        url='http://webinary.biz/index.php?option=com_content&view=article&id=90&Itemid=86';
                        document.location.replace(url);
                        alert('Данные успешно изменены!');
                        
                    }
                    if (xmlHttp.responseText == "Your information has been succesfully changed!") {
                        url='http://webinary.biz/index.php?option=com_content&view=article&id=90&Itemid=86';
                        document.location.replace(url);
                        alert('Your information has been succesfully changed!');

                    }
                    if (xmlHttp.responseText == "Вы не заполнили все обязательные поля, либо введенные пароли не совпадают или содержат кирилические символы.") {
                        alert('Вы не заполнили все обязательные поля, либо введенные пароли не совпадают или содержат кирилические символы.');
                    }
                    if (xmlHttp.responseText == "You have not filled all required fields or entered passwords are different or contains cyrillic characters.") {
                        alert('You have not filled all required fields or entered passwords are different or contains cyrillic characters.');
                    }
		}
            } // end of function

            function confirmPayment () {

                if (confirm('Произвети оплату?')) {

                    return true;

                } // end if

                else {

                    return false;
                    
                } // end else


            } // end of function


            function base64_encode(data) {
              var i = 0;
              var keyChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
              var resultStr = "";
              var charCd1, charCd2, charCd3;
              var charEnc1, charEnc2, charEnc3, charEnc4;

              while (i < data.length) {
                charCd1 = data.charCodeAt(i++);
                charCd2 = data.charCodeAt(i++);
                charCd3 = data.charCodeAt(i++);

                charEnc1 = charCd1 >> 2;
                charEnc2 = ((charCd1 & 3) << 4) | (charCd2 >> 4);
                charEnc3 = ((charCd2 & 15) << 2) | (charCd3 >> 6);
                charEnc4 = charCd3 & 63;

                if (isNaN(charCd2)) {
                  charEnc3 = charEnc4 = 64;
                } else if (isNaN(charCd3)) {
                  charEnc4 = 64;
                } else {
                  /***/
                }

                resultStr += keyChars.charAt(charEnc1) + keyChars.charAt(charEnc2) + keyChars.charAt(charEnc3) + keyChars.charAt(charEnc4);
              }

              return resultStr;
            }

            function setLangCookie(language) {
            //    alert(language);
                var forCookie;
                if (language == 'Russian') {
                    forCookie = 'ru';
                }
                if (language == 'English') {
                    forCookie = 'en';
                }
                setCookie('language', forCookie, {expires: 3600000});
            //    setCookie('jfcookie[lang]', forCookie, {expires: 3600000});
            //    alert(forCookie);
            }



	function taxCodexWebinarSubscribe_new() {
		if (xmlHttp.readyState==4) {
			var answer = xmlHttp.responseText;
			if (answer == 1) {
				alert('Формат электронной почты неверный!');
			} else {
				if (answer == 2) {
					alert('В строке пароля содержатся недопустимые символы!');
				} else {
					document.getElementById('taxKodeksSubscribe').innerHTML = answer;
				}
			}
		}
	}



    function taxCodexWebinarSubscribe() {
        	var fio = trim(document.getElementById('fio').value);
		var mail = document.getElementById('mail').value;
		var pwd = document.getElementById('pwd').value;
		var pwd2 = document.getElementById('pwd2').value;
		var question = trim(document.getElementById('question').value);

		if (fio != '' && mail != '' && pwd != '' && pwd2 != '') {
                    if (pwd == pwd2) {
                        if (pwd.length > 5) {
							xmlHttp=GetXmlHttpObject();
							if (xmlHttp==null)   {
								alert ("Your browser does not support AJAX!");
								return;
							}
							var data = "fio="+fio;
								data = data + "&mail="+mail;
								data = data + "&pwd="+pwd;
								data = data + "&question="+question;
								data = data + "&sid="+Math.random();

							var contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
							url="custom_files/ajax/taxcodexwebinarsubscribe.php";
							xmlHttp.onreadystatechange = taxCodexWebinarSubscribe_new;
							xmlHttp.open("POST", url, true);
							xmlHttp.setRequestHeader("Content-Type", contentType);
							xmlHttp.send(data);
							

                        } else {
                            alert('Длина пароля должна быть более 5-ти символов!');
                        }
                    } else {
                        alert('Введённые пароли не совпадают!');
                    }
		} else {
                    alert('Вы не заполнили все обязательные поля!');
		}
    }



        
