$(document).ready(function() {
    jQuery('#whyus').jcarousel({
        vertical: true,
        scroll: 1
	});
	
	$('#bestcomments').innerfade({
		animationtype: 'fade',
		speed: 1500,
		timeout: 4000
	});

	$("select").selectBox();

//	$($('#emrrotator img')[0]).addClass('emrrotator_show'));
	var emrRotatorTime = 5000;
	autoPlayTimer = setInterval(showEmrRotator, emrRotatorTime);
	$($('#emrrotator div.emrrotator_content')[0]).addClass('emrrotator_show');	
	$('#emrrotator_controls a:first').addClass('emrrotator_controls_selected');	
	
	$('#emrrotator_controls a').click(function() {
		var index = $(this).index();
		showEmrRotator('', index);
	});
	
	$('#emrrotator div').each(function(index) {
		$(this).mouseover(function() {
			clearInterval(autoPlayTimer);
		});
		$(this).mouseout(function() {
			autoPlayTimer = setInterval(showEmrRotator, emrRotatorTime);
		});
	});
});

emrrotator_index = 0;
function showEmrRotator(asd, index)
{
	var first_image = emrrotator_index;
	var second_image = emrrotator_index+1;
	if(typeof(index) !== 'undefined')
	{
		second_image = index;
		emrrotator_index = index-1;
	}
	if(typeof($('#emrrotator div.emrrotator_content')[second_image]) === 'undefined')
	{
		emrrotator_index = -1;
		second_image = 0;
	}

	$($('#emrrotator div.emrrotator_content')[first_image]).fadeOut('slow');
	$($('#emrrotator div.emrrotator_content')[second_image]).fadeIn('slow');
	$('#emrrotator_controls a').removeClass('emrrotator_controls_selected');
	$($('#emrrotator_controls a')[second_image]).addClass('emrrotator_controls_selected');
	
	emrrotator_index++;
}

$(document).ready(function() {
	Cufon.replace(' #emrrotator div.emrrotator_content a strong.vegur', { fontFamily: 'Vegur' });
	Cufon.replace('.myriad, #menu li a, .footerparthead, .rightblock strong, .indexsearch, .indextabs-right strong, .rentalservers strong, .rentalservers span, .servers-left strong, .serverprice, .ssl strong, .sslin, .indexfooterinleft strong, .sslin, .indexfooterincenter strong, .sslin, .indexfooterinright strong, .indexfooterticket, .indexfootertel, .indexfootermail, #emrrotator div.emrrotator_content strong, .comment, .indexlinks a, .domaintabslinks a, .hostingprice-green span, .hostingprice-black span, .hostingprice-yellow span, .hostingprice-blue span, .rentalserversprice a', { fontFamily: 'Myriad Pro' });
	Cufon.replace('.hostingprice-green strong, .hostingprice-black strong, .hostingprice-yellow strong, .hostingprice-blue strong, .rentalserversprice b, .vegurbold', { fontFamily: 'Vegur Bold' });
	
	Cufon.replace('#emrrotator_controls a strong', { fontFamily: 'Arial' });
	Cufon.replace('.commentheader, .commentfooter, #headlogintext', { fontFamily: 'Tahoma' });

	
	$('#emrrotator div.emrrotator_content').click(function() {
		var index = $(this).index();
		window.location = $($('#emrrotator div.emrrotator_content a')[index]).attr('href');
	});
	
	
	$('.hostingtabdiv').hide();
	$('.hostingtabdiv:first').show();
	
	$('.domaintabsdiv:first').show();
	$('.domaintabslinks a').click(function() {
		var index = $(this).index();
		$('.domaintabsdiv').fadeTo(100, 0.1).hide();
		$($('.domaintabsdiv')[index]).show().fadeTo(500, 1);
		$('.domaintabslinks a').removeClass('domaintabslinksselected');
		$(this).addClass('domaintabslinksselected');
		Cufon.replace('.domaintabslinks a', { fontFamily: 'Myriad Pro' });
	});
	
	$('.domaintabsprices:first').show();
	$('.domains2').click(function() {
		var index =  $(".domains2").index(this);
		$('.domaintabsprices').fadeTo(100, 0.1).hide();
		$($('.domaintabsprices')[index]).show().fadeTo(500, 1);
	});

	
	$('.indextabs:first').show();
	$('.indexlinks a').click(function() {
		var index = $(this).index();
		$('.indextabs').fadeTo(100, 0.1).hide();
		$($('.indextabs')[index]).show().fadeTo(500, 1);
		$('.indexlinks a').removeClass('indexlinksselected');
		$(this).addClass('indexlinksselected');
		Cufon.replace('.indexlinks a', { fontFamily: 'Myriad Pro' });

	});
	
	$('.hostingtabs a').click(function() {
		var index = $(this).index();
		$('.hostingtabdiv').fadeTo(100, 0.1).hide();
		$($('.hostingtabdiv')[index]).show().fadeTo(500, 1);
		$('.hostingtabs a').removeClass('hostingtabactive');
		$(this).addClass('hostingtabactive');
	});
	
	$('div.sss > div').hide();  
	$('div.sss > h3').click(function() {
		$(this).next('div').slideToggle('fast').siblings('div:visible').slideUp('fast');
			$('div.sss div').removeClass('sssactive');
			$('div.sss h3').removeClass('sssactive');
		
		if($(this).next('div').attr('class') != 'sssactive')
		{
			$(this).addClass('sssactive');
			$(this).next('div').addClass('sssactive');
		}
	});
	
	$('.mydetails-menu li a').corner("top 8px");
	$('.buttongreen, .buttonred, .buttongrey, .ticketcats li a').corner("8px");
	$('input.normalinput').corner("3px");
	$('.domaintabslinks a, .indexlinks a').corner("top 5px");
	$('.domaintabsinput, .indexprice a').corner("5px");
	$('#bodyleft').corner("bottom 8px");
	
});

