(function ($) {
    $.fn.customFadeIn = function (speed, callback) {
        $(this).fadeIn(speed, function () {
            if (jQuery.browser.msie) $(this).get(0).style.removeAttribute('filter');
            if (callback != undefined) callback();
        });
    };
    $.fn.customFadeOut = function (speed, callback) {
        $(this).fadeOut(speed, function () {
            if (jQuery.browser.msie) $(this).get(0).style.removeAttribute('filter');
            if (callback != undefined) callback();
        });
    };
})(jQuery);
fader = function (id, _in) { if (_in) $('#' + id).customFadeIn('fast'); if (!_in) $('#' + id).customFadeOut('fast'); }; 
  
  


$(document).ready(function () {
    //$('.top5Img').hoverbox(); $('.top5ImgHow').hoverbox(); /*$('.hoverMe').hoverbox();*/
    
    
    if ( !$.browser.msie ) if (typeof (Cufon) != "undefined") { Cufon.replace('h1'); Cufon.replace('h2'); Cufon.replace('h3'); Cufon.replace('h4'); Cufon.replace('h5'); Cufon.replace('h6'); Cufon.replace('div.h7'); Cufon.replace('div.h8'); }

    //$('.boldDesc').hover(function () { $(this).css('font-weight', 'bold').css('font-size','110%'); }, function () { $(this).css('font-weight', 'normal').css('font-size','100%'); });

    //$('.opacityFadeInVehicle').hover(function () { $('#' + $(this).attr('fader')).animate({ opacity: 1 }); }, function () { $('#' + $(this).attr('fader')).animate({ opacity: 0.86 }); }); 

    
    roundedCorners();

   // if ($('.focus').length > 0) if (!$($('.focus')[0]).attr('disabled')) $('.focus')[0].focus();

    $('.onclick').each(function (i) { $(this).keypress(function (e) { if (e.which == 13) { $('#' + $(this).attr('clicker')).click(); return false; } }); });
   // $('.hoverAuto').each(function (i) { $(this).hover(function () { $(this).attr('src', $(this).attr('hover')); }, function () { $(this).attr('src', $(this).attr('orig')); }); });
    $('.watermark').each(function (i) { $(this).watermark($(this).attr('watermark')); }); 


    /*if ($('.profileMenu').length > 0) {
    $('.profileMenu').contextMenu({ menu: 'myMenu' }, function (action, el, pos) {
    if (action == 'viewProfile') { document.location.href = '/profile.aspx?UID=' + $(el).attr('userid'); return; }
    if (action.split('_')[0] == 'shortList') { addToShortList(action.split('_')[1], $(el).attr('userid'), $('#jobid').val()); return; }
    alert('Action: ' + action + '\n\n' + 'Element ID: ' + $(el).attr('userid') + '\n\n' + 'X: ' + pos.x + '  Y: ' + pos.y + ' (relative to element)\n\n' + 'X: ' + pos.docX + '  Y: ' + pos.docY + ' (relative to document)');
    });*/

    
});





jQuery.fn.tabs = function (t, i) {

    var formArea = $(this[0]);

    if (t == 'select') {
        var p = 0;
        // i is the index we want to show

        formArea.find('li').each(function () { $(this).removeClass('active'); });

        formArea.find('li').each(function () {
            var li = $(this);
            var a = $($(this).find('a')[0]);
            if (i == p) {
                li.addClass('active');
                $(a.attr('href')).css('display', 'block');
            } else {
                li.removeClass('active');
                $(a.attr('href')).css('display', 'none');
            }
            p += 1;
        });

        var g = {};
        g.index = i;

        formArea.trigger('tabsselect', g);
        return;
    }




    formArea.find('ul').addClass('safeTabs');

    $($(formArea.find('ul')[0]).find('li')[0]).addClass('active');

    formArea.find('li').each(function () {

        var a = $($(this).find('a')[0]);
        var di = $(a.attr('href'));
        
        di.css('width','574px');
        di.css('position','relative');
        if (!$(this).hasClass('active')) {
            $(a.attr('href')).css('display', 'none');

        }

        a.click(function () {
            var p = $(this).parent().parent(); p.find('li').removeClass('active'); $(this).parent().addClass('active');

            p.find('li').each(function () {

                var a = $($(this).find('a')[0]);

                if (!$(this).hasClass('active')) {
                    $(a.attr('href')).css('display', 'none');
                } else { $(a.attr('href')).css('display', 'block'); }


            });
            return false;
        });

    });

}


showPopAlert=function(text){$('#popAlert').html(text);$('#popAlert').customFadeIn('fast');setTimeout("$('#popAlert').customFadeOut('fast')",2000);}
sendMail=function(toPerson,jobID,tgmID){
if($('#message').val()!=''&&$('#subject').val()!=''){
$.post('/genericAuth.asmx?T=EMAIL&JOB='+jobID+'&TGM='+tgmID,
{subject:$('#subject').val(),message:$('#message').val(),to:toPerson},
function(data)
{

if ( document.location.href.indexOf('subGroupAccess.aspx')!=-1 )
{
    document.location.href =document.location.href + '&' + Math.random();
    return;
}
if(jobID=='00000000-0000-0000-0000-000000000000'||
document.location.href.indexOf('mail.aspx')!=-1){
document.location.href='/mail.aspx';}

else{document.location.href='/Employer/contactApplicants.aspx?JOB='+jobID;}});}
else{$('.error').remove();if($('#subject').val()=='')$('<label/>').addClass('error').html('This field is required.').insertAfter($('#subject'));if($('#message').val()=='')$('<label/>').addClass('error').html('This field is required.').insertAfter($('#message'));}}
importEmail=function(uid){$('#emailResults').css('display','none');$('#loading').css('display','block');$('#emailResultsTable').css('display','none');$('#inviteSelected').css('display','none');$('#emailResults').customFadeIn('slow');$.get('/generic.asmx?T=IMPORTEMAIL&provider='+$('#provider').val()+'&username='+$('#username').val()+'&password='+$('#password').val()+'&UID='+uid,function(data){$('#loading').customFadeOut('fast');$('#emailResultsTable').customFadeIn('fast');$('#inviteSelected').customFadeIn('slow');$('#emailImportResults').html(strip(data));});}
inviteSelected=function(jobid,type){if(typeof type=="undefined")type='';var emails='';for(x=0;x<$("input[name='contact']").length;x++){if($("input[name='contact']")[x].checked){emails+=$("input[name='contact']")[x].value+',';}}
if(emails!=''){emails=emails.substr(0,emails.length-1);Boxy.load('/Popup/Invite.aspx?EMAILS='+emails+(jobid!=''?'&JOB='+jobid:'')+'&TYPE='+type,{modal:true});}
else{alert('No emails selected');}}
sendInviteAction=function(){$('#sendInvite').val("Sending Invite(s)");$('#sendInvite').attr('disabled','true');$.get("/genericAuth.asmx?T=QUICKINVITE&EMAILS="+$('#emails').val()+"&MESSAGE="+$('#message').val().replace(/\n/gi,'~'),function(data){alert(strip(data));document.location.href='/home.aspx';});}


extendedInvite = function (email,name,t) {
    $.get("/genericAuth.asmx?T=QUICKINVITETEAM" + "&ISJOB=false" + "&EMAILS=" + name + ','+email +
            "&MESSAGE=" + $('#messageEmbed').val().replace(/\n/gi, '~'),
        function (data) {
            Boxy.get(t).hideAndUnload();
            Boxy.load('/Popup/Message.aspx?CUSTMSG=' + strip(data), { modal: true });
         });
}


previewInviteEmbedAction = function (isTeam, isIframe) {
    var emailSendString = '';
    for (x = 0; x < 100; x++) {
        if ($('#email' + x).length == 0) break;
        if ($('#email' + x).val() != '' && $('#email' + x).length > 0) {
            emailSendString += $('#name' + x).val() + ',' + $('#email' + x).val() + ',';
        }
    }
    if (emailSendString == '') {
        alert('You have not entered anyone to send the invite to');
    }
    else {
        $.get("/genericAuth.asmx?T=QUICKINVITEPENDING&EMAILS=" + emailSendString, function data() {
            if (isIframe) {
                document.location.href = '/iframe/previewInvite.aspx?BACK=' + escape(document.location.href) + (isTeam ? "&ISTEAM=true" : "");
            } else {

                document.location.href = '/previewInvite.aspx?BACK=' + escape(document.location.href) + (isTeam ? "&ISTEAM=true" : "");
            }
        });
    }
}
sendInviteEmbedAction = function (isjob, jobid, isteam) {

    var emailSendString = '';
    for (x = 0; x < 100; x++) {
        if ($('#email' + x).length == 0) break;
        if ($('#email' + x).val() != '' && $('#email' + x).length > 0) {
            emailSendString += $('#name' + x).val() + ',' + $('#email' + x).val() + ',';
        }
    }



    if (emailSendString == '') {
        alert('You have not entered anyone to send the invite to');
    }
    else {
        $('.error').remove();
        $('#sendInviteEmbed').val("Sending Invite(s)");
        $('#sendInviteEmbed').attr('disabled', 'true');
        $.get("/genericAuth.asmx?T=QUICKINVITE" +  (isteam?"TEAM":"") +"&ISJOB=" + isjob + "JOBID="
            + jobid + "&EMAILS=" + emailSendString +
            "&MESSAGE=" + $('#messageEmbed').val().replace(/\n/gi, '~'),
        function (data) {

            Boxy.load('/Popup/Message.aspx?CUSTMSG=' + strip(data), { modal: true });
            $('#sendInviteEmbed').removeAttr('disabled');
            $('#sendInviteEmbed').val('Send Invite(s)');


            for (x = 0; x < 100; x++) {
                if ($('#email' + x).length == 0) break;
                $('#name' + x).val('');
                $('#email' + x).val('');
            }

        });
    }
}


addToShortList=function(selectID,userid,jobid){if($('#'+selectID).length>0){if($('#'+selectID).val()=='new'){Boxy.load('/Popup/Shortlist.aspx?USERS='+userid+'&JOB='+jobid+'&RURL='+escape(document.location.href),{modal:true});}
else{$.get('/genericAuth.asmx?T=ADDSHORTLIST&ADDUSER='+userid+'&SHORTLIST='+$('#'+selectID).val(),function(data){showPopAlert('Added to short list');});}}
else{if(selectID=='new'){Boxy.load('/Popup/Shortlist.aspx?USERS='+userid+'&JOB='+jobid+'&RURL='+escape(document.location.href),{modal:true});}
else{$.get('/genericAuth.asmx?T=ADDSHORTLIST&ADDUSER='+userid+'&SHORTLIST='+selectID,function(data){showPopAlert('Added to short list');});}}}
createShortlist=function(addUserId,jobId,url){if($('#shortListName').val()==''){if($('#shortListName').val()=='')$('<label/>').addClass('error').html('This field is required.').insertAfter($('#shortListName'));}
else{$('.error').remove();$.get('/genericAuth.asmx?T=CREATESHORTLIST&ADDUSER='+addUserId+'&SHORTLISTNAME='+escape($('#shortListName').val())+'&JOBID='+jobId,function(data){document.location.href=url;});}}
newShortListMulti=function(users,jobid){$('select').css('display','none');Boxy.load('/Popup/Shortlist.aspx?USERS='+users+'&JOB='+jobid+'&RURL='+escape(document.location.href),{modal:true});}
removeFromShortList=function(delUser,shortList){$.get('/genericAuth.asmx?T=REMOVESHORTLIST&USER='+delUser+'&SHORTLIST='+shortList,function(data){document.location.reload();});}
quickAccept=function(rel,t,rev){$.get('/genericAuth.asmx?T=ACCEPTREVIEW&REL='+rel,function(data){$('#'+rel).html('Accepted');if(strip(data)=='NO'){Boxy.load('/Popup/ReviewBack.aspx?UID='+rev,{modal:true});}});$(t).customFadeOut('fast');}
sendBreakNotification=function(bid,b){$.get('/genericAuth.asmx?T=BREAKTHROUGHEMAIL&BREAK='+bid,function(data){alert('Notification Sent');Boxy.get(b).hideAndUnload(function(){document.location.reload();});});}
showPop=function(data){Boxy.load('/Popup/BreakthroughAlert.aspx?BREAK='+data,{modal:true});}

removeComment=function(comment){$.get('/genericAuth.asmx?T=REMOVECOMMENT&COMMENT='+comment,function(data){document.location.reload();});}
showExtendedNetworkActivity=function(a){if($('#networkExtended').css('display')==''||$('#networkExtended').css('display')=='none'){$('#networkExtended').customFadeIn('fast');$(a).html('Hide More');}
else{$('#networkExtended').customFadeOut('fast');$(a).html('Show More');}}
removeRequest=function(inviteRequestId){if(confirm('Are you sure you want to hide this request?')){$.get('/genericAuth.asmx?T=REMOVEREQUEST&ID='+inviteRequestId,function(data){$('#'+inviteRequestId).css('display','none');});}}
onHelp=function(type){Boxy.load('/Popup/Message.aspx?MSG='+type,{modal:true})}
previewInvite = function (name, val, user) {

    
    window.open('/mailTemplates/invitePreview.aspx?NAME=' + escape('&lt;First Name&gt;') + 
'&BODY=' + escape(val) + '&USER=' + user, "popup", "width=650,height=600,status=0,scrollbars=1"); }


previewTeamInvite = function (name, val, uid, known) { window.open('/mailTemplates/teamPreview.aspx?NAME=' + escape('&lt;First Name&gt;') + '&BODY=' + escape(val) + '&USER=' + uid + (known?'&ISKNOWN=true':''), "popup", "width=650,height=600,status=0,scrollbars=1"); }


replySent=function(id){if($('#s_'+id).css('display')=='block'||$('#s_'+id).css('display')=='table-row'){$('#s_'+id).css('display','none');}
else{if(!$.browser.msie)$('#s_'+id).css('display','table-row');else $('#s_'+id).css('display','block');}}
reply=function(id){if($('#'+id).css('display')=='block'||$('#'+id).css('display')=='table-row'){$('#'+id).css('display','none');}
else{$('#'+id).css('display','block');if(!$.browser.msie)$('#'+id).css('display','table-row');$.get('/generic.asmx?T=MARKREAD&EMAILID='+id,function(data){$('#b_'+id).css('font-weight','normal');});}}
unread=function(id){$.get('/generic.asmx?T=MARKUNREAD&EMAILID='+id,function(data){$('#b_'+id).css('font-weight','bold');});reply(id);}
canSubmitReview=function(){var selector='img[src="/IMG/Review/top_s.png"]';if($.browser.msie&&$.browser.version<=7){selector='img[src="http://www.viewsonyou.com/IMG/Review/top_s.png"]';}
if($(selector).length==5){return true;}
else{alert('You need to select five questions that you consider are your review top 5. Click on the "Top 5" image next to the questions until you have five selected.');return false;}}

setFilterAndRefresh = function (rtype, stype) {
    var rtypeA = []; var stypeA = []; $('#' + rtype + ' :selected').each(function (i, selected) {
        rtypeA[i] = $(selected).val();
    }); $('#' + stype + ' :selected').each(function (i, selected) {
        stypeA[i] = $(selected).val();
    });
    $.get('/genericAuth.asmx?T=REVIEWFILTERS&RTYPE=' + rtypeA.join(',') + '&STYPE=' + stypeA.join(','),
   function (data) { document.location.reload(); });
}

addFilterAndRefresh = function (rtype, stype) {
    var rtypeA = []; var stypeA = []; $('#' + rtype + ' :selected').each(function (i, selected) {
        rtypeA[i] = $(selected).val();
    }); $('#' + stype + ' :selected').each(function (i, selected) {
        stypeA[i] = $(selected).val();
    });
    $.get('/genericAuth.asmx?T=REVIEWFILTERSADD&RTYPE=' + rtypeA.join(',') + '&STYPE=' + stypeA.join(','),
   function (data) { document.location.reload(); });
}


showMoreInfoRecruiter=function(){Boxy.load('/Popup/RecruiterMore.aspx',{modal:true});}
onReuse=function(profileUser){if($('#reuseID').val()!=''){$.get('/genericauth.asmx?T=REUSE&UID='+profileUser+'&USEON='+$('#reuseID').val(),function(data){showMessage('You have succesfully reused this review on '+$('#reuseName').val()+'. <a href="/reviewManagement.aspx?TABSELECT=1">Manage this Review</a>');});}}

weHaveFacebook=function(user){$('p.facebook').css('display','block');}
getReviewsHowWorks=function(){window.open('/Popup/ReviewWorksMore.aspx',"popup","width=630,height=600,status=0,scrollbars=1");}
highlightLogin=function(){$.scrollTo(0,50);$('#topLogin1_txtEmail').focus();$('#topLogin').highlightFade('yellow');}
update_state=function(){if($('#country').val()=='US'){$('#state').css('display','block');$('#state').highlightFade('yellow');}
else{$('#state').css('display','none');$('#state').val('');}}
accountOptions=function(){if($('#menu').css('display')=='block'){$('#menu').customFadeOut('fast',function(){$('#menuBlock').customFadeIn('fast',function(){$('#menuUpDown').attr('src','/IMG/Buttons/menuDown.png');});});}
else{$('#menuBlock').customFadeOut('fast',function(){$('#menu').customFadeIn('fast',function(){$('#menuUpDown').attr('src','/IMG/Buttons/menuUp.png');});});}}
seeProfileUrl = function (addr) { Boxy.load('/Popup/ViewProfileUrl.aspx?ADDR=' + addr, { modal: true }); };

handleDrag = function (e, i) {
    
    if (i.helper.attr('slider') != '') $('#' + i.helper.attr('slider')).customFadeOut('fast');
    if (typeof hasMoved != 'undefined') { hasMoved = true; }
    if (typeof completedQuestions != 'undefined') {
        var qa = i.helper.attr('questionarea');
        if ($.inArray(qa, completedQuestions) == -1) completedQuestions.push(qa);

        if (completedQuestions.length == 1) {


            if ($('#holderUntilSliderMoved').length == 0) {
                $('.f3').customFadeIn('fast');
            } else {
                $('#holderUntilSliderMoved').customFadeOut('fast', function () { $('.f3').customFadeIn('fast'); });
            }

            if ($('#reviewTabs').tabs('option', 'selected') == 2) {
                $('.f4').customFadeIn('fast');
            }

        }
    }
    vChange((i.position.left / 2.5), i.helper.attr('id'));
    $('.tracksHowto').customFadeOut('slow');
}



handleStop = function (e, i) {



    var setAccepted = false;
    if (document.location.href.indexOf('completeSlider') != -1) {
        setAccepted = true;
    }
    if (i.helper.attr('slider') != '') $('#' + i.helper.attr('slider')).customFadeOut('fast');
    var reviewer = i.helper.attr('reviewer'); var reviewed = i.helper.attr('reviewed'); var question = i.helper.attr('question'); var level = ((i.position.left<=2?i.position.left:(i.position.left>=471?i.position.left+34:i.position.left)) / 2.5); if (level == 0) level = 1; if (i.position.left == 0) { i.helper.css('left', '1px'); }
    i.helper.css('opacity', 0.9); var job = i.helper.attr('job'); var qs = i.helper.attr('questionset'); var tgm = i.helper.attr('tgm'); var session = i.helper.attr('session'); var how = i.helper.attr('how');

    if (how != undefined && how != null && how != '') {
        level = ((i.position.left + 34) / 2.5);
        $.get('/genericAuth.asmx?T=HOWREVIEW&REVIEWER=' + reviewer + '&REVIEWED=' + reviewed + '&LEVEL=' + level + '&QUESTION=' + question);
        updateReviewProgress();

        if (setAccepted) {
            var foundCount = 0;
            $('.nut').each(function () { if ($(this).css('left') == '0' || $(this).css('left') == '0px') { } else { foundCount += 1; } })

            if ( foundCount == 2 ) document.location.href = "completeSliderData.aspx"
        }
        return;
    }
    if (session != undefined && session != null && session != '') { $.get('/genericAuth.asmx?T=SESSIONREVIEW&LEVEL=' + level + '&QUESTION=' + question, function (d) { updateSessionComparison(); }); }
    else {
        if (tgm != undefined && tgm != null && tgm != '') { $.get('/genericAuth.asmx?T=TGMREVIEW&TGM=' + tgm + '&LEVEL=' + level + '&QUESTION=' + question); }
        else if (job != undefined && job != null && job != '') { $.get('/genericAuth.asmx?T=JOBREVIEW&JOB=' + job + '&LEVEL=' + level + '&QUESTION=' + question); }
        else if (qs != undefined && qs != null && qs != '') { $.get('/genericAuth.asmx?T=CUSTOMQUESTION&QS=' + qs + '&LEVEL=' + level + '&QUESTION=' + question); }
        else {
            if (!setAccepted) {
                $.get('/genericAuth.asmx?T=REVIEW&REVIEWER=' + reviewer + '&REVIEWED=' + reviewed + '&LEVEL=' + level + '&QUESTION=' + question + '&GEN=' + $('#gen').val());
            } else {
                $.get('/genericAuth.asmx?T=REVIEW&REVIEWER=' + reviewer + '&REVIEWED=' + reviewed + '&LEVEL=' + level + '&QUESTION=' + question + '&KEEPSTATUS=true' + '&GEN=' + $('#gen').val(),
                   function (d) {
                       if ($('.howNut').length == 0) {


                           var foundCount = 0;
                           $('.nut').each(function () { if ($(this).css('left') == '0' || $(this).css('left') == '0px') { } else { foundCount += 1; } })

                           if (foundCount == 2) document.location.href = "completeSliderData.aspx"

                           
                       }
                   });
            }
        }
    }
    $('#finalize').customFadeIn('fast'); updateReviewProgress();
}

   var boxyLoaded = false;
   updateReviewProgress = function () {
       var x = 0; var completed = 0;
       for (x = 0; x < $('.nut').length; x++) {
           if ($($('.nut')[x]).css('left') != '0px' && $($('.nut')[x]).css('left') != '505px') { completed += 1; }
       }
       $('#reviewProgressBar').css('display', 'block');
       $('#reviewProgressBar').animate({ backgroundPosition: '-' + (220 - (((completed / $('.nut').length) * 220))) + 'px center' }, { duration: 500 });
       $('#reviewProgressText').html('Questions Progress ' + Math.round(((completed / $('.nut').length) * 100)) + '%');
       if (Math.round(((completed / $('.nut').length) * 100)) == 100) { $('#nextUnansweredText').html('All Questions Answered'); } else { }
       var selector = 'img[src="/IMG/Review/top_s.png"]';
       if ($.browser.msie && $.browser.version <= 7) { selector = 'img[src="http://www.viewsonyou.com/IMG/Review/top_s.png"]'; }

       $('#top5ProgressBar').animate({ backgroundPosition: '-' + (220 - ($(selector).length * (220 / 5))) + 'px center' }, { duration: 500 });
       $('#top5ProgressText').html('Top 5 Progress ' + Math.round($(selector).length * (100 / 5)) + '%')
    ; if ($(selector).length == 0 && completed == 0) {
           $('#top5ProgressBar').css('background-position', '-220px center');
           $('#top5ProgressBar').animate({ backgroundPosition: '220px center' }, { duration: 800 });
           $('#reviewProgressBar').css('background-position', '-220px center');
           $('#reviewProgressBar').delay(200).animate({ backgroundPosition: '220px center' }, { duration: 800 });
       }
       var completedSelf = 0;
       if (Math.round(((completed / $('.nut').length) * 100)) == 100) {
           $('.nut100').css('display', 'block');
       }
       if (Math.round(((completed / $('.nut').length) * 100)) == 100 && typeof newReview != "undefined") {
           var selectorSelf = 'img[src="/IMG/Review/top_how.png"]';
           if ($.browser.msie && $.browser.version <= 7) {
               selectorSelf = 'img[src="http://www.viewsonyou.com/IMG/Review/top_how.png"]';
           }

           if ($(selectorSelf).length > 0) {
               selectorSelf = 'img[src="/IMG/Review/top_how_s.png"]';
               if ($.browser.msie && $.browser.version <= 7) {
                   selectorSelf = 'img[src="http://www.viewsonyou.com/IMG/Review/top_how_s.png"]';
               }


               for (x = 0; x < $('.howNut').length; x++) {
                   if ($($('.howNut')[x]).css('left') != '-34px') { completedSelf += 1; }
               }
               if (completedSelf - $('.howNut').length == 0) {
                   //Boxy.load('/Popup/ReviewDone.aspx', { modal: true });
               }
           } else {
               if ($('#leftColContent_ddlRelationship').length > 0) {
                   if ($('#leftColContent_ddlRelationship').val() != '' && $('#leftColContent_ddlKnownFor').val() != '') {
                       //Boxy.load('/Popup/ReviewDone.aspx', { modal: true });
                   }
               }
               else {

                   if ($('.howNut').length > 0) {
                       for (x = 0; x < $('.howNut').length; x++) {
                           if ($($('.howNut')[x]).css('left') != '-34px') { completedSelf += 1; }
                       }

                       if (completedSelf - $('.howNut').length == 0) {

                           //if ( ! boxyLoaded ) Boxy.load('/Popup/ReviewDone.aspx', { modal: true });
                           // boxyLoaded = true;
                       }
                   } else {

                       //Boxy.load('/Popup/ReviewDone.aspx', { modal: true });
                   }
               }
           }


       }
       if ($('#reviewProgressBarHow').length > 0) {
           var selector = 'img[src="/IMG/Review/top_how_s.png"]'; if ($.browser.msie && $.browser.version <= 7) { selector = 'img[src="http://www.viewsonyou.com/IMG/Review/top_how_s.png"]'; }
           $('#top5ProgressBarHow').animate({ backgroundPosition: '-' + (220 - ($(selector).length * (220 / 5))) + 'px center' }, { duration: 500 }); $('#top5ProgressHowText').html('Top 5 How Progress ' + Math.round($(selector).length * (100 / 5)) + '%'); var howCompleted = 0; for (x = 0; x < $('.howNut').length; x++) { if ($($('.howNut')[x]).css('left') != '-34px') { howCompleted += 1; } }
           $('#reviewProgressBarHow').css('display', 'block'); $('#reviewProgressBarHow').animate({ backgroundPosition: '-' + (220 - (((howCompleted / $('.howNut').length) * 220))) + 'px center' }, { duration: 500 }); $('#reviewProgressTextHow').html('Questions Progress ' + Math.round(((howCompleted / $('.howNut').length) * 100)) + '%');
       }
   }
vChange=function(v,id){if(v>=0&&v<=100){$('#'+id+'_q3').css('color',otoh(0));if(v<=50)$('#'+id+'_q2').css('color',otoh(0));$('#'+id+'_q1').css('color',otoh(Math.abs(((v-100)/100.0))));}
if(v>=50&&v<=100){l=v-50;$('#'+id+'_q2').css('color',otoh(Math.abs(((l)/100.0))*2));}
if(v>=100&&v<=150){l=v+50;$('#'+id+'_q2').css('color',otoh(Math.abs(((l-200)/100.0))*2));}
if(v>=100&&v<=200){if(v>=150)$('#'+id+'_q2').css('color',otoh(0));v-=100;$('#'+id+'_q3').css('color',otoh(Math.abs(((v)/100.0))));$('#'+id+'_q1').css('color',otoh(0));}}
function otoh(n){n=n*100;n=Math.abs(n-50);m=255/100;m=Math.round(n*m);return'#'+tohex(m)+tohex(m)+tohex(m)}
function tohex(n){var retval='';if(n<=0){retval='00';return retval;}
var nt=n;while(n>0){var m=n;n=m>>4;m=m%16;var string='';if(m<10)string=''+m;else{switch(m){case 10:default:string='A'
break;case 11:string='B'
break;case 12:string='C'
break;case 13:string='D'
break;case 14:string='E'
break;case 15:string='F'
break;}}
retval=string+retval;}
if(nt<16)retval='0'+retval;return retval;}

function zxcMseClick(event, obj, id, isIcon) {
    zxcObj = obj; zxcMse(event); zxcDragX = zxcMseX - zxcPos(zxcObj)[0]; zxcDragY = zxcMseY - zxcPos(zxcObj)[1]; var ishow = false;
   
    // this is from having two tracks which we no longer do
    //if (eval(id + "_state=!" + id + "_state")) { id = id + "_how"; ishow = true; }
    if (isIcon) {
        
        if ($('#' + id).css('left') !='0px') return;
    }

    $('#' + id).animate({ "left": (zxcMseX - zxcPos(zxcObj)[0]) - (ishow ? 50 : 16) + 'px' }, function () {
        $('#' + id).animate({ opacity: 1 });
        var i = $('#' + id); var reviewer = i.attr('reviewer'); var reviewed = i.attr('reviewed'); var question = i.attr('question'); var level = ((i.position().left - 32) / 2.5); if (level == 0) level = 1; if (i.position().left - 16 <= 0) { i.css('left', '1px'); }
        var job = i.attr('job'); var how = i.attr('how'); if (how != undefined && how != null && how != '') { level = ((i.position().left - 50) / 2.5); $.get('/genericAuth.asmx?T=HOWREVIEW&REVIEWER=' + reviewer + '&REVIEWED=' + reviewed + '&LEVEL=' + level + '&QUESTION=' + question); updateReviewProgress(); return; }
        if (job != undefined && job != null && job != '') { $.get('/genericAuth.asmx?T=JOBREVIEW&JOB=' + job + '&LEVEL=' + level + '&QUESTION=' + question); }
        else { $.get('/genericAuth.asmx?T=REVIEW&REVIEWER=' + reviewer + '&REVIEWED=' + reviewed + '&LEVEL=' + level + '&QUESTION=' + question + '&GEN=' + $('#gen').val()); }
        $('#finalize').customFadeIn('fast'); updateReviewProgress();
    });

    if (typeof completedQuestions != 'undefined') {
        var qa = $('#' + id).attr('questionarea');
        if ($.inArray(qa, completedQuestions) == -1) completedQuestions.push(qa);

        if (completedQuestions.length >= 1) {

            if ($('#holderUntilSliderMoved').length == 0) {
                $('.f3').customFadeIn('fast');
            } else {
                $('#holderUntilSliderMoved').customFadeOut('fast', function () { $('.f3').customFadeIn('fast'); });
            }
            if ($('#reviewTabs').tabs('option', 'selected') == 2) {
                $('.f4').customFadeIn('fast');
            }
            
        }
    }
}


function zxcPos(zxc){zxcObjLeft=zxc.offsetLeft;zxcObjTop=zxc.offsetTop;while(zxc.offsetParent!=null){zxcObjParent=zxc.offsetParent;zxcObjLeft+=zxcObjParent.offsetLeft;zxcObjTop+=zxcObjParent.offsetTop;zxc=zxcObjParent;}
return[zxcObjLeft,zxcObjTop];}
function zxcMse(event){if(!event)var event=window.event;if(document.all){zxcMseX=event.clientX;zxcMseY=event.clientY;}
else{zxcMseX=event.pageX;zxcMseY=event.pageY;}};onRelationshipType=function(reviewed,reviewer,rtypeid,durationid,t,tm){var relationshipType=$('#'+rtypeid).val();;var duration=$('#'+durationid).val()
$.get('/genericAuth.asmx?T=KNOWING&REVIEWER='+reviewer+'&REVIEWED='+reviewed+'&RTYPE='+relationshipType+'&DURATION='+duration,function(res){if(t)document.location.href='/review.aspx?UID='+reviewed+(tm?'&TM=true':'');else alert('Relationship Saved');});}
onTop5=function(t,question,reviewed,reviewer){var selector='img[src="/IMG/Review/top_s.png"]';if($.browser.msie&&$.browser.version<=7){selector='img[src="http://www.viewsonyou.com/IMG/Review/top_s.png"]';}
if($(t).attr('src')==$(t).attr('select')||$(selector).length<5){$(t).attr('src',$(t).attr('src')!=$(t).attr('select')?$(t).attr('select'):$(t).attr('hover'));var questions='';$(selector).each(function(i){questions+=$(this).attr('question')+',';});$.get('/genericAuth.asmx?T=TOP5&REVIEWER='+reviewer+'&REVIEWED='+reviewed+'&QUESTIONS='+questions.substring(0,questions.length-1));}
else{Boxy.load('/Popup/Message.aspx?MSG=TOP5MAX',{modal:true})}
updateReviewProgress();
}

onTop5How=function(t,question,user){var selector='img[src="/IMG/Review/top_how_s.png"]';if($.browser.msie&&$.browser.version<=7){selector='img[src="http://www.viewsonyou.com/IMG/Review/top_how_s.png"]';}
if($(t).attr('src')==$(t).attr('select')||$(selector).length<5){$(t).attr('src',$(t).attr('src')!=$(t).attr('select')?$(t).attr('select'):$(t).attr('hover'));var questions='';$(selector).each(function(i){questions+=$(this).attr('question')+',';});$.get('/genericAuth.asmx?T=TOP5HOW&QUESTIONS='+questions.substring(0,questions.length-1));}
else{Boxy.load('/Popup/Message.aspx?MSG=TOP5MAX',{modal:true})}
updateReviewProgress();}
onTop5Session=function(t){var selector='img[src="/IMG/Review/top_s.png"]';if($.browser.msie&&$.browser.version<=7){selector='img[src="http://www.viewsonyou.com/IMG/Review/top_s.png"]';}
if($(t).attr('src')==$(t).attr('select')||$(selector).length<5){$(t).attr('src',$(t).attr('src')!=$(t).attr('select')?$(t).attr('select'):$(t).attr('hover'));var questions='';$(selector).each(function(i){questions+=$(this).attr('question')+',';});$.get('/genericAuth.asmx?T=TOP5SESSION&QUESTIONS='+questions.substring(0,questions.length-1));}
else{Boxy.load('/Popup/Message.aspx?MSG=TOP5MAX',{modal:true})}
updateSessionComparison();}
onTop5Job=function(t,job){var selector='img[src="/IMG/Review/top_s.png"]';if($.browser.msie&&$.browser.version<=7){selector='img[src="http://www.viewsonyou.com/IMG/Review/top_s.png"]';}
if($(t).attr('src')==$(t).attr('select')||$(selector).length<5){$(t).attr('src',$(t).attr('src')!=$(t).attr('select')?$(t).attr('select'):$(t).attr('hover'));var questions='';$(selector).each(function(i){questions+=$(this).attr('question')+',';});$.get('/genericAuth.asmx?T=TOP5JOB&JOB='+job+'&QUESTIONS='+questions.substring(0,questions.length-1));}
else{Boxy.load('/Popup/Message.aspx?MSG=TOP5MAX',{modal:true})}
updateReviewProgress();};onTop5TGM=function(t,tgm){var selector='img[src="/IMG/Review/top_s.png"]';if($.browser.msie&&$.browser.version<=7){selector='img[src="http://www.viewsonyou.com/IMG/Review/top_s.png"]';}
if($(t).attr('src')==$(t).attr('select')||$(selector).length<5){$(t).attr('src',$(t).attr('src')!=$(t).attr('select')?$(t).attr('select'):$(t).attr('hover'));var questions='';$(selector).each(function(i){questions+=$(this).attr('question')+',';});$.get('/genericAuth.asmx?T=TOP5TGM&TGM='+tgm+'&QUESTIONS='+questions.substring(0,questions.length-1));}
else{Boxy.load('/Popup/Message.aspx?MSG=TOP5MAX',{modal:true})}
updateReviewProgress();};showError=function(msg,errorid){if(errorid==undefined)errorid='errorDisplay';$(window).ready(function(){if($('#'+errorid).length!=0){$($('#'+errorid)[0]).html(msg);}
else{$('<div id="'+errorid+'" class="errorDisplay curved"/>').html(msg).insertBefore($($('.form')[0]));}
$('#'+errorid).customFadeIn("slow");});}
showSuccess=function(msg){$(window).ready(function(){if($('#successDisplay').length!=0){$('#successDisplay').html(msg);}
else{$('<div id="successDisplay" class="curved"/>').html(msg).insertBefore($($('.form')[0]));}
$('#successDisplay').customFadeIn("slow");});}
showMessage=function(msg){$(window).ready(function(){if($('#messageDisplay').length!=0){$('#messageDisplay').html(msg);}
else{$('<div id="messageDisplay" class="curved"/>').html(msg).insertBefore($($('.form')[0]));}
$('#messageDisplay').customFadeIn("slow");});}
pleaseWait=function(t){$(t).css('display','none');Boxy.load('/Popup/PleaseWait.aspx',{modal:true});}
sendInviteActionRecruiter=function(t,job){$('#sendInvite').val("Sending Invite(s)");$('#sendInvite').attr('disabled','true');if(job==''){$.get("/genericAuth.asmx?T=QUICKINVITE&ISJOB=false&EMAILS="+$('#emails').val()+"&MESSAGE="+$('#message').val().replace(/\n/gi,'~'),function(data){alert(strip(data));Boxy.get(t).hideAndUnload();return false;});}
else{$.get("/genericAuth.asmx?T=QUICKINVITE&ISJOB=true&JOBID="+job+"&EMAILS="+$('#emails').val()+"&MESSAGE="+$('#message').val().replace(/\n/gi,'~'),function(data){alert(strip(data));Boxy.get(t).hideAndUnload();return false;});}}
onRemoveFilters=function(a,b){$('#'+a+' option').attr('selected',false);$('#'+b+' option').attr('selected',false);}
checkEmailExist=function(e){$.get('/generic.asmx?T=CHECKEMAIL&EMAIL='+e,function(data){if(strip(data)!='0'){showMessage('This email is already registered as a secondary email on another account. You can still register but will need to verify your email.');}});}
nextUnanswered = function () {
    var found = false; $('.nut').each(function (i) {
        if ($(this).css('left') == '0px' || $(this).css('left') == '505px') {
            if (!found) {
                found = true;
                $('#reviewTabs').tabs('select', parseInt($(this).attr('tab'))); $.scrollTo($('#table_' + $(this).attr('id')), 150, function ()
                { }); $('#table_' + $(this).attr('id')).highlightFade({color:'yellow',speed:800}); 
            } 
        } 
    });
}
changesLost=function(u){if(confirm('If you jump to this step any changes in this page will be lost. Are you sure?'))document.location.href=u;}
showOutlook=function(){$('#normalImporter').customFadeOut('fast',function(){$('#outlookInviter').customFadeIn('fast');});$.scrollTo('#endOfBuildNetwork',200);}
hideOutlook=function(){$('#outlookInviter').customFadeOut('fast',function(){$('#normalImporter').customFadeIn('fast');});}
showLinkedIn=function(){$('#normalImporter').customFadeOut('fast',function(){$('#linkedinInviter').customFadeIn('fast');});$.scrollTo('#endOfBuildNetwork',200);}
hideLinkedIn=function(){$('#linkedinInviter').customFadeOut('fast',function(){$('#normalImporter').customFadeIn('fast');});}
linkedInRequest = function (n, id) { Boxy.load('/Popup/LinkedInMessage.aspx?NAME=' + n + '&ID=' + id, { modal: true }); }

linkedInRequestTeam = function (n, id) { Boxy.load('/Popup/LinkedInMessage.aspx?NAME=' + n + '&ID=' + id + '&ISTEAM=true', { modal: true }); }

linkedInRequestGlobal = function () { Boxy.load('/Popup/LinkedInMessageGlobal.aspx', { modal: true }); }

facebookRequestGlobal = function (url,n) {

    //Boxy.load('/Popup/FacebookMessage.aspx?NAME=' + n + '&ID=' + id, { modal: true });


    FB.ui(
   {
       method: 'feed',
       name: n + ' is using ViewsOnYou to build a public 360 profile',
       link: url,
       picture: 'http://www.viewsonyou.com/img/voy75.png',
       caption: 'Review me on ViewsOnYou',
       description: 'I\'m using ViewsOnYou to help me discover my key traits, what others think of me. It\'s a really useful tool that helps people and teams work better together.',
       message: ''
   },
   function (response) {
       if (response && response.post_id) {
           document.location.href = '/home.aspx?PRIVACY=true';
       } else {
           document.location.href = '/home.aspx?PRIVACY=true';
       }
   }
 );



}



facebookRequest = function (n, fid, url) {

    //Boxy.load('/Popup/FacebookMessage.aspx?NAME=' + n + '&ID=' + id, { modal: true });


    FB.ui(
   {
        to:fid,
       method: 'feed',
       name: 'ViewsOnYou Review Request',
       link: url,
       picture: 'http://www.viewsonyou.com/IMG/Icons/getReviews.png',
       caption: 'ViewsOnYou Review Request',
       description: 'Review ' + n + ' on ViewsOnYou',
       message: 'I use ViewsOnYou to build a unique professional profile of what others think of me. It is a really useful tool that helps people and teams work better together.\n\nPlease complete a review of me to help me build my professional reference profile. The review should take no more than 3 minutes, and you dont have to write any free text. It\'s really easy. '
   },
   function (response) {
       if (response && response.post_id) {
           alert('Post sent succesfully.');
       } else {
           alert('Post was not published.');
       }
   }
 );



}


facebookRequestTeam = function (n, fid, url) {


    //Boxy.load('/Popup/FacebookMessage.aspx?NAME=' + n + '&ID=' + id, { modal: true });



    FB.ui(
   {
       to: fid,
       method: 'feed',
       name: 'Connect with my team on ViewsOnYou',
       link: url,
       picture: 'http://www.viewsonyou.com/IMG/Icons/getReviews.png',
       caption: 'ViewsOnYou Team Request',
       description: 'Join ' + n + ' team on ViewsOnYou',
       message: 'I would like to invite you to connect with my teams on ViewsOnYou, so that we can both see each other\'s profiles side by side in any team we put together.'
   },
   function (response) {
       if (response && response.post_id) {
           alert('Post sent succesfully.');
       } else {
           alert('Post was not published.');
       }
   }
 );



}

twitterRequestTeam = function (n) { Boxy.load('/Popup/TwitterMessage.aspx?NAME=' + n + '&ISTEAM=true', { modal: true }); }


twitterRequest = function (n) { Boxy.load('/Popup/TwitterMessage.aspx?NAME=' + n, { modal: true }); }
sendWallPost = function (t) {
    $.post('/genericAuth.asmx?T=LINKEDWALLPOST', { BODY: $('#message').val() }, function (data) {
        Boxy.get(t).hideAndUnload(); if (strip(data) == 'OK') { alert('Message has been sent'); }
        else { alert('Message send failed, you might have reached your message limit for today.'); } document.location.href = '/home.aspx?PRIVACY=true';
    });
}
sendLinkedInRequest=function(id,t){$.post('/genericAuth.asmx?T=LINKEDREQ&ID='+id,{SUB:$('#subject').val(),BODY:$('#message').val()},function(data){Boxy.get(t).hideAndUnload();if(strip(data)=='OK'){alert('Message has been sent');}
else{alert('Message send failed, you might have reached your message limit for today.');}});}
sendFacebookRequest=function(id,t){$.post('/genericAuth.asmx?T=FACEBOOKREQ&ID='+id,{BODY:$('#message').val()},function(data){Boxy.get(t).hideAndUnload();if(strip(data)=='OK'){alert('Message has been sent');}
else{alert('Message send failed, you might have reached your message limit for today or this user might now allow you to post things to their wall. Consider emailing them instead.');}});}
sendTwitterRequest=function(id,t){$.post('/genericAuth.asmx?T=TWITTERREQ&ID='+id,{BODY:$('#message').val()},function(data){Boxy.get(t).hideAndUnload();if(strip(data)=='OK'){alert('Message has been sent');}
else{alert('Message send failed, you might have reached your message limit for today.');}});}
function facebook_prompt_permission(permission,callbackFunc){FB.Facebook.apiClient.users_hasAppPermission(permission,function(result){if(result==0){FB.Connect.showPermissionDialog(permission,callbackFunc);}
else{callbackFunc(true);}});}
onQReview=function(){if(!$('#is18')[0].checked){alert('Please check the 18 box');return;}
if($('#email').val().indexOf('@')==-1){alert('Please enter a valid email address');return;}
if($('#firstName').val()==''||$('#lastName').val()==''){alert('Please provide your first name and last name');return;}
$.get('/generic.asmx?T=QREVIEW&FIRSTNAME='+$('#firstName').val()+'&LASTNAME='+$('#lastName').val()+'&EMAIL='+$('#email').val(),function(data){if(strip(data)!='OK'){alert(strip(data));}
else{document.location.href=(document.location.href+'&R=t');}});}
onAReview=function(){if(!$('#is18')[0].checked){alert('Please check the 18 box');return;}
if($('#email').val().indexOf('@')==-1){alert('Please enter a valid email address');return;}
if($('#firstName').val()==''||$('#lastName').val()==''){alert('Please provide your first name and last name');return;}
$.get('/generic.asmx?T=QREVIEW&FIRSTNAME='+$('#firstName').val()+'&LASTNAME='+$('#lastName').val()+'&EMAIL='+$('#email').val(),function(data){if(strip(data)!='OK'){alert(strip(data));}
else{document.location.href=(document.location.href+'&R=t');}});}
saveApplicantNotes=function(appid){var txt=$('#text_'+appid).val();$('#link_'+appid).addClass('busy');$('#link_'+appid).html('Saving..');$.post('/genericAuth.asmx?T=APPNOTES&APP='+appid,{notes:txt},function(data){$('#link_'+appid).removeClass('busy');$('#link_'+appid).html('Save');});}
addAnother=function(id){$($(id)[0]).removeClass('hidden');}
dnsCheck=function(v,ip){$.get('/genericAuth.asmx?T=DNS&DNS='+v,function(data){$('.domainD').html(v);$('.ipD').html(data);if(strip(data)!=''&&ip!=strip(data)){$('#problemP').removeClass('hidden');$('#instructions').removeClass('hidden');}
if(data==''){$('#noneP').removeClass('hidden');$('#instructions').removeClass('hidden');}
if(data==ip){$('#complete').removeClass('hidden');}});}
viewShortList=function(id,t){if($('#sl_'+id).css('opacity')=='1'){$('#sl_'+id).customFadeOut('fast',function(){$('#sl_'+id).css('opacity','0');});}
else{$('#sl_'+id).css('opacity','1');$('#sl_'+id).customFadeIn('fast');}
$(t).html($(t).html()=='Hide Shortlists'?'Show Shortlists':'Hide Shortlists');}
viewSkillList=function(id,t){if($('#sk_'+id).css('opacity')=='1'){$('#sk_'+id).customFadeOut('fast',function(){$('#sk_'+id).css('opacity','0');});}
else{$('#sk_'+id).css('opacity','1');$('#sk_'+id).customFadeIn('fast');}
$(t).html($(t).html()=='Hide Skills'?'Show Skills':'Hide Skills');}
showJobList=function(job){$('#applicantList').html('<center><img src="/IMG/Loading/hori.gif" alt="Loading..." style="margin-top:50px;"/></center>');$.get('/Employer/Pipeline/Blank/applicantList.aspx?JOB='+job,function(d){$('#applicantList').customFadeOut('fast',function(){$('#applicantList').html(d);$('#applicantList').customFadeIn();})});}
showShortList=function(sl){$('#applicantList').html('<center><img src="/IMG/Loading/hori.gif" alt="Loading..." style="margin-top:50px;"/></center>');$.get('/Employer/Pipeline/Blank/applicantList.aspx?SL='+sl,function(d){$('#applicantList').customFadeOut('fast',function(){$('#applicantList').html(d);$('#applicantList').customFadeIn();})});}
showGlobalShortList=function(sl){$('#applicantList').html('<center><img src="/IMG/Loading/hori.gif" alt="Loading..." style="margin-top:50px;"/></center>');$.get('/Employer/Pipeline/Blank/applicantList.aspx?GSL='+sl,function(d){$('#applicantList').customFadeOut('fast',function(){$('#applicantList').html(d);$('#applicantList').customFadeIn();})});}
showSkillSetList=function(sl){$('#applicantList').html('<center><img src="/IMG/Loading/hori.gif" alt="Loading..." style="margin-top:50px;"/></center>');$.get('/Employer/Pipeline/Blank/applicantList.aspx?C='+sl,function(d){$('#applicantList').customFadeOut('fast',function(){$('#applicantList').html(d);$('#applicantList').customFadeIn();})});}
addToGlobalShortList=function(selectID,userid){if($('#'+selectID).length>0){if($('#'+selectID).val()=='new'){Boxy.load('/Popup/GlobalShortlist.aspx?USERS='+userid+'&RURL='+escape(document.location.href),{modal:true});}
else{$.get('/genericAuth.asmx?T=ADDGLOBALSHORTLIST&ADDUSER='+userid+'&SHORTLIST='+$('#'+selectID).val(),function(data){showPopAlert('Added to short list');});}}}
createGlobalShortlist=function(addUserId,jobId,url){if($('#shortListName').val()==''){if($('#shortListName').val()=='')$('<label/>').addClass('error').html('This field is required.').insertAfter($('#shortListName'));}
else{$('.error').remove();$.get('/genericAuth.asmx?T=CREATEGLOBALSHORTLIST&ADDUSER='+addUserId+'&SHORTLISTNAME='+escape($('#shortListName').val()),function(data){document.location.href=url;});}}
contactSelectedPipeline=function(){var l='';for(x=0;x<$('.emailContact:checked').length;x++){l+=$($('.emailContact:checked')[x]).attr('id')+',';}
$.post('/genericAuth.asmx?T=PIPECONTACT',{users:l},function(data){document.location.href='mail.aspx';});}
showShortListJobBenchmark=function(jobid){$('#applicantList').html('<center><img src="/IMG/Loading/hori.gif" alt="Loading..." style="margin-top:50px;"/></center>');$.get('/Employer/Pipeline/Blank/applicantList.aspx?JOB_BENCHMARK='+jobid,function(d){$('#applicantList').customFadeOut('fast',function(){$('#applicantList').html(d);$('#applicantList').customFadeIn();})});}
updateSessionComparison=function(){$('#applicantList').html('<center><img src="/IMG/Loading/hori.gif" alt="Loading..." style="margin-top:50px;"/></center>');$.get('/Employer/Pipeline/Blank/applicantList.aspx?SESSION_BENCHMARK=true',function(d){$('#applicantList').customFadeOut('fast',function(){$('#applicantList').html(d);$('#applicantList').customFadeIn();})});}
benchmarkCandidateInvite=function(job,b){if($('#name').val()==''){alert('Name is required');return;}
if($('#email').val()==''||$('#email').val().indexOf('@')==-1){alert('Email is required and must be valid');return;}
if($('#message').val()==''){alert('A message is required');return;}
$.post('/genericAuth.asmx?T=BENCHMARKCANDIDATEINVITE',{NAME:$('#name').val(),EMAIL:$('#email').val(),MSG:$('#message').val()},function(data){if(data!='OK'){if(confirm('This user is already on ViewsOnYou. Set benchmark to this person now?')){document.location.href='setApplicantCriteria.aspx?JOB='+job+'&USER='+data;}
else{}}
else{alert('Benchmark Invite Sent');Boxy.get(b).hideAndUnload();}});}
sendFBUpgrade=function(pid,b){if($('#email').val().indexOf('@')==-1){alert('Email not valid');return;}
$.get('/genericAuth.asmx?T=FBINVITE&UID='+pid+'&E='+$('#email').val(),function(data){alert('Invite Sent');Boxy.get(b).hideAndUnload();});}
function selectAllChecks(){$("input[type='checkbox']:not([disabled='disabled'])").attr('checked',true);}
selectTemplate=function(s,subid,bodyid,company){switch($(s).val()){case'reviews':$('#'+subid).val('Build you Personal Reviews on ViewsOnYou');$('#'+bodyid).val('Building your reviews on ViewsOnYou helps us to judge your talent better.\n\nFollow this link to go to your Talent Management Dashboard and start building reviews of your co-workers.');break;case'welcome':$('#'+subid).val('Welcome to '+company+' Talent Management on ViewsOnYou');$('#'+bodyid).val(company+' uses ViewsOnYou for their Talent Management.\n\nTo take part in the '+company+' talent management process, you can register with ViewsOnYou, provide a review of yourself and then start to build peer reviews.\n\nPrivacy settings within ViewsOnYou enable you to limit access to your profile to the '+company+' talent management process.  Alternatively if you prefer, you can also choose to make your profile more widely available through ViewsOnYou.\n\nTo learn more and to participate, follow the link to be taken to '+company+'\'s Talent Management portal within ViewsOnYou and start building your peer review network.');break;case'questionSet':$('#'+subid).val('Additional Questions at '+company+' Talent Management');$('#'+bodyid).val('A new questions set has been added to your Talent Management process.\n\nFollow this link to view and answer the new questions.');break;case'blank':$('#'+subid).val('');$('#'+bodyid).val('');break;}}
ensureSafe=function(){$('textarea').each(function(l,i){$(i).val($(i).val().replace('>','&gt;'));$(i).val($(i).val().replace('<','&lt;'));});}
deleteTag=function(tid){$.get('/genericAuth.asmx?T=DELTAG&TAG='+tid,function(data){$('#tr_'+tid).remove();});}
createTag=function(uid,t){if($('#newTitle').val()==''||$('#newValue').val()==''){alert('You must provide a value');}
else{$.get('/genericAuth.asmx?T=NEWTAG&TITLE='+$('#newTitle').val()+'&VALUE='+$('#newValue').val()+'&UID='+uid+'&PRIVATE='+($('#isPrivate')[0].checked?'true':'false'),function(data){if(strip(data)=='OK'){if(uid=='00000000-0000-0000-0000-000000000000'){Boxy.load('/Popup/TalentManagement/TagMaster.aspx',{modal:true});return false;}
else{Boxy.get(t).hideAndUnload(function(g){Boxy.load('/Popup/TalentManagement/Tags.aspx?USER='+uid,{modal:true});});}}});}}
updateTag=function(uid,tag){$.get('/genericAuth.asmx?T=UPDATETAG&TAG='+tag+'&TITLE='+$('#title_'+tag).val()+'&VALUE='+$('#value_'+tag).val()+'&PRIVATE='+($('#priv_'+tag)[0].checked?'true':'false'));alert('Tag Updated');}
copyTag=function(uid,tag,t){$.get('/genericAuth.asmx?T=NEWTAG&TITLE='+$('#title_'+tag).val()+'&VALUE='+$('#value_'+tag).val()+'&UID='+uid+'&PRIVATE='+($('#priv_'+tag)[0].checked?'true':'false'),function(data){if(strip(data)=='OK'){Boxy.get(t).hideAndUnload(function(g){Boxy.load('/Popup/TalentManagement/Tags.aspx?USER='+uid,{modal:true});});}});}
editMasterTags=function(t){Boxy.get(t).hideAndUnload(function(g){Boxy.load('/Popup/TalentManagement/TagMaster.aspx',{modal:true});});}
setTagFilters=function(tgm){var grp='';for(x=0;x<$('[name=tagFilters]').length;x++){if($('[name=tagFilters]')[x].checked){grp+=$('[name=tagFilters]')[x].value+'|';}}
$.get('/genericAuth.asmx?T=TAGFILTER&GRP='+grp+'&TGM='+tgm,function(data){document.location.reload();});}
toggleTree=function(id){if($('#'+id+'_table').css('display')=='none'){$('#'+id+'_table').customFadeIn('fast');$('#'+id+'_bar').attr('src','/IMG/Icons/unexpand.png');}
else{$('#'+id+'_table').customFadeOut('fast');$('#'+id+'_bar').attr('src','/IMG/Icons/expand.png');}}
postSessionData=function(name,data,callback){$.post('/genericAuth.asmx?T=SESSIONSTORE&STORENAME='+name,{DATA:data},function(d){callback();});}
selectId=function(type,id){superSelectWork();}
superSelectWork=function(){var selects=[];$('.caCheckbox').each(function(i,v){if(v.checked)selects.push(($(v).attr('id')))})
if(typeof(loadIframeSuper)!='undefined'){loadIframeSuper($.toJSON(selects));}}
deleteQuestionSet=function(qs){if(confirm('Are you sure you want to delete this question set? It will also delete all user responses (if any).')){document.location.href='/CreateQuestions/?DEL='+qs;}
else
return false;}
getPrivacyWindow=function(){window.open('/Popup/PrivacyExplain.aspx',"popup","width=630,height=600,status=0,scrollbars=1");}
getTalentUserMoreInfoWindow=function(){window.open('/Popup/TalentManagement/UserMoreInfo.aspx',"popup","width=630,height=600,status=0,scrollbars=1");}
function strip(html)
{
   return html.split('</script>').length>1?html.split('</script>')[1]:html;
}

requestReview = function ( uid )
{
    Boxy.load ( '/Popup/RequestReview.aspx?UID=' + uid, {modal:true});
}

sendReviewRequest=function(t,email){$('#requestReview').attr('disabled','disabled'); $.post('/genericAuth.asmx?T=EMAILREQ&EMAIL='+email,{BODY:$('#message').val()},function(data){Boxy.get(t).hideAndUnload();if(strip(data)=='OK'){alert('Message has been sent');}
    else { alert('Message send failed, this person might have blocked ViewsOnYou mails, however they will get a review request on their dashboard.'); } 
});
}
deleteReview = function (rel) {
    if (confirm('Are you sure you want to delete this review?')) {
        $.get('/genericAuth.asmx?T=DELETEREVIEW&REL=' + rel, function (data) { $('#rel_' + rel).hide(); });
    }
}

onMakeJOCPrivate = function (t) {    
    $.get('/genericAuth.asmx?T=JOCPRIVATE&VAL=' + (t.checked ? 'true' : 'false'));
}

changeTalentGate = function (t, tgm) {
    $.get('/genericAuth.asmx?T=LOGIC&VAL=' + (t.checked ? 'true' : 'false') + '&TGM=' + tgm);
    $('.logicText').html(t.checked ? 'AND' : 'OR ');
}


hideProfileComplete = function () {
    $.get('/genericAuth.asmx?T=HIDEPROFILE', function (d) { $('#profileCompleteBox').customFadeOut('fast'); });
}



canDoNextStep = function (jobid, uid, pid) {

    // TYPES
    // coworker
    // dReview
    // jobSocial
    // social
    // TMInvite
    // reviewSelf
    // normalReview
    // jobListing
    // qReviewJob
    // qReviewSocial
    // aReview

    if ($('#reviewProgressText').html() != 'Questions Progress 100%') { Boxy.load('/Popup/Unanswered.aspx', { modal: true }); if ($('#reviewProgressText').html() != 'Questions Progress 100%') { nextUnanswered(); } }
    else {


        if (document.location.href.indexOf('&TM=true') != -1) {
            document.location.href = '/chooseTop5.aspx?UID=' + pid + '&TYPE=coworker';
            return;
        }

        if (document.location.href.indexOf('qReview') == -1 && document.location.href.indexOf('aReview') == -1) {

            if (document.location.href.indexOf('dReview') != -1) { document.location.href = '/chooseTop5.aspx?UID=' + pid + '&TYPE=dReview'; return; }


            if (document.location.href.indexOf('/review/reviewSelf.aspx') != -1) {
                if (jobid != '') { document.location.href = '/chooseTop5.aspx?UID=' + uid + '&JOB=' + jobid + '&TYPE=jobSocial'; return; }
                else { document.location.href = '/chooseTop5.aspx?UID=' + uid + '&TYPE=social'; return; }
            }

            else if (document.location.href.indexOf('TalentManagement') != -1) { document.location.href = '/chooseTop5.aspx?UID=' + uid + '&TYPE=TMInvite'; return; }


            else if (document.location.href.indexOf('Review/reviewSelf.aspx') != -1) { document.location.href = '/chooseTop5.aspx?JOB=' + jobid + '&TYPE=jobReviewSelf'; }

            else if (document.location.href.indexOf('com/reviewSelf.aspx') != -1) { document.location.href = '/chooseTop5.aspx?UID=' + pid + '&TYPE=reviewSelf&USER=' + jobid; return; }
            else if (document.location.href.indexOf('.com') == document.location.href.length - 5 || document.location.href.indexOf('com/default.aspx') != -1
            || document.location.href.indexOf('?teamrequest=')!=-1) { document.location.href = '/chooseTop5.aspx?UID=' + pid + '&TYPE=reviewSelf&MAKEUSER=true'; return; }

            else if (document.location.href.indexOf('/review.aspx') != -1) { document.location.href = '/chooseTop5.aspx?UID=' + pid + '&TYPE=normalReview'; return; }

            else { document.location.href = '/chooseTop5.aspx?JOB=' + jobid + '&TYPE=jobListing'; return; }


        } else if (document.location.href.indexOf('qReview') != -1) {

            if (jobid != '') { document.location.href = '/chooseTop5.aspx?JOB=' + jobid + '&TYPE=qReviewJob'; return; }
            else {
                document.location.href = '/chooseTop5.aspx?UID=' + uid + '&TYPE=qReviewSocial'; return;
            }
        } else {

            if ($('#leftColContent_ddlRelationship')[0].selectedIndex == 0) { alert('You need to select a relationship type'); return; }

            if ($('#leftColContent_ddlKnownFor')[0].selectedIndex == 0) { alert('You need to select a Known For type'); return; }

            $.get('/genericAuth.asmx?T=UPDATEREL&REVIEWER=' + uid + '&REVIEWED=' + pid + '&REL=' + $('#leftColContent_ddlRelationship').val() + '&KNOWN=' + $('#leftColContent_ddlKnownFor').val(), function (data) { document.location.href = '/chooseTop5.aspx?UID=' + pid + '&JOB=' + jobid + '&TYPE=aReview'; return; });

        }
        /*


        if (document.location.href.indexOf('&TM=true') != -1) { document.location.href = '/TalentManagement/Review/coworkers.aspx?REVIEWCOMPLETE=' + uid; return; }

        if (document.location.href.indexOf('qReview') == -1 && document.location.href.indexOf('aReview') == -1) {

        if (document.location.href.indexOf('dReview') != -1) { document.location.href = 'dReviewFinished.aspx?UID=' + pid; return; }

        if (document.location.href.indexOf('/review/reviewSelf.aspx') != -1) {
        if (jobid != '') { document.location.href = 'reviewSocial.aspx?JOB=' + jobid; }
        else { document.location.href = 'reviewSocial.aspx?USER=' + uid; }
        }

        else if (document.location.href.indexOf('TalentManagement') != -1) { document.location.href = 'invite.aspx?UID=' + uid; }

        else if (document.location.href.indexOf('Review/reviewSelf.aspx') != -1) { document.location.href = 'reviewSocial.aspx?JOB=' + jobid; }

        else if (document.location.href.indexOf('com/reviewSelf.aspx') != -1) { document.location.href = 'reviewSelfComplete.aspx?UID=' + pid; }

        else if (document.location.href.indexOf('/review.aspx') != -1) { document.location.href = 'judgeOfCharacterResult.aspx?UID=' + pid; }

        else { document.location.href = 'jobListingAttachments.aspx?JOB=' + jobid; }
        }
        else if (document.location.href.indexOf('qReview') != -1) {

        if (jobid != '') { document.location.href = 'qReviewSocial.aspx?JOB=' + jobid; }
        else { document.location.href = 'qReviewSocial.aspx?USER=' + uid; }

        }
        else {

        if ($('#leftColContent_ddlRelationship')[0].selectedIndex == 0) { alert('You need to select a relationship type'); return; }

        if ($('#leftColContent_ddlKnownFor')[0].selectedIndex == 0) { alert('You need to select a Known For type'); return; }

        $.get('/genericAuth.asmx?T=UPDATEREL&REVIEWER=' + uid + '&REVIEWED=' + pid + '&REL=' + $('#leftColContent_ddlRelationship').val() + '&KNOWN=' + $('#leftColContent_ddlKnownFor').val(), function (data) { document.location.href = 'aReviewFinished.aspx?UID=' + pid + '&JOB=' + jobid; });
        }*/




    }
}

onProviderChange = function (t) {
    if ($(t).val() == 'outlook') showOutlook();
    if ($(t).val() == 'linkedin') showLinkedIn();
}

setNewPassword = function (t) {
    if ($('#passwordb').val() == '') {
        alert('Password cannot be blank');
        return;
    }

    if ($('#passwordb').val().length < 6) {
        alert('Password must be at least six characters');
        return;
    }

    if ($('#passwordb').val() != $('#passwordAgain').val()) {
        alert('Passwords do not match');
        return;
    }

    $.get('/genericAuth.asmx?T=NEWPASSWORD&P=' + $('#passwordb').val(), function (data) { Boxy.get(t).hideAndUnload(); });



}

assocFacebook = function () {
    FB.login();
}



updateRelationshipInline = function (id) {


    var duration = $('#' + id + '_duration').val();
    var type = $('#' + id + '_type').val();

    $.get('/genericAuth.asmx?T=RELTYPEUPDATE&REL=' + id + '&RTYPE=' + type + '&DURATION=' + duration);

    var duration_text = $('#' + id + '_duration option:selected').text();
    var type_text = $('#' + id + '_type option:selected').text();

    $('.relationshipEdit').customFadeOut('fast', function () { $('.relationshipView').customFadeIn('fast'); });

    $('#' + id + '_text_duration').html(duration_text);
    $('#' + id + '_text_type').html(type_text);
}



addToTeamsPopup = function (user) {
    if (typeof (users) == "undefined") { users = []; users.push(user); Boxy.load('/Popup/addToTeam.aspx?USERS=' + users.join(','), { modal: true }); return; }

    if (users.length > 0) {
        Boxy.load('/Popup/addToTeam.aspx?USERS=' + users.join(','), { modal: true });
    } else { alert('No users selected'); }
}

addToTeam = function (users, t) {
    if ($('#teamSelected').val() == 'new') {

        if ($('#teamName').val() == '') {
            alert('You must name the team.');
            return;
        }
    }

    $.get('/genericAuth.asmx?T=ADDTOTEAM&USERS=' + users + '&TEAM=' + $('#teamSelected').val() + '&TEAMNAME=' + $('#teamName').val());

    if (typeof (t) != "undefined") Boxy.get(t).hideAndUnload();

    if (typeof (newTeamCreate) != "undefined") newTeamCreate();
}

privSelectPop = function (t) {
    switch ($(t).val()) {
        case 'Normal':
            return 'Your profile is visible by all and can be found by using the search features of the site. Your profile may also be indexed by search engines like Google.';
        case 'Private':
            return 'Your profile can be found by using the site search feature but it is not visible to external sources such as search engines like Google.';
        case 'Employer/Recruiter/Network':
            return 'Your profile cannot be seen using the site search feature and is not visible to external sources such as search engines like Google. It is only visible to your reviewers, your team and whichever employer you agree to share it with.';
        case 'Hidden':
            return 'Your profile is not visible to anyone apart from yourself.';
    }
}

setPrivacySetting = function (sel, t) {

    $.get('/genericAuth.asmx?T=SETPRIV&VAL=' + sel);

    Boxy.get(t).hideAndUnload();
}

showLargeImage = function (img) {
    Boxy.load('/Popup/LargeImage.aspx?IMG=' + img, { modal: true });
}



updateBreakthrough = function () {
    $.get('/genericAuth.asmx?T=BREAKTHROUGH&C=' + escape($('#breakthroughText').val()) + ($('#alertNetwork')[0].checked ? '&ALERT=true' : ''),
     function (data) {
         $('#networkcarousel').prepend(data);
         $('#breakthroughText').val('');
     });
}



updateBreakthroughComment = function (breakthrough, t) {
    $.get('/genericAuth.asmx?T=BREAKTHROUGHCOMMENT&C=' + escape($('#' + t).val()) + '&BREAKTHROUGH=' + breakthrough,
function (data) {
    $('#' + t).val('');
    $('#' + breakthrough).prepend(data);});
}



function checkEnter(e) {
    e = e || event;
    return (e.keyCode || event.which || event.charCode || 0) !== 13;
}
showHideMore = function (id) {
    $('.' + id).toggle();


    if ($($('.' + id)[0]).is(':visible')) {
        $('#' + id + '_button').attr('src', '/IMG/Buttons/less.png');
    } else {
        $('#' + id + '_button').attr('src', '/IMG/Buttons/more.png');
    }
}

loadSocial = function () {

    if ($.browser.msie) {
        $('.lazy2').each(function () { $(this).attr('src', $(this).attr('original')); });
    }
}
