(function(){var a={appId:mmt.social.config.fb_appId,perms:mmt.social.config.fb_perms,connecturl:"connect.facebook.net/en_US/all.js",JS:function(){return document.location.protocol+"//"+a.connecturl},channelUrl:mmt.social.config.fb_channelUrl,custLikeTag:"mmts-fb-like",custShareTag:"mmts-fb-share",custLoginTag:"mmts-fb-login",custCommentsTag:"mmts-fb-comments",custUserTag:"mmts-fb-user",custFriendTag:"mmts-fb-friend",custRegisterTag:"mmts-fb-register",custInviteTag:"mmts-fb-invite",custSendTag:"mmts-fb-send"};window.onerror=function(f,d,c){mmt.social.log(f+":"+mmt.social.lastLoadJS+"=="+a.JS());if(mmt.social.lastLoadJS==a.JS()){if((f=="Script error."||f=="Syntax error")){var e="Error caught :"+f+" ,on "+mmt.social.browser.name+" ,Failed to load - "+mmt.social.lastLoadJS;mmt.social.log(e);mmt.social.event.callEvent(b.name,"error",e);return mmt.social.browser.name!="Chrome"}}};var b=new mmt.social.plugin({name:"fb",fullName:"Facebook",config:a,init:function(){mmt.social.log("fb ---");if(mmt.social.browser.name=="Explorer"&&mmt.social.browser.version<8){return null}mmt.social.services.fb.serverInit(true)},serverInit:function(e){var g=document.getElementById("fb-root");if(!g){g=document.createElement("div");g.id="fb-root";document.getElementsByTagName("body")[0].appendChild(g)}var h=false;for(var d=0;d<this.components.length;d++){if(mmt.social.isTagPresent(this.components[d].name)){mmt.social.log("tag present----------"+this.components[d].name);if(this.components[d].name==a.custLikeTag){var f=document.getElementsByTagName(a.custLikeTag);for(var c=0;c<f.length;c++){if(f[c].getAttribute("share")=="true"||f[c].getAttribute("share")==true||f[c].getAttribute("send")=="true"||f[c].getAttribute("send")==true){h=true;break}}this.parseComp(a.custLikeTag);continue}else{h=true;break}}}mmt.social.log("loading async----------fb:"+h);if(!h){return}if(e){window.fbAsyncInit=function(){mmt.social.services.fb.finalInit()};(function(){mmt.social.loadJS(a.JS)}())}else{mmt.social.services.fb.finalInit()}},finalInit:function(){FB.init({appId:a.appId,status:true,cookie:true,xfbml:false,channelUrl:a.channelUrl});mmt.social.event.callEvent(b.name,"userStatus",FB._userStatus+"");if(FB._userStatus=="unknown"){b._load(null)}else{if(FB._userStatus=="connected"){b._loadFromServer(function(){mmt.social.event.callEvent(b.name,"login")})}}FB.Event.subscribe("auth.login",function(c){mmt.social.log("login event");b._loadFromServer(function(){mmt.social.event.callEvent(b.name,"login")})});FB.Event.subscribe("auth.logout",function(c){mmt.social.log("logout event");b._load(null,function(){mmt.social.event.callEvent(b.name,"logout")})});FB.Event.subscribe("edge.create",function(c){mmt.social.log("edge.create event");mmt.social.event.callEvent(b.name,"like",c)});FB.Event.subscribe("edge.remove",function(c){mmt.social.log("edge.remove event");mmt.social.event.callEvent(b.name,"unlike",c)});FB.Event.subscribe("comments.add",function(c){mmt.social.log("comments.add event");mmt.social.event.callEvent(b.name,"comments_add",c)});FB.Event.subscribe("comment.create",function(c){mmt.social.log("comment.create event");mmt.social.event.callEvent(b.name,"comments_create",c)});FB.Event.subscribe("comment.remove",function(c){mmt.social.log("comment.remove event");mmt.social.event.callEvent(b.name,"comments_remove",c)});FB.Event.subscribe("auth.statusChange",function(c){mmt.social.log("auth.statusChange")});mmt.social.event.callEvent(b.name,"load")},_loadFromServer:function(c){if(mmt.social.config.isFql){mmt.social.services.fb.getUserInfo_FQL(function(d){b._load(d,c)})}else{FB.api("/me",function(d){b._load(d,c)})}},_load:function(d,e){if(d&&!d.error){mmt.social.log("connected :"+d.name);var c=new mmt.social.user();if(mmt.social.config.isFql){c.id=d.uid;c.imageUrl=d.pic;c.gender=d.sex;c.birthday=d.birthday_date;if(d.current_location){c.location=d.current_location.city+" "+d.current_location.state}c.link=d.profile_url;c.interest=d.interests}else{c.id=d.id;c.imageUrl="http://graph.facebook.com/"+d.id+"/picture";c.gender=d.gender;c.birthday=d.birthday;c.interest=d.interests;c.link=d.link;if(d.location){c.location=d.location.name}}c.first_name=d.first_name;c.last_name=d.last_name;c.name=d.first_name+" "+d.last_name;c.email=d.email;mmt.social.services.fb.user=c;mmt.social.services.fb.masterObj=d}else{mmt.social.log("not connected");mmt.social.services.fb.user=null}if(e){e()}b.parseComp(b.components);FB.init({appId:a.appId,status:false,cookie:true,xfbml:true,channelUrl:a.channelUrl});if(mmt.social.isTagPresent(a.custShareTag)){}},components:[new mmt.social.plugin.component({name:a.custLikeTag,config:{url:mmt.social.config.location,type:"standard",type_options:["standard","button_count","box_count"],action:"like",action_options:["like","recommend"],show_faces:false,share:false,font:"arial",font_options:["arial","lucida grande","segoi ui","tohama","trebuchet ms","verdana"],send:false},load:function(f,g){var e={standard:"300",button_count:"80",box_count:"70"};var d={standard:"24",button_count:"20",box_count:"60"};if(mmt.social.browser.name=="Explorer"&&parseInt(mmt.social.browser.version)<8){g.send=false}if(g.send){g.share=true}if(!this.getAttribute("width")){g.width=e[g.type]}if(!this.getAttribute("height")){g.height=d[g.type]}if(g.action=="recommend"){g.width="113"}if(g.share){return"<fb:like font='"+g.font+"' href='"+escape(g.url)+"' action='"+g.action+"' show_faces='"+g.show_faces+"' width='"+g.width+"' height='"+g.height+"' layout='"+g.type+"' send='"+g.send+"'></fb:like>"}else{return'<iframe src="http://www.facebook.com/plugins/like.php?href='+escape(g.url)+"&amp;layout="+g.type+"&amp;show_faces="+g.show_faces+"&amp;width="+g.width+"&amp;action="+g.action+"&amp;colorscheme=light&amp;send="+g.send+"&amp;height="+g.height+'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'+g.width+"px; height:"+g.height+'px;" allowTransparency="true" ></iframe>'}}}),new mmt.social.plugin.component({name:a.custShareTag,config:{url:mmt.social.config.location,text:"Share",type:"button",type_options:["button","link","icon"],display:"normal",display_options:["normal","detailed"],name:"MakeMyTrip.com",picture:document.location.protocol+"//"+document.location.host+"/images/150x150-MMT-logo.gif",caption:"MakeMyTrip.com",description:"Planning a trip? Log on and book on MakeMyTrip.com, India's leading online travel company. Find deals on domestic and international airfares, hotels, holiday packages and other travel products.",message:"I just checked out great travel deals on MakeMyTrip.com.",html:"",width:"400",default_message:"I just checked out great travel deals on MakeMyTrip.com.",default_picture:document.location.protocol+"//www.makemytrip.com/images/150x150-MMT-logo.gif"},load:function(i,t){var s=false;if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var n=new Number(RegExp.$1);if(n>=8){s=false}else{if(n>=7){s=true}else{if(n>=6){s=true}else{if(n>=5){s=true}}}}}if(s){var o=document.location.href.split("?")[1];if(o&&o.indexOf("close=true")>-1){self.close()}}var d=function(){var x=(FB&&FB._session&&FB._session.access_token)?FB._session.access_token:"";x=escape(x);if(s){var w=t.picture&&t.picture!=""?"&picture="+t.picture:"";var c="http://www.facebook.com/dialog/feed?_path=feed&app_id="+a.appId+"&link="+escape(t.url)+w+"&name="+t.name+"&caption="+t.caption+"&description="+t.description+"&message="+t.message+"&redirect_uri="+escape(mmt.social.config.path+"fb/xdRedirector.html?close=true");window.open(c,"shareWindow","left=100,top=100,height=400,width=800,scrollbars=1,location=no")}else{FB.ui({method:"feed",display:"popup",name:t.name,link:t.url,picture:t.picture,caption:t.caption,description:t.description,message:t.message},function(y){if(y&&y.post_id){mmt.social.log("Post was published.");mmt.social.event.callEvent(b.name,"share_publish",y)}else{mmt.social.log("Post was not published."+mmt.social.toString(y));mmt.social.event.callEvent(b.name,"share_skip",y)}})}};var u="";if(t.type=="button"){u='<span class="fb_button fb_button_medium"><span class="fb_button_text">'+t.text+"</span></span>"}else{if(t.type=="link"){u='<div style="style=text-decoration:underline;color:blue;">'+t.text+"</span>"}else{if(t.type=="icon"){u='<img src="'+mmt.social.config.path+'/image/facebook.gif" style="cursor:pointer;width:20px;height:20px;"/>'}}}if(t.html&&t.html.length>0){u=t.html}if(t.display=="normal"){this.onclick=d;return u}else{if(t.display=="detailed"){var l=t.picture.split(",");var v=t.message.split(",");var r=l.length>v.length?l.length:v.length;var f=0;t.width=t.width<320?320:t.width;t.width=t.width>800?800:t.width;var g=document.createElement("div");g.style.display="inline-block";g.style.width=t.width+"px";g.style.height="116px";g.style.border="1px solid lightgrey";g.className="fbShareMainDiv";this.appendChild(g);var k=document.createElement("img");k.src=l[0];k.style.cssFloat="left";k.style.styleFloat="left";k.style.width="100px";k.style.height="100px";k.style.border="1px solid lightgrey";k.style.padding="2px";k.style.margin="5px";k.className="fbShareLogoImg";g.appendChild(k);var m=document.createElement("textarea");m.innerHTML=t.message;m.style.resize="none";m.style.cssFloat="left";m.style.styleFloat="left";m.style.width=(t.width-134)+"px";m.style.height="68px";m.style.border="1px solid lightgrey";m.style.padding="2px";m.style.margin="5px";m.className="fbShareContentDiv";g.appendChild(m);var h=document.createElement("div");h.src=l[0];h.style.cssFloat="left";h.style.styleFloat="left";h.style.display="inline-block";h.style.width="26px";h.style.height="22px";h.style.margin="5px";h.style.backgroundImage="url('"+mmt.social.config.path+"/image/fb_nav.gif')";h.style.backgroundPosition="0px -83px";h.className="fbShareLeftImg";g.appendChild(h);var j=document.createElement("div");j.src=l[0];j.style.cssFloat="left";j.style.styleFloat="left";j.style.display="inline-block";j.style.width="25px";j.style.height="22px";j.style.margin="5px";j.style.backgroundImage="url('"+mmt.social.config.path+"/image/fb_nav.gif')";j.style.backgroundPosition="-25px -83px";j.className="fbShareRightImg";g.appendChild(j);var q=document.createElement("div");q.innerHTML="1 of "+r;q.style.display="inline-block";q.style.cssFloat="left";q.style.styleFloat="left";q.style.fontSize="11px";q.style.paddingTop="10px";q.style.paddingLeft="10px";q.style.color="gray";q.className="fbShareNumDiv";g.appendChild(q);var e=document.createElement("div");e.innerHTML=u;e.style.display="inline-block";e.style.cssFloat="right";e.style.styleFloat="right";e.style.paddingRight="7px";e.style.paddingTop="5px";e.className="fbShareShareDiv";e.onclick=function(){d()};g.appendChild(e);var p=function(){h.style.backgroundPosition="0px -83px";j.style.backgroundPosition="-25px -83px";h.style.cursor="pointer";j.style.cursor="pointer";if(f==0){h.style.backgroundPosition="-50px -83px";h.style.cursor="default"}if(f==r-1){j.style.backgroundPosition="-75px -83px";j.style.cursor="default"}};p();h.onclick=function(){if(f>0){f--;k.src=l[f]||t.default_picture;m.value=v[f]||t.default_message;q.innerHTML=(f+1)+" of "+r}p()};j.onclick=function(){if(f<r-1){f++;k.src=l[f]||t.default_picture;m.value=v[f]||t.default_message;q.innerHTML=(f+1)+" of "+r}p()}}}}}),new mmt.social.plugin.component({name:a.custLoginTag,config:{html:'<label style="color:blue;text-decoration:underline;cursor:pointer;">Logout</label>',text:"",perms:a.perms.join(),perms_options_multi:a.perms,registration_url:""},load:function(n,i){var k=i.registration_url.length>0?'registration-url="'+i.registration_url+'"':"";var o="";if(i.type=="link"){var e=i.style&&i.style!=""?" style="+i.style:"style=text-decoration:underline;color:blue;";var j=i.title&&i.title!=""?" title="+i.title:"";var m=i.text&&i.text!=""?i.text:"Login";o="<div onclick='return mmt.social.services.fb.login()' "+e+j+">"+m+"</div>"}else{if(i.type=="image"){var d=i.src&&i.src!=""?" src="+i.src:" ";var l=i.height&&i.height!=""?" height="+i.height:"";var f=i.width&&i.width!=""?" width="+i.width:"";var g=i.alt&&i.alt!=""?" alt="+i.alt:"";var e=i.style&&i.style!=""?" style="+i.style:"";var j=i.title&&i.title!=""?" title="+i.title:"";var h=i.imageText&&i.imageText!=""?i.imageText:"";o="<img "+d+l+f+g+e+j+" onclick='return mmt.social.services.fb.login()'>"+h+"</img>"}else{if(i.type=="autologout"){return"<fb:login-button autologoutlink=true "+k+' perms="'+i.perms+'"></fb:login-button>'}else{var m=i.text&&i.text!=""?i.text:"";o="<fb:login-button "+k+' perms="'+i.perms+'">'+m+"</fb:login-button>"}}}if(mmt.social.services.fb.user){if(i.html){o='<span onclick="mmt.social.services.fb.logout();" style="cursor:pointer" >'+i.html+"</span>"}}return o}}),new mmt.social.plugin.component({name:a.custCommentsTag,config:{xid:a.appId,numposts:"10",width:"425",publish_feed:true,href:document.location.href},load:function(e,f){var d='<fb:comments xid="'+f.xid+'" numposts="'+f.numposts+'" width="'+f.width+'" publish_feed="'+f.publish_feed+'" href="'+f.href+'" ></fb:comments>';return d}}),new mmt.social.plugin.component({name:a.custRegisterTag,config:{fields:"name,birthday,gender,location,email,captcha",fields_options_multi:["name","birthday","gender","location","email","captcha","password"],redirect_url:document.location.href},load:function(e,f){var d='<fb:registration fields="'+f.fields+'" redirect-uri="'+f.redirect_url+'"width="530"></fb:registration>';return d}}),new mmt.social.plugin.component({name:a.custUserTag,config:{type:"name",type_options:["id","name","first_name","last_name","gender","image","imageUrl","link","location","birthday","interest","specialties"]},load:function(d,e){if(mmt.social.services.fb.user){if(e.type=="link"){return"<a href='"+mmt.social.services.fb.user[e.type]+"' >Check My Profile</a>"}else{if(e.type=="image"){return"<img src='http://graph.facebook.com/"+mmt.social.services.fb.user.id+"/picture' ></img>"}else{return mmt.social.services.fb.user[e.type]+""}}}return" "}}),new mmt.social.plugin.component({name:a.custFriendTag,config:{id:"",type:"link",type_options:["id","name","first_name","last_name","gender","image","imageUrl","link","location","birthday","interest","specialties"]},load:function(d,f){var e=mmt.social.services.fb.getFriendDtls(f.id);if(e){if(f.type=="link"){return"<a href='"+e[f.type]+"' >Check My Profile</a>"}else{if(f.type=="image"){return"<img src='http://graph.facebook.com/"+e.id+"/picture' ></img>"}else{return e[f.type]+""}}}return" "}}),new mmt.social.plugin.component({name:a.custInviteTag,config:{title:"MakeMyTrip",content:"Memories Unlimited",condensed:true,actiontext:"Select the friends you want to invite.",rows:3,width:615,custom:false,buttontext:"Invite %n",buttontext_desc:"%n (First name) or %N (full name) is compulsory",friend_count:2},load:function(e,g){if(g.custom){var f=document.createElement("div");b.getFriendInfo(function(j){var c='<fb:serverfbml width="'+g.width+'"><script type="text/fbml"><fb:request-form  method="POST" invite="true" type="'+g.title+'" action="'+document.location.href+'" content="'+g.content+'" >';for(var h=0;h<g.friend_count&&j.data&&h<j.data.length;h++){c+=' <table><tr><td><fb:profile-pic uid="'+j.data[h].id+'" size="square"></fb:profile-pic></td> <td align="bottom"><fb:request-form-submit uid="'+j.data[h].id+'" label="'+g.buttontext+'" ></fb:request-form-submit></td></tr></table>'}c+="</fb:request-form ><\/script></fb:serverfbml>";f.innerHTML=c;FB.XFBML.parse(f)});return f}else{var d='<fb:serverfbml width="615"><script type="text/fbml"><fb:request-form method="POST" invite="true" type="'+g.title+'" action="'+document.location.href+'" content="'+g.content+'" ><fb:multi-friend-selector condensed="'+g.condensed+'" actiontext="'+g.actiontext+'" rows="'+g.rows+'" style="width: 200px;" ></fb:multi-friend-selector>';if(g.condensed){d+=" <fb:request-form-submit>Should I?</fb:request-form-submit>"}d+="</fb:request-form><\/script></fb:serverfbml>";return d}}}),new mmt.social.plugin.component({name:a.custSendTag,config:{url:mmt.social.config.location},load:function(d,e){if(mmt.social.browser.name=="Explorer"&&parseInt(mmt.social.browser.version)<8){return""}return'<fb:send href="'+e.url+'" ></fb:send>'}})],postComment:function(c,d){FB.api("/me/feed","post",{message:c},function(e){if(!e||e.error){d(b.name,e)}else{d(b.name,e)}})},getUserInfo:function(){return mmt.social.services.fb.user},getFriendInfo:function(c){FB.api("/me/friends/",function(d){if(c){c(d,b)}})},getFriendProfileInfo:function(c){if(mmt.social.services.fb.friendInfo){c(mmt.social.services.fb.friendInfo);return}if(mmt.social.config.isFql){mmt.social.services.fb.getSocialUserInfo_FQL(function(f){var d=f.length;var h=0;var e=[];mmt.social.services.fb.friendInfo=e;for(var g=0;g<d;g++){f[g].imageUrl="http://graph.facebook.com/"+f[g].uid+"/picture";e.push(f[g]);h++;if(c&&h==d){c(e)}}})}else{mmt.social.services.fb.getFriendInfo(function(g){var d=g.data.length;var h=0;var e=[];mmt.social.services.fb.friendInfo=e;for(var f=0;f<d&&f<mmt.social.config.numOfFriends;f++){FB.api(g.data[f].id,function(i){i.imageUrl="http://graph.facebook.com/"+i.id+"/picture";if(i.location){i.location=i.location.name}e.push(i);h++;if(c&&(h==d||h==mmt.social.config.numOfFriends)){c(e)}})}})}},getFriendDtls:function(e){var c=mmt.social.services.fb.friendInfo;for(var d=0;c&&d<c.length;d++){if(c[d].id==e){return c[d]}}},getUserInfo_FQL:function(c){FB.api({method:"fql.query",query:"select email,birthday_date,uid,name,first_name,last_name,profile_url,quotes,locale,current_location,profile_update_time,pic,interests,sex,education_history from user where uid = me()"},function(d){d=d[0];if(c){c(d,b)}})},getSocialUserInfo_FQL:function(c){FB.api({method:"fql.query",query:"select proxied_email,contact_email,email,birthday_date,uid,name,first_name,last_name,profile_url,quotes,locale,current_location,profile_update_time,pic,interests,sex,education_history from user where uid in (SELECT uid2 FROM friend WHERE uid1 = me()) limit "+mmt.social.config.numOfFriends},function(d){if(c){c(d,b)}})},login:function(c){FB.login(function(d){if(c){c()}},{perms:a.perms.join()})},logout:function(){FB.logout(function(c){})},getPermission:function(c,d){if(window.FB){FB.login(function(e){if(d){d()}},{perms:c.join()})}}})}());
