var request = null;

//подкачка бекграундов
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {
  }

var js={
	id:function(z){return document.getElementById(z);},
	el:{
		r:function(z){return js.id(z).innerHTML;},
		w:function(z,x){js.id(z).innerHTML=x;},
		ax:function(z,x,y){js.id(z).setAttribute(x,y);},
		fx:function(z,x){js.id(z).innerHTML=js.id(x).value;},
		ex:function(z,x){js.id(z).innerHTML=js.id(x).innerHTML;}
	},
	frm:{
		r:function(z){return js.id(z).value;},
		w:function(z,x){js.id(z).value=x;},
		fx:function(z,x){js.id(z).value=js.id(x).value;},
		ex:function(z,x){js.id(z).value=js.id(x).innerHTML;}
	}
}

var aG_DayVar1 = {
	'var1':'act_var1',
	'var2':'act_var2',
	'var3':'act_var3',
	'var4':'act_var4',
	'var5':'act_var5'
};
var aG_DayVar2 = {
	'var1':'act_var1',
	'var2':'act_var2'
};

function that(id){return document.getElementById(id)}
function sub(id,act){that(id).style.display=act;}

function multySub(_ThisEl,_CurrentId,_GlobArr){
	for (var L_Key in _GlobArr){
		if (L_Key == _CurrentId){
			that(_GlobArr[L_Key]).className = 'act_small_link';
			sub(L_Key,'');
		}else{
			that(_GlobArr[L_Key]).className = 'small_link';
			sub(L_Key,'none');
		}
	}
}
//для работы с таблицой
function qorder(_id_, _price_){
	order_str ='КОМПЛЕКСНЫЙ ОБЕД:'+"\n";
	order_date_el = js.id(_id_);
	order_str = order_str + order_date_el.parentNode.previousSibling.innerHTML+"\n\n";
	for(i=0;i<4;i++){
		id = _id_ + '_' + i;
		order_str = order_str + js.el.r(id) + "\n";
	}
	order_str = order_str + "Итого: " + _price_ + " руб.\n";
	zakaziOn('askvop2');
	js.frm.w('order_text', order_str);
}


// остальное

function  cmf_hider(name,id)	{
	el=document.getElementById(name+id);
		if(el.style.display=='none') el.style.display='';
		else el.style.display='none';
}
function sub(id,act){that(id).style.display=act;}
function bg_act(id,act){that(id).style.backgroundPosition=act;}
function subnav(id,act){	var subItem = that(id).firstChild.style;	if(act=='off'){
		subItem.color='#eeeeee';
		subItem.borderBottomWidth="1px";
		subItem.borderBottomStyle="dashed";
		subItem.borderBottomColor="#eeeeee";
	 } else {
		subItem.color='#782421';
		subItem.borderBottom = 'none';
	  }
}

//check forms
function CheckQuestionForm()
{

	if (that('author_name').value == '')
	{
		alert("Не указано имя. "+that('author_name').value);
		return false;
	}

	if (that('author_mail').value == '' ||
		that('author_mail').value.search(/^[0-9a-zA-Z_\-\.]+@[0-9a-zA-Z_\-\.]+\.[a-z]{2,5}$/) == -1)
	{
		alert("Не указан или некорректен адрес электронной почты.");
		return false;
	}

	if (that('author_captcha').value == '')
	{
		alert("Введите текст с картинки");
		return false;
	}

	return true;

}

function CheckOrderForm()
{
	if (that('order_name').value == ''
		|| that('order_mail').value == ''
		|| that('order_phone').value == ''
		|| that('order_text').value == ''
		|| that('order_captcha').value == '')
	{
		alert("Проверте заполненность всех полей");
		return false;
	}

	return true;
}

function CheckSmallQuestForm()
{
	if (that('quick_text').value == '')
	{
		alert("Проверте заполненность вопроса");
		return false;
	}

	return true;
}

function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
xScroll = document.documentElement.scrollWidth;
yScroll = document.documentElement.scrollHeight;
} else { // Explorer Mac…would also work in Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}

var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}

// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}

// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}

return [pageWidth,pageHeight,windowWidth,windowHeight];
}

function zakaziOn(vt){
	var totalHeight;
	that('prozz').style.display = '';
	that(vt).style.display = '';
	totalHeight = getPageSize();
	//that('prozz').style.height = document.getElementsByTagName('body')[0].offsetHeight+'px';
	totalHeight=totalHeight[0]+350;
	that('prozz').style.height = totalHeight+'px';

	//that('prozz').style.display = '';that(vt).style.display = '';
}

function zakaziOFF(tde){
	that('prozz').style.display = 'none';that(tde).style.display = 'none';
}


