
function selectTab(num) {
    
    $('.current').removeClass('current');
    
    $('#wdNav ul li a:eq('+num+')').addClass('current');
    
}

function hideTTT() {
 
    $('.mainTTT').fadeOut();   
    
}

function showTTT() {
    
    $('.mainTTT').fadeIn();
    
}

function focusSwitcher(focus, unfocus) {
    
    $(focus).hover(function(){
	
	$(this).animate({opacity: 100}, 300);
	$(unfocus).animate({opacity: .38}, 300);
	
    }, function(){

	$(unfocus).animate({opacity: 100},300);	
	
    });
    
    
}


function init() {
    
    
    $('.frame .wrap').hover(function(){
	
	$(this).addClass('hover');
	
	}, function(){
	
	    $(this).removeClass('hover');    
	    
	});
    
    
    focusSwitcher('#buyCol','.impCol');
    focusSwitcher('.impCol','#buyCol');

    
    $('#buyCol').hover(function(){
	
	$(this).animate({opacity: 100}, 300);
	$('.impCol').animate({opacity: .62}, 300);
	
    }, function(){

	$('.impCol').animate({opacity: 100},300);	
	
    });
    
    
    $('#buyCol').hover(function(){
	
	$(this).animate({opacity: 100}, 300);
	$('.impCol').animate({opacity: .62}, 300);
	
    }, function(){

	$('.impCol').animate({opacity: 100},300);	
	
    });
    
    $('.jumpto, .helper').hover(function(){
     
        $(this).addClass('hover');     
        
    }, function(){
    
        $(this).removeClass('hover');    
        
    });

    
    $('.profileHover').hover(function(){
     
        $(this).addClass('hover pHov');     
        
    }, function(){
    
        $(this).removeClass('hover pHov');    
        
    });
    
    
    $('.profileHover').click(function(){
        
        
    
    
        $('#profileText').html($(this).children().html());

        $('#profileBg').fadeIn('30',function(){
            
           
        
            $('#profileBg').fadeOut('30');
        
            
        });

        
        $('#profileText').prepend('<div class="clear"></div>').prepend('<h2>'+$(this).attr('id')+'</h2>').prepend('<img src="img/profile-sub-'+$(this).attr('id')+'.gif" class="profileSub" />');
        

        $('#profileText').append('<div id="areYouButton">Are you a '+$(this).attr('id')+'? <a href="enter.php">Take the test to find out now</a></div>');
        
    });
    
    

    $('#subscribe').ajaxForm(function(){
    
    	$('.qtip').fadeOut();
    
        
        // hide the subscribe, display
        $('#widget').fadeOut(function(){
        
            $('#widget').empty();
            
            $('#widget').html('<h3>Thanks! In a moment you should check your email to see what we have sent you.</h3>');
            
            $('#widget').fadeIn();
                
            
        });
        
    });   
    
          
      
    $('.helper').qtip({
        content: { url: 'whatisatoken.php' },
        tip: true,
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'leftMiddle',
                tooltip: 'rightMiddle'
            }
        },
        show: { effect: { type: 'fade', length: 0}, delay: 0, solo: true },
        hide: { effect: { type: 'fade', length: 0}},
        style: {
            border: {
                width: 0,
                radius: 7,
                color: '#22b5e3'
            },

            name: 'green',
            backgroundColor: '#22b5e3',
            fontSize: '13px',
            color: '#ffffff',
            lineHeight: '150%',
            width: 389
        }
    });
    
    
    $('.jumpto').click(function(){

        $('#loading').fadeIn();

        $.ajax({
        	method: "GET",
          	url: $(this).attr('name'),
                data: 'tab=test',
                dataType: 'text',
          	cache: true,
          	success: function(text){
                        $('#loading').remove();
			$('#bannerBlock').html(text);			
 	}});    
        
        
    });
    
    
    $('ul.imgList li').hover(function(){
	
	$('ul.imgList li').removeClass('hover');

	$(this).addClass('hover');	
	
    }, function(){

	$(this).removeClass('hover');	
	
    });
    
    $(document).pngFix(); 
    
    
            
}


function doLoading(){
    
    $('#loading').fadeIn('slow');        
    
}


function unLoading() {
    
    $('#loading').fadeOut('fast');
    
}


function setPermLink(what) {

	var href = 'http://www.wdprofiletest.com/'+what;
	$('#permLink').attr('href', href).text(href);
    
}

$(document).ready(function(){
    
        
    $.localScroll();

    
    $('#wdNav ul li[title]').qtip({
        tip: true,
        position: {
            corner: {
                target: 'bottomMiddle',
                tooltip: 'topMiddle'
            },
            target: 'mouse'
        },
        show: { effect: { type: 'fade', length: 0}, delay: 0, solo: true },
        hide: { effect: { type: 'fade', length: 0}},
        style: {
            border: {
                width: 0,
                radius: 7,
                color: '#22b5e3'
            },

            name: 'dark',
            backgroundColor: '#22b5e3',
            fontSize: '14px',
            lineHeight: '150%',
                    width: 150
        }
    });
      
      

    
    
    // qtip for test Button
    $('.mainTTT').qtip({
        content: { url: 'youreceive.php' },
        tip: true,
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                tooltip: 'topMiddle',
                target: 'bottomMiddle'
            }
        },
        show: { effect: { type: 'fade', length: 0}, delay: 0, solo: true },
        hide: { effect: { type: 'fade', length: 300}},
        style: {
            border: {
                width: 0,
                radius: 7,
                color: '#333'
            },
            

            name: 'dark',
            backgroundColor: '#333',
            fontSize: '18px',
            lineHeight: '150%',
                    width: 519
        },
        show: {
            
            effect: { type: 'fade' }
            
        }
    });
    
    
    // qtip for test Button
    $('.iching-hov').qtip({
        tip: true,
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                tooltip: 'rightMiddle',
                target: 'leftMiddle'
            },
	    target: 'mouse'
        },
        show: { effect: { type: 'fade', length: 0}, delay: 0, solo: true },
        hide: { effect: { type: 'fade', length: 300}},
        style: {
            border: {
                width: 16,
                radius: 16,
                color: '#ececec'
            },
            

            name: 'light',
            fontSize: '13px',
            lineHeight: '150%',
            width: 400,
	    opacity: 81
        },
        show: {
            
            effect: { type: 'fade' }
            
        },
	content: { url: 'iching.php' }

    });
    
    
    
    

    // navigation hover stuff
     $('#wdNav ul li, .mainTTT').hover(function(){
    
        $(this).addClass('hover');
        
    }, function(){
                
        $(this).removeClass('hover');
        
    });
    
    
    //$('.mainTTT').hover(function() {
    
   //     $('#veil').fadeIn();

        
    //}, function() {
    
   //     $('#veil').fadeOut();    
        
   // });
    
    var clickTest =  function(){
        
        doLoading();
        
        $('.qtip').slideUp('fast');
        
       
	setPermLink('enter');
        // $('#topWrap').animate({opacity: .1}, 1000);
    
        $.ajax({
        	method: "GET",
          	url: 'enter.php',
                data: 'tab=enter',
		dataType: 'text',
          	cache: true,
          	success: function(text){
                        unLoading();
			$('#bannerBlock').html(text);			
 		}});
        
    }
    
    $('.mainTTT').click(clickTest);
    


    // navigation click codes
    $('#wdNav ul li a').click(function(){
        
	setPermLink($(this).attr('id'));
	
        $('.current').removeClass('current');
        $(this).addClass('current');
        $('.qtip').slideUp('fast');
        
               doLoading();
        
        
        	$.ajax({
        	method: "GET",
          	url: $(this).attr('id')+'.php',
		data: 'tab='+$(this).attr('id'),
		dataType: 'text',
          	cache: true,
          	success: function(text){
                        unLoading();
			$('#bannerBlock').html(text);			
    		}});
        
    });
    
    
    

    init();
 
   
    
    

    
    
});