$(document).ready(function() {
	Cufon.replace('#menu a, .www, .domainright li.domainhead, .contactsend, .sendpw, .clientareatotal, .clientprice, .clientname', { fontFamily: 'Tahoma' });
	Cufon.replace('#menutop a, ul#news li, .leftmenuhead, .head, .domaintabs a, .domainbutton, .headbig, .hostingtabs a, .hostingsub strong, .myriad, .serverhead, .packageheader span, .packageperiod, .headsub, .boxhead, .boxheadnobg, .profilemenu a, .replyuser strong, .step4, div.clientareahead, .indexhostingdesc, .indexhostingtabs a, .alanaditabs a, .alanadipricediv, .vpshead, .vpsinfo, .step span, .step strong', { fontFamily: 'Myriad Pro' });
	Cufon.replace('.tel, .packageprice, .packagepricesmall', { fontFamily: 'Bebas Neue' });
	Cufon.replace('.hostingorder', { fontFamily: 'Myriad Pro Bold' });
	Cufon.replace('.hostingprice, .hostingcurrency, .serverprice, .servercurrency', { fontFamily: 'Rawengulk' });
	
	$("input[type=checkbox], input[type=radio]").css('width', 'auto');

	$(".fancy").fancybox({ titleShow : false, autoScale : false, showCloseButton : false });

	$(".select").selectBox();
	
	$('.menulast').click(function(e) {
		$('.menusub').slideToggle('slow');
	});
	$('.menusub, .menulast').click(function(e) {
		e.stopPropagation();
	});
	$(document).click(function(a,b) {
		$('.menusub').slideUp('slow');
	});
	
	$('#news').innerfade({
		animationtype: 'fade',
		speed: 750,
		timeout: 3000,
		containerheight: '20px'
	});

	$('#bignews').innerfade({
		animationtype: 'fade',
		speed: 750,
		timeout: 3000,
		dotclass: '.bignews a',
		containerheight: '205px'
	});
	
	$('.domainprices').each(function(index) {
		$(this).mouseover(function() {
			$(this).addClass('rowhover');
		});
		$(this).mouseout(function() {
			$(this).removeClass('rowhover');
		});
		if(index%2)
		{
			$(this).addClass('row1');
		}
	});

	$('.specs').each(function(index) {
		$(this).mouseover(function() {
			$(this).addClass('rowhover');
		});
		$(this).mouseout(function() {
			$(this).removeClass('rowhover');
		});
		if(index%2)
		{
			$(this).addClass('row2');
		}
	});
	
	$('.datacenter').each(function(index) {
		$(this).mouseover(function() {
			$(this).addClass('rowhover');
		});
		$(this).mouseout(function() {
			$(this).removeClass('rowhover');
		});
		if(index%2)
		{
			$(this).addClass('row2');
		}
	});
	
	
	$('.boxheadrows').each(function(index) {
		$(this).mouseover(function() {
			$(this).addClass('rowhover');
		});
		$(this).mouseout(function() {
			$(this).removeClass('rowhover');
		});
		if(index%2)
		{
			$(this).addClass('row3');
		}
	});

	var totaldots = $('#bignews li').length;
	var currenta = 0;
	for(i = 0; i < totaldots; i = i+1)
	{
            if ((currenta + 1) < totaldots) {
                currenta = currenta + 1;
                lasta = currenta - 1;
            } else {
                currenta = 0;
                lasta = totaldots - 1;
            }

		$('.bignews').append('<a href="javascript:showDot(' + i + ');"></a>');
	}
	
	
	$($('.bignews a')[0]).addClass('bignewsselected');

	$('.showspecs').click(function(e) {
		var index = $('.showspecs').index(this);
		$($('.specshidden')[index]).slideToggle('slow');
	});

	$('.indexhostingtabs a').click(function(e) {
		var index = $('.indexhostingtabs a').index(this);
		$('.indexhostingtabs a').removeClass('indextabsselected');
		$($('.indexhostingtabs a')[index]).addClass('indextabsselected');
		$('.indexhostingtab').hide();
		$($('.indexhostingtab')[index]).show();
		
		Cufon.replace('.indexhostingtabs a', { fontFamily: 'Myriad Pro' });

	});
	
	$('.alanaditabs a').click(function(e) {
		var index = $('.alanaditabs a').index(this);
		$('.alanaditabs a').removeClass('selected');
		$($('.alanaditabs a')[index]).addClass('selected');
		$('.alanaditab').hide();
		$($('.alanaditab')[index]).show();
		
		Cufon.replace('.alanaditabs a', { fontFamily: 'Myriad Pro' });
	});
	
	
	$('.closeopen').click(function(e) {
		var index = $('.closeopen').index(this);
		if($($('.closeopen')[index]).attr('src').indexOf('minus') > 0)
		{
			$($('.closeopen')[index]).attr('src', 'templates/hostbaycan/images/plus.png');
		}
		else
		{
			$($('.closeopen')[index]).attr('src', 'templates/hostbaycan/images/minus.png');
		}

		$($('.closeopendiv')[index]).slideToggle('slow');
	});

	
	$($('.alanaditab')[0]).show();
	$($('.indexhostingtab')[0]).show();
	
});

function showDot(id)
{
	$('.bignews a').removeClass('bignewsselected');
	$($('.bignews a')[id]).addClass('bignewsselected');
	var totaldots = $('#bignews li').length;
	for(i = 0; i < totaldots; i = i+1)
	{
		if(id != i)
		{
			$($('#bignews li')[i]).fadeOut(500);
		}
	}
	$($('#bignews li')[id]).fadeIn(500);

}

