function countdown(){
	if ($('.countdown').length < 1) return false;
	var targetDate = new Date($('.countdown').attr('title'));
	var currentDate = new Date();
	var SysSecond = (targetDate.getTime() - currentDate.getTime())/1000 + 2;	
	var interval_id = setInterval(timeCount,1000);	

	function timeCount() {		
		if (SysSecond > 0) {
				SysSecond--
				var second = Math.floor(SysSecond % 60);
				var minite = Math.floor((SysSecond / 60) % 60);
				var hour = Math.floor((SysSecond / 3600) % 24);
				var day = Math.floor((SysSecond / 3600) / 24);

				$('.countdown .days').html(day);
				$('.countdown .hours').html(hour);
				$('.countdown .minutes').html(minite);
				$('.countdown .seconds').html(second);				
			} else {
				clearInterval(interval_id);
		}
	};
	timeCount();
}


//run fun
$(document).ready(function() {
	if ($.browser.msie && (parseInt($.browser.version) <= 7)) {
		try {
			document.execCommand('BackgroundImageCache', false, true);
		} catch(e){}
		$('.clearfix').css('zoom', 1);
	}
	if (window.navigator.userAgent.indexOf("Chrome") !== -1) {
		$('html').css('-webkit-text-size-adjust', 'none');
	}

	Cufon.replace(".ubuntu", {fontFamily:"Ubuntu"});
	Cufon.replace(".ME", {fontFamily:"MEgalopolisExtra"});
	Cufon.replace(".ME-banner", {fontFamily:"MEgalopolisExtra", color:"-linear-gradient(#32517e, #182b45)"});

	countdown();
	
	if ($('.ui-bar').length > 0) {
		$('.hosting-packages .item').each(function() {
			var lis = $('.ui-icon li', $(this));
			lis.find('img').css('opacity', 0.3);
			lis.eq(0).find('img').css('opacity', 1);
			lis.eq(0).find('span').addClass('active');
			$('.ui-bar', $(this)).slider({
				value:0,
				min: 0,
				max: 8,
				animate: true,
				slide:function(e,ui){
					lis.find('img').css('opacity', 0.3);
					lis.find('span').removeClass('active');
					lis.filter(':lt('+(ui.value+1)+')').find('img').css('opacity', 1);
					lis.filter(':lt('+(ui.value+1)+')').find('span').addClass('active');
					$(this).parent().children('.ui-tab-content').find('tbody tr').eq(ui.value).show().siblings().hide();
					$(this).find('.line-active').css('width', 94*(ui.value) + 23 + 'px');
				}
			});

		});

		$('.hosting-packages .tab-title li').click(function() {
			$(this).addClass('active').siblings().removeClass('active');

			$('.hosting-packages > .tab-content > .item').eq($(this).index()).addClass('item-active').siblings().removeClass('item-active');
		});
	}
});
