window.fbAsyncInit = function() {
    FB.init({
        appId:facebookAppID, cookie:true, oauth:true, xfbml:true
     });

    FB.Event.subscribe('auth.login', function(response) {
        FacebookLogin();        
    });

    FB.Event.subscribe('xfbml.render', function(response) {
        if (FB.getUserID()){
            var button_html = '<a class="fb_button fb_button_medium" onclick="FacebookLogin()"><span class="fb_button_text">Login with Facebook</span></a>';
            var fb_buttons = $('.fb_button').parent();
            fb_buttons.after(button_html);
            fb_buttons.remove();
        }
    });

}



function FacebookLogin()
{
    if (FB.getUserID())
    {
        setTimeout(function(){
            parent.window.location.href = '/fb';
        }, 1000);        
    }
}


$(document).ready(function(){

    $('.upload_form select').jqTransSelect();
	$('.transSelect select').jqTransSelect();

    $('input[placeholder]').placeholder();

    $(".btn").mouseover(function(){
        $(this).addClass("btn_ov");
    }).mouseout(function(){
        $(this).removeClass("btn_ov");
    });


    $('#btn_search_keywords').click(function(){
        if(!validateSearchForm()) return false;
        document.searchForm.submit();
    });



});
function validateSearchForm()
{
         if($('#search_keywords').val()==''|| $('#search_keywords').val()=='Search'){
           return false;
         }
         else return true;
}

function initPanels(selectedPanel)
{
    if(selectedPanel > 0)
    {
        if(selectedPanel == 1)
        {
            $('#iLoginForm').show();
            $('#iRegisterForm').hide();
            $('#iBenefits').hide();

        }else
        {
            $('#iLoginForm').hide();
            $('#iRegisterForm').show();
            $('#iBenefits').show();

        }

    }else
    {
        if($("input[name=rbLoginRegister]:checked").val() == "1")
        {
            $('#iLoginForm').show();
            $('#iRegisterForm').hide();
            $('#iBenefits').hide();

        }else
        {
            $('#iLoginForm').hide();
            $('#iRegisterForm').show();
            $('#iBenefits').show();
        }
    }

}
