/*///////////////// CUFON IMAGE REPLACEMENT /////////////////////////*/
	Cufon.replace('#container h1');
	Cufon.replace('#container h2');
	Cufon.replace('#container h3');
	Cufon.replace('#container h4');

/*///////////////// END CUFON IMAGE REPLACEMENT /////////////////////////*/

/*///////////////// BEGIN NIVO SLIDER /////////////////////////*/
$(document).ready(function() {
    $('#slider').nivoSlider({
        'captionOpacity':1,
        'pauseTime':5000
    });

    $('#slider-box-1, #slider-box-2').each(function() {
        $(this).click(function() {
            window.location = $(this).find('a').attr('href')
        });
    })
})
/*///////////////// END NIVO SLIDER /////////////////////////*/

/*///////////////// BEGIN TABS /////////////////////////*/
$(document).ready(function() {
    $('.tabs-content li:eq(0)').siblings().hide();
    $('.tabs-nav li a').click(function() {
        $(this).parent().addClass('current').siblings().removeClass('current');
        $('.tabs-content li#'+$(this).attr('href').substr(1)).show().siblings().hide();
        return false;
    })
})
/*///////////////// END TABS /////////////////////////*/

/*///////////////// PORTFOLIO HOVER EFFECT /////////////////////////*/
$(document).ready(function(){
$('.enlarge').css({opacity: 0});
$('.enlarge').css({cursor: 'pointer'});
$('.enlarge').hover(function(){
    $(this).stop().animate({opacity: 1}, 500);

}, function(){
   $(this).stop().animate({opacity: 0}, 300);

});
});
/*///////////////// END PORTFOLIO HOVER EFFECT /////////////////////////*/

/*///////////////// SOCIAL LINKS HOVER EFFECT /////////////////////////*/
$(document).ready(function(){
	$('.social-links li a img').hover(function(){
		$(this).stop().animate({marginTop: "-5px"}, 300);

	}, function(){
	   $(this).stop().animate({marginTop: "0px"}, 300);

	});
});
/*///////////////// END SOCIAL LINKS HOVER EFFECT /////////////////////////*/

/*///////////////// SUBMENU HOVER EFFECT /////////////////////////*/
$(document).ready(function(){
	$('.box-body ul li a ').hover(function(){
		$(this).stop().animate({marginLeft: "30px"}, 300);

	}, function(){
	   $(this).stop().animate({marginLeft: "15px"}, 300);

	});
});
/*///////////////// END SUBMENU HOVER EFFECT /////////////////////////*/

/*///////////////// FOOTER NAVIGATION HOVER EFFECT /////////////////////////*/
$(document).ready(function(){
	$('.footer-navigation li a').hover(function(){
		$(this).stop().animate({marginLeft: "15px"}, 300);

	}, function(){
	   $(this).stop().animate({marginLeft: "0px"}, 300);
	});
});
/*///////////////// END FOOTER NAVIGATION HOVER EFFECT /////////////////////////*/

/*///////////////// LATEST POSTS HOVER EFFECT /////////////////////////*/
$(document).ready(function(){
	$('.latest-post').hover(function(){
		$(this).stop().animate({marginLeft: "10px"}, 300);

	}, function(){
	   $(this).stop().animate({marginLeft: "0px"}, 300);


	});
});
/*///////////////// END LATEST POSTS HOVER EFFECT /////////////////////////*/


/*///////////////// ACCORDION /////////////////////////*/
$(document).ready(function(){
	//Set default open/close settings
	$('.acc_container').hide(); //Hide/close all containers
	$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

	//On Click
	$('.acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
			$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
		}
		return false; //Prevent the browser jump to the link anchor
	});
});
/*///////////////// END ACCORDION /////////////////////////*/

jQuery(function() {
    var live_account_reqs = [
            ['inf_field_FirstName',
            'inf_field_LastName',
            'inf_field_Email',
            'inf_field_Phone1'],
            ['inf_field_StreetAddress1',
            'inf_field_Country',
            'inf_field_Birthday',
            'inf_custom_HowLongatCurrentAddress'],
            ['inf_custom_UnderstandthenatureofmarginedInstruments',
            'inf_custom_Experiencewforexffdsoptionsfuturesspreadbetting',
            'inf_custom_TradingAccountPurpose',
            'inf_custom_ClientAgreement',
            'inf_custom_RiskWarning',
            'inf_custom_TermsOfService',
            'inf_custom_ServiceAgreement',
            'inf_custom_FundingMoneywasLegallyobtained',
            'captcha.typed']
    ];
    var demo_account_reqs = [
        'inf_field_FirstName',
        'inf_field_Email',
        'inf_field_Phone1',
        'inf_custom_Country0'
    ];
    var ib_reqs = [
        'inf_field_FirstName',
        'inf_field_LastName',
        'inf_field_Address2Street1',
        'inf_field_Address2Street2',
        'inf_field_City2',
        'inf_field_State2',
        'inf_field_PostalCode2',
        'inf_field_Country2',
        'inf_field_Phone1',
        'inf_field_Email'
    ];


    $("#steps li:eq(0)").siblings().hide();
    $("#steps li input[value=Back]").click(function() {
        $("#steps li:eq(1)").show().siblings().hide();
        return false;
    })
    $("#steps li .btn-continue").click(function() {
        // verification
        errors = '';
        reqs = live_account_reqs[$(this).parent('li').index()];
        $.each(reqs, function() {
            if (!$('input[name='+this+']').val() || ($('input[name='+this+']').attr('type') == 'checkbox' && !$('input[name='+this+']').is(':checked')) || ($('input[name='+this+']').attr('type') == 'radio' && !$('input[name='+this+']:checked').length)) {
                var label = $('label[for='+this+']').length ? $('label[for='+this+']').text() : $('label[for='+this+'_1]').text();
                errors += '<li>'+label.replace('*','')+'</li>';
            }
        })
        if (errors != '') {
            $('#form-errors').html('<strong>Required Fields:</strong><ul>'+errors+'</ul>');
            window.scrollTo(0,$('#form-errors').offset().top-40);
            return false;
        }
        $('#form-errors').html('');
        $(this).parent('li').hide();
        $(this).parent('li').next().show();
        $("#steps-nav li").eq($(this).parent('li').index()+1).addClass('current-step').siblings().removeClass('current-step')
        return false;
    })
    $("#steps li .btn-back").click(function() {
        $(this).parent('li').hide();
        $(this).parent('li').prev().show();
        $("#steps-nav li").eq($(this).parent('li').index()-1).addClass('current-step').siblings().removeClass('current-step')
        return false;
    })
    $("#steps-nav li a").click(function() {
        return false;
    })

    $(".custom-form").before('<div id="form-errors"></div>');
    $(".custom-form").submit(function() {
        errors = '';
        var reqs;
        if ($(".custom-form").attr('id') == 'live-account-form')
            reqs = live_account_reqs[2];
        else if ($(".custom-form").attr('id') == 'demo-account-form')
            reqs = demo_account_reqs;
        else if ($(".custom-form").attr('id') == 'ib-form')
            reqs = ib_reqs;
        $.each(reqs, function() {
            if (!$('input[name='+this+']').val() || ($('input[name='+this+']').attr('type') == 'checkbox' && !$('input[name='+this+']').is(':checked')) || ($('input[name='+this+']').attr('type') == 'radio' && !$('input[name='+this+']:checked').length)) {
                var label = $('label[for='+this+']').length ? $('label[for='+this+']').text() : $('label[for='+this+'_1]').text();
                errors += '<li>'+label.replace('*','')+'</li>';
            }
        })
        if (errors == '')
            return true;
        $('#form-errors').html('<strong>Required Fields:</strong><ul>'+errors+'</ul>');
        window.scrollTo(0,$('#form-errors').offset().top-40);
        return false;
    })
})
