﻿	function check_lotus()
	{ 
		createRequest();
 		str = "";
		var fio 		= gE('fio');
		var nick 		= gE('nick');
		var account 	= gE('account');
		var email 		= gE('email');
		
		var c_fio = c_nick = c_account = c_email = false;
		
		if (lang!="ru")
		{
			if (strlen(fio.value) < 4) 		{ str +='You have to input your name with al least 4 characters\n'; c_fio=true;}
			if (!strlen(account.value) || !IsNumeric(account.value))  	{	str +='You have entered wrong account format\n'; c_account=true;}
			if (!strlen(email.value) || !ValidateEmail(email.value)) 		{	str +='You provoded wrong email format\n'; c_email=true;}
			if (strlen(nick.value) < 4)		{ str +='You have to input your nick with al least 4 characters\n'; c_nick=true;}
		}
		else
		{
			if (strlen(fio.value) < 4) 									{str +='Фамилия должна содержать минимум 4 символа\n'; c_fio=true;}
			if (!strlen(account.value) || !IsNumeric(account.value))  	{str +='Неправильный формат номера счета\n'; c_account=true;}
			if (!strlen(email.value) || !ValidateEmail(email.value)) 	{str +='E-mail имеет неверный формат\n'; c_email=true;}
			if (strlen(nick.value) < 4)									{str +='Ник должен содержать минимум 4 символа\n'; c_nick=true;}
		}
		if (strlen(str)) 
		{
			alert(str);
			if (c_fio) fio.className = "contest_error"; else fio.className="contest_offer_input";
			if (c_email) email.className = "contest_error"; else email.className="contest_offer_input";
			if (c_account) account.className = "contest_error"; else account.className="contest_offer_input";
			if (c_nick) nick.className = "contest_error"; else nick.className="contest_offer_input";
			return false;
		}
		else
		{	
			switchStyle ("myform", "myloading");
			resetClass();

			var url = "/contest/mirror.php?action="+escape("https://secure.instaforex.com/php/etc/lotus_contest.php?account="+escape(account.value)+"&email="+escape(email.value)
			+"&fio="+encodeURIComponent(fio.value)+"&nick="+encodeURIComponent(nick.value)+"&lang="+escape(lang)+"&ie="+isIE6);
			
			if (xhr) 
			{
				xhr.onreadystatechange = updateHummer;
				xhr.open("GET", url, true);
				xhr.send(null);
			}
			else 
			{
				alert("Sorry, but I couldn't create an XMLHttpRequest");
			}
		}
	}

	function check_contest(lang)
	{
		createRequest();

		contest_errors = new Array();
		str = "";
		var fio 		= gE('fio');
		var nick 		= gE('nick');
		var account 	= gE('account');
		var email 		= gE('email');
		var leverage 	= gE('leverage');
		var swap 		= gE('swapfree');
		
		var c_fio = c_nick = c_account = c_email = false;
		
		if (lang == "ru")
		{
			if (strlen(fio.value) < 4) 		{ str +='Фамилия должна содержать минимум 4 символа\n'; c_fio=true;			}
			if (!strlen(account.value) || !IsNumeric(account.value))  	{	str +='Неправильный формат номера счета\n'; c_account=true; 					}
			if (!strlen(email.value) || !ValidateEmail(email.value)) 		{	str +='E-mail имеет неверный формат\n'; c_email=true; 	}
			if (strlen(nick.value) < 4)		{ str +='Ник должен содержать минимум 4 символа\n'; c_nick=true; 		}
			if (leverage.selectedIndex==0) {str +='Выберите нужное плечо\n';}
		}
		else
		{
			if (strlen(fio.value) < 4) 		{ str +='You have to input your name with al least 4 characters\n'; c_fio=true;			}
			if (!strlen(account.value) || !IsNumeric(account.value))  	{	str +='You have entered wrong account format\n'; c_account=true; 					}
			if (!strlen(email.value) || !ValidateEmail(email.value)) 		{	str +='You provoded wrong email format\n'; c_email=true; 	}
			if (strlen(nick.value) < 4)		{ str +='You have to input your nick with al least 4 characters\n'; c_nick=true; 		}
			if (leverage.selectedIndex==0) {str +='You have to select preferred leverage\n';}
		}
		if (strlen(str))
		{
			alert(str);
			if (c_fio) fio.className = "contest_error"; else fio.className="contest_offer_input";
			if (c_email) email.className = "contest_error"; else email.className="contest_offer_input";
			if (c_account) account.className = "contest_error"; else account.className="contest_offer_input";
			if (c_nick) nick.className = "contest_error"; else nick.className="contest_offer_input";
			return false;
		}
		else
		{	 
			switchStyle ("myform", "myloading");
			resetClass();
			
			var url = "http://instaforex.com/contest/mirror.php?action="+escape("https://secure.instaforex.com/php/etc/contest.php?account=")+escape(account.value)+"&email="+escape(email.value)+"&lev="+escape(leverage.value)+"&swap="+escape(swap.checked);
			
			if (xhr) 
			{
				xhr.onreadystatechange = updatePage;
				xhr.open("GET", url, true);
				xhr.send(null);
			}
			else 
			{
				alert("Sorry, but I couldn't create an XMLHttpRequest");
			}
		}
	}
	
	function check_hummer()
	{
		createRequest();

		str = "";
		var fio 		= gE('fio');
		var nick 		= gE('nick');
		var account 	= gE('account');
		var email 		= gE('email');
		
		var c_fio = c_nick = c_account = c_email = false;
		
		if (lang!="ru")
		{
			if (strlen(fio.value) < 4) 		{ str +='You have to input your name with al least 4 characters\n'; c_fio=true;			}
			if (!strlen(account.value) || !IsNumeric(account.value))  	{	str +='You have entered wrong account format\n'; c_account=true; 					}
			if (!strlen(email.value) || !ValidateEmail(email.value)) 		{	str +='You provoded wrong email format\n'; c_email=true; 	}
			if (strlen(nick.value) < 4)		{ str +='You have to input your nick with al least 4 characters\n'; c_nick=true; 		}
		}
		else
		{
			if (strlen(fio.value) < 4) 									{str +='Фамилия должна содержать минимум 4 символа\n'; c_fio=true;			}
			if (!strlen(account.value) || !IsNumeric(account.value))  	{str +='Неправильный формат номера счета\n'; c_account=true; 					}
			if (!strlen(email.value) || !ValidateEmail(email.value)) 	{str +='E-mail имеет неверный формат\n'; c_email=true; 	}
			if (strlen(nick.value) < 4)									{str +='Ник должен содержать минимум 4 символа\n'; c_nick=true; 		}
		}
		if (strlen(str)) 
		{
			alert(str);
			if (c_fio) fio.className = "contest_error"; else fio.className="contest_offer_input";
			if (c_email) email.className = "contest_error"; else email.className="contest_offer_input";
			if (c_account) account.className = "contest_error"; else account.className="contest_offer_input";
			if (c_nick) nick.className = "contest_error"; else nick.className="contest_offer_input";
			return false;
		}
		else
		{	
			switchStyle ("myform", "myloading");
			resetClass();

			var url = "/contest/mirror.php?action="+escape("https://secure.instaforex.com/php/etc/hummer_contest.php?account="+escape(account.value)+"&email="+escape(email.value)
			+"&fio="+encodeURIComponent(fio.value)+"&nick="+encodeURIComponent(nick.value)+"&lang="+escape(lang)+"&ie="+isIE6);
			
			if (xhr) 
			{
				xhr.onreadystatechange = updateHummer;
				xhr.open("GET", url, true);
				xhr.send(null);
			}
			else 
			{
				alert("Sorry, but I couldn't create an XMLHttpRequest");
			}
		}
	}

	function updateHummer() 
	{	
		if (xhr.readyState == 4) 
		{
			if (xhr.status == 200) 
			{	
				if (xhr.responseText) 
				{
					var res = xhr.responseText;
					if (res.indexOf("ok")> -1)
					{
						res = res.replace("ok","");
						gE('myform').style.display="none";
						gE('myloading').style.display="none";
						gE('offer_panel').style.display="none";
						var ok = gE('ok');
						str +=res;
						ok.innerHTML = str;
						Appear("ok");
					}
					else
					{
						switchStyle ("myform", "myloading");
						alert(res);
					}
				}
			}
			else 
			{
				//alert("There was a problem with the request " + xhr.status);
			}
		}
	}

	function updatePage() 
	{	
		if (xhr.readyState == 4) 
		{
			if (xhr.status == 200) 
			{	
				if (xhr.responseText) 
				{
					var res = xhr.responseText;
					if (res.indexOf("ok")> -1)
					{
						gE('myform').style.display="none";
						gE('myloading').style.display="none";
						res = res.replace("ok","");
						
						var ok = gE('ok');
						if (res.indexOf("ru") > -1)
						{
							res = res.replace("ru","");
							str = "<p class='contest_reg' \">Успешная регистрация!</p>";
						}
						else str = "<p class='contest_reg' \">Registration successfull!</p>";
					
						str +=res;
						ok.innerHTML = str;
						Appear("ok");
					}
					else
					{
						switchStyle ("myform", "myloading");
						alert(res);
					}
				}
			}
			else 
			{
				//alert("There was a problem with the request " + xhr.status);
			}
		}
	}

	//------------------------------------------------------------------//

	function Check_Contest_Form(lang, account, idContest)
	{	
		var response = "";
		if (lang=="ru")
			if (account=="") response = encodeURIComponent("Пожалуйста, введите номер счета или ник");		
		else
			if (account=="") response = encodeURIComponent("Please, provide your account or nickname!");
		return response;
	}

	function getCheckedRadio(radio)
	{
		var group = gN(radio);
		for (var i=0;i<group.length;i++)
		{
			if (group[i].checked) return group[i].id;
		}
		return false;
	}

	function get_contest(q, p, sType, sDir) 
	{
		
		var isSearch	=	(q=="search");
		var sType		=	!isset(sType)?'default':sType;
		var sDir 		=	!isset(sDir)?'default':sDir;
		cntContest  	=	cntContest?cntContest:1;
		idContest		=	!isset(idContest)?cntContest:idContest;
		var p 			=	!isset(p)?1:p;
		var account 	=	gE("account").value;
		account 		=	isSearch?((!strlen(account))?"":escape(Trim(account))):(sType!="default"?q:"all");
		var ssDate		=	!isset(ssDate)?'0':ssDate;
		if (isSearch)
		{
			var q = decodeURIComponent(Check_Contest_Form(lang, account, idContest));
			if (strlen(q))
			{
				alert(q);
				return false;
			}
		}
		createRequest();
		switchStyle("littlelogo", "info");
		
		if (xhr) 
		{
			url = "/contest/search.php?q="+account+"&p="+escape(p)+"&lang="+escape(lang)+"&sType="+sType+"&sDir="+sDir+"&idContest="+idContest+"&cType="+escape(cType)+"&debug="+escape(debug)+"&ssDate="+ssDate;
			xhr.onreadystatechange = find_contest;
			xhr.open("GET", url, true);
			xhr.send(null);
		}	
	}

	function find_contest()
	{
		var res = new Array();
		var div = gE("info");
		if (xhr.readyState == 4) 
		{
			if (xhr.status == 200) 
			{
				switchStyle("littlelogo", "info");
				if (xhr.responseText) 
				{
					var res = xhr.responseText;
					div.innerHTML = res;
					Appear("info2");
				}
			}
		}
	}

	function distance_education()
	{
		str = "";
		var account 		= gE('account');
		var email 			= gE('email');
		var pass 			= gE('pass1');
		var gencode			= gE('gencode');
		
		var c_account = c_email = false;
		
		if (lang!="ru")
		{
			if (!strlen(account.value) || !IsNumeric(account.value))  	{	str +='You have entered wrong account format<br />'; c_account=true; 					}
			if (!strlen(email.value) || !ValidateEmail(email.value)) 	{	str +='You provoded wrong email format<br />'; c_email=true; 	}	
			if (!strlen(pass.value)) 									{	str +='You did not enter the password<br />'; c_email=true; 	}	
		}
		else
		{
			if (!strlen(email.value) || !ValidateEmail(email.value)) 	{	str +='Неправильный формат email<br />'; c_email=true; 	}
			if (!strlen(account.value) || !IsNumeric(account.value))  	{	str +='Неправильный формат номера счета<br />'; c_account=true; 					}
			if (!strlen(pass.value)) 									{	str +='Вы не ввели пароль<br />'; c_email=true; 	}	
			
		}
		if (strlen(str)) 
		{
			
			gE('alert').style.display 		= "block";
			gE('alert_exit').style.display  = "block";
			gE('alert_text').style.display  = "block";
			gE('alert_text').innerHTML	    = str;
			
			if (c_account) account.className = "contest_error"; else account.className="contest_offer_input";
			if (c_email) email.className = "contest_error"; else email.className="contest_offer_input";
			
			return false;
		}
		else
		{	
			gE('alert').style.display 		= "none";
			switchStyle ("myform", "myloading");
			var url = "/mirror.php?code="+gencode.value+"&action="+escape("https://secure.instaforex.com/php/etc/rating.php?pass="+encodeURIComponent(pass.value)+"&account="+encodeURIComponent(account.value)+"&email="+encodeURIComponent(email.value)+"&lang="+encodeURIComponent(lang)+"&ie="+isIE6);
			 
			var answer;
			var oAjax;

			if (window.XMLHttpRequest)
			{
				oAjax = new XMLHttpRequest();
			}
			else if (window.ActiveXObject)
			{
				try 
				{
					oAjax = new ActiveXObject('Msxml2.XMLHTTP');
				} catch (e){}
				try 
				{
					oAjax = new ActiveXObject('Microsoft.XMLHTTP');
				} catch (e){}
			}

			if (oAjax)
			{
				oAjax.onreadystatechange = function()
				{
					if (oAjax.readyState == 4 && oAjax.status == 200) 
					{
						answer = oAjax.responseText;
						
						if(strlen(answer))
						{
							gE('alert').style.display 		= "block";
							gE('alert_exit').style.display  = "block";
							gE('alert_text').innerHTML	    = answer;
							 
							gE('myloading').style.display="none";
							gE('myform').style.display="block";
							
							account.value 		 = '';
							email.value 		 = '';
							pass.value			 = '';
							gencode.value		 = '';
							
						}
						else
						{
							 
						}
						 
					}
				}
				oAjax.open("POST", url, true);
				oAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				oAjax.send('is_ajax=1');
			}
			else
			{
				alert("AJAX not init!");
			}
			
			
			
		}
	}
	function check_pass()
	{
	
	str = "";
	var acc		 = gE('affiliate_account').value;
	var pas		 = gE('affiliate_password').value;
	var cod		 = gE('par_code').value;
	var email	 = gE('email').value;
	
	
		if (!strlen(acc))  				{	str +='You did not fill in the field: Affiliate account<br />';}
		if (!strlen(pas))  				{	str +='You did not fill in the field: Affiliate password<br />';}
		if (!ValidateEmail(email))  	{	str +='Wrong format email<br />';}
		
		
	
	if (strlen(str)) 
	{
		
		gE('error').innerHTML  = str;
		
	}
	else
	{	
		
		document.getElementById('myloading').style.display="";
		document.getElementById('myform').style.display="none";
		
		var url = "/mirror_sem.php?action="+escape("http://bcd4621.instaforex.com/t/test1.php?affiliate_account="+encodeURIComponent(acc)+"&affiliate_password="+encodeURIComponent(pas)+"&par_code="+cod+"&email="+email);
		 
		var answer;
		var oAjax;

		if (window.XMLHttpRequest)
		{
			oAjax = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			try 
			{
				oAjax = new ActiveXObject('Msxml2.XMLHTTP');
			} catch (e){}
			try 
			{
				oAjax = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e){}
		}

		if (oAjax)
		{
			oAjax.onreadystatechange = function()
			{
				if (oAjax.readyState == 4 && oAjax.status == 200) 
				{
					answer = oAjax.responseText;
					
					if(strlen(answer))
					{
						
						switch(parseInt(answer))
						{
							case 1:
							gE('myform').innerHTML = '<h2 style="text-align:center;color:red;border:1px solid red; height:30px;">Thank you for your registration.</h2><br /><br /><br />';
							break;
							case 2:
							gE('error').innerHTML  = 'Your account is already registered';
							break;
							case 3:
							gE('error').innerHTML  = 'Wrong password';
							break;
							case 4:
							gE('error').innerHTML  = 'Wrong account affiliate;';
							break;
						}
						 
						document.getElementById('myloading').style.display="none";
						document.getElementById('myform').style.display="block";
						acc 		= '';
						pas 		= '';
						
					}
					else
					{
						 
					}
					 
				}
			}
			oAjax.open("POST", url, true);
			oAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			oAjax.send('is_ajax=1');
		}
		else
		{
			alert("AJAX not init!");
		}
	}
}
	/**
	 * /contest_search.js
	 */
