jQuery(document).ready(function(){
	jQuery('.addServices tr:nth-child(2n+1):not(:first)').addClass('even');
	jQuery('.addServices tr:nth-child(2n)').addClass('odd');
								
	jQuery('#mainRow1 #seltld').selectbox();
	if(jQuery('#mainRow1 input#domain').val()!='www.'){
		jQuery('#mainRow1 input#domain').css('color','#000');
	}
	jQuery('#mainRow1 input#domain').bind("click focus", function(){
		if(jQuery(this).val()=='www.'){
			jQuery(this).css('color','#000');
			jQuery(this).val('');
		}
	});
	jQuery('#mainRow1 input#domain').blur(function(){
		if(jQuery(this).val()==''){
			jQuery(this).css('color','#b9beb9');
			jQuery(this).val('www.');
		}
	});
	
	var homePricingInputText = jQuery('#mainRow2 .pricing .inputText').val();
	jQuery('#mainRow2 .inputText').bind("click focus", function(){
		if(jQuery(this).val()==homePricingInputText){
			jQuery(this).val('');
		}
	});
	jQuery('#mainRow2 .inputText').blur(function(){
		if(jQuery(this).val()==''){
			jQuery(this).val(homePricingInputText);
		}
	});
	
	jQuery('.btnInput').hover(function(){
		jQuery(this).toggleClass('btnInputActive');
		jQuery(this).children('.right').toggleClass('rightActive');
	});
	
	var id = 2;
	function slideChange() {
		jQuery('#mainRow1 div.promo div').hide();
		jQuery('#promo_' + id).fadeIn();
		jQuery('#mainRow1 div.promo .switch a').removeClass("active");
		jQuery('#mainRow1 div.promo .switch a[href="promo_' + id + '"]').addClass("active");
		clearInterval( change );
		if( id==1 ){
			change = setInterval(slideChange, 9500);
		}
		else {
			change = setInterval(slideChange, 7500);			
		}
		if( jQuery('#mainRow1 div.promo').length==1 ){
			id = parseInt( jQuery('#mainRow1 div.promo .switch a:first').attr('href').substr(6) )==id ? 1 : id+1;
		}
	}
	var change = setInterval(slideChange, 9500);
	jQuery('#mainRow1 div.promo .switch a').click(function(){
		jQuery('#mainRow1 div.promo div').not('#' + jQuery(this).attr('href')).hide();
		jQuery('#' + jQuery(this).attr('href')).not(':visible').fadeIn();
		jQuery('#mainRow1 div.promo .switch a').removeClass("active");
		jQuery(this).addClass("active");
		clearInterval( change );
		return false;
	});
	
	
	jQuery('.ppContainer img').hover(function(){
		jQuery(this)
		.tooltipClass('overDivPP')
		.tooltipPP( '<span class="bold">' + jQuery(this).attr('alt') + '</span><br /><div style="padding-top: 6px; color: #0097d8" class="bold"><span style="font-size: 17px">' + jQuery(this).parent().attr('rel') + '</span> pkt.</div>' );
	});

	jQuery('.ppContainer').hover(
		function(){
			jQuery('.ppContainer > a').css('display','block');
		},
		function(){
			jQuery('.ppContainer > a').hide();		
		}
	);
	
	var idPP = 1;
	var ppNavEnabled = true;
	
	jQuery('.ppContainer img').hover(
		function(){
			ppNavEnabled = false;
		},
		function(){
			ppNavEnabled = true;	
		}
	);
	
	var changePP = setInterval(function() {
		if(ppNavEnabled){
			idPP = jQuery('#pp_' + parseInt(idPP+1)).length==1 ? idPP+1 : 1;
			jQuery('.ppContainer .pp').hide();
			jQuery('#pp_' + idPP).show();
		}
	}, 10000 );
	jQuery('.ppContainer .prev').click(function(){
		if(ppNavEnabled){
			ppNavEnabled = false;
			if(jQuery('#pp_1').is(':visible')){
				jQuery('.ppContainer .pp:visible').animate({width: 'hide'}, function(){
					jQuery('.ppContainer .pp:last').show();
					ppNavEnabled = true;
				});		
				idPP = jQuery('.ppContainer .pp:last').attr('id').substr(3);
			}
			else {
				idPP--;
				jQuery('.ppContainer .pp:visible').animate({width: 'hide'}, function(){
					jQuery('#pp_' + idPP).show();
					ppNavEnabled = true;
				});	
			}
		}
		clearInterval( changePP );
		return false;
	});
	jQuery('.ppContainer .next').click(function(){
		if(ppNavEnabled){
			ppNavEnabled = false;
			if(jQuery('.ppContainer .pp:last').is(':visible')){
				jQuery('.ppContainer .pp').hide();
				jQuery('.ppContainer .pp:first').animate({width: 'show'}, function(){
					ppNavEnabled = true;
				});	
				idPP = 1;
			}
			else {
				jQuery('.ppContainer .pp').hide();
				jQuery('#pp_' + parseInt(idPP+1)).animate({width: 'show'}, function(){
					ppNavEnabled = true;
				});
				idPP++;
			}
		}
		clearInterval( changePP );
		return false;
	});
	
	//homepage btnTransfer tooltip			
	jQuery('#mainRow1 .domains .transfer')
	.tooltipClass('overDivPP overDivTransfer')
	.tooltip('<b>Przenieś do nas domeny</b><br />dostaniesz świetne ceny<br />i 50% więcej punktów<br />w Programie Partnerskim');

});