$(document).ready(function(){
	$('input.TfE').focus(function() {
		if($(this).val() == $(this).attr("defaultValue")) $(this).val("");
	});

	$('input.TfE').blur(function() {
		if($(this).val() == "") $(this).val($(this).attr("defaultValue"));
	
	});
	
	$(".box_slide").jCarouselLite({
		auto: 10000,
		speed: 200,
		visible: 1,
		btnGoEvent: "hover",
		btnGo: [".tabs .1", ".tabs .2", ".tabs .3", ".tabs .4"]
	});
	
	$(".box_logo").jCarouselLite({
		auto: 3000,
		speed: 200,
		visible: 4
	});
	
	$("#jDrawer-1").jDrawer();
	
	$("#jDrawer-2").jDrawer();
	
})

function submitlogin(){
	var lgn=$('#i_login').val();
	var pwd=$('#i_pas').val();
	var data = {
		ctrl:'auth',
		cmd:'logon',
		login:lgn,
		password:pwd
		}
	if(lgn!='' && pwd!=''){
		$.get("/ctrl.html",data,function(data){
				window.location='./';
		});
	}
}

hs.graphicsDir = '/_com/highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.fadeInOut = true;
hs.dimmingOpacity = 0.8;
hs.outlineType = 'rounded-white';
hs.captionEval = 'this.thumb.alt';
hs.marginBottom = 105; // make room for the thumbstrip and the controls
hs.numberPosition = 'caption';

// Add the slideshow providing the controlbar and the thumbstrip
hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	overlayOptions: {
		className: 'text-controls',
		position: 'bottom center',
		relativeTo: 'viewport',
		offsetY: -60
	},
	thumbstrip: {
		position: 'bottom center',
		mode: 'horizontal',
		relativeTo: 'viewport'
	}
});

function checkForm(){
	var brand="";
	var redir_str="?";
	$('.brand_check').each(function(i){
	if($(this)[0].checked){
	brand=brand+$(this).attr('id')+",";
	}
	});
	brand=brand.substring(0,brand.length-1);
	if(brand) redir_str="?brand="+brand;
	document.location=redir_str
	}

$(document).ready(function(){
	var Obj = $(this);
	$(".menunav_ul li").hover(function(){
		Obj = $(this);
		Obj.css('color','#FFFFFF');
		Obj.click(function(){
			window.location=Obj.attr("href"); return false;
		})
	},function(){
		Obj.css('color','#BBDFF2');
		})
})

/*Выдача капча*/
function captcha(sParam){
	var oElem=$('#captcha_img');
	if(oElem.length > '0'){
		var sSRC='/ctrl.html?ctrl=captcha&rnd='+Math.round(10000*Math.random());
		if(sParam){
			sSRC+='&cmd='+sParam;
		}
		oElem.attr("src", sSRC);
		var oElem=$('#cap_id');
		if(oElem.length > '0'){
			oElem.value='';
		}
	}
}

/*Проверка регистрационных данных*/
function validateFormSubmitMin(){
	$('.auser_field').css('border','1px solid #D0D0D0');
	var reg_email=/^[-._a-z0-9]+@(?:[a-z0-9][-a-z0-9]+\.)+[a-z]{2,6}$/;
	var reg_icq=/^\d{5,9}$/;
	var reg_phone=/^\d{5,7}$/;
	var reg_code=/^\d{3,5}$/;
	var reg_INN=/^\d{9,12}$/;

	/*Название компании:*/
	if($('#reg_name_company').val() == ''){
		$('#error_log_reg').html('<div>Укажите название компании</div>');
		$('#error_log_reg').show();
		$('#reg_name_company').css('border','1px solid red');
		return false;
	};
	$('#reg_name_company').css('style','');

	/*ИНН:*/
/*	if($('#reg_INN').val() == ''){
		$('#error_log_reg').html('<div>Укажите ИНН</div>');
		$('#error_log_reg').show();
		$('#reg_INN').css('border','1px solid red');
		return false;
	};
	if(!reg_INN.test($('#reg_INN').val())){
		$('#error_log_reg').html('<div>Неверно введен ИНН</div>');
		$('#error_log_reg').show();
		$('#reg_INN').css('border','1px solid red');
		return false;
	}; */
	if($('#reg_INN').val() != ''){
		if(!reg_INN.test($('#reg_INN').val())){
			$('#error_log_reg').html('<div>Неверно введен ИНН</div>');
			$('#error_log_reg').show();
			$('#reg_INN').css('border','1px solid red');
			return false;
		};
	};	
	$('#reg_INN').css('style','');
	
	/*Адрес компании:*/
	if($('#reg_address').val() == ''){
		$('#error_log_reg').html('<div>Укажите адрес компании</div>');
		$('#error_log_reg').show();
		$('#reg_address').css('border','1px solid red');
		return false;
	};
	$('#reg_site_address').css('style','');
	
	/*Контактное лицо:*/
	if($('#reg_contact_men').val() == ''){
		$('#error_log_reg').html('<div>Укажите ФИО контактного лица</div>');
		$('#error_log_reg').show();
		$('#reg_contact_men').css('border','1px solid red');
		return false;
	};
	$('#reg_contact_men').css('style','');
	
	/*Код города:*/
	if($('#reg_code').val() == ''){
		$('#error_log_reg').html('<div>Укажите код города</div>');
		$('#error_log_reg').show();
		$('#reg_code').css('border','1px solid red');
		return false;
	};
	if(!reg_code.test($('#reg_code').val())){
		$('#error_log_reg').html('<div>Неверно введен код города</div>');
		$('#error_log_reg').show();
		$('#reg_code').css('border','1px solid red');
		return false;
	};
	$('#reg_code').css('style','');
	
	/*Телефон:*/
	if($('#reg_phone').val() == ''){
		$('#error_log_reg').html('<div>Укажите телефон</div>');
		$('#error_log_reg').show();
		$('#reg_phone').css('border','1px solid red');
		return false;
	};
	if(!reg_phone.test($('#reg_phone').val())){
		$('#error_log_reg').html('<div>Неверно введен телефон</div>');
		$('#error_log_reg').show();
		$('#reg_phone').css('border','1px solid red');
		return false;
	};
	$('#reg_phone').css('style','');
	
	/* Факс */
	if($('#reg_fax').val() != ''){
		if(!reg_phone.test($('#reg_fax').val())){
			$('#error_log_reg').html('<div>Не верно введен Fax</div>');
			$('#error_log_reg').show();
			$('#reg_fax').css('border','1px solid red');
			return false;
		};
	};
	$('#reg_fax').css('style','');
	
	/* Электронная почта */
	if($('#reg_email').val() == ''){
			$('#error_log_reg').html('<div>Введите Ваш e-mail</div>');
			$('#error_log_reg').show();
			$('#reg_email').css('border','1px solid red');
			return false;
	};
	if(!reg_email.test($('#reg_email').val())){
		$('#error_log_reg').html('<div>Неверно введен e-mail</div>');
		$('#error_log_reg').show();
		$('#reg_email').css('border','1px solid red');
		return false;
	};
	$('#reg_email').css('style','');

/* Индекс */
if($('#reg_post_index').val() != ''){
		if(!reg_phone.test($('#reg_post_index').val())){
			$('#error_log_reg').html('<div>Не верно введен почтовый индекс</div>');
			$('#error_log_reg').show();
			$('#reg_post_index').css('border','1px solid red');
			return false;
		};
	};
	$('#reg_post_index').css('style','');

	/*Введите символы:*/
	if($('#cap_id').val() == ''){
		$('#error_log_reg').html('<div>Введите символы</div>');
		$('#error_log_reg').show();
		$('#cap_id').css('border','1px solid red');
		return false;
	};
};

/*Проверка данных, заполняемых партнером в личном разделе*/
function validateFormSubmit(){

};


/*Редактирование личных данных */
function ChangeFilds(){
	$('.auser_field').each(function(i){
		$(this).attr('readonly', false);
		$(this).css('border', '1px solid #333');
		$(this).css('margin-top', '-3px');
	});
	$('.inpt_txt').each(function(i){
		$(this).attr('readonly', false);
		$(this).css('border', '1px solid #333');
	});
	$('#change_button').each(function(i){
		$(this).attr('disabled', true);
	});
	$('#save_button').each(function(i){
		$(this).attr('disabled', false);
	});
	$('.ui-datepicker-trigger').show();
}

/* Выход из пользователя */
function Quit(){
	window.location='/logout/';
}
