$.cookie=function(a,b,c){if(arguments.length>1&&String(b)!=="[object Object]"){c=$.extend({},c);if(b===null||b===undefined){c.expires=-1}if(typeof c.expires==="number"){var d=c.expires,e=c.expires=new Date;e.setDate(e.getDate()+d)}b=String(b);return document.cookie=[encodeURIComponent(a),"=",c.raw?b:encodeURIComponent(b),c.expires?"; expires="+c.expires.toUTCString():"",c.path?"; path="+c.path:"",c.domain?"; domain="+c.domain:"",c.secure?"; secure":""].join("")}c=b||{};var f,g=c.raw?function(a){return a}:decodeURIComponent;return(f=(new RegExp("(?:^|; )"+encodeURIComponent(a)+"=([^;]*)")).exec(document.cookie))?g(f[1]):null};var Invite={init:function(a,b){if($.cookie("invite")){return this}this.elem=a;this.options=$.extend({},this.defaults,b);this.setWindowDims().initialiseDOM();return this},defaults:{speed:1e3,cookieExpiresIn:5,images:["bg-invite.png","praise.png","curtain-left.png","curtain-right.png"],imgPath:"images",imgWidth:509,imgHeight:362,targetURL:"/requestsample/default.aspx"},initialiseDOM:function(){Invite.preloadImages();return this},preloadImages:function(){var a=[];for(var b=0;b<Invite.options.images.length;b++){var c=new Image;$(c).load(function(){a[a.length]=Invite.options.images[b];if(a.length==Invite.options.images.length){Invite.start()}}).error(function(){}).attr("src",Invite.options.imgPath+"/"+Invite.options.images[b])}},close:function(){this.setCookie();this.$elem.remove()},start:function(){$("body").append("<div id="+Invite.elem.replace(/#/,"")+"></div>");var a=Math.floor(Invite.windowHeight/2-Invite.options.imgHeight/2);var b=Math.floor(Invite.windowWidth/2-Invite.options.imgWidth/2);var c=20;Invite.$elem=$(Invite.elem);Invite.$elem.css({position:"absolute",zIndex:9999,top:a,left:b,height:Invite.options.imgHeight,width:Invite.options.imgWidth,overflow:"hidden",background:"url('images/bg-invite.png') no-repeat"}).html(this);var d={position:"absolute",left:c/2,top:c/2,width:Invite.options.imgWidth-c,height:Invite.options.imgHeight-c};Invite.$elem.append('<div id="bg-white"></div>');var e=$("#bg-white");e.css($.extend(d,{background:"url('"+Invite.options.imgPath+"/bg-white.png"+"') no-repeat",zIndex:0}));Invite.$elem.append('<div id="curtain-container"></div><a style="display: block; width: 100%; height: 100%" href="'+Invite.options.targetURL+'"></a>');var f=$("#curtain-container");f.css($.extend(d,{overflow:"hidden",zIndex:1}));f.append('<div id="curtain-left" style="position: absolute; left: 0; top: 0; width: 50%; height: 100%; background: url('+Invite.options.imgPath+'/curtain-left.png) no-repeat"></div>'+'<div id="curtain-right" style="position: absolute; left: 50%; top: 0; width: 50%; height: 100%; background: url('+Invite.options.imgPath+'/curtain-right.png) 100% 0 no-repeat"></div>');Invite.$elem.append('<div id="invite-logo"></div>');var g=$("#invite-logo");g.css($.extend(d,{background:"url('"+Invite.options.imgPath+"/praise.png"+"') 50% 50% no-repeat",zIndex:2}));$("#curtain-right").delay(2e3).animate({left:Invite.options.imgWidth},Invite.options.speed);$("#curtain-left").delay(2e3).animate({left:-236},Invite.options.speed,function(){g.remove();f.remove();e.animate({opacity:0},500,function(){e.remove()})});Invite.$elem.append('<div id="invite-close" onclick="Invite.close()"></div>');var h=$("#invite-close");h.css({position:"absolute",top:0,right:0,width:33,height:33,background:"url('"+Invite.options.imgPath+"/close.png"+"') no-repeat",zIndex:99,cursor:"pointer"});return this},setCookie:function(){$.cookie("invite",true,{expires:Invite.options.cookieExpiresIn})},setWindowDims:function(){this.windowWidth=null;this.windowHeight=null;if($.browser.msie){var a=document.documentElement;this.windowWidth=a.clientWidth;this.windowHeight=a.clientHeight}else{var b=window;this.windowWidth=b.innerWidth;this.windowHeight=b.innerHeight}return this}}
