/******************************************************************************
                  ____ _ _         _     _  __        _  __
                 / ___(_) |_ _   _| |   (_)/ _| ___  | |/ / ____
                | |   | | __| | | | |   | | |_ / _ \ | ' / |_  /
                | |___| | |_| |_| | |___| |  _|  __/_| . \  / /
                 \____|_|\__|\__, |_____|_|_|  \___(_)_|\_\/___|
                             |___/

          2008-2010 (C) Innovation Group, Astana, Kazakhstan
******************************************************************************/

jQuery(function(){tabs.set_tab('top',set_block_company_top).set_tab('last_company',set_block_company_top).set_slide_right_btn('.slider img.sr',4,'.slider').set_slide_left_btn('.slider img.sl',4,'.slider').start();tabs.set_tab('last_events',set_events_blocks).set_slide_right_btn('.last_events .blocks > .r',3,'.last_events').set_slide_left_btn('.last_events .blocks > .l',3,'.last_events').start();});function set_block_company_top(info){jQuery(tabs.b).each(function(i){var est_link='http://'+info[i].est_subdomain+'.'+TK_PUB_DOMAIN;var full_name=info[i].est_type+' '+info[i].est_name;var b=jQuery(this).children('ul');b.siblings('.company_logo').children('img').attr('src',(info[i].logo?imgs_stat+info[i].logo:imgs+'cats/slider_no_logo.gif')).parent('a').attr('title',full_name).attr('href',est_link);b.children('li').children('.company_name').text(info[i].est_name).attr('title',full_name).attr('href',est_link);b.children('li').children('sup').text(info[i].rank);b.children('.company_town').text(info[i].town_name);b.children('.company_address').text((info[i].address?info[i].address:'&nbsp;'));});}
function set_events_blocks(info){jQuery(tabs.b).each(function(i){var ev_link='http://'+info[i].est_subdomain+'.'+TK_PUB_DOMAIN+'/event/'+info[i].id+'.html';var b=jQuery(this);if(info.length){if(info[i]!=undefined){b.children('p:last').children('a').attr('href',ev_link).text(info[i].event_title);b.children('a').attr('href',ev_link).children('img').attr('src',(info[i].event_image?imgs_stat+info[i].event_image:imgs+'cats/slider_no_image.gif'));b.fadeIn(300);}else{b.hide();}}else{tabs.pages['last_events']=0;}});return false;}
function choose_company_default_town(selec_ted,_reload)
{jQuery.getJSON(CLAjaxPreffix+'/company/get_company_town_list',function(json)
{var str='<select id="company_town_selector"><option value="0">все города</option>';for(var p in json.country)
{str+='<optgroup label="'+json.country[p]+'">';for(var l in json.towns[p])
{str+='<option value="'+l+'"';if(l==selec_ted)str+=' selected="selected"';str+='>'+json.towns[p][l]+'</option>';}
str+='</optgroup>';}
str+='</select>';str+=' <input type="button" onclick="return On_town_choose_save('+_reload+');" value=" Выбрать " id="company_town_select_button"/>';jQuery('#company_town_selector_container').html(str);json=null;});return false;}
function On_town_choose_save(_reload)
{jQuery.getJSON(CLAjaxPreffix+'/company/set_company_town_list?t='+SelectBox.GetSelectedValue('company_town_selector'),function(json)
{jQuery('#company_town_selector_container').html('<a href="" onclick="return choose_company_default_town('+SelectBox.GetSelectedValue('company_town_selector')+', '+_reload+');">'+SelectBox.GetSelectedText('company_town_selector')+'</a>');if(_reload)window.location.href=window.location.href;});};function ShowHelp()
{jQuery.msgbox().show('Как добавить свою компанию?',jQuery('#company_help').html());return false;}