 function showPanorama(flash_name){ 
	var str='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="panorama" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="./img/'+flash_name+'.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="./img/'+flash_name+'.swf" quality="high" bgcolor="#ffffff" width="100%" height="100%" name="panorama" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'; 
	//alert(str);
	document.writeln(str); 
}

function fillTables(contentBlockId,headerNeed,reCellBordered) {
	if(document.getElementsByTagName){
		var items = document.getElementById(contentBlockId).getElementsByTagName("TABLE");
		for(var i=0;i<items.length; i++){
			if (!reCellBordered || (items[i].getAttribute(classFix) && (items[i].getAttribute(classFix)).indexOf("reCellBordered")>0)){
				var nodes = items[i].getElementsByTagName("TR");
				var start = 0;
				if (headerNeed && (nodes[0].getAttribute(classFix)==""  || nodes[0].getAttribute(classFix)==null)){
					nodes[0].setAttribute(classFix,"color_2");
					start = 1;
				}
				for(var j=start;j<nodes.length; j++){
					if (nodes[j].getAttribute(classFix)=="" || nodes[j].getAttribute(classFix)==null){
						nodes[j].setAttribute(classFix,"color_"+(j%2));
					}
				}
			}
		}
	}
}	
 function ScaleBlank(){
	var content_div = document.getElementById("content_div");
	var bodyHeight = document.body.clientHeight - 422;
	var menu_div = document.getElementById("left_column_div");
	var newHeight = Math.max((menu_div.offsetHeight),bodyHeight);
	content_div.style.height = newHeight+"px";
}

/****************формы для подбора по авто********************/
function changeOptionValues(formId,thisSelect){

	var form=document.getElementById(formId);
	var clear=false;// убираем все заполненые значения селектов но не сразу
	var needRequest=true;//флаг запроса, по умолчанию запрос делаем если что нетак выключим
	var needFeildNeed=false;//флаг состояния поиска селекта которому необходимы данные
	var data1 = {action:'getAutoOptionValues','formId':formId};
    for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].tagName=="SELECT"){// проверяем только селекты
			if (form.elements[i].getAttribute("norequest")==1)continue;// ну раз ненать то пропустим
			if(clear && !needFeildNeed){// удаляем все значения селектов зависящих от текущего (если конечно нашли селект которому нужны наши данные)
				form.elements[i].innerHTML='';
				form.elements[i].options[0] = new Option('Выберите','');
			}else{
				if (form.elements[i]==thisSelect){// выбираем следущий селект после текущего(ему мы скормим наши данные)
					data1[form.elements[i].name]=form.elements[i].value;
					if (form.elements[i+1]){// если он вобще есть
						if (form.elements[i+1].getAttribute("norequest")!=1)// и если ему нужен запрос
							data1['feildNeed']=form.elements[i+1].name;
						else{// иначе ну его нафиг этот запрос
							needRequest=false;// чёт нетак нафиг запрос :)
							needFeildNeed=true;// чёт мы потеряли поле для запроса... возьмём первое попавшееся которое можно :)
						}
					}else// нет элемента нет запроса :)
						needRequest=false;

					clear=true;// всё можно стирать всё лишнее...
				}else{//ну раз не текущий то просто берём его значение в запрос
					data1[form.elements[i].name]=form.elements[i].value;
					if (needFeildNeed && form.elements[i].getAttribute("norequest")!=1){// если мы в поисках селекта для запроса и этот селект нам подходит
						data1['feildNeed']=form.elements[i].name;
						needRequest=true;// во ща всё норм запрос мона отправмить :)
						needFeildNeed=false;// раз нашли больше ненадо искать ;)
					}
				}
			}
		}
	}
	if (needRequest)// ну если можно то поехали :)
		(new DEC_HttpRequest()).send(base+'js.php', data1, function (data,formId){addOptions(data,formId);});
}

function addOptions(data,formId){
	var item;
	var items;
	var i;
	for (selectId in data){
		var oSelect=document.getElementById(formId+"_"+selectId);
		if (oSelect){
			items=data[selectId];
			i=1;
			for (item in items){
				oSelect.options[i] = new Option(items[item].value,items[item].value);
				i++;
			}
		}
	}
}

/*переключалка между закладками*/
	function selectBookmark(name,className){
		var firstzacladka=document.getElementById(name);
		firstzacladka.className=className;
		var oDiv=document.getElementById(name+'_'+className);
		var oTmp=false;
		for (var i=1;i<4 ;i++){
			oTmp=document.getElementById(name+'_zakladka'+i);
			if (oTmp) oTmp.style.display="none";
			oTmp=false;
		}
		if (oDiv) 
			oDiv.style.display="block";
		return false;
	}
	
	function changeCheckBox(name){
		var oCheckBox=document.getElementById(name);
		if (oCheckBox)
			oCheckBox.checked=!oCheckBox.checked;
	}

// ........................................................
// Проверка введенных данных
	function checkInputValue(idInput,type){
		var oInput = document.getElementById(idInput);
		var iclass = oInput.getAttribute(classFix);
		var pos = iclass.indexOf("errorfield");
		if(pos>=0){ 
			if(pos==0) oInput.removeAttribute(classFix);
			else			 oInput.setAttribute(classFix,iclass.substr(0,pos-1));
		}
		switch(type){
			case 0: // положительное целое
				if(oInput.value != oInput.value*1 || !(oInput.value>=0)){
					alert("Ошибка заполнения:\nВведите положительное целое число!");
					oInput.value = 0;
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)
						oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else
						oInput.setAttribute(classFix,"errorfield");
					return false;
				}else{
					oInput.value = Math.abs(Math.round(oInput.value));
					return true;
				}
			break;
			case 1: // email
				var re_mail = /([\w\.\-_]+@[\w\.\-_]+)/;
				if(oInput.value.match(re_mail)!=null){
					return true;
				}else{
					alert("Ошибка заполнения:\nВведите email адрес!");
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)
						oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else
						oInput.setAttribute(classFix,"errorfield");
					return false;
				}
			break;
			case 2: // пароли
				var oReInput = document.getElementById("re"+idInput);
				iclass = oReInput.getAttribute(classFix);
				var pos = iclass.indexOf("errorfield");
				if(pos>=0){ 
					if(pos==0)
						oReInput.removeAttribute(classFix);
					else
						oReInput.setAttribute(classFix,iclass.substr(0,pos-1));
				}
				if(oInput.value.length>=3 && oReInput.value==oInput.value){
					return true;
				}else if(oInput.value.length<3){
					alert("Ошибка заполнения:\nСлишком короткий пароль");
					oInput.value = ""; 
					oReInput.value = "";
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)
						oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else
						oInput.setAttribute(classFix,"errorfield");
					if(oReInput.getAttribute(classFix).length>0)
						oReInput.setAttribute(classFix,oReInput.getAttribute(classFix)+" errorfield");
					else
						oReInput.setAttribute(classFix,"errorfield");
					return false;
				}else{
					alert("Ошибка заполнения:\nВведенные пароли не совпадают!");
					oInput.value = ""; 
					oReInput.value = "";
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)
						oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else
						oInput.setAttribute(classFix,"errorfield");
					if(oReInput.getAttribute(classFix).length>0)
						oReInput.setAttribute(classFix,oReInput.getAttribute(classFix)+" errorfield");
					else
						oReInput.setAttribute(classFix,"errorfield");
					return false;
				}
			break;
			default: // не пустое
				if(oInput.value.length>=3){
					return true;
				}else{
					alert("Ошибка заполнения:\nВведите текст!");
					oInput.focus();
					if(oInput.getAttribute(classFix).length>0)
						oInput.setAttribute(classFix,oInput.getAttribute(classFix)+" errorfield");
					else
						oInput.setAttribute(classFix,"errorfield");
					return false;
				}
			break;
		}
	}

//---------------------calendar----------------------
var ns6=document.getElementById&&!document.all
var ie4=document.all

var Selected_Month;
var Selected_Year;
var Current_Date = new Date();
var Current_Month = Current_Date.getMonth();

var Days_in_Month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var Month_Label = new Array('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь');

/*var Current_Year = Current_Date.getYear();
if (Current_Year < 1000)
Current_Year+=1900
*/
var Current_Year = Current_Date.getFullYear();
var Today = Current_Date.getDate();

function Header(Year, Month) {
	if (Month == 1) {
		Days_in_Month[1] = ((Year % 400 == 0) || ((Year % 4 == 0) && (Year % 100 !=0))) ? 29 : 28;
	}
	
	var Header_String = Month_Label[Month] + ' ' + Year;
	return Header_String;
}

function Make_Calendar(Year, Month) {
	var First_Date = new Date(Year, Month, 0);
	var Heading = Header(Year, Month);
	var First_Day = First_Date.getDay();
//	var arrL='<div style="width: 20px;float:left;padding:7px 10px 0px 10px;cursor:pointer;" onClick="Skip(\'-\')"><img src="./img/design/arrL.gif" border="0" alt="" onClick="Skip(\'-\')" style="float:right;"></div>';
//	var arrR='<div style="width: 20px;float:left;padding:7px 10px 0 10px;cursor:pointer;" onClick="Skip(\'+\')"><img src="./img/design/arrR.gif" border="0" alt="" onClick="Skip(\'+\')" style="float:left;"></div>';
	var arrL='<div style="width: 20px;float:left;cursor:pointer;" onClick="Skip(\'-\')">&lt;&lt;</div>';
	var arrR='<div style="width: 20px;float:left;cursor:pointer;" onClick="Skip(\'+\')">&gt;&gt;</div>';
	if (((Days_in_Month[Month] == 31) && (First_Day >= 5)) || ((Days_in_Month[Month] == 30) && (First_Day == 6)))
		var Rows = 6;
	else if ((Days_in_Month[Month] == 28) && (First_Day == 1))
		var Rows = 4;
	else
		var Rows = 5;

	var HTML_String = '<table BORDER=0 CELLSPACING=0 cellpadding=0 class="tCalendar" rules="all">';
	HTML_String += '<tr><th class="calcHeader noBorder" colspan=7 ALIGN="CENTER">'+ arrL +'<span style="float:left;width: 235px;text-align:center;">' + Heading + '</span>'+ arrR +'</th></tr>';
	HTML_String += '<tr><th ALIGN="CENTER" class="noBorderLeft noBorderTop">Пн.</th><th ALIGN="CENTER">Вт.</th><th ALIGN="CENTER">Ср.</th><th ALIGN="CENTER">Чт.</th>';
	HTML_String += '<th ALIGN="CENTER">Пт.</th><th ALIGN="CENTER">Сб.</th><th ALIGN="CENTER">Вс.</th></tr>';
	var Day_Counter = 1;
	var Loop_Counter = 0;
	var tempTime = new Date();
	var styleClass='';
	var noBorderLeft='';
	for (var j = 1; j <= Rows; j++) {
		HTML_String += '<tr ALIGN="left">';
		for (var i = 1; i < 8; i++) {
			noBorderLeft='';
			if (i==1)
				noBorderLeft = " noBorderLeft";
			if ((Loop_Counter >= First_Day) && (Day_Counter <= Days_in_Month[Month])) {
				var tempTime = new Date(Year, Month, Day_Counter);
				styleClass=((Day_Counter == Today) && (Year == Current_Year) && (Month == Current_Month))?'curDay':'';
				if ( Day_Counter>=Today && Day_Counter<(Today+10) && (Year == Current_Year) && (Month == Current_Month))
					HTML_String += '<td class="'+noBorderLeft+'"><a class="'+styleClass+'" href="'+clndrSelf+'?y='+tempTime.getFullYear()+'&m='+((tempTime.getMonth()+1))+'&d='+Day_Counter+'">' + Day_Counter + '</a></td>';
				else
					HTML_String += '<td class="'+noBorderLeft+'">' + Day_Counter + '</td>';

				Day_Counter++; 
			} else
				HTML_String += '<td class="'+noBorderLeft+'"> &nbsp;</td>';
			Loop_Counter++;
		}
		HTML_String += '</tr>';
	}
	HTML_String += '</table>';
	cross_el=ns6? document.getElementById("Calendar") : document.all.Calendar
	cross_el.innerHTML = HTML_String;
}


function Check_Nums() {
	if ((event.keyCode < 48) || (event.keyCode > 57)) {
		return false;
	}
}

function On_Year() {
	var Year = document.when.year.value;
	if (Year.length == 4) {
		Selected_Month = document.when.month.selectedIndex;
		Selected_Year = Year;
		Make_Calendar(Selected_Year, Selected_Month);
	}
}

function On_Month() {
	var Year = document.when.year.value;
	if (Year.length == 4) {
		Selected_Month = document.when.month.selectedIndex;
		Selected_Year = Year;
		Make_Calendar(Selected_Year, Selected_Month);
	}else {
		alert('Please enter a valid year.');
		document.when.year.focus();
	}
}

function Defaults() {
	if (!ie4&&!ns6)
		return
//	var Mid_Screen = Math.round(document.body.clientWidth / 2);
	var oMonth= document.getElementById("month");
	var oYear= document.getElementById("year");
	if (oMonth&&oYear){
		oMonth.selectedIndex = Current_Month;
		oYear.value = Current_Year;
	}
/*	if (document.when.month&&document.when.year){
		document.when.month.selectedIndex = Current_Month;
		document.when.year.value = Current_Year;
	}
*/
	Selected_Month = Current_Month;
	Selected_Year = Current_Year;
	Make_Calendar(Current_Year, Current_Month);
}


function Skip(Direction) {
	if (Direction == '+') {
		if (Selected_Month == 11) {
			Selected_Month = 0;
			Selected_Year++;
		} else {
			Selected_Month++;
		}
	} else {
		if (Selected_Month == 0) {
			Selected_Month = 11;
			Selected_Year--;
		} else {
			Selected_Month--;
		}
	}

	Make_Calendar(Selected_Year, Selected_Month);

	var oMonth= document.getElementById("month");
	var oYear= document.getElementById("year");
	if (oMonth&&oYear){
		oMonth.selectedIndex = Selected_Month;
		oYear.value = Selected_Year;
	}
/*	if (document.when.month&&document.when.year){
		document.when.month.selectedIndex = Selected_Month;
		document.when.year.value = Selected_Year;
	}
*/
}