function clistShow(id)
{
    var v = $('#'+id);
    if(v.css('display') == 'block')
    {
        v.hide()
    }
    else
    {
        $(".search_res").each(function() {
            $(this).find("div.invisible").hide();
        });
        v.show();
    }
    return false;
}


$(document).ready(function() {
    if($("a.openImg").length > 0){
      $("a.openImg").fancybox();
    }

    });

$(document).ready(function(){

        $('h2.leftcol .header_block').click(function(){

            $(this).parent().parent().parent().children('div.flash_block').slideToggle('slow');

        });

    });
(function($) { 
    $.fn.iqcreativeMenu = function(options) {
        $(this).children("li").each(function(index, the){
            $(the).hover( function() {
                if($(this).children("ul").css("display") == 'block')
                {
                    $(this).children("ul").hide(150);
                }
                else
                {
                    $(this).children("ul").show(150);
                }
            });
        });
    }
})(jQuery);

/** Oh, yeah!
 *  Some strings of useful code will no far from here. 
 */
function ajaxSocial(section,action,p1,p2){
  $.post("/scripts/iqsocial.php", { part: section, act: action, par1:p1,par2:p2  }, function(data){
  if(data=='0'){ alert('Готово!'); location.reload(); }else
  {alert('Упс, что-то пошло не так.');}
  }); return false;
}
//---
function trim_(arg){return arg.replace( /\s+$/g, '').replace( /^\s+/g, '');}
//---
var gray_color = '#929195';
var black_color = '#494f55';
var input_delimiter = '|';
$(document).ready(function() {
  // Creating DatePickers
  // Ex.: <input class='* dp' title='1992' />
  $('input.dp').each(function(){
	$(this).datepicker({dateFormat : "dd.mm.yy",defaultDate: +1, firstDay: 1, yearRange: $(this).attr('title')+":2012", changeMonth: true, changeYear: true, monthNamesShort: ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],prevText:"Назад",nextText:"Вперед",currentText:"Сегодня",monthNames:['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'], dayNames:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"],dayNamesShort:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],dayNamesMin:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"]})
  });
  // Smart input
  // Ex.: <input title='Address' />
  $('input.si').each(function(){
    $(this).blur(function(){ if(trim_($(this).val())==''){ $(this).css('color',gray_color);$(this).val($(this).attr('title'));  } });
	$(this).focus(function(){ if($(this).val()==$(this).attr('title')){ $(this).css('color',black_color);$(this).val('');  } });
    $(this).blur();
  });
  // Places concatenated values into result input (hidden as a rule)
  // <input type=hidden class='ir' id='addr' /> <input class='is' id='addr1'/>
  $('input.ir').each(function(){
    var el_id = $(this).attr('id');
	$('input.is[id^="'+el_id+'"]').each(function(){
	  $(this).change(function(){
	    var temp_val = '';
		$('input.is[id^="'+el_id+'"]').each(function(){
		  if(trim_($(this).val())!=$(this).attr('title')){
		    temp_val += input_delimiter+$(this).val();
		  }else{ temp_val += input_delimiter; }
		});
		$('#'+el_id).val(temp_val);
	  });
	});
  });
  
});

