var tgl_obj_settings=null;
var tgl_glb_obj={id:"tgl_me",initialized:false,tungleMePIDS:0,host:"https://www.tungle.me/",tungleMeObj:{},bUrl:"portal/widget.htm#",meetPopup:{id:"tgl_me_schedule",margin:10,border:3,height:575,offset:60,width:346,iframe:true},infoPopup:{id:"tgl_me_info",margin:20,border:3,height:90,offset:45,width:220},findPos:function(_1){
var _2=curtop=0;
if(_1.offsetParent){
do{
_2+=_1.offsetLeft;
curtop+=_1.offsetTop;
}while(_1=_1.offsetParent);
}
return [_2,curtop];
},getViewportSize:function(){
var _3=[0,0];
if(typeof window.innerWidth!="undefined"){
_3=[window.innerWidth,window.innerHeight];
}else{
if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!=0){
_3=[document.documentElement.clientWidth,document.documentElement.clientHeight];
}else{
_3=[document.getElementsByTagName("body")[0].clientWidth,document.getElementsByTagName("body")[0].clientHeight];
}
}
return _3;
},hideMe:function(_4,id){
var _6=_4.getAttribute("tglid");
var _7=tgl_glb_obj.tungleMeObj[_6];
if(_7){
_7.visible=false;
}
var _8=document.getElementById(id);
if(_8){
_8.style.display="none";
}
},createUrl:function(_9){
var _a=tgl_glb_obj.host+tgl_glb_obj.bUrl+_9.pCode;
if(_9.options.name){
_a+="&self="+_9.options.name;
}
if(_9.options.position){
_a+="&pos="+_9.options.position;
}
if(_9.options.company){
_a+="&firm="+_9.options.company;
}
if(_9.options.URI){
_a+="&uri="+_9.options.URI;
}
if(_9.options.img){
_a+="&img="+_9.options.img;
}
return _a;
},createPopup:function(_b,_c,_d){
var _e=tgl_glb_obj.findPos(_b);
var _f=[_b.offsetWidth,_b.offsetHeight];
var _10=[0,0];
var _11=[0+"px",0+"px","auto","auto"];
var _12="0px 0px";
var _13=tgl_glb_obj.getViewportSize();
if(_13[0]-(_e[0]+_f[0])>=_c.width){
_10[0]=_e[0]+_f[0];
_10[1]=Math.max(_e[1]-_c.height+_f[1],0);
_10[1]=Math.min(_10[1],_e[1]);
var _14=(_e[1]-_10[1]);
if(_14<(_c.border+_c.margin)){
_14=(_c.border+_c.margin);
}else{
if(_14>_c.height-2*(_c.border+_c.margin)){
_14=_c.height-2*(_c.border+_c.margin);
}
}
_11=[_14+"px","auto","auto","0px"];
_12="L";
}else{
if(_e[0]>=_c.width){
_10[0]=_e[0]-_c.width;
_10[1]=Math.max(_e[1]-_c.height+_f[1],0);
_10[1]=Math.min(_10[1],_e[1]);
var _14=(_e[1]-_10[1]);
if(_14<(_c.border+_c.margin)){
_14=(_c.border+_c.margin);
}else{
if(_14>_c.height-2*(_c.border+_c.margin)){
_14=_c.height-2*(_c.border+_c.margin);
}
}
_11=[_14+"px","0px","auto","auto"];
_12="R";
}else{
if(_e[1]>=_c.height){
_10[1]=_e[1]-_c.height;
_10[0]=Math.min(_e[0]+_f[0]/2,_13[0]-_c.width);
_10[0]=Math.max(0,_10[0]);
var _15=(_f[0]/2);
if(_10[0]<_e[0]){
_15=(_c.width-_f[0]/2);
}
_11=["auto","auto","0px",_15+"px"];
_12="D";
}else{
_10[1]=_e[1]+_f[1];
_10[0]=Math.min(_e[0]+_f[0]/2,_13[0]-_c.width);
_10[0]=Math.max(0,_10[0]);
var _15=(_f[0]/2);
if(_10[0]<_e[0]){
_15=(_c.width-_f[0]/2);
}
_11=["0px","auto","auto",_15+"px"];
_12="Up";
}
}
}
var _16=document.getElementById(_c.id);
if(!_16){
var _17=(_c.height-2*(_c.border+_c.margin));
var _18=(_c.width-2*(_c.border+_c.margin));
var _19="<div class=\"tgl_x\" id=\"x_"+_c.id+"\" tglid=\""+_d.id+"\" onclick=\"tgl_glb_obj.hideMe(this, '"+_c.id+"');\"><img src=\""+tgl_glb_obj.host+"portal/images/widget/close.png\"/></div>";
_19+="<div class=\"tgl_arr\" id=\"arr_"+_c.id+"\"><img id=\"arrimg_"+_c.id+"\" height=\"21\" width=\"21\" src=\""+tgl_glb_obj.host+"/portal/images/widget/arrowL.png\"/></div>";
if(_c.iframe&&_d){
_19+="<div class=\"tgl_ctn\" style=\"height:"+_17+"px;width:"+_18+"px;\"><iframe id=\"ctn_"+_c.id+"\" SCROLLING=\"NO\" frameborder=\"0\" style=\"border:0px;height:540px;width:"+_18+"px;\" src=\""+tgl_glb_obj.createUrl(_d)+"\"></div>";
}else{
if(_d&&_d.content){
_19+="<div class=\"tgl_ctn\" id=\"ctn_"+_c.id+"\" style=\"padding:10px;background:white;height:"+_17+"px;width:"+_18+"px;\">"+_d.content+"</div>";
}
}
var _1a=document.createElement("div");
_1a.id=_c.id;
_1a.className="tgl_me_schedule";
_1a.innerHTML=_19;
document.body.appendChild(_1a);
_16=document.getElementById(_c.id);
}else{
var x=document.getElementById("x_"+_c.id);
x.setAttribute("tglid",_d.id);
if(_c.iframe&&_d){
var _1c=document.getElementById("ctn_"+_c.id);
if(_1c){
var src=tgl_glb_obj.createUrl(_d);
var _1e=_1c.getAttribute("src");
if(_1e!=src){
_1c.setAttribute("src",src);
}
}
}else{
if(_d&&_d.content){
var _1f=document.getElementById("ctn_"+_c.id);
if(_1f.innerHTML!=_d.content){
_1f.innerHTML=_d.content;
}
}
}
}
var _20=document.getElementById("arr_"+_c.id);
_20.style.top=_11[0];
_20.style.right=_11[1];
_20.style.bottom=_11[2];
_20.style.left=_11[3];
var _21=document.getElementById("arrimg_"+_c.id);
_21.src=tgl_glb_obj.host+"/portal/images/widget/arrow"+_12+".png";
_16.style.left=_10[0]+"px";
_16.style.top=_10[1]+"px";
_16.style.display="block";
},onclickFunction:function(obj){
if(!obj){
obj=this;
}
var id=obj.getAttribute("tglid");
var _24=tgl_glb_obj.tungleMeObj[id];
if(!_24.visible){
tgl_glb_obj.createPopup(obj,tgl_glb_obj.meetPopup,_24);
tgl_glb_obj.hideInfoPopup();
for(var i in tgl_glb_obj.tungleMeObj){
tgl_glb_obj.tungleMeObj[i].visible=false;
if(i==id){
tgl_glb_obj.tungleMeObj[i].visible=true;
}
}
}
return false;
},showInfoPopup:function(obj){
if(!obj){
obj=this;
}
var id=obj.getAttribute("tglid");
var _28=tgl_glb_obj.tungleMeObj[id];
if(!_28.visible){
tgl_glb_obj.createPopup(obj,tgl_glb_obj.infoPopup,_28);
}
},hideInfoPopup:function(){
var _29=document.getElementById(tgl_glb_obj.infoPopup.id);
if(_29){
_29.style.display="none";
}
},initBehaviours:function(obj,_2b){
var _2c=obj.getAttribute("teml");
var _2d={visible:false,id:tgl_glb_obj.id+tgl_glb_obj.tungleMePIDS,domId:obj.getAttribute("id"),pCode:_2c,content:"<img src=\""+tgl_glb_obj.host+"portal/images/widget/tglLogo2.png\" style=\"float:left;margin-right:10px;\"/> <b>Click</b> to see my availability or schedule a meeting with me.",options:{name:obj.getAttribute("self"),position:obj.getAttribute("pos"),company:obj.getAttribute("firm"),URI:obj.getAttribute("uri"),img:obj.getAttribute("img")}};
if(_2b){
if(_2b.tungleId){
_2d.pCode=_2b.tungleId;
}
if(_2b.options){
_2d.options=_2b.options;
}
}
if(!_2d.pCode){
return false;
}
tgl_glb_obj.tungleMePIDS++;
obj.setAttribute("tglid",_2d.id);
if(!_2d.domId){
_2d.domId=_2d.id;
obj.setAttribute("id",_2d.id);
}
tgl_glb_obj.tungleMeObj[_2d.id]=_2d;
tgl_glb_obj.attachEvent(obj,"click",tgl_glb_obj.onclickFunction);
tgl_glb_obj.attachEvent(obj,"mouseover",tgl_glb_obj.showInfoPopup);
tgl_glb_obj.attachEvent(obj,"mouseout",tgl_glb_obj.hideInfoPopup);
},loadTungleMe:function(){
initTgl_me();
},attachEvent:function(_2e,_2f,_30){
if(_2e.addEventListener){
_2e.addEventListener(_2f,function(){
_30(_2e);
},false);
}else{
if(_2e.attachEvent){
_2e.attachEvent("on"+_2f,function(){
_30(_2e);
});
}
}
},movePopup:function(){
clearTimeout(tgl_glb_obj.moveTimeout);
for(var i in tgl_glb_obj.tungleMeObj){
if(tgl_glb_obj.tungleMeObj[i].visible==true){
tgl_glb_obj.docWidth=tgl_glb_obj.getViewportSize()[0];
tgl_glb_obj.moveTimeout=setTimeout(tgl_glb_obj.movePopupTimeout,300);
break;
}
}
},moveTimeout:null,movePopupTimeout:function(){
var _32=tgl_glb_obj.getViewportSize()[0];
if(_32==tgl_glb_obj.docWidth){
var obj=null;
var _34=null;
for(var i in tgl_glb_obj.tungleMeObj){
if(tgl_glb_obj.tungleMeObj[i].visible==true){
obj=document.getElementById(tgl_glb_obj.tungleMeObj[i].domId);
_34=tgl_glb_obj.tungleMeObj[i];
break;
}
}
if(obj){
tgl_glb_obj.createPopup(obj,tgl_glb_obj.meetPopup,_34);
}
}
}};
function initTgl_me(obj,_37){
if(!tgl_glb_obj.initialized){
if(tgl_obj_settings){
if(tgl_obj_settings.width=="L"){
tgl_glb_obj.meetPopup.width=426+2*(tgl_glb_obj.meetPopup.border+tgl_glb_obj.meetPopup.margin);
tgl_glb_obj.bUrl="portal/widget.htm?s=l#";
}
}
setTimeout(function(){
var _38=document.createElement("link");
_38.setAttribute("rel","stylesheet");
_38.setAttribute("type","text/css");
_38.setAttribute("href",tgl_glb_obj.host+"portal/css/plugins/widget.css");
document.getElementsByTagName("head")[0].appendChild(_38);
},100);
if(document.getElementsByClassName==undefined){
document.getElementsByClassName=function(_39){
var _3a=new RegExp("(?:^|\\s)"+_39+"(?:$|\\s)");
var _3b=document.getElementsByTagName("*");
var _3c=[];
var _3d;
for(var i=0;(_3d=_3b[i])!=null;i++){
var _3f=_3d.className;
if(_3f&&_3f.indexOf(_39)!=-1&&_3a.test(_3f)){
_3c.push(_3d);
}
}
return _3c;
};
}
tgl_glb_obj.docWidth=tgl_glb_obj.getViewportSize()[0];
tgl_glb_obj.attachEvent(window,"resize",tgl_glb_obj.movePopup);
tgl_glb_obj.initialized=true;
}
if(obj){
tgl_glb_obj.initBehaviours(obj,_37);
}else{
var _40=document.getElementsByClassName("tungle-me");
for(var i=0;i<_40.length;i++){
tgl_glb_obj.initBehaviours(_40[i]);
}
}
}
(function(){
var ie=!!(window.attachEvent&&!window.opera);
var wk=/webkit\/(\d+)/i.test(navigator.userAgent)&&(RegExp.$1<525);
var fn=[];
var run=function(){
for(var i=0;i<fn.length;i++){
fn[i]();
}
};
var d=document;
d.ready=function(f){
if(!ie&&!wk&&d.addEventListener){
return d.addEventListener("DOMContentLoaded",f,false);
}
if(fn.push(f)>1){
return;
}
if(ie){
(function(){
try{
d.documentElement.doScroll("left");
run();
}
catch(err){
setTimeout(arguments.callee,0);
}
})();
}else{
if(wk){
var t=setInterval(function(){
if(/^(loaded|complete)$/.test(d.readyState)){
clearInterval(t),run();
}
},0);
}
}
};
document.ready(tgl_glb_obj.loadTungleMe);
if(document.location.host.indexOf("tungle.me")!=-1||document.location.host.indexOf("192.168.1")!=-1){
tgl_glb_obj.host="https://"+document.location.host+"/";
}
})();


