function bookmark(title, url) 
{
	// хёыш эрчтрэшх ёЄЁрэшЎv эх сvыю ў¬Єъю єърчрэю, тюч№ь¬ь чруюыютюъ Єхъє•хщ ёЄЁрэшЎv
	if (title == undefined)
		title = document.title;

	// Єю цх ёрьюх ш ё URL-юь
	if (url == undefined)
		url = top.location.href;

	if (window.sidebar) {
		// Firefox
		window.sidebar.addPanel(title, url, '');
	} else if (window.opera && window.print) {
		// Opera
		var t = document.createElement('a');
		t.setAttribute('rel', 'sidebar');
		t.setAttribute('href', url);
		t.setAttribute('title', title);
		t.click();
	} else {
		// IE
		window.external.AddFavorite(url, title);
	}
	return false;
}
function changeColor(res,el) 
{
	document.getElementById(el).className= (res.checked ? 'result' : 'bk');
	return true;
}


function rss_form()
{
	this.repeat_select=function(opt)
	{
		var ocount=opt.length;
		for(var j=0;j<ocount;j++)
			if(opt[j].selected)
		return opt[j].text;
	}
 	
	this.show=function(elem,url,innerURL,type)
	{
		var count=elem.length;
		var html='';
		var city='';
		
		for(var i=0;i<count;i++)
		{
			if(elem[i].type=='select-one')
			{ 
					if(('Section_ID_Vacancy'==elem[i].name) || ('Section_ID_Resume'==elem[i].name) || ('Rubrics_ID_Events' == elem[i].name))
					{
						html+=(elem[i].value!=0)?this.repeat_select(elem[i].options):'';
					}
					if(('City_ID_Vacancy'==elem[i].name) || ('City_ID_Resume'==elem[i].name) || ('City_ID_Events'==elem[i].name))
					{
						if(elem[i].value!='00000000000000000000000000000000000')
						{
							city=elem[i].value;
							html+=(html!='')?', ':'';
							html+=this.repeat_select(elem[i].options);
						}
						else
						{
							city='notcity';
							html+='';
						}
					}
			}
		}

		if(city=='notcity' && section_id==0)
		innerURL.innerHTML='<a href="'+url+'rss/last-'+type+'.xml">'+url+'rss/last-'+type+'.xml</a>';			
		else
		innerURL.innerHTML='<a href="'+url+'rss/'+type+'/'+city+'/rub-'+section_id+'.html" >'+url+'rss/'+type+'/'+city+'/rub-'+section_id+'.html';

		document.getElementById('b_path_'+type).innerHTML=html;
	}

	this.set_default=function(url,type,name_button)
	{
		document.getElementById('button_'+type).innerHTML='<input class="postKey" id="rss'+type+'" type="button" value="'+name_button+'">';
		document.getElementById('sa_'+type).innerHTML='<a href="'+url+'rss/last-'+type+'.xml">'+url+'rss/last-'+type+'.xml</a>';
		document.getElementById('a_'+type).style.display=document.getElementById('submit_'+type).style.display='none';
		document.getElementById('b_path_'+type).innerHTML='';
	}
}	

/*ajax main*/
function ajax_component(){
	//!Установка домена
	this.xclose=function(name){
		this.wclose=name;
	}
	this.set_select=function(name){
		this.setselect=name;
		}
	this.set_link=function (res,a_class)
	{
		return ' <a class="'+a_class+'" href="javascript:'+this.setselect+'(\''+res.Page+'\',\''+res.TXT+'\')">'+res.TXT+'</a>';
	}
	this.column=function(num){
		this.scolumn=num;
		}
	this.tables=function(result){
		//alert(document.body.clientWidth);
		count=result.length;
		html='<div class="inner"><table>';
		html+='<tr><td>';
		html+=''+this.set_link(result[0], 'main');
		html+='<br />';
		count2=Math.ceil(count/2)-1;
		for(var i=1;i<count;i++)
		{
			html+=this.set_link(result[i],'item');
			html+='<br />';
			if(count2==i && this.scolumn) html+='</td><td>';
		}

		html+='</td></tr></table></div>';
		return html;
	}
}

	function city_show(name)
	{

//		html = '<div id="city_id" style="display:none"></div>';
		html = '';
		html += '<div id="set_city">' + city_text(name) + '</div> <div class="split"><a href="javascript:select_city()"><img src="/images/split.gif"  alt="" width="9" height="5" /></a></div>';

		document.getElementById('setcity').innerHTML=html;
	}
	
	function section_show(name)
	{

		html = '<div id="section_id" style="display:none"></div>';
		html += '<div id="set_section">' + section_text(name) + '</div> <div class="split"><a href="javascript:select_section()"><img src="/images/split.gif"  alt="" width="9" height="5" /></a></div>'

		document.getElementById('setsection').innerHTML = html;
	}
	
	//!Город поумолчанию
	function city_text(name){
		name = (name=='') ? 'Выберите город' : 'в г. ' + name;
		return '<a href="javascript:select_city()">' + name + '</a>';
	}
	
	//!Рубрика по умолчанию
	function section_text(name){

		/*if(name==''){
		name='Выберите рубрику';	
			}*/
		/*else{
			num=(name.indexOf('/'));
			if(num>0)
			name=name.substr(0,num);
			/*else
			{
					num=(name.indexOf(' '));
					name=name.substr(0,num)+' '+name.substr(num,4)+'.';
			}
		}	*/
		
		return '<a href="javascript:select_section()">'+name+'</a>';
		}

	function select_city()
	{	

		document.getElementById('popup').style.display='block';
		document.getElementById('popup').innerHTML='<div class="label">Выберите город <a class="close" href="javascript:wclose()"><img src="/images/close.gif"/></a> </div><div class="area"><img src="/images/spin.gif" alt="" width="16" height="16" /></div>';


		var list_city = new Subsys_JsHttpRequest_Js();
		var comp_city=new ajax_component();

		
		list_city.onreadystatechange = function() 
		{
			if (list_city.readyState == 4) 
			{
				if (list_city.responseJS) {
					
					comp_city.xclose('wclose');
					comp_city.set_select('set_city');
					comp_city.column(true);
					document.getElementById('popup').innerHTML = '<div class="label">Выберите город <a class="close" href="javascript:wclose()"><img src="/images/close.gif"/></a> </div><div class="area">' + comp_city.tables(list_city.responseJS.result) + '</div>';
					
				}
			}
		}
		
		list_city.open('POST', '/plugins/getcity.php', true);
		list_city.caching=true;
		list_city.send();
	}
	
	function select_section(){
		document.getElementById('popup').style.display='block';
		document.getElementById('popup').innerHTML='<div class="acity"><img src="/images/spin.gif" alt="" width="16" height="16" / ></div>';
		var list_section=new Subsys_JsHttpRequest_Js();
		var comp_section=new ajax_component();
		list_section.onreadystatechange=function(){
			if(list_section.readyState ==4){
				if(list_section.responseJS){
				
				comp_section.xclose('sclose');
				comp_section.set_select('set_section');
				comp_section.column(false);
				document.getElementById('popup').innerHTML=comp_section.tables(list_section.responseJS.result);
				}
			}
		}
		list_section.open('POST','/plugins/getsection.php',true);
		list_section.caching=true;
		list_section.send();
	}
		
	function sclose(){
		document.getElementById('popup').style.display='none';
	}	
	
	function wclose()
	{
			document.getElementById('popup').style.display='none';
	}
	
	//Установка рубрики
	function set_section(page,name_city)
	{
		page=(page=='undefined' || page=='')?0:page;
		set_value_section_form(page);
		set_cookie('Section_ID',page,1000,'/');
		document.getElementById('popup').style.display='none';
		document.getElementById('set_section').innerHTML=(page!='undefined')?section_text(name_city):section_text('');
	}
	
	//Установка в форме поиска рубрики
	function set_value_section_form(id)	{
		
		if(document.fsearch.Section_ID)
			document.fsearch.Section_ID.value=id;
	}

	
	function set_city(page,name_city)
	{
		document.getElementById('popup').style.display='none';
		document.getElementById('set_city').innerHTML=(page!='undefined')?city_text(name_city):city_text('');

		if (page!='undefined' && page!='')
		 document.location='http://'+page+'.'+domain+'/'
		else
			if(document.domain!=domain)
		 		document.location='http://'+domain+'/';
	}
	
	function set_cookie(name, value, expires, path, domain, secure)
	{
		var today = new Date();
		today.setTime( today.getTime() );
		if ( expires )
			expires = expires * 1000 * 60 * 60 * 24;
		var expires_date = new Date( today.getTime() + (expires) );
		document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
	}

	function set_value_city_form(id)
	{
		if(document.fsearch.City_ID)
			document.fsearch.City_ID.value=id;
	}
/*end ajax main*/
