var _x = 0;
var _y = 0;
var __x = 0;
var __y = 0;
var IE = document.all?true:false;
var tlt = '';


// POINTER COORDINATES
$(document).mousemove(function(e) {

if (IE) {
	_x = event.clientX + document.documentElement.scrollLeft;
	_y = event.clientY + document.documentElement.scrollTop;
	
	__x = event.clientX;
	__y = event.clientY; 
}
else {
	_x = e.pageX;
	_y = e.pageY;
	
	__x = e.clientX;
	__y = e.clientY;
}

});


var quoteAnimTime = 5000;
var quoteAnimTO = false;

function quoteNext() {
	quoteAnimTO = setTimeout("quoteNext()", quoteAnimTime)
	var cur = $(".packs-index .pager .current");
	var next = cur.next();
	if (!cur.nextAll().length) {
		next = cur.siblings().eq(0)
	}
	if ($('.packs-index .item').length == 1) {
		return false;
		clearTimeout(quoteAnimTO);
	}
		next.click();
		
}


function quotePrev() {
	var cur = $(".packs-index .pager .current");
	var prev = cur.prev();
	
	if (!cur.prevAll().length) {
		prev = cur.siblings().eq($('.packs-index .pager span').length - 2)
	}
	
	if ($('.packs-index .item').length == 1) {
		return false;
		clearTimeout(quoteAnimTO);
	}
		prev.click();	
}



$(function(){

	var wWidth = $(window).width();
	var wHeight = $(window).height();

	$(".packs-index .pager span").click(function(){	
		var pos = $(this).prevAll().length,
			par = $(this).closest(".packs-index"),
			els = $(".item", par),
			cur = els.filter(":visible");
			

		if (!$(this).hasClass("current")) {
			$(this).addClass("current").siblings(".current").removeClass("current");
			cur.fadeOut(100);
			els.eq(pos).fadeIn(500);
		}
		return false;
	})
	

	$(".packs-index").hover(
		function(){if (quoteAnimTO) clearTimeout(quoteAnimTO);},
		function(){quoteAnimTO = setTimeout("quoteNext()", quoteAnimTime);
	})
	

	if ($('.packs-index .item').length == 1) {
		$('.packs-index > .prev, .packs-index > .next').hide();
		return false;
	}
	else {
		quoteAnimTO = setTimeout("quoteNext()", quoteAnimTime);	
	}
	
	
	
	$('.packs-index .next').click(function() {
		quoteNext();
		clearTimeout(quoteAnimTO);
	})
	
	$('.packs-index .prev').click(function() {
		quotePrev();
		clearTimeout(quoteAnimTO);
	})

// small hint
	
	$(".hint").hover(
							
	function() {
		
		var targ = $(".hint-i").length ? $(".hint-i") : $('<div class="hint-i"><div class="l"><div class="r"><div class="h"></div></div></div><div class="bl"><div class="br"><div class="b"></div></div></div><div class="tl"><div class="tr"><div class="t"></div></div></div></div>').appendTo("body").hide();
		
		
		
		if ($(this).attr('title')!='') {
			tlt = $(this).attr('title');
			$(this).attr('title', '');
		}
		
		else {
			tlt = $(this).html();	
			tlt = tlt;
		}
		
		$('.hint-i .h').html(tlt);
		
		var h = $('.hint-i').innerHeight();
		var w = $('.hint-i').innerWidth();
		
		if ((__y - 25) < h) {
			var t = _y + 25;
		}
		
		else {
			var t = _y - h - 15;	
		}
		
		if ((__x + w + 15) > wWidth) {
			var l = _x - w;
		}
		
		else {
			var  l = _x;	
		}
		
		
		
			$('.hint-i').css({
				left: l,
				top: t
			})
		$('.hint-i').show();
	},
	
	function() {
		
		if ($(this).attr('title') != 'undefined') {
			$(this).attr('title', tlt);
		}
	
		$('.hint-i').hide();
		
	});
	
	$(".hint").mousemove(
		function(){
			
			
			
			var h = $('.hint-i').innerHeight();
			var w = $('.hint-i').innerWidth();
			
			if ((__y - 25) < h) {
				var t = _y + 25;
			}
		
			else {
				var t = _y - h - 15;	
			}
		
			if ((__x + w + 15) > wWidth) {
				var l = _x - w;
			}
		
			else {
				var  l = _x;	
			}
			
			$('.hint-i').css({
				left: l,
				top: t
			})

		},
		
		function() {
			$('.hint-i').hide();
			
		}
	);
        

        
        $(".hint").mouseleave(function(){
                $('.hint-i').hide();
        });





 
$('.srv-tbl td.txt .slideDown').click(function() {
		$(this).closest('td').children('.hidden').slideToggle(300);							
	});
	
	$('.srv-tbl td.txt .slideUp').click(function() {
		$(this).closest('td').children('.hidden').slideUp(300);									
	});  


})

	
	


