(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');};if(typeof(Cufon)!="undefined"){Cufon.replace('h1');Cufon.replace('h2');Cufon.replace('h3');Cufon.replace('h4');Cufon.replace('h5');Cufon.replace('h6');Cufon.replace('h7');}
$(document).ready(function () {
    $('.top5Img').hoverbox();
    $('.hoverMe').hoverbox();

    $('.opacityFadeInVehicle').hover(function () { $('#' + $(this).attr('fader')).animate({ opacity: 1 }); }, function () { $('#' + $(this).attr('fader')).animate({ opacity: 0.25 }); });

    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')); }); $('.staticNut').customFadeIn(250); $('.nut').draggable({ axis: 'x', opacity: 0.4, cursor: 'e-resize', containment: 'parent', stop: function (e, i) { handleStop(e, i); }, drag: function (e, i) { handleDrag(e, i); } }); 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)');
        });
    }
});  showPopAlert=function(text)
{$('#popAlert').html(text);$('#popAlert').customFadeIn('fast');setTimeout("$('#popAlert').customFadeOut('fast')",2000);}
sendMail=function(toPerson,jobID){if($('#message').val()!=''&&$('#subject').val()!=''){$.post('/genericAuth.asmx?T=EMAIL&JOB='+jobID,{subject:$('#subject').val(),message:$('#message').val(),to:toPerson},function(data){if(jobID=='00000000-0000-0000-0000-000000000000'||document.location.href.indexOf('mail.aspx')!=-1){document.location.href='/mail.aspx';}else{document.location.href='/Recruiter/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(){$('#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(),function(data){$('#loading').customFadeOut('fast');$('#emailResultsTable').customFadeIn('fast');$('#inviteSelected').customFadeIn('slow');$('#emailImportResults').html(data);});}
inviteSelected=function(){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!=''){Boxy.load('/Popup/Invite.aspx?EMAILS='+emails,{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("Invite(s) sent");document.location.href='/home.aspx';});}
sendInviteEmbedAction=function(){if($('#emailsEmbed').val()==''){if($('#emailsEmbed').val()=='')$('<label/>').addClass('error').html('This field is required.').insertAfter($('#emailsEmbed'));}else{$('.error').remove();$('#sendInviteEmbed').val("Sending Invite(s)");$('#sendInviteEmbed').attr('disabled','true');$.get("/genericAuth.asmx?T=QUICKINVITE&EMAILS="+$('#emailsEmbed').val()+"&MESSAGE="+$('#messageEmbed').val().replace(/\n/gi,'~'),function(data){alert("Invites sent");$('#sendInviteEmbed').removeAttr('disabled');$('#sendInviteEmbed').val('Send Invite(s)');$('#emailsEmbed').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){$.get('/genericAuth.asmx?T=ACCEPTREVIEW&REL='+rel,function(data){$('#'+rel).html('Accepted');});$(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();});});}
updateBreakthrough = function () {
    $.get('/genericAuth.asmx?T=BREAKTHROUGH&C=' + escape($('#breakthroughText').val()), function (data) {
        $('#breakthroughText').val('');
        showPop(data);
        
    });
}
showPop = function (data) { Boxy.load('/Popup/BreakthroughAlert.aspx?BREAK=' + data, { modal: true }); }
updateBreakthroughComment=function(breakthrough,t){$.get('/genericAuth.asmx?T=BREAKTHROUGHCOMMENT&C='+escape($('#'+t).val())+'&BREAKTHROUGH='+breakthrough,function(data){$('#'+t).val('');document.location.reload();});}
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(val){window.open('/mailTemplates/invitePreview.aspx?BODY='+escape(val),"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();});}
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>');});}}
canDoNextStep = function (jobid) {
    if ($('#top5ProgressText').html() != 'Top 5 Progress 100%' ||
        $('#reviewProgressText').html() != 'Questions Progress 100%') {
        alert('You need to answer all questions and select your top 5 before continuing.');


        if ($('#reviewProgressText').html() != 'Questions Progress 100%') {
            nextUnanswered();
        }

    } else {
        if (document.location.href.indexOf('qReview') == -1) {
            document.location.href = 'jobListingAttachments.aspx?JOB=' + jobid;
        } else {
            document.location.href = 'qReviewSocial.aspx?JOB=' + jobid;
        }
    }

}
weHaveFacebook=function(){$('.facebook').css('display','block');}
getReviewsHowWorks=function(){Boxy.load('/Popup/ReviewWorksMore.aspx',{modal:true});}
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){vChange((i.position.left/2.5),i.helper.attr('id'));$('.tracksHowto').customFadeOut('slow');}
handleStop=function(e,i){var reviewer=i.helper.attr('reviewer');var reviewed=i.helper.attr('reviewed');var question=i.helper.attr('question');var level=(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');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);}
$('#finalize').customFadeIn('fast');updateReviewProgress();}
updateReviewProgress = function () {
    var x = 0; var completed = 0; for (x = 0; x < $('.nut').length; x++) { if ($($('.nut')[x]).css('left') != '0px') { completed += 1; } }
    $('#reviewProgressBar').css('display', 'block');


    //$('#reviewProgressBar').css('background-position', '-' + (220 - (((completed / $('.nut').length) * 220))) + 'px center');

    $('#reviewProgressBar').animate({ backgroundPosition: '-' + (220 - (((completed / $('.nut').length) * 220))) + 'px center' }, { duration: 500 });


    $('#reviewProgressText').html('Questions Progress ' + Math.round(((completed / $('.nut').length) * 100)) + '%'); 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 (Math.round(((completed / $('.nut').length) * 100)) == 100) {
        $('#nextUnansweredText').html('All Questions Answered');
    } else {
        
    }

    //$('#top5ProgressBar').css('background-position', '-' + (220 - ($(selector).length * (220 / 5))) + 'px center');
    $('#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) {
        // flash the progress bars
        $('#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 });
    }
}
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){zxcObj=obj;zxcMse(event);zxcDragX=zxcMseX-zxcPos(zxcObj)[0];zxcDragY=zxcMseY-zxcPos(zxcObj)[1];$('#'+id).animate({"left":(zxcMseX-zxcPos(zxcObj)[0])-16+'px'},function(){var i=$('#'+id);var reviewer=i.attr('reviewer');var reviewed=i.attr('reviewed');var question=i.attr('question');var level=((i.position().left-16)/2.5);if(level==0)level=1;if(i.position().left-16<=0){i.css('left','1px');}
var job=i.attr('job');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);}
$('#finalize').customFadeIn('fast');updateReviewProgress();});}
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){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;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();}
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();
}; 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) {

    $('#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("Invite(s) sent"); 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 ( 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') { if (!found) {  $('#reviewTabs').tabs('select', parseInt($(this).attr('tab'))); $.scrollTo($('#table_' + $(this).attr('id')), 150, function () { }); $('#table_' + $(this).attr('id')).highlightFade('yellow'); found = true; } } });

}


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 });
}


facebookRequest = function (n, id) {


    facebook_prompt_permission('publish_stream', function (accepted) {
        if (accepted) {
            Boxy.load('/Popup/FacebookMessage.aspx?NAME=' + n + '&ID=' + id, { modal: true });
        }
    });

    
}


twitterRequest = function (n) {
    Boxy.load('/Popup/TwitterMessage.aspx?NAME=' + n, { modal: 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 (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 (data == 'OK') { alert('Message has been sent'); } else { alert('Message send failed, you might have reached your message limit for today'); }
    });
}


sendTwitterRequest = function (id, t) {
    $.post('/genericAuth.asmx?T=TWITTERREQ&ID=' + id, { BODY: $('#message').val() }, function (data) {
        Boxy.get(t).hideAndUnload(); if (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) {
    
        //check is user already granted for this permission or not
        FB.Facebook.apiClient.users_hasAppPermission(permission,
     function (result) {
         // prompt offline permission
         if (result == 0) {
             // render the permission dialog
             FB.Connect.showPermissionDialog(permission, callbackFunc);
         } else {
             // permission already granted.
             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;
     }


     // VALID!

     $.get('/generic.asmx?T=QREVIEW&FIRSTNAME=' + $('#firstName').val() + '&LASTNAME=' + $('#lastName').val() + '&EMAIL=' + $('#email').val(),
    function (data) {
        if (data != 'OK') {
            alert(data);
        } else {
            document.location.href = (document.location.href + '&R=t');
        }
    });
 }