Cufon.set("fontFamily", "Myriad Pro");
Cufon.replace("#top-menu li a, #contact a, .img-heading span", {
    hover: true
});

Cufon.set("fontFamily", "AGLettericaCondensed");
Cufon.replace("#header-bottom h1, #header-bottom h2, #services p");

Cufon.replace(".heading span", {
	textShadow: "0 2px #fff6eb"
});

Cufon.set("fontFamily", "AGLettericaCondensedLight");
Cufon.replace(".img-heading p", {
	textShadow: "0 3px #3a190e"
});

$(function()
{
	$('.portfolio-item a div').mouseover(function(){
    $(this).css({'background-color' : 'rgb(0, 0, 0)', 'opacity' : '0.9'});
	});

	$('.portfolio-item a div').mouseout(function(){
    $(this).css({'background-color' : '', 'opacity': ''});
	});
	
	// Input File
	$('input.file').change(function(){
		var realValue = $(this).val();
		$('.fakefile input').val(realValue);		
	});
	
	// Checkbox
    $(".checkbox input").live("change", function () {
        if ($(this).attr('checked')) {
            $(this).parent().addClass("on");
        }
        else {
            $(this).parent().removeClass("on");
        }
    });

	//Key 

	$('.key').click(function()
  {
    var number = $(this).attr('rel');
    var change = true;

    if(number == 3)
    {
      if($(this).attr('class') == 'key left key2')
      {
        $(this).removeAttr("class").attr("class", "key left key3");

        change = false;
      }
    }

    if(change)
    {
      number = (++number > 3) ? 1 : number;
      $(this).attr('rel', number);

      if ($(this).attr('rel') == 1) {
       $(this).removeClass("key3").removeClass("key2").addClass("key4");
      } else if ($(this).attr('rel') == 2) {
       $(this).removeClass("key4").addClass("key1");
      } else if ($(this).attr('rel') == 3) {
       $(this).removeClass("key1").addClass("key2");
      } else {
       $(this).removeClass("key3").addClass("key4");
      }
    }
	});

	// Radio

	jQuery(".radio input").each(
	/* при загрузке страницы меняем обычные на стильные radio */
	function() {
	     
	     changeRadioStart(jQuery(this));
	     
	});
	
	
	});
	
	
	function changeRadio(el)
	/* 
		функция смены вида и значения radio при клике на контейнер
	*/
	{
	
		var el = el,
			input = el.find("input").eq(0);
		var nm=input.attr("name");
			
		jQuery(".radio input").each(
		
		function() {
	     
			if(jQuery(this).attr("name")==nm)
			{
				jQuery(this).parent().removeClass("on");
			}
		   
		   
		});					  
		
		
		if(el.attr("class").indexOf("disabled")==-1)
		{	
			el.addClass("on");
			input.attr("checked", true);
		}
		
	    return true;
	}
	
	function changeVisualRadio(input)
	{
	/*
		меняем вид radio при смене значения
	*/
		var wrapInput = input.parent();
		var nm=input.attr("name");
			
		jQuery(".radio input").each(
		
		function() {
	     
			if(jQuery(this).attr("name")==nm)
			{
				jQuery(this).parent().removeClass("on");
			}
		   
		   
		});
	
		if(input.attr("checked")) 
		{
			wrapInput.addClass("on");
		}
	}
	
	function changeRadioStart(el)
	/* 
		новый контрол выглядит так <span class="niceRadio"><input type="radio" name="[name radio]" id="[id radio]" [checked="checked"] /></span>
		новый контрол получает теже name, id и другие атрибуты что и были у обычного
	*/
	{
	
	try
	{
	var el = el,
		radioName = el.attr("name"),
		radioId = el.attr("id"),
		radioChecked = el.attr("checked"),
		radioDisabled = el.attr("disabled"),
		radioTab = el.attr("tabindex"),
		radioValue = el.attr("value");
		if(radioChecked)
			el.after("<div class='radio on'>"+
				"<input type='radio'"+
				"name='"+radioName+"'"+
				"id='"+radioId+"'"+
				"checked='"+radioChecked+"'"+
				"tabindex='"+radioTab+"'"+
				"value='"+radioValue+"' /></div>");
		else
			el.after("<div class='radio'>"+
				"<input type='radio'"+
				"name='"+radioName+"'"+
				"id='"+radioId+"'"+
				"tabindex='"+radioTab+"'"+
				"value='"+radioValue+"' /></div>");
		
		/* если контрол disabled - добавляем соответсвующий класс для нужного вида и добавляем атрибут disabled для вложенного radio */		
		if(radioDisabled)
		{
			el.next().addClass("disabled");
			el.next().find("input").eq(0).attr("disabled","disabled");
		}
		
		/* цепляем обработчики стилизированным radio */		
		el.next().bind("mousedown", function(e) { changeRadio(jQuery(this)) });
		el.next().find("input").eq(0).bind("change", function(e) { changeVisualRadio(jQuery(this)) });
		if(jQuery.browser.msie)
		{
			el.next().find("input").eq(0).bind("click", function(e) { changeVisualRadio(jQuery(this)) });	
		}
		el.remove();
	}
	catch(e)
	{
		// если ошибка, ничего не делаем
	}
	
	    return true;
	}

function randomFromTo(from, to)
{
  return Math.floor(Math.random() * (to - from + 1) + from);
}
