var protocol = "http";
var pKey = "H9aGx2KdCpJxMskpFrYbSeClYd1kiFH29ubIGtkIN4FBvYGIDL63grUQpsR7ZawH";
var available = true;
var display = "full";
var container = 'phpLive';
try {
function loadCorners(){
;(function($){var style=document.createElement('div').style,moz=style['MozBorderRadius']!==undefined,webkit=style['WebkitBorderRadius']!==undefined,radius=style['borderRadius']!==undefined||style['BorderRadius']!==undefined,mode=document.documentMode||0,noBottomFold=$.browser.msie&&(($.browser.version<8&&!mode)||mode<8),expr=$.browser.msie&&(function(){var div=document.createElement('div');try{div.style.setExpression('width','0+0');div.style.removeExpression('width');}
catch(e){return false;}
return true;})();$.support=$.support||{};$.support.borderRadius=moz||webkit||radius;function sz(el,p){return parseInt($.css(el,p))||0;};function hex2(s){var s=parseInt(s).toString(16);return(s.length<2)?'0'+s:s;};function gpc(node){while(node){var v=$.css(node,'backgroundColor'),rgb;if(v&&v!='transparent'&&v!='rgba(0, 0, 0, 0)'){if(v.indexOf('rgb')>=0){rgb=v.match(/\d+/g);return'#'+hex2(rgb[0])+hex2(rgb[1])+hex2(rgb[2]);}
return v;}
if(node.nodeName.toLowerCase()=='html')
break;node=node.parentNode;}
return'#ffffff';};function getWidth(fx,i,width){switch(fx){case'round':return Math.round(width*(1-Math.cos(Math.asin(i/width))));case'cool':return Math.round(width*(1+Math.cos(Math.asin(i/width))));case'sharp':return Math.round(width*(1-Math.cos(Math.acos(i/width))));case'bite':return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));case'slide':return Math.round(width*(Math.atan2(i,width/i)));case'jut':return Math.round(width*(Math.atan2(width,(width-i-1))));case'curl':return Math.round(width*(Math.atan(i)));case'tear':return Math.round(width*(Math.cos(i)));case'wicked':return Math.round(width*(Math.tan(i)));case'long':return Math.round(width*(Math.sqrt(i)));case'sculpt':return Math.round(width*(Math.log((width-i-1),width)));case'dogfold':case'dog':return(i&1)?(i+1):width;case'dog2':return(i&2)?(i+1):width;case'dog3':return(i&3)?(i+1):width;case'fray':return(i%2)*width;case'notch':return width;case'bevelfold':case'bevel':return i+1;}};$.fn.corner=function(options){if(this.length==0){if(!$.isReady&&this.selector){var s=this.selector,c=this.context;$(function(){$(s,c).corner(options);});}
return this;}
return this.each(function(index){var $this=$(this),o=[$this.attr($.fn.corner.defaults.metaAttr)||'',options||''].join(' ').toLowerCase(),keep=/keep/.test(o),cc=((o.match(/cc:(#[0-9a-f]+)/)||[])[1]),sc=((o.match(/sc:(#[0-9a-f]+)/)||[])[1]),width=parseInt((o.match(/(\d+)px/)||[])[1])||10,re=/round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/,fx=((o.match(re)||['round'])[0]),fold=/dogfold|bevelfold/.test(o),edges={T:0,B:1},opts={TL:/top|tl|left/.test(o),TR:/top|tr|right/.test(o),BL:/bottom|bl|left/.test(o),BR:/bottom|br|right/.test(o)},strip,pad,cssHeight,j,bot,d,ds,bw,i,w,e,c,common,$horz;if(!opts.TL&&!opts.TR&&!opts.BL&&!opts.BR)
opts={TL:1,TR:1,BL:1,BR:1};if($.fn.corner.defaults.useNative&&fx=='round'&&(radius||moz||webkit)&&!cc&&!sc){if(opts.TL)
$this.css(radius?'border-top-left-radius':moz?'-moz-border-radius-topleft':'-webkit-border-top-left-radius',width+'px');if(opts.TR)
$this.css(radius?'border-top-right-radius':moz?'-moz-border-radius-topright':'-webkit-border-top-right-radius',width+'px');if(opts.BL)
$this.css(radius?'border-bottom-left-radius':moz?'-moz-border-radius-bottomleft':'-webkit-border-bottom-left-radius',width+'px');if(opts.BR)
$this.css(radius?'border-bottom-right-radius':moz?'-moz-border-radius-bottomright':'-webkit-border-bottom-right-radius',width+'px');return;}
strip=document.createElement('div');$(strip).css({overflow:'hidden',height:'1px',minHeight:'1px',fontSize:'1px',backgroundColor:sc||'transparent',borderStyle:'solid'});pad={T:parseInt($.css(this,'paddingTop'))||0,R:parseInt($.css(this,'paddingRight'))||0,B:parseInt($.css(this,'paddingBottom'))||0,L:parseInt($.css(this,'paddingLeft'))||0};if(typeof this.style.zoom!=undefined)this.style.zoom=1;if(!keep)this.style.border='none';strip.style.borderColor=cc||gpc(this.parentNode);cssHeight=$(this).outerHeight();for(j in edges){bot=edges[j];if((bot&&(opts.BL||opts.BR))||(!bot&&(opts.TL||opts.TR))){strip.style.borderStyle='none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');d=document.createElement('div');$(d).addClass('jquery-corner');ds=d.style;bot?this.appendChild(d):this.insertBefore(d,this.firstChild);if(bot&&cssHeight!='auto'){if($.css(this,'position')=='static')
this.style.position='relative';ds.position='absolute';ds.bottom=ds.left=ds.padding=ds.margin='0';if(expr)
ds.setExpression('width','this.parentNode.offsetWidth');else
ds.width='100%';}
else if(!bot&&$.browser.msie){if($.css(this,'position')=='static')
this.style.position='relative';ds.position='absolute';ds.top=ds.left=ds.right=ds.padding=ds.margin='0';if(expr){bw=sz(this,'borderLeftWidth')+sz(this,'borderRightWidth');ds.setExpression('width','this.parentNode.offsetWidth - '+bw+'+ "px"');}
else
ds.width='100%';}
else{ds.position='relative';ds.margin=!bot?'-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px':(pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';}
for(i=0;i<width;i++){w=Math.max(0,getWidth(fx,i,width));e=strip.cloneNode(false);e.style.borderWidth='0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';bot?d.appendChild(e):d.insertBefore(e,d.firstChild);}
if(fold&&$.support.boxModel){if(bot&&noBottomFold)continue;for(c in opts){if(!opts[c])continue;if(bot&&(c=='TL'||c=='TR'))continue;if(!bot&&(c=='BL'||c=='BR'))continue;common={position:'absolute',border:'none',margin:0,padding:0,overflow:'hidden',backgroundColor:strip.style.borderColor};$horz=$('<div/>').css(common).css({width:width+'px',height:'1px'});switch(c){case'TL':$horz.css({bottom:0,left:0});break;case'TR':$horz.css({bottom:0,right:0});break;case'BL':$horz.css({top:0,left:0});break;case'BR':$horz.css({top:0,right:0});break;}
d.appendChild($horz[0]);var $vert=$('<div/>').css(common).css({top:0,bottom:0,width:'1px',height:width+'px'});switch(c){case'TL':$vert.css({left:width});break;case'TR':$vert.css({right:width});break;case'BL':$vert.css({left:width});break;case'BR':$vert.css({right:width});break;}
d.appendChild($vert[0]);}}}}});};$.fn.uncorner=function(){if(radius||moz||webkit)
this.css(radius?'border-radius':moz?'-moz-border-radius':'-webkit-border-radius',0);$('div.jquery-corner',this).remove();return this;};$.fn.corner.defaults={useNative:true,metaAttr:'data-corner'};})(jQuery);}
} catch (err){}
var theJID='ask-a-librarian-general@chat.libraryh3lp.com';var offReg=/^(www.|libdevl.lib.){0,1}umanitoba.ca$/i;var offSite=((offReg.test(window.location.hostname))?false:true);var email_to=['dafref','cc.umanitoba.ca'];var mailService=protocol+'://umanitoba.ca/libraries/app/mail_service.php';var cssFile=protocol+'://umanitoba.ca/libraries/includes/css/ask_a_chat.css';try{jQuery(function(){jQuery.support.borderRadius=false;jQuery.each(['BorderRadius','MozBorderRadius','WebkitBorderRadius','OBorderRadius','KhtmlBorderRadius'],function(){if(document.body.style[this]!==undefined){jQuery.support.borderRadius=true;}
return(!jQuery.support.borderRadius);});});}catch(err){}
function importJS(url){var newS=document.createElement('script');newS.type='text/javascript';newS.src=url;return newS;}
function makeForm(on_off){var mainD=jQuery('<div></div>');if(on_off=='online'){var tmpD=jQuery('<div id="askA_online" class="libraryh3lp" jid="'+theJID+'"></div>');if(offSite){jQuery(tmpD).append(jQuery('<div id="askA_head"><img src="'+protocol+'://umanitoba.ca/libraries/images/askA_banner_sm.png" alt="Ask A Librarian"/></div>'));}else{jQuery(tmpD).append(jQuery('<div id="askA_head"><img src="/libraries/images/askA_banner_sm.png" alt="Ask A Librarian"/></div>'));}
var iTmp=jQuery('<div id="askA_frame"><iframe class="libraryh3lp-iframe" frameborder="0" src="'+protocol+'://libraryh3lp.com/chat/ask-a-librarian-general@chat.libraryh3lp.com?title=&identity=librarian&theme=gota&css='+cssFile+'"></iframe><p>...or text us at <span style="white-space:nowrap;">204-510-2090</span></p></div>');jQuery(tmpD).append(iTmp);jQuery(mainD).append(tmpD);}else{var tmpD='<div id="askA_offline">';if(offSite){tmpD+='<div id="askA_head"><img src="'+protocol+'://umanitoba.ca/libraries/images/askA_banner_sm.png" alt="Ask A Librarian"/></div>';}else{tmpD+='<div id="askA_head"><img src="/libraries/images/askA_banner_sm.png" alt="Ask A Librarian"/></div>';}
tmpD+='<div id="askA_frame">';if(offSite){tmpD+='<form method="post" action="'+mailService+'" onsubmit="return validateForm();" id="askA_form" name="askA_form">';}else{tmpD+='<form method="post" action="#" id="askA_form" name="askA_form">';}
tmpD+='<h3>We can\'t chat right now,</h3><p>but we\'ll get back to you on the next business day or sooner.</p>\n<p id="askA_message"></p>\n<div class="l">Your name:</div> <div class="c"><input type="text" id="askA_pName" name="askA_pName" class="text" size="20" maxlength="200" /></div> <br clear="all" /> <div class="l">Your e-mail address:</div> <div class="c"><input type="text" id="askA_pEmail" name="askA_pEmail" class="text" size="20" maxlength="200" /></div> <br clear="all" /> <div class="l">&nbsp;</div> <div class="c"><textarea id="askA_pQues" name="askA_pQues" rows="5" cols="20" class="text" wrap="virtual"></textarea></div> <br clear="all" />';if(offSite){tmpD+='<div class="center"><input type="submit" name="action" value="Send Email" /><input type="hidden" name="t" value="'+pKey+'" /></div><input type="hidden" name="l" value="1"/>';tmpD+='<input type="hidden" name="askA_sub" value="Ask a Librarian"/><input type="hidden" name="askA_name" value="'+email_to[0]+'"/><input type="hidden" name="askA_dom" value="'+email_to[1]+'"/>';}else{tmpD+='<div class="center"><input type="button" onclick="sendMsg();" name="action" value="Send Email" /></div>';}
tmpD+='</form>';tmpD+='</div>';tmpD+='</div>';tmpD=jQuery(tmpD);var off=jQuery('#'+container).offset();var h=off.top+(jQuery('#'+container).height()/2);tmp=jQuery('<div id="askA_load" class="loading" style="top: '+(off.top+(jQuery('#'+container).height()/2))+'px; left: '+(off.left+(jQuery('#'+container).width()/2))+'px;"></div>');jQuery(tmp).append(jQuery('<img src="'+(offSite?protocol+'://umanitoba.ca':'')+'/libraries/graphics/ajax_load/snake_circle.gif" alt="loading..." />'));jQuery(tmp).append('Sending...');jQuery(mainD).append(tmp);jQuery(mainD).append(tmpD);}
return mainD;}
function makePopUp(on_off){var mainD=jQuery('<div></div>');var tmpA=jQuery('<a href="javascript://" onclick="askAPop(\''+on_off+'\');"></a>');jQuery(tmpA).append('<img src="'+(offSite?protocol+'://umanitoba.ca':'')+'/libraries/images/askA_banner.png" alt="Ask a Librarian"/>');if(on_off=='online'){jQuery(tmpA).append(jQuery('<p>Online</p>'));}else{jQuery(tmpA).append(jQuery('<p>Send an e-mail</p>'));}}
function show_presence(){callShow=true;var on_off='offline';if(typeof(jabber_resources)!='undefined'){for(var i=0;i<jabber_resources.length;++i){var resource=jabber_resources[i];if(resource.show==='available'){on_off='online';break;}}}
verifyContainer();jQuery('#'+container).append(makeForm(on_off));if(!jQuery.support.borderRadius){try{jQuery('#askA_frame').corner("10px");jQuery('#catalogue, #main_faq').corner("bl br tr 10px");jQuery('#li_cat, #li_faq').corner("top 10px");}catch(err){jQuery('body').append(jQuery('<script type="text/javascript" src="https://github.com/malsup/corner/raw/master/jquery.corner.js?v2.09"></script>'));}}}
function add2Head(obj){if(typeof(jQuery)=='undefined'){var heads=document.getElementsByTagName('HEAD');heads[0].appendChild(obj);}else{jQuery('head')[0].appendChild(obj);}}
function check_presence(){var attr=theJID;var jid=attr.split('@');var url=protocol+'://libraryh3lp.com/presence/jid/'+jid[0]+'/'+jid[1]+'/js';var js=importJS(url+'?cb=show_presence');add2Head(js);}
function validateEmail(theEmail){var myReg=/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i;return myReg.test(theEmail);}
function validateForm(){var tName=jQuery('#askA_pName').val();var tEmail=jQuery('#askA_pEmail').val();var tMsg=jQuery('#askA_pQues').val();var errors=new Array();if(tMsg==''){errors.push("You forgot to send us your question, this will help us serve you.");}
if(tEmail==''){errors.push("We need your e-mail address to send you an answer.");}else if(!validateEmail(tEmail)){errors.push("Your e-mail address appears incorrect. If it is not, please e-mail dafref@cc.umanitoba.ca directly.");if(!offSite){logEmail(tEmail);}}
if(errors.length>0){var msg=errors.join('<br />\n');showMsg(msg,'failed');return false;}else{return true;}}
function sendMsg(){var tName=jQuery('#askA_pName').val();var tEmail=jQuery('#askA_pEmail').val();var tMsg=jQuery('#askA_pQues').val();if(validateEmail(tEmail)){tMsg+="\n\n\tSent by: "+tName+" <"+tEmail+">";var thedata={"t":pKey,"e_n":email_to[0],"e_d":email_to[1],"m":encodeURIComponent(tMsg),"s":"Ask a Librarian",'f':encodeURIComponent(tEmail)};disable(jQuery('#askA_form'),1);jQuery('#askA_load').show();sendEmail(thedata,'showResult(data)');}}
function logEmail(theE){var msg='The email address "'+theE+'" appeared and was rejected by Ask a Librarian';var data={'e_n':'libwww','e_d':'umanitoba.ca','s':'Ask a Librarian Email Address Error','m':encodeURIComponent(msg)};sendEmail(data);}
function sendEmail(tData){var URL="/libraries/app/mail_service.php";var callback=((arguments.length>1)?arguments[1]:null);tData['t']=pKey;var args={url:URL,type:"POST",data:tData,dataType:'json',cache:false,error:function(r,e){showMsg('There was an error, '+e,'failed');}};if(arguments.length>1)
eval("args['success'] = function(data,textStatus){ "+arguments[1]+";}");try{jQuery.ajax(args);}catch(e){window.alert("major error: "+e);}}
function showResult(data){if(data.result=='success'){showMsg('Your message has been sent.','success');}else{showMsg('There was an error sending your message.','failed');}
disable(jQuery('#askA_form'),0);jQuery('#askA_load').hide();}
function showMsg(theText,classN){jQuery('#askA_message').empty();jQuery('#askA_message').append(theText);jQuery('#askA_message').attr('class',classN);jQuery('#askA_message').show();}
function verifyContainer(){if(container!='phpLive'){if(jQuery)
if(!jQuery('#'+container).length){container='phpLive';}}}
function disable(theForm,disable){jQuery(':input',theForm).each(function(){if(disable==1)
this.disabled='disabled';else
this.disabled='';});}
function tryJQuery(timeOut){if(typeof(jQuery)=='undefined'){if(timeOut<5000){setTimeout("tryJQuery("+(timeOut+200)+")",200);}else{var tp=document.createElement('p');tp.appendChild(document.createTextNode("We're sorry but chat is unavailable."));var php=document.getElementById(container);if(php.length>0){php[0].appendChild(tp);}}}else{jQuery(document).ready(check_presence);}}
if(typeof(jQuery)=='undefined'){var load=document.createElement('script');load.type='text/javascript';load.src=protocol+"://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js";if(available){load.onload=load.onreadystatechange=function(){if(typeof(jQuery)!='undefined'){jQuery.noConflict();check_presence();if(!jQuery.support.borderRadius){loadCorners();}}};}else{load.onload=load.onreadystatechange=function(){if(typeof(jQuery)!='undefined'){jQuery.noConflict();var form=(display=='full'?makeForm('offline'):makePopUp('offline'));verifyContainer();jQuery('#'+container).append(form);if(!jQuery.support.borderRadius){loadCorners();}}};}
add2Head(load);}else{if(!jQuery.support.borderRadius){loadCorners();}
if(available){jQuery(document).ready(check_presence);}else{jQuery(document).ready(function(){var form=(display=='full'?makeForm('offline'):makePopUp('offline'));verifyContainer();jQuery('#'+container).append(form);});}}
