// JavaScript Document - Global Functions for WebCash Public Website
$(document).ready(function(){
    
    
    //Safe MailTo Link for Email Addresses - Prevents Spam
    if ($('.email').length > 0){
        $.getScript('js/mailto.js',function(){
            // Execute this function once the plugin is loaded
            $('.email').mailto();
        });
    }

    //Dynamically clears out any text in the input fields
    if ($('.focus-blur').length > 0){
        $.getScript('js/jquery.valueFx.js',function(){
            // Execute this function once the plugin is loaded
            $('.focus-blur').valueFx();
        });
    }
	
    //Makes Twitter Bird bounce on Hover
    $("#account-links a").hover(function() {
        $(this).stop().animate({
            marginTop: "-5px"
        }, 200);
        $(this).parent().find("span").stop().animate({
            marginTop: "10px",
            opacity: 0.25
        }, 200);
    },function(){
        $(this).stop().animate({
            marginTop: "0px"
        }, 300);
        $(this).parent().find("span").stop().animate({
            marginTop: "0px",
            opacity: 1
        }, 300);
    });

	
    //General Show-Hide Link for Seeing Additional Content
    if ($('a.showhide').length > 0){
        // hide divs
        $('div.hidden').hide();
        // slide effect
        $('a.showhide').click(function(){
            $(this).parent().next('div').slideToggle('fast');
            return false;
        });
    }

	

    //Show a Confirmation message when the support form is successfully sent
    if ($('input.support-button').length > 0){
        // hide divs
        $('div.confirmation').hide();
        // slide effect
        $('input.support-button').click(function(){
            $(this).parent().parent('form').slideUp('fast');
            $('div.confirmation').slideDown('fast');
            return false;
        });
    }
	
    //Toggle account tabs/forms
    if ($('#tab-navigation a').length > 0){
        // hide divs
        $('div.form-wrapper').hide();
        $('div.form-wrapper .no-js').hide();
        newForm = $('#tab-navigation a.current').attr('href') + '-wrapper';
        $(newForm).fadeIn('fast');
			
        $('#tab-navigation a').click(function() {
            oldForm = newForm;
            newForm = $(this).attr('href') + '-wrapper';
            $('#tab-navigation a').removeClass();
            $(this).addClass('current');
            $(oldForm).fadeOut('fast', function() {
                $(newForm).fadeIn('fast');
                $('span.update').hide();
            })
				
            return false;
        });
    }
	
    // Show Success Message after saving account settings
    if ($('input.show-updated').length > 0){
        $('span.update').hide();
    }
    $('input.show-updated').click(function() {
        $('span.update').fadeIn();
        return false;
    });
	
    // Show or Hide a Different Set of Options Based on Company Type
    if ($('input.show-company-1').length > 0){
        $('div.company-2,div.company-3').hide();
    }
    $('input.show-company-1').click(function() {
        $('div.company-2').hide();
        $('div.company-3').hide();
        $('div.company-1').fadeIn('fast');
    });
    $('input.show-company-2').click(function() {
        $('div.company-1').hide();
        $('div.company-3').hide();
        $('div.company-2').fadeIn('fast');
    });
    $('input.show-company-3').click(function() {
        $('div.company-1').hide();
        $('div.company-2').hide();
        $('div.company-3').fadeIn('fast');
    });
		
    //Show an Additional Proof of ID for Company Members
    if ($('a.add-company-id').length > 0){
        $('div.company-document-id').hide();
    }
    $('a.add-company-id').click(function() {
        $(this).parent().parent().next('div').slideDown('fast');
        return false;
    });
    $('a.hide-company-id').click(function() {
        $(this).parent().parent('div').slideUp('fast');
        return false;
    });
		
    //Same for Company Onboarding Proof of Address
    if ($('a.add-company-address').length > 0){
        $('div.company-document-address').hide();
    }
    $('a.add-company-address').click(function() {
        $(this).parent().parent().next('div').slideDown('fast');
        return false;
    });
    $('a.hide-company-address').click(function() {
        $(this).parent().parent('div').slideUp('fast');
        return false;
    });
		
    //Hide an Alert when the Hide This link is clicked
    $('a.hide-alert').click(function() {
        $('span.alert').slideUp('fast');
        return false;
    });
		
    //Tool Tip for Onboarding Process
    $("#maincontent a[title]").tooltip({
        // use div.tooltip as our tooltip
        tip: '.tooltip',
        // use the fade effect instead of the default
        effect: 'fade',
        // make fadeOutSpeed similar to the browser's default
        fadeOutSpeed: 100,
        // the time before the tooltip is shown
        predelay: 20,
        // tweak the position
        position: "top center",
        offset: [-20, 4]
    });


});

function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
}
