if(typeof logicbox == "undefined") var logicbox = {};

(function($) {
		  
	logicbox.prototype = $.extend(logicbox,{
			 
	//forces capitalisation on each word
	capitalize: function() {
		var text = $(this).val();
		var wordArray = text.split(" ");
		for (i=0; i<wordArray.length;i++) {
			var t = wordArray[i].substr(0,1);
			wordArray[i] = t.toUpperCase() + wordArray[i].substr(1);
		}
		$(this).val(wordArray.join(" "));
	},
	
	//new window wrapper
	newWin: function() {
		var w = window.open($(this).attr('href'),'_blank');
		w.focus();
		return false;
	},
	
	/* toggles a div containing alternate content for a select box
	* @param string Target Element - jQuery Selector
	* @param string Container DIV - jQuery Selector
	* @param string Input text element - jQuery Selector */
	toggleOtherField: function(el,divTarget,inputTarget) {
		if ($(el).val().toLowerCase()=='other') {
			$(divTarget).slideDown('fast',function() {
				if(!$.browser.msie)
					$(inputTarget).focus();
			});
		}
		else if ($(el).val().toLowerCase()!='other' && $(divTarget).css('display')=='block') {
			$(divTarget).hide();
			$(inputTarget).val('');
		}
	},
	injectMovie: function(skipIntro) {
		
		var flashUrl = "/k2lweb_v9.swf?090526";
		var flashContainer = "pic-block";
		
		var so = new SWFObject(flashUrl, "k2l", "774", "422", "9", "#000000");
		so.useExpressInstall('expressinstall.swf');
		so.addParam('wmode', 'transparent');
		so.addVariable('skipIntro', skipIntro);
		//write flash or show no flash player notice on failure
		so.write(flashContainer) || $("#" + flashContainer + " > span").show();
	},
	injectPortraitMovie: function() {

		var flashUrl = "/movie.swf";
		var flashContainer = "movie";
		var so = new SWFObject(flashUrl, "k2l", "255", "365", "9", "#000000");
		so.addParam('wmode', 'transparent');	
		//write flash or show no flash player notice on failure
		so.write(flashContainer) || $("#" + flashContainer + " > span").show();	
		$('.key2luxury-video').css('background','none');
	}
	
	}); // /logicbox
		  
	var selectCJ  = "select[name=company_jobtitle]",
		inputCJO = "input[name=company_jobtitle_other]";
	
	var jobTitle = function() {
		logicbox.toggleOtherField(this,'#jobTitle',inputCJO);
	}
		  
	$(function() {
	   $(".venues, .c-index #wrap-content").click(function(){
			elements = this.getElementsByTagName('a');
			if (elements.length!=0)
				document.location=elements[0].getAttribute('href');
		});
	   
	   	if ($(".key2luxury-video").length) {
			$(window).load(function() {
				logicbox.injectPortraitMovie();
			});	
		}
		
		//Invites
		if ($(selectCJ).length) {
			if ($(inputCJO).val()=='' && $(selectCJ).val()!='Other') {
				$("#jobTitle").hide();
			}
			
			$(selectCJ).change(jobTitle);
		}
		
		$('#video').flash({
			swf: '/player5.swf',
			width: 770,
			height: 367,
			params: {
				wmode: "transparent",
				flashvars: {
					file: '/flv/tgp_2mb.flv',
					image: '/images/home_silo.jpg',
					autostart: false,
					bufferlength: 3,
					stretching: 'fill',
					skin: '/modieus.zip'
				}
			}
		});
		
		var itemsToInsert = parseInt(($("#wrap-main").height() - 2880) / (2021 - 18 -26)) - 1;
		var $items = $("div#gold-sponsors > p:not(.gold)").clone();
		for (i=0; i<=itemsToInsert; i++) {
			$("div#gold-sponsors").append($items.clone());
		}
		
		$("a[rel=external],.newWin").click(logicbox.newWin);
		$("input[type=text]").not("[name*=email],[name=q],[name*=website],[name*=usn]").change(logicbox.capitalize);
		$('body').supersleight();

	});

})(jQuery);
jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: '/images/x.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				//console.log(this);
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
/* jquery.swfobject.license.txt */
(function(C){var E=document,B="object",D=window,A="";C.flashPlayerVersion=(function(){var H,F,K,J,M=false,L="ShockwaveFlash.ShockwaveFlash";if(!(H=navigator.plugins["Shockwave Flash"])){try{F=new ActiveXObject(L+".7")}catch(K){try{F=new ActiveXObject(L+".6");H=[6,0,21];F.AllowScriptAccess="always"}catch(J){if(H&&H[0]===6){M=true}}if(!M){try{F=new ActiveXObject(L)}catch(I){H="X 0,0,0"}}}if(!M&&F){try{H=F.GetVariable("$version")}catch(G){}}}else{H=H.description}H=H.match(/^[A-Za-z\s]*?(\d+)(\.|,)(\d+)(\s+r|,)(\d+)/);return[H[1]*1,H[3]*1,H[5]*1]}());C.flashExpressInstaller="expressInstall.swf";C.hasFlashPlayer=(C.flashPlayerVersion[0]!==0);C.hasFlashPlayerVersion=function(G){var F=C.flashPlayerVersion;G=(/string|number/.test(typeof G))?G.toString().split("."):G;G=[G.major||G[0]||F[0],G.minor||G[1]||F[1],G.release||G[2]||F[2]];return(C.hasFlashPlayer&&(G[0]>F[0]||(G[0]===F[0]&&(G[1]>F[1]||(G[1]===F[1]&&G[2]>=F[2])))))};C.flash=function(Q){if(!C.hasFlashPlayer){return false}var G=Q.swf||A,O=Q.params||{},I=E.createElement("body"),F,P,L,H,N,M,K,J;Q.height=Q.height||180;Q.width=Q.width||320;if(Q.hasVersion&&!C.hasFlashPlayerVersion(Q.hasVersion)){C.extend(Q,{id:"SWFObjectExprInst",height:Math.max(Q.height,137),width:Math.max(Q.width,214)});G=Q.expressInstaller||C.flashExpressInstaller;O={flashvars:{MMredirectURL:location.href,MMplayerType:(C.browser.msie&&C.browser.win)?"ActiveX":"PlugIn",MMdoctitle:E.title.slice(0,47)+" - Flash Player Installation"}}}if(typeof O===B){if(Q.flashvars){O.flashvars=Q.flashvars}if(Q.wmode){O.wmode=Q.wmode}}for(N in (M=["expressInstall","flashvars","hasVersion","params","swf","wmode"])){delete Q[M[N]]}F=[];for(N in Q){if(typeof Q[N]===B){P=[];for(M in Q[N]){P.push(M.replace(/([A-Z])/,"-$1").toLowerCase()+":"+Q[N][M]+";")}Q[N]=P.join(A)}F.push(N+'="'+Q[N]+'"')}Q=F.join(" ");if(typeof O===B){F=[];for(N in O){if(typeof O[N]===B){P=[];for(M in O[N]){if(typeof O[N][M]===B){L=[];for(K in O[N][M]){if(typeof O[N][M][K]===B){H=[];for(J in O[N][M][K]){H.push([J.replace(/([A-Z])/,"-$1").toLowerCase(),":",O[N][M][K][J],";"].join(A))}O[N][M][K]=H.join(A)}L.push([K,"{",O[N][M][K],"}"].join(A))}O[N][M]=L.join(A)}P.push([M,"=",D.escape(O[N][M])].join(A))}O[N]=P.join("&amp;")}F.push(['<PARAM NAME="',N,'" VALUE="',O[N],'">'].join(A))}O=F.join(A)}if(!(/style=/.test(Q))){Q+=' style="vertical-align:text-top;"'}if(!(/style=(.*?)vertical-align/.test(Q))){Q=Q.replace(/style="/,'style="vertical-align:text-top;')}if(C.browser.msie){Q+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';O='<PARAM NAME="movie" VALUE="'+G+'">'+O}else{Q+=' type="application/x-shockwave-flash" data="'+G+'"'}I.innerHTML=["<OBJECT ",Q,">",O,"</OBJECT>"].join(A);return C(I.firstChild)};C.fn.flash=function(G){if(!C.hasFlashPlayer){return this}var F=0,H;while((H=this.eq(F++))[0]){H.html(C.flash(C.extend({},G)));if(E.getElementById("SWFObjectExprInst")){F=this.length}}return this}}(jQuery));