$wpjQ.getScript("http://use.typekit.com/sjt7gow.js",function(){
    try{Typekit.load();}catch(e){};
});

//This file will be loaded on every view of id.theroot.com screens
$wpjQ(document).ready(function($){
    //set a body class for if the page is in an iframe. The idea being that, if it
    //isn't, the user may not have javaScript. Thus, any css should for iframes
    //should override existing rules just on the body for non-iframes, right?
    if(self !== top){
        $('body').addClass('iframe');
    } else {
        $('body').addClass('non-iframe');
    }
    
    if($('#wapolabs_wrapperOtherLogin').length > 0){
        //addBetaHtmlLogin();  
    }
    
    $("#email_collection_show").click(function(){
        $("#emailCollection.frm-login").slideDown();
    });
    
/*    function addBetaHtmlLogin(){
      var contactEmail = 'help@trove.com',
          welcome =
              '<header class="welcome-message">' +
                  '<h1>Welcome to the Trove Beta!</h1>' +
                  '<h2>Trove keeps you up-to-the-minute on all your interests.</h2>' +
              '</header>',
          legal =
              '<section id="legal" class="legal-message drop-message">' +
                  '<header>' +
                      '<h1>By signing into this site, I accept the <span class="link">Terms of Use</span>.</h1>' +
                  '</header>' +
                  '<div class="body">' +
                      '<p><strong>I understand that this website is not public. I agree to keep confidential all technology, processes, characteristics, details any and all other specifications or information relating in any way to the website not known to me from other sources without an obligation of confidentiality (collectively, the &quot;Confidential Information&quot;). I (i) will not divulge Confidential Information to any third party; (ii) will not copy or reverse engineer any Confidential Information; (iii) will take reasonable precautions to protect such Confidential Information; and (iv) will notify [Company] promptly in the event Confidential Information is revealed to any unauthorized person or persons. I agree to use the Confidential Information only for the purpose of accessing and evaluating the website.</strong></p>' +
                  '</div>' +
              '</section>',
          why =
              '<section id="why" class="why-message drop-message">' +
                  '<header>' +
                      '<h1><span class="link">Why Facebook Connect?</span></h1>' +
                  '</header>' +
                  '<div class="body">' +
                      '<p><strong>We want to deliver the right personalized news and information to get you started.</strong> Connecting with the Likes and Interests in your Facebook profile will improve your experience on Trove.</p>' +
                      '<p><strong>Don&#039;t worry</strong>&#x2014;during the private beta your activity will not be public to your Facebook friends. And we will notify you of any changes to privacy settings.</p>' +
                      '<p class="help">More questions or not interested in connecting via Facebook? <a href="mailto:' + contactEmail + '">Click here</a> to email us.' +
                  '</div>' +
              '</section>',
          help = '<p class="help help-message">' +
              '<strong>You must be authorized to access the private beta.</strong> ' +
              'If you wish to request access or are having difficulty accessing the site, <a href="mailto:' + contactEmail + '">Click here</a> to email us.' +
              '</p>';
      
      $('#wapolabs_wrapperOtherLogin').prepend(welcome).append(legal).append(why).append(help);
      
          
      $('.drop-message h1 span.link').click(function(e){
          var body = $(this).closest('.drop-message').find('.body');
          if( body.is(":hidden") ){
              body.slideDown('fast');
          } else {
              body.slideUp('fast');
          }
          
          $(this).parent('h1').toggleClass('open');
          
      });
    }*/
    
        
    $('input[placeholder]').each(function(){
        var $input = $(this);
        if($input.attr('value') === '' || $input.attr('value') === $input.attr('placeholder')){
            $input.attr('value',$input.attr('placeholder')).addClass('default');
        }
        $input.bind('focusin.message',function(){
            if($input.hasClass('default') && $input.attr('value') == $input.attr('placeholder')){
                $input.attr('value','').removeClass('default');
            }
        })
        .bind('focusout.message', function(){
            if(!$input.hasClass('default') && $input.attr('value') == ''){
                $input.attr('value', $input.attr('placeholder')).addClass('default');
            }
        })
        .closest('form').bind('submit',function(){
            if($input.attr('value') === $input.attr('placeholder')){
                alert('Missing ' + $input.attr('placeholder'));
                return false;
            }
        });
    });
    
});


