function showInset (sel_inst) {
//меняем вкладки 	
	all_inst=sel_inst.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('td');
	for(i=0;i<all_inst.length;i++){
		if(all_inst[i].className=='sel') {all_inst[i].className='';	curr_inst_num=i; }
		if(all_inst[i]==sel_inst) sel_inst_num=i;
		
	}
sel_inst.className='sel';
//меняем содержимое		
	all_blk=sel_inst.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('div');
	var all_cntn=[];
	for (j=0;j<all_blk.length;j++) {
		if(all_blk[j].className=='padd'||all_blk[j].className=='padd sel'){ all_cntn.push(all_blk[j]);}
	}	
	all_cntn[curr_inst_num].className='padd';
	all_cntn[sel_inst_num].className='padd sel';

}

//закрыть регионы
var timerID = null;
function closeBlock (obj) {
	clearTimeout(timerID);
	timerID = setTimeout("document.getElementById('regions').style.display = 'none';", 1000);
}







/////////////////

//определения ширины окна броузера
function show() {	

	var w = document.body.clientWidth;	
	if ( w <= 1000 ) {	
		document.getElementById('basebg').style.display = 'none';
		document.getElementById('content').style.width = '100%';	
	}
	else if (w < 1149 && w > 1000) {	
		document.getElementById('basebg').style.display = 'block';
		document.getElementById('content').style.width = '1000px';	
		document.getElementById('basebg').style.marginLeft = '1000px';		
	}
	else {			
		document.getElementById('basebg').style.display = 'block';
		document.getElementById('basebg').style.marginLeft = '87%';	
		document.getElementById('content').style.width = '87%';	
	}	
}

// авторизация
function showLog(obj) {
	if (obj.value == '') { obj.value = 'Логин'; obj.className = 'text'; } 
	else { if (obj.value == 'Логин') { obj.value = ""; obj.className = 'text act'; }	}
}
function showPass(n) {
	if (n == true) {
		document.getElementById('pass1').style.display = 'none';
		document.getElementById('pass2').style.display = 'inline';
		document.getElementById('pass2').focus();
	} else {
		if( document.getElementById('pass2').value == '' ) {
			document.getElementById('pass1').style.display = 'inline';
			document.getElementById('pass2').style.display = 'none';
		}
	}
}
//закрыть регионы
var timerID = null;
function closeBlock (obj) {
	clearTimeout(timerID);
	timerID = setTimeout("document.getElementById('regions').style.display = 'none';", 1500);
}
//
function showPopup (popup1, popup2) {
	if (document.getElementById(popup1).style.display == 'block') 
		document.getElementById(popup1).style.display = 'none';
	else {
		document.getElementById(popup2).style.display = 'none';
		document.getElementById(popup1).style.display = 'block';
	}		
}
function showSearch (spar, cpar) {
	var sel_par = spar.innerHTML;
	var cur_par = document.getElementById(cpar).innerHTML;	
	document.getElementById(cpar).innerHTML = sel_par;
	spar.innerHTML = cur_par;
	if (sel_par == 'Цены туроператоров') {
		document.getElementById('srch1').style.display = 'none';
		document.getElementById('srch2').style.display = 'block';
	}
	if (sel_par == 'Туры от агенств') {
		document.getElementById('srch1').style.display = 'block';
		document.getElementById('srch2').style.display = 'none';
	}
}

function showBlock (blk) {	
	document.getElementById(blk).style.display =	document.getElementById(blk).style.display == 'none' ? 'block' : 'none';
}

function showComm(obj, comm) {
	if (obj.value == '') { obj.value = comm; obj.className = 'text'; } 
	else { if (obj.value == comm) { obj.value = ''; obj.className = 'text act'; }	}
}

// wiki
function replaceSelectedText(obj,code) { 
	obj.focus(); 
	if (document.selection) {
		var s = document.selection.createRange();
		s.text = code + s.text + code;
		s.select();
	}
	else if (typeof(obj.selectionStart)=="number") {
		if (obj.selectionStart!=obj.selectionEnd) {
			var start = obj.selectionStart;
			var end = obj.selectionEnd;
			var t = obj.value.substr(start,end-start);
			var t1 = code + t + code;
			obj.value = obj.value.substr(0,start)+t1+obj.value.substr(end);
			obj.setSelectionRange(end+4,end+4);
		}
		return true;
	}
	return false;
}

function addBookmark(url, title) {
        if (!url) url = location.href;
        if (!title) title = document.title;
        //Gecko
        if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
        //IE4+
        else if (typeof window.external == "object") window.external.AddFavorite(url, title);
        //Opera7+
        else if (window.opera && document.createElement)
        {
                var a = document.createElement('A');
                if (!a) return false; //IF Opera 6
                a.setAttribute('rel','sidebar');
                a.setAttribute('href',url);
                a.setAttribute('title',title);
                a.click();
        }
        else
                alert('Bookmarks not support on your browser.');
}

function hidePopup() {
	if(document.getElementById('ppb1')){document.getElementById('ppb1').style.display='none';}
	if(document.getElementById('ppb2')){document.getElementById('ppb2').style.display='none';}
	if(document.getElementById('ppb3')){document.getElementById('ppb3').style.display='none';}
	if(document.getElementById('ppb4')){document.getElementById('ppb4').style.display='none';}
	if(document.getElementById('ppb5')){document.getElementById('ppb5').style.display='none';}
	if(document.getElementById('ppb6')){document.getElementById('ppb6').style.display='none';}
	if(document.getElementById('ppb7')){document.getElementById('ppb7').style.display='none';}
	if(document.getElementById('ppb8')){document.getElementById('ppb8').style.display='none';}
}

function popup (td) {
	hidePopup();			
    var tag = td.getElementsByTagName('div');
	for (i=0; i<tag.length; i++) {
		if (tag[i].className=='popupblock'){
			tag[i].style.display='block';
			wb=document.getElementsByTagName('body'); w=wb[0].offsetWidth;  
			d=tag[i].offsetLeft;
			if (w<1024) {  
				if(d>900){for (i=0; i<tag.length; i++) {if (tag[i].className=='popupin') {tag[i].style.left='auto'; tag[i].style.right='-80px';}}}
			}
			else if(d>1100){for (i=0; i<tag.length; i++) {if (tag[i].className=='popupin') {tag[i].style.left='auto'; tag[i].style.right='-90px';}}}
					
		}										
	}			
}	