﻿VOYFB.init = function () {

    $(".fbimg").lazyload({
        placeholder: "/IMG/Avatar/noAvatar.png",
        container: $(".lazyContainer")
    });

    $(".fbimg2").lazyload({
        placeholder: "/IMG/Avatar/noAvatar.png",
        container: $(".lazyContainer2")
    });


    if (typeof (Cufon) != "undefined" && !$.browser.msie) {
        Cufon.replace('h1');
        Cufon.replace('h2');
        Cufon.replace('h3');
        Cufon.replace('h4');
        Cufon.replace('h5');
        Cufon.replace('h6');
    }

    $('.tipsey').tipsy({ gravity: $.fn.tipsy.autoWE, fade: true });
    $('.tipseyHTML').tipsy({ gravity: $.fn.tipsy.autoWE, fade: true, html: true });
    $('.tipseySouth').tipsy({ gravity: $.fn.tipsy.NS, fade: true });
    $('.tipseySouthHTML').tipsy({ gravity: $.fn.tipsy.NS, fade: true, html: true });

    if ($.browser.msie) {
        $('div.sidebar').each(function () {
            PIE.attach(this);
        });
    }

    $("body").bind("click", function (e) {
        $('a.menu').parent("li").removeClass("open");
    });

    $("a.menu").click(function (e) {
        var $li = $(this).parent("li").toggleClass('open');
        return false;
    });


    $('.nut').draggable({ axis: 'x', opacity: 0.4, cursor: 'e-resize', containment: 'parent', stop: function (e, i) { VOYFB.handleStop(e, i); }, drag: function (e, i) { VOYFB.handleDrag(e, i); } });

    $('.sidebar').after('<div class="poweredBy"><img src="/img/logo/poweredBy.png" alt="Powered By"/></div>');

    $('.focus').focus();

}





VOYFB.Popup = function (title, text, insertID) {
    var id = "pop";
    $('#' + insertID).after('<div class="modal" id="' + id + '" style="position: absolute; top: auto; left: auto; margin: 0 auto; z-index: 100000"><div class="modal-header"><h3>' + title + '</h3><a href="#" class="close" onclick="if(typeof(VOYFB.nextc)!=\'undefined\')VOYFB.nextc();$(\'.modal\').remove();return false;">×</a></div><div class="modal-body"><p>' + text + '</p></div><div class="modal-footer"><a href="#" class="btn primary" onclick="if(typeof(VOYFB.nextc)!=\'undefined\')VOYFB.nextc();$(\'.modal\').remove();return false;">Close</a></div></div>');

}



VOYFB.ReviewBroadcast = function (pl) {

    mpq.track('VOYFB.ReviewBroadcast');

    FB.ui(
   {
       method: 'feed',
       name: 'Review me on ViewsOnYou',
       link: 'http://apps.facebook.com/viewsonyou' + pl,
       picture: 'http://www.viewsonyou.com/img/voy75.png',
       caption: "I'm using ViewsOnYou to get reviewed by the people who know me best, and it would be great if you could review me. It's really easy, only takes 3 minutes, and you can be as honest as you like!",
       description: '',
       message: ''

   },
   function (response) {
       if (response && response.post_id) {

       } else {

       }
   }
 );


}


VOYFB.Request = function (n, fid, url) {
    mpq.track('VOYFB.Request', { 'mp_note': n + ' to:' + fid });
    $.get('/genericfb.asmx?T=REQUEST&id=' + fid);

    FB.ui(
   {
       to: fid,
       method: 'send',
       name: 'Review ' + n + ' on ViewsOnYou',
       link: url,
       picture: 'http://facebook.viewsonyou.com/img/voy75.png',
       caption: "I'm using ViewsOnYou to get reviewed by the people who know me best, and it would be great if you could review me. It's really easy, only takes 3 minutes, and you can be as honest as you like!",
       description: '',
       message: ''

   },
   function (response) {
       if (response && response.post_id) {

       } else {

       }
   }
 );



}



VOYFB.InviteCompanyJoin = function (n, fid, url) {
    mpq.track('VOYFB.InviteCompanyJoin', { 'mp_note': n + ' to:' + fid });
    

    FB.ui(
   {
       to: fid,
       method: 'feed',
       name: 'Join ViewsOnYou',
       link: 'http://apps.facebook.comn/viewsonyou',
       picture: 'http://facebook.viewsonyou.com/img/voy75.png',
       caption: "I'm using ViewsOnYou to discover my match with leading companies. Join ViewsOnYou to share your company profile with me, and find YOUR best company match.",
       description: '',
       message: ''

   },
   function (response) {
       if (response && response.post_id) {

       } else {

       }
   }
 );



}






VOYFB.RolePublishComparisons = function (text, link, i1, i2) {

    mpq.track('VOYFB.RolePublishComparisons', { 'mp_note': text + ' link:' + link });

    FB.ui(
   {
       method: 'feed',
       name: text + '!',
       link: 'http://apps.facebook.com/viewsonyou/?REDIR=' + link,
       picture: 'http://facebook.viewsonyou.com/generic.asmx?T=DOUBLEUPIMG&I1=' + escape(i1) + '&I2=' + escape(i2),
       caption: 'View the culture of leading companies, compare them against each other and discover how you fit',
       description: '',
       message: ''
   },
   function (response) {
       if (response && response.post_id) {

       } else {

       }
   }
 );
}


VOYFB.RolePublishComparisonsModels = function (text, link, i1, i2) {

    mpq.track('VOYFB.RolePublishComparisons', { 'mp_note': text + ' link:' + link });

    FB.ui(
   {
       method: 'feed',
       name: text + '!',
       link: 'http://apps.facebook.com/viewsonyou/?REDIR=' + link,
       picture: 'http://facebook.viewsonyou.com/generic.asmx?T=DOUBLEUPIMG&I1=' + escape(i1) + '&I2=' + escape(i2),
       caption: 'Discover the global role models you are most similar to and see what key traits you and your network share with politicians, entrepreneurs and business leaders. Are you the next Steve Jobs or Richard Branson?',
       description: '',
       message: ''
   },
   function (response) {
       if (response && response.post_id) {

       } else {

       }
   }
 );
}



VOYFB.RolePublish = function (text, name, u1, u2) {

    mpq.track('VOYFB.RolePublish', { 'mp_note': text + ' name:' + name});

    FB.ui(
   {
       method: 'feed',
       name: text+'!',
       link: 'http://apps.facebook.com/viewsonyou/?REDIR=/site/compare/teamDNA.aspx?USER=' + u1 + '%26USER2=' + u2,
       picture: 'http://facebook.viewsonyou.com/generic.asmx?T=DOUBLEUP&U1=' + u1 + '&U2=' + u2,
       caption: 'View the comparison on ViewsOnYou and find out how YOU compare to ' + name + ' and other role models.',
       description: '',
       message: ''
   },
   function (response) {
       if (response && response.post_id) {
           
       } else {
           
       }
   }
 );
}


VOYFB.SharePublicProfile = function (url) {

    mpq.track('VOYFB.SharePublicProfile', { 'mp_note': url });

    FB.ui(
   {
       method: 'feed',
       name: 'My ViewsOnYou Public Profile',
       link: url,
       picture: 'http://facebook.viewsonyou.com/img/voy75.png',
       caption: 'View my public ViewsOnYou Profile',
       description: '',
       message: ''
   },
   function (response) {
       if (response && response.post_id) {
           //document.location.href = '/site/';
       } else {
           // document.location.href = '/site/';
       }
   }
 );
}




VOYFB.ShareJOC = function (text, uid) {
    mpq.track('VOYFB.ShareJOC', { 'mp_note': text + ' ' + uid });

    FB.ui(
   {
       method: 'feed',
       name: 'My ViewsOnYou Judge of Character',
       link: 'http://apps.facebook.com/viewsonyou/',
       picture: 'http://www.viewsonyou.com/generic.asmx?T=JOCEMBLEM&U=' + uid,
       caption: text,
       description: '',
       message: text
   },
   function (response) {
       if (response && response.post_id) {
           //document.location.href = '/site/';
       } else {
           // document.location.href = '/site/';
       }
   }
 );
}


VOYFB.ShareMost = function (text, u1, u1pic) {
    mpq.track('VOYFB.ShareMost', { 'mp_note': text });

    FB.ui(
   {
       method: 'feed',
       name: text,
       link: 'http://apps.facebook.com/viewsonyou/?REDIR=/site/analyseMe.aspx?UID=' + u1,
       picture: u1pic,
       caption: 'Review your friends on ViewsOnYou and discover how you compare to each other!',
       description: '',
       message: text
   },
   function (response) {
       if (response && response.post_id) {
           //document.location.href = '/site/';
       } else {
           // document.location.href = '/site/';
       }
   }
 );
}




VOYFB.ShareCompare = function (text, u1, u2) {

    mpq.track('VOYFB.ShareCompare', { 'mp_note': text });

    FB.ui(
   {
       method: 'feed',
       name: text,
       link: 'http://apps.facebook.com/viewsonyou/?REDIR=/site/compare/teamDNA.aspx?USER=' + u1 + '%26USER2=' + u2,
       picture: 'http://facebook.viewsonyou.com/generic.asmx?T=DOUBLEUP&U1=' + u1 + '&U2=' + u2,
       caption: 'Review your friends on ViewsOnYou and discover how you compare to each other!',
       description: '',
       message: text
   },
   function (response) {
       if (response && response.post_id) {
           //document.location.href = '/site/';
       } else {
          // document.location.href = '/site/';
       }
   }
 );
}



VOYFB.ShareCompanyCompare = function (text, img, u1) {

    mpq.track('VOYFB.ShareCompanyCompare', { 'mp_note': text });

    FB.ui(
   {
       method: 'feed',
       name: text,
       link: 'http://apps.facebook.com/viewsonyou/?REDIR=/site/analyseMe.aspx?UID=' + u1,
       picture: img,
       caption: 'Review your friends on ViewsOnYou and discover how you compare to each other!',
       description: '',
       message: text
   },
   function (response) {
       if (response && response.post_id) {
           //document.location.href = '/site/';
       } else {
           // document.location.href = '/site/';
       }
   }
 );
}



VOYFB.TellReviewRoleModel = function (fid, url, fn, u1, u2) {
    mpq.track('VOYFB.TellReviewRoleModel', { 'mp_note': url });

    FB.ui(
   {
       method: 'feed',
       name: 'ViewsOnYou Public Role Model Review',
       link: url,
       picture: 'http://facebook.viewsonyou.com/generic.asmx?T=DOUBLEUP&U1=' + u1 + '&U2=' + u2,
       caption: 'I\'ve just reviewed ' + fn + ' on ViewsOnYou! See what I think and how similar we are.',
       description: '',
       message: ''
   },
   function (response) {
       if (response && response.post_id) {
           document.location.href = '/site/reviewJOC.aspx?UID=' + u1;
       } else {
           document.location.href = '/site/reviewJOC.aspx?UID=' + u1;
       }
   }
 );
}


VOYFB.TellReview = function (fid, url, fn, u1, u2, c) {

    mpq.track('VOYFB.TellReview', { 'mp_note': url });
    FB.ui(
   {
       to: fid,
       method: 'feed',
       name: 'ViewsOnYou Review',
       link: url,
       picture: 'http://facebook.viewsonyou.com/generic.asmx?T=DOUBLEUP&U1=' + u1 + '&U2=' + u2,
       caption: c,
       description: '',
       message: ''
   },
   function (response) {
       if (response && response.post_id) {
           document.location.href = '/site/reviewJOC.aspx?UID=' + u1;
       } else {
           document.location.href = '/site/reviewJOC.aspx?UID=' + u1;
       }
   }
 );
}






$(document).ready(function () { VOYFB.init(); });




VOYFB.Scroll = function (x, y) {
    var isInIFrame = (window.location != window.parent.location) ? true : false;

    if (isInIFrame) { FB.Canvas.scrollTo(x, y); }
    else {
        $.scrollTo(x, 100);
    }
}


VOYFB.notEnough = function () {
    VOYFB.Popup('Validate Profile', 'You must have a validated profile in order to access ViewsOnYou.com.<br/><br/>Receive 7+ reviews to validate your profile. This means your profile is trusted by employers, clients and co-workers, and allows you to unlock additional functionality', 'notEnough'); return false;
}



VOYFB.HowReviewsWork = function () {
    VOYFB.Popup('How reviews work', '<b>Get Reviews</b><br/><br/>Send a message to people inviting them to review you.<br/><br/>You can choose which reviews you publish to your profile.<br/><br/>The more reviews you receive, the more accurate your profile becomes. Receive 7+ reviews to get a Validated Profile, that is trusted by recruiters and hiring managers.<br/><br/><b>Review People</b><br/><br/>Review anyone in your network.<br/><br/>You can update or delete reviews you make whenever you want.<br/><br/>The more reviews you make, the more accurate you Judge of Character ranking becomes.', 'reviewsText'); return false;
}   
