function ch_td(id, t){
	thisCheckBoxes = document.getElementById('all_tables').getElementsByTagName('tr'); 
	for (i = 0; i < thisCheckBoxes.length; i++){	
	fo=thisCheckBoxes[i].id;   
	if (fo.substring(4)=='tab_'+id){
		document.getElementById(fo).style.display=t;
	}
}
}

function mouse_on(obj, name){
obj.className = name;
}

function getAbsolutePos(el)
{
 var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent)
   {
       var tmp = getAbsolutePos(el.offsetParent);
       r.x += tmp.x;
       r.y += tmp.y;
   }
   return r;


}


var temp_obj;

function view_temas(obj){
if (obj==1)
obj_pos=getAbsolutePos(temp_obj);
else {
obj_pos=getAbsolutePos(obj);
temp_obj=obj;
}
var div0=document.getElementById('abs_temas');
if (div0.style.display=="none")
{

div0.innerHTML=document.getElementById('div_temas').innerHTML;
obj_pos.x=obj_pos.x-50;
div0.style.left=obj_pos.x+'px'; 
obj_pos.y=obj_pos.y+12;
div0.style.top=obj_pos.y+'px'; 

div0.style.width=obj_pos.x+'px'; 
div0.style.display="block";
}
}


function hide_temas(){
var div0=document.getElementById('abs_temas');
div0.style.display="none";
}



function view_title(obj, t){
if (t){
obj_pos=getAbsolutePos(obj);

var div0=document.getElementById('div_title');

if (div0.style.display=="none")
{

div0.innerHTML=t;
obj_pos.x=obj_pos.x+20;
div0.style.left=obj_pos.x+'px'; 
obj_pos.y=obj_pos.y+25;
div0.style.top=obj_pos.y+'px'; 
div0.style.display="block";
div0.style.width=(t.length*10)+'px'
}}


}


function hide_title(){
var div0=document.getElementById('div_title');
div0.style.display="none";
}



function colorCitysIS2(){

 var innerHeight_ = window.innerHeight ? window.innerHeight : document.documentElement.offsetHeight;

 var obj = document.getElementById('div_cc_all');
 obj.style.left = ( document.body.clientWidth / 2 - 350  + document.body.scrollLeft) + 'px';
 obj.style.top = ( document.documentElement.scrollTop + innerHeight_ / 2 - obj.clientHeight / 2 + document.body.scrollTop) + 'px';


obj.style.display='block';
return true;
}


function colorCitysIS(id, val, sec, obj){


if (obj.checked)
display='';
else
display='none';
thisCheckBoxes = document.getElementById('all_tables_'+sec).getElementsByTagName('a'); 
	for (i = 0; i < thisCheckBoxes.length; i++){	
	fo=thisCheckBoxes[i].id;   
fo1=fo.substring(0, (id.length+sec.length+1));

		if(fo1==id+'_'+sec){
			document.getElementById(fo).style.display=display;
			}
	}
document.getElementById('div_cc_all').style.display='none';

}


function colorCitys(id, val, obj){



if (obj.checked)
display='';
else
display='none';

if (document.getElementById('contact_region_'+id)){
	document.getElementById('contact_region_'+id).style.display=display;
}

thisCheckBoxes = document.getElementById('all_tables').getElementsByTagName('a'); 
	for (i = 0; i < thisCheckBoxes.length; i++){	
	fo=thisCheckBoxes[i].id;   
fo1=fo.substring(0, (id.length+1));


		if(fo1==id+'_'){
			document.getElementById(fo).style.display=display;
			}
	}
document.getElementById('div_cc_all').style.display='none';

}





function set_table(){
var div0=document.getElementById('all_tables');
if (div0.style.position=="relative"){
div0.style.position="";
div0.style.width="";
thisCheckBoxes = document.getElementById('all_tables').getElementsByTagName('td'); 
	for (i = 0; i < thisCheckBoxes.length; i++){	
	fo=thisCheckBoxes[i].id;   
		if(fo.substring(0, 8)=='date_td_'){
			document.getElementById(fo).style.display='none';
			//alert(fo);
				
			}
	}



}else{
div0.style.position="relative";
div0.style.width="980px";

//div0.style.left="0px";


thisCheckBoxes = document.getElementById('all_tables').getElementsByTagName('td'); 
	for (i = 0; i < thisCheckBoxes.length; i++){	
	fo=thisCheckBoxes[i].id;   
		if(fo.substring(0, 8)=='date_td_'){
			document.getElementById(fo).style.display='';
			//alert(fo);
			
			}
	}



}
}


function ch_tab2(id){

if(document.getElementById('s_'+id).innerHTML=='скрыть список'){
ch_td(id, 'none');
//document.getElementById('tab_'+id).style.display='none'; 
document.getElementById('img_'+id).src="/images/plus.gif";
document.getElementById('s_'+id).innerHTML='раскрыть список'; 
document.getElementById('td_'+id).style.borderBottom=''; 
document.getElementById('td_'+id).style.borderTop='2px solid #ff6d02'; 
}
else{
//document.getElementById('tab_'+id).style.display='';
ch_td(id, '');
document.getElementById('td_'+id).style.borderTop=''; 
document.getElementById('td_'+id).style.borderBottom='2px solid #ff6d02'; 
document.getElementById('img_'+id).src="/images/minus.gif";
document.getElementById('s_'+id).innerHTML='скрыть список'; 
}

}













//Video description
function set_value(obj, for_name, for_id){
	if (obj.value==0) return false;
	
	loadchan(obj.value, for_name, for_id);
	


}

function loadchan(value, for_name, for_id)  
         { 		
          url = 'http://'+location.host+'/bitrix/varka/ocenka/form.php?for_id='+for_id+'&value='+value+'&for_name='+for_name; 		

         if (window.XMLHttpRequest) 
             { 
             req = new XMLHttpRequest(); 
             req.onreadystatechange = processReqChange2; 
             req.open("GET", url, true); 
             req.send(null); 
             } 
         else if (window.ActiveXObject) 
              { 
              req = new ActiveXObject("Microsoft.XMLHTTP"); 
                    if (req) 
                        { 
                        req.onreadystatechange = processReqChange2; 
                        req.open("GET", url, true); 
                        req.send(); 
                        } 
              } 
} 	

  


function processReqChange2() 
         { 

         if (req.readyState == 4) 
             { 
             if (req.status == 200) 
                 { 
                  if(req.responseText) eval(req.responseText);
                 } 
             else 
                 { 
                 alert("Не удалось получить данные:\n" +req.statusText); 
                 } 
} 
} 

function res_out(type, txt) 
{


	if (type==0)	
	alert(txt);
	else {
			if (type==1)
				{
					//document.getElementById("all_ocenka").innerHTML='Спасибо за оценку.';
					document.getElementById("all_rait").innerHTML=txt;
				}
	}
} 
//
 function ImgShw(ID, width, height, alt)
            {
                var scroll = "no";
                var top=0, left=0;
                if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
                if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
                if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
                width = Math.min(width, screen.width-10);
                height = Math.min(height, screen.height-28);
                var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
                wnd.document.write("<html><head>\n");
                wnd.document.write("<"+"script language='JavaScript'>\n");
                wnd.document.write("<!--\n");
                wnd.document.write("function KeyPress()\n");
                wnd.document.write("{\n");
                wnd.document.write("    if(window.event.keyCode == 27)\n");
                wnd.document.write("        window.close();\n");
                wnd.document.write("}\n");
                wnd.document.write("//-->\n");
                wnd.document.write("</"+"script>\n");
                wnd.document.write("<title>"+(alt == ""? "Картинка":alt)+"</title></head>\n");
                wnd.document.write("<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">\n");
                wnd.document.write("<img src=\""+ID+"\" border=\"0\" alt=\""+alt+"\">");
                wnd.document.write("</body>");
                wnd.document.write("</html>");
                wnd.document.close();
            }





//view title
function mouse_on(obj, name){
obj.className = name;
}



function view_title(obj, t){
if (t){
obj_pos=getAbsolutePos(obj);

var div0=document.getElementById('div_title');

if (div0.style.display=="none")
{

div0.innerHTML=t;
obj_pos.x=obj_pos.x+20;
div0.style.left=obj_pos.x+'px'; 
obj_pos.y=obj_pos.y+25;
div0.style.top=obj_pos.y+'px'; 
div0.style.display="block";
}}
}


function hide_title(){
var div0=document.getElementById('div_title');
div0.style.display="none";
}

function getAbsolutePos(el)
{
 var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent)
   {
       var tmp = getAbsolutePos(el.offsetParent);
       r.x += tmp.x;
       r.y += tmp.y;
   }
   return r;


}



//

function colorCitysIS2(){

 var innerHeight_ = window.innerHeight ? window.innerHeight : document.documentElement.offsetHeight;

 var obj = document.getElementById('div_cc_all');
 obj.style.left = ( document.body.clientWidth / 2 - 350  + document.body.scrollLeft) + 'px';
 obj.style.top = ( document.documentElement.scrollTop + innerHeight_ / 2 - obj.clientHeight / 2 + document.body.scrollTop) + 'px';


obj.style.display='block';
return true;
}


function colorCitysIS(id, val, sec, obj){


if (obj.checked)
display='';
else
display='none';
thisCheckBoxes = document.getElementById('all_tables_'+sec).getElementsByTagName('a'); 
	for (i = 0; i < thisCheckBoxes.length; i++){	
	fo=thisCheckBoxes[i].id;   
fo1=fo.substring(0, (id.length+sec.length+1));

		if(fo1==id+'_'+sec){
			document.getElementById(fo).style.display=display;
			}
	}
document.getElementById('div_cc_all').style.display='none';

}










function CheckCity(w, tab, c_n){
var str=''+w;
var len=str.length;
	thisCheckBoxes = document.getElementById('tab_'+tab).getElementsByTagName('div');
	for (i = 0; i < thisCheckBoxes.length; i++){
	fo=thisCheckBoxes[i].id;
	if (fo.substring(0,5)=='city_')
		{
			if (fo.substring(0, (5+len))=='city_'+w)
			document.getElementById(fo).style.display='block';
			else
			document.getElementById(fo).style.display='none';
		}
	
}

document.getElementById('city_name_'+tab).style.display='';
document.getElementById('city_name_'+tab).innerHTML=c_n;


}

function view_citys(obj, id){

obj_pos=getAbsolutePos(obj);

var div0=document.getElementById('citys_'+id);

if (!div0){
alert('Расписание в других городах отсутствует');
return;
}
if (div0.style.display=="none")
{
obj_pos.x=obj_pos.x+5;
div0.style.left=obj_pos.x+'px'; 
obj_pos.y=obj_pos.y+5;
div0.style.top=obj_pos.y+'px'; 
div0.style.width='150px'; 
div0.style.display="block";
}else hide_citys(id);


}

function hide_citys(id){
document.getElementById('citys_'+id).style.display="none";
}

//table highlight
function mouse_on(obj, name){
obj.className = name;
}



function view_title(obj, t){
if (t){
obj_pos=getAbsolutePos(obj);

var div0=document.getElementById('div_title');

if (div0.style.display=="none")
{

div0.innerHTML=t;
obj_pos.x=obj_pos.x+20;
div0.style.left=obj_pos.x+'px'; 
obj_pos.y=obj_pos.y+25;
div0.style.top=obj_pos.y+'px'; 
div0.style.display="block";
}}
}


function hide_title(){
var div0=document.getElementById('div_title');
div0.style.display="none";
}

function getAbsolutePos(el)
{
 var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent)
   {
       var tmp = getAbsolutePos(el.offsetParent);
       r.x += tmp.x;
       r.y += tmp.y;
   }
   return r;


}

function view_zag(obj, id){

obj_pos=getAbsolutePos(obj);

var div0=document.getElementById('div_zag_'+id);

if (div0.style.display=="none")
{



/*div0.style.width='634px'; */


div0.style.display="block";
}

}


function hide_zag(id){
document.getElementById('div_zag_'+id).style.display="none";
}


//

function ch_tab(id){

		if(document.getElementById('tab_'+id).style.display==''){
			
		//	document.getElementById('s_'+id).className=" switch";
			
			
document.getElementById('tab_'+id).style.display='none'; 
document.getElementById('img_'+id).src="/images/plus.gif";
document.getElementById('s_'+id).innerHTML='раскрыть список'; 
document.getElementById('td_'+id).style.borderBottom=''; 
document.getElementById('td_'+id).style.borderTop='2px solid #ff6d02'; 
document.getElementById('count_'+id).style.display=''; 
}
else{
//	document.getElementById('s_'+id).className=document.getElementById('s_'+id).className.replace(new RegExp(" switch\\b"), "");;
document.getElementById('tab_'+id).style.display='';
document.getElementById('td_'+id).style.borderTop=''; 
document.getElementById('td_'+id).style.borderBottom='2px solid #ff6d02'; 

document.getElementById('count_'+id).style.display='none'; 
document.getElementById('img_'+id).src="/images/minus.gif";
document.getElementById('s_'+id).innerHTML='скрыть список'; 
}

}