/*$(document).ready(function() { 
//$('div.wrapper').hide(); 
$('a.widgetToggler').toggle(function() { $(this).siblings('div.wrapper').fadeIn('fast'); $('a.widgetToggler').html("Свернуть"); }, function() { $(this).siblings('div.wrapper').fadeOut('fast'); $('a.widgetToggler').html("Разверуть"); return false; 
}); 
});*/


var obj = null;
showTimer = null;
hideTimer = null;

function checkHover() {
	if (obj) {
		obj.find('.info').fadeOut('fast');
	}//if
}//checkHover

function showInfo(objct) {
	if (!obj) {	
	objct.find('.info').css({display:'block',position:'absolute'});
    objct.parent().find('li').css({zIndex:1});
    objct.css({zIndex:2});
    objct.parent().parent().parent().parent().find('.pane').css({zIndex:1});
    objct.parent().parent().parent().css({zIndex:2});
    }
}//showInfo

$(document).ready(function() {
   
   	searchField();
   
	$("a.write_comment").click(function () {
      $("form.commentform").toggle('fast');
      $("#commentButton").css({disabled:"true"});
      return false;
    });//comment button

	$("#paneHolder > div > div > ul > li").hover(function() {
        if (obj) {
			obj.find('.info').fadeOut('fast');
            obj = null;
         } //if
		
		clearTimeout(hideTimer);
         objct=$(this);
      	 showTimer = setTimeout("showInfo(objct)",400);
         

      }, function() {
        // obj = $(this);
        obj= $(this);
        clearTimeout(showTimer);
        hideTimer = setTimeout("checkHover()",400);
          //$(this).next('div').fadeOut('fast');
      });//news popup
      
      
      
      $('#statisticsPane .control a').click(function () {
      	
      	var text = $(this).text();
      	
      	if (text=="Депозиты") {
      		$('#statisticsPane .body').hide();
      		$('#statisticsPane #depositWgt').show();
      		
      	}
      	if (text=="Кредиты") {
      		$('#statisticsPane .body').hide();
      		$('#statisticsPane #creditWgt').show();
       	}
      	if (text=="Каско") {
      		
      		$('#statisticsPane .body').hide();
      		$('#statisticsPane #kaskoWgt').show();
      		
      	}
      	$('#statisticsPane .control a').removeClass('current');
      	$(this).addClass('current');
       	return false;
      });
     
});




function searchField () {
	var s=document.getElementById('s');
	if (s) {
	var DEF_VAL = "поиск";
	var AUTOSAVE_URL = "gde.ua";
	var NUM_RESULTS = 5;
	var isSafari = ((parseInt(navigator.productSub)>=20020000)&&(navigator.vendor.indexOf("Apple Computer")!=-1));
	if (isSafari) {
		s.setAttribute('type', 'search');
		s.setAttribute('placeholder', DEF_VAL);
		s.setAttribute('autosave', AUTOSAVE_URL);
		s.setAttribute('results', NUM_RESULTS);
		s.setAttribute('style', 'position:relative;right:-5px');
	} 
	else {
		s.className="empty";
		s.onfocus = function() { 
			if (this.value==DEF_VAL) {
				this.value = '';
				this.className="";
			}
		};
		s.onblur  = function() { 
			if (this.value=='') {
				this.value = DEF_VAL;
				this.className="empty";
			}
		};
		if (s.value=='') {
			s.value = DEF_VAL;
			s.className="empty";
		}
	}
	}
}
