function print_open(hrf){
	pwin=window.open(hrf, 'win2','status=no,toolbar=no,scrollbars=yes,titlebar=yes,menubar=no,resizable=yes,width=640,height=540,directories=no,location=no');
	pwin.focus();
}

function m8h8y(t1,t2){
 this.location='mailto:'+t1+'@'+t2+'?Subject=Letter%20from%20sp-mebel.ru';
 return false
};

function print_mail(t2,t1){
	document.write("<a href='mailto:[antispam_protected]' onClick='return m8h8y(\"",t1,"\",\"",t2,"\")' title='Наш em@il'>"+t1+'@'+t2+"</a>");
}


var d = document;

function GEByID(id) {
	return d.all ? d.all[id] : d.getElementById(id);
}

function check_form(form){
	var req = new JsHttpRequest();
	value=GEByID(form);	
	req.onreadystatechange = function() { 
		if (req.readyState == 4) {
			//alert(req.responseText);
			if(req.responseJS){
				if (req.responseJS.empty_field != ""){ // то есть есть ошибки
					arr=req.responseJS.empty_field;
					for(i=0; i<arr.length; i++){
						empty_field_css($("#"+arr[i]+"")); 
					}
					alert("Заполните обязательные поля!");
				}
				else{
					//исключение для формы заказа - ответ печатаем здесь
					if(form == 'zakaz_form'){
						req = new JsHttpRequest();
						req.onreadystatechange = function() {
							if (req.readyState == 4) {
							//alert(req.responseText);
								if(req.responseJS){
									$.prompt(req.responseJS.res);
									//$("#zakaz_form").reset();
									$("form")[0].reset();
								} 
							}
						}
						req.open(null, "/modul/scripts/srv_send_form.php", true);
						req.send( {'action': 'send_mail'} );
					}
					//--End
					else
						location.href='/request/';
				}
			}
		}
	}
	req.open(null, "/modul/scripts/check_form.php", false);
	req.send( {'action': 'check_form', 'q': value, 'form': form} ); 
	return;
}

function empty_field_css(obj){
		obj.css("background-color", "#ffe3e3");
		obj.css("border", "solid #f00 1px");
		obj.focus(function () { 
		      obj.css("background-color", "#eee");
			  obj.css("border", "solid #999 1px");
		});
}

jQuery(document).ready(function() {
	$("#mycarousel").jcarousel({
		// Configuration goes here
	});
	$(".jcarousel-container img").click(function() {
		$("#img_big").attr("src", $(this).attr("id"));
	});

});

