jQuery.fn.grayText = function() {

    return this.each(function() {   
      $(this).css('color','#ccc !important');

      $(this).val($(this).attr('title'));
      $(this).focus(function (){
        if ($(this).val()==$(this).attr('title')) {
          $(this).val('');
          $(this).css('color','#000');
        }
      })
      $(this).blur(function (){
        if ($(this).val()=='') {
          $(this).val($(this).attr('title'));
          $(this).css('color','#ccc !important');
        }
      })
    })

}


jQuery.fn.hTitle = function() {
    $('body').prepend("<span id='htitle'></span>");
    $('#htitle').css({'position':'absolute','display':'','z-index':1000});
   return this.each(function() { 
      $(this).hover(function(){
        if ($(this).attr('alt')) {
          $('#htitle').text($(this).attr('alt')); 
          $('#htitle').show(50); 
        } 
      },
      function(){ 
        $('#htitle').hide(50);  
      });
      $(this).mousemove(function(e){
        $('#htitle').css({'left':e.pageX+6, 'top': e.pageY+6});
      })
    })

}


jQuery.fn.tdRuller = function() {
   return this.each(function() { 
      $(this).find('td').hover(function(){
        $(this).parent().find('td').addClass('hover');
      },
      function(){ 
        $(this).parent().find('td').removeClass('hover');  
      });
      $(this).find('td').click(function(){ 
        $(this).parent().parent().find('td').removeClass('select');
        $(this).parent().find('td').addClass('select'); 
      })
    })
}

jQuery.fn.doConfirm = function() {
   return this.each(function() { 
        $(this).click(function(){
               lbl = $(this).attr('title') ? $(this).attr('title')+'?' : 'Вы уверены?';
              if (window.confirm (lbl)) {  
                        return true;
              } else {
                        return false;
              }
        }) 
     })
}

jQuery.fn.doConfirm2 = function() {
   
}


// image preloader
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

// jQuery.preLoadImages("style/images/partner-logistetica-c.gif", "style/images/partner-uridb-c.gif");

function Show_Block(block,number){
	for (i=number-3;i<6;i++){
		$("#block_"+block+"_"+i).css('display','none');
	}
        $("#block_"+block+"_"+number).css('display','block');
                
	for (i=number-3;i<6;i++){
		$("#tab_"+block+"_"+i).removeClass('rounded-box-g');
		$("#tab_"+block+"_"+i).addClass('rounded-box-w');
	}
	$("#tab_"+block+"_"+number).removeClass('rounded-box-w');
	$("#tab_"+block+"_"+number).addClass('rounded-box-g');
}

function set_Cookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function get_Cookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
