$(document).ready(function(){
	$paymentMethod=$("#invisiblePaymentMethod").text();
	if($paymentMethod=="phone")
		$("#tel").click();
	else
		$("#webmoney").click();
	$("#registerForm").submit(function(){
		var log=$("#login").val();
		var ch;
		for(var i=0;i<log.length;i++){
			ch=log[i];
			if(!(
				ch>='a' && ch<='z'
				||ch>='A' && ch<='Z'
				||ch>='0' && ch<='9'
				|| ch=='_'
			)){
				alert('Имя аккаунта может состоять только из букв латинского алфавита, чисел и символа нижнего подчеркивания "_"');
				return false;
			}
		}
		var agree=false;
		var pas1= $("input").filter('[name=password]').eq(0).val();
		var pas2= $("input").filter('[name=password1]').eq(0).val();
		if(pas1!=pas2){alert("Пароли не совпадают.");return false;};
		if(pas1.length<7)
			if(!confirm("Пароль слишком короткий.\n Вы уверены что хотите его использовать?"))return false;
		return true;
	});
});
function doClear(theText) { if (theText.value == theText.defaultValue) { theText.value = "" } }
function doClearP(theText) {
	try{
	if(typeof itIE!='undefined'&&itIE>10)
		return;
		if(typeof itIE!='undefined')
			++itIE;
	if (theText.value == theText.defaultValue) {
		var c=$(theText);
		var t=theText.defaultValue;
		var n=c.attr('name');
		var i=theText.id;
		var top=c.css('top');
		var mLeft=c.css('margin-left');
		c.attr('id','');
		try{
			c.before('<input type="password" style="top:'+top+';margin-left:'+mLeft+';" class="input-234_" value="'+t+'" name="'+n+'" />').prev().val('').focus();
			c.prev().blur(function(){doDefaultP(this);return;}).focus(function(){doClearP(this);return;});
		}
		catch(eee){alert(eee+'\n'+eee)};
		c.remove();
		setTimeout('itIE=0',10);
		//theText.value = ""; $(this).attr('type','password'); 
	}
	}
	catch(eee){alert(eee);};
}
function doDefault(theText) { if (theText.value == "") { theText.value = theText.defaultValue } }
function doDefaultP(theText)  {

	if (theText.value == "") {
		var c=$(theText);
		var t=theText.defaultValue;
		var n=c.attr('name');
		var i=theText.id;
		var top=c.css('top');
		var mLeft=c.css('margin-left');
		c.attr('id','');
		try{
			c.before('<input type="text" style="top:'+top+';margin-left:'+mLeft+';" class="input-234_" value="'+t+'" name="'+n+'" />');
			c.prev().blur(function(){doDefaultP(this)}).focus(function(){doClearP(this)});
		}
		catch(eee){alert(eee+'\n'+eee.name)};
		c.remove();
		//theText.value = ""; $(this).attr('type','password'); 
	}
}
