$(document).ready(function(){ 
    
    // sliding registration form
    $('div.registration').scrollFollow({ speed: 1500});

    $('#booking-img').fancyZoom({width:350, height:410});
    
    $('div.testimonials div p').slice(1).css('display','none').next('strong').css('display','none');
    
    var _currPos = 0, _nextPos = 1;
    var _length = $('div.testimonials div p').length - 1;
    setInterval( function() {
        _nextPos = _currPos + 1;
        if (_currPos >= _length) {
            _nextPos = 0;
        }
        $('div.testimonials div p')
            .eq(_currPos)
            .fadeOut('slow', function() { 
                $('div.testimonials div p').eq(_nextPos).fadeIn('slow');
            })
            .next('strong')
            .fadeOut('slow', function() { 
                $('div.testimonials div p').eq(_nextPos).next('strong').fadeIn('slow', function(){ _currPos =  _nextPos; });
            });
     }, 6000);
	 
	 $('.force-code a').hover(
		function() {
			$('.force-code a span').removeClass('hidden')
		},
		function() {
			$('.force-code a span').addClass('hidden')
		}
	 );
     
     $('#fname, #flname, #email, #phone, #zipcode, #fcode').keydown(function () {
        if ( $(this).val() != '' ) $(this).parent('li').removeClass('error');
     });
     
     $('div.registration form input.iagree').change( function() {
        if ( $(this).attr('checked') ) $(this).parent('li').removeClass('error');
     });
     
     $('#activate').click( function () {
        var _valid = true;

        if ( $('#fname').val() == '' ) {
            $('#fname').parent('li').addClass('error');
            _valid = false;
        } else {
            $('#fname').parent('li').removeClass('error');
        }
        
        if ( $('#flname').val() == '' ) {
            $('#flname').parent('li').addClass('error');
            _valid = false;
        } else {
            $('#flname').parent('li').removeClass('error');
        }
        
        var _emailval = $('#email').val();
        if ( _emailval == '' || !/^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/.test(_emailval) ) {
            $('#email').parent('li').addClass('error');
            _valid = false;
        } else {
            $('#email').parent('li').removeClass('error');
        }
        
        if ( $('#phone').val() == '' ) {
            $('#phone').parent('li').addClass('error');
            _valid = false;
        } else {
            $('#phone').parent('li').removeClass('error');
        }
        
        var _zipval = $('#zipcode').val();
        if ( _zipval == '' || !/^[0-9]{5}$/.test(_zipval) ) {
            $('#zipcode').parent('li').addClass('error');
            _valid = false;
        } else {
            $('#zipcode').parent('li').removeClass('error');
        }
        
        if ( $('#fcode').val() == '' ) {
            $('#fcode').parent('li').addClass('error');
            _valid = false;
        } else {
            $('#fcode').parent('li').removeClass('error');
        }
        
        if ( !$('div.registration form input.iagree').attr('checked') ) {
            $('div.registration form input.iagree').parent('li').addClass('error');
            _valid = false;
        } else {
            $('div.registration form input.iagree').parent('li').removeClass('error');
        }
        
        if (_valid) $('div.registration form').submit();
        
        return false;
    })
        
    // for pricing page
    $('div.hover-details').hide();
    $('.modal-special-offer').hide();
    
    // yellow popup
    var _timeOut;
    $('div.pop-plan table tr').each( function (i) {
        var _defTop = 157;
        
        $(this).hover(
                function() { 
                    //console.log( this.nodeName );
                    var _html = $(this).find('td div').html();

                    if (!_html) return;
                    
                    window.clearTimeout(_timeOut);
                    $('div.hover-details-top').html(_html);
                    $('div.hover-details').css('top', i*30+_defTop).show(); 
                },
                function() { _timeOut = window.setTimeout(function() { $('div.hover-details').hide(); }, 2000); }
            );
    });
    
    $('div.hover-details').hover(
            function() { window.clearTimeout(_timeOut); $(this).show(); },
            function() { $(this).hide(); }
        );
    
    // modal
    $('.modal-special-offer a.nothanks').click(function() { $.modal.close(); return false; });
    
    var _timeOutModal = window.setTimeout(function() {
            $('.modal-special-offer').modal({
                'close' : false
            });
            $('#simplemodal-container').css('position', 'absolute')
        }, 15000);
        
    $('a.special-offer').click( function() {
        if ( _timeOutModal ) clearTimeout(_timeOutModal);
        $('.modal-special-offer').modal({
                'close' : false,
                'containerCss' : {
                        position : 'anbsolute'
                    }
            });
        $('#simplemodal-container').css('position', 'absolute');
        return false;
    });
    
    $('#watch-clip').click(function () {
            window.open('http://artistforce.com/new/video.html','','width=660,height=400');
            return false;
        });
        
}); 

hs.graphicsDir = 'highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.numberPosition = 'caption';
hs.dimmingOpacity = 0.75;
hs.showCredits = false;

// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: .75,
		position: 'bottom center',
		hideOnMouseOut: true
	}
});