function RegisterNamespace(name){eval(name+" = new Object();")}function RegisterEnum(name){eval(name+" = new "+name+"();")}function RegisterGlobal(name){eval(name+" = new "+name+"();")}RegisterNamespace("SpotlightSpace");SpotlightSpace.Spotlight=function(d,b,g,a,f,e,c){this._target=d||null;this._urlToRequest=SpotlightSpace.Const.AJAX_DIR+b||null;this._crossDomain=g||false;if(this._urlToRequest){if(this._crossDomain){this._urlToRequest=SpotlightSpace.Const.BASE_DIR+this._urlToRequest}}this._scriptElement=null;this._loadingImageUrl=SpotlightSpace.Const.BASE_DIR+SpotlightSpace.Const.PICS_DIR+"spotlight_loader.gif";this._loadingImage=null;this._container=null;this._align=f||SpotlightSpace.Align.LEFT;this._lang=e||"es";this._templatesData=a||SpotlightSpace.Templates.WEBCAMS;this._categoryTemplateUrl=SpotlightSpace.Const.TEMPLATES_DIR+this._templatesData.category["remote"]||null;this._categoryTemplate=null;this._itemTemplateUrl=SpotlightSpace.Const.TEMPLATES_DIR+this._templatesData.item["remote"]||null;this._itemTemplate=null;this._footerTemplateUrl=SpotlightSpace.Const.TEMPLATES_DIR+this._templatesData.footer["remote"]||null;this._footerTemplate=null;this._getTemplatesLocally=true;this._timer=null;this._preId="spotlight_item_";this._cssClass=this._templatesData.css||null;this._cssClassSelected="selected_item";this._width=c||null;this._hasItems=false;this._itemCount=0;this._selectedIndex=-1;this._itemLinks=new Array();this._searchPageSystem={link:null,params:null,types:new Array()};if(Prototype.Browser.IE){Event.observe(window,"load",Function.createDelegate(this,this._initialize))}else{Event.observe(document,"dom:loaded",Function.createDelegate(this,this._initialize))}};SpotlightSpace.Spotlight.prototype={_initialize:function(){this._loadContainer();this._loadLoadingImage();this._loadCategoryTemplate();this._loadItemTemplate();this._loadFooterTemplate();Event.observe(this._target,SpotlightSpace.Events.KEYUP,Function.createDelegate(this,this._targetOnKeyUp));Event.observe(this._target,SpotlightSpace.Events.KEYDOWN,Function.createDelegate(this,this._targetOnKeyPress));Event.observe(this._target,SpotlightSpace.Events.CLICK,Function.createDelegate(this,this._targetOnClick));Event.observe(document.body,SpotlightSpace.Events.CLICK,Function.createDelegate(this,this._bodyOnClick))},_loadContainer:function(){var b=new Element("div");b.className=this._cssClass;if(Prototype.Browser.IE){Element.insert(document.body,b);window.onresize=Function.createDelegate(this,function(){var c=this._calculatePosition();b.setStyle({top:c.top+"px",left:c.left+"px"})})}else{Element.insert(this._target,{after:b})}var a=this._calculatePosition();b.setStyle({display:"none",width:a.width+"px",position:"absolute",top:a.top+"px",left:a.left+"px",overflow:"visible"});this._container=b},_calculatePosition:function(){var c=this._target.getDimensions();if(Prototype.Browser.IE){var d=this._target.cumulativeOffset()}else{var d=this._target.positionedOffset()}var b=this._width?this._width:c.width;var a=0;if(this._align==SpotlightSpace.Align.RIGHT){a=d.left-(b-c.width)}else{a=d.left}return{top:(d.top+c.height),left:a,width:b}},_loadLoadingImage:function(){var a=new Element("img",{src:this._loadingImageUrl});var c=this._target.positionedOffset();var b=this._target.getDimensions();a.setStyle({display:"none",position:"absolute",top:(c.top+6)+"px",left:(c.left+b.width-16)+"px"});Element.insert(this._target,{after:a});this._loadingImage=a},_loadCategoryTemplate:function(){if(this._getTemplatesLocally){this._categoryTemplate=new Template(this._templatesData.category["local"])}else{if(this._categoryTemplateUrl){if(this._crossDomain){this._getTemplateCrossDomain(this._templatesData.category)}else{new Ajax.Request(this._categoryTemplateUrl,{encoding:"iso-8859-1",method:"GET",onSuccess:Function.createDelegate(this,function(a){this._categoryTemplate=new Template(a.responseText)})})}}}},_loadFooterTemplate:function(){if(this._getTemplatesLocally){this._footerTemplate=new Template(this._templatesData.footer["local"])}else{if(this._footerTemplateUrl){if(this._crossDomain){this._getTemplateCrossDomain(this._templatesData.footer)}else{new Ajax.Request(this._footerTemplateUrl,{encoding:"iso-8859-1",method:"GET",onSuccess:Function.createDelegate(this,function(a){this._footerTemplate=new Template(a.responseText)})})}}}},_loadItemTemplate:function(){if(this._getTemplatesLocally){this._itemTemplate=new Template(this._templatesData.item["local"])}else{if(this._itemTemplateUrl){if(this._crossDomain){this._getTemplateCrossDomain(this._templatesData.item)}else{new Ajax.Request(this._itemTemplateUrl,{encoding:"iso-8859-1",method:"GET",onSuccess:Function.createDelegate(this,function(a){this._itemTemplate=new Template(a.responseText)})})}}}},_requestData:function(){clearInterval(this._timer);new Ajax.Request(this._urlToRequest,{encoding:"iso-8859-1",method:"GET",asynchronous:false,parameters:{subject:this._target.value,lang:this._lang},onSuccess:Function.createDelegate(this,function(a){this._loadingImage.hide();this._generateSpotlight.call(this,a.responseText.evalJSON())})})},_requestDataCrossDomain:function(){SpotlightSpace.spotobject=this;clearInterval(this._timer);if(this._scriptElement!=null){Element.remove(this._scriptElement)}this._scriptElement=document.createElement("script");this._scriptElement.src=this._urlToRequest+"?subject="+this._target.value+"&cd=1&lang="+this._lang;document.body.appendChild(this._scriptElement)},_getTemplateCrossDomain:function(b){SpotlightSpace.spotobject=this;var a=document.createElement("script");a.src=SpotlightSpace.Const.BASE_DIR+SpotlightSpace.Const.TEMPLATE_LOADER_URL+"?tpl="+b;document.body.appendChild(a)},_generateSpotlight:function(d){this._hideSpotlight();this._showSpotlight();if(d.link){this._searchPageSystem.link=d.link.url;this._searchPageSystem.params=d.link.params}var c=0;this._hasItems=false;if(d.categories){d.categories.each(Function.createDelegate(this,function(f){if(f.itemCollection!=null){var g=this._categoryTemplate.evaluate(f);var e=g.toDOMElement();this._container.appendChild(e);this._searchPageSystem.types[this._searchPageSystem.types.length]=f.id;f.itemCollection.each(Function.createDelegate(this,function(h){var j=this._itemTemplate.evaluate(h);var i=j.toDOMElement();i.writeAttribute("id",this._preId+c);this._container.appendChild(i);Event.observe(i,SpotlightSpace.Events.OVER,Function.createDelegate({spot:this,index:c},this._itemOnMouseOver));if(h.itemLink!=""){this._itemLinks[c]=h.itemLink;Event.observe(i,SpotlightSpace.Events.CLICK,Function.createDelegate(h,function(){window.location.href=this.itemLink}))}c++}))}}));this._itemCount=c;this._selectedIndex=-1;this._hasItems=true}if(d.footer){var b=this._footerTemplate.evaluate(d.footer);var a=b.toDOMElement();this._container.appendChild(a);if(this._hasItems&&this._searchPageSystem.link){Event.observe(a,SpotlightSpace.Events.CLICK,Function.createDelegate(this,this._goSearchPage))}}},_showSpotlight:function(){this._container.show()},_hideSpotlight:function(){this._searchPageSystem={link:null,params:null,types:new Array()};this._selectedIndex=-1;this._container.hide();this._container.update("")},_validateKey:function(a){var b=(document.all)?a.keyCode:a.which;if((b>48&&b<90)||b==8){return true}else{return false}},_tryNavigate:function(a){var b=(document.all)?a.keyCode:a.which;if(b==38){var c=this._selectedIndex-1;if($("spotlight_item_"+c)){this.setSelectedIndex(c)}else{this.setSelectedIndex(this._itemCount-1)}}else{if(b==40){var c=this._selectedIndex+1;if($("spotlight_item_"+c)){this.setSelectedIndex(c)}else{this.setSelectedIndex(0)}}else{if(b==13){if(this._itemLinks[this._selectedIndex]){window.location.href=this._itemLinks[this._selectedIndex]}else{if(this._searchPageSystem.link){this._goSearchPage()}}}else{if(b==27){this._hideSpotlight()}else{return false}}}}},_goSearchPage:function(){window.location.href=this._searchPageSystem.link+"?"+this._searchPageSystem.params[SpotlightSpace.Const.SEARCH_GET_PARAMS.type]+"="+this._searchPageSystem.types.join(",")+"&"+this._searchPageSystem.params[SpotlightSpace.Const.SEARCH_GET_PARAMS.search]+"="+this._target.value.replaceAll(" ","+")},init:function(){this._initialize()},_targetOnKeyUp:function(a){if(this._urlToRequest){if(this._target.value!=""){if(this._validateKey(a)){if(this._timer){clearInterval(this._timer)}this._loadingImage.show();SpotlightSpace.spotobject=this;if(this._crossDomain){this._timer=setInterval("SpotlightSpace.spotobject._requestDataCrossDomain()",300)}else{this._timer=setInterval("SpotlightSpace.spotobject._requestData()",300)}}else{}}else{this._loadingImage.hide();this._hideSpotlight()}}},_targetOnKeyPress:function(a){this._tryNavigate(a)},_targetOnClick:function(a){Event.stop(a)},_containerOnClick:function(a){Event.stop(a)},_bodyOnClick:function(a){this._hideSpotlight();this._target.value=""},_itemOnMouseOver:function(a){this.spot.setSelectedIndex(this.index)},setSelectedIndex:function(a){if($("spotlight_item_"+this._selectedIndex)){$("spotlight_item_"+this._selectedIndex).removeClassName(this._cssClassSelected)}$("spotlight_item_"+a).addClassName(this._cssClassSelected);this._selectedIndex=a},getSelectedIndex:function(){return this._selectedIndex},setUrl:function(a){this._urlToRequest=a},getUrl:function(){return this._urlToRequest},setItemTemplateUrl:function(a){this._itemTemplateUrl=a},getItemTemplateUrl:function(){return this._itemTemplateUrl},setCategoryTemplateUrl:function(a){this._categoryTemplateUrl=a},getCategoryTemplateUrl:function(){return this._categoryTemplateUrl},setFooterTemplateUrl:function(a){this._footerTemplateUrl=a},getFooterTemplateUrl:function(){return this._footerTemplateUrl}};SpotlightSpace.Util=function(){};SpotlightSpace.Util.prototype={addStyleSheet:function(a){if(document.createStyleSheet){document.createStyleSheet(a)}else{var b="@import url('"+a+"');";var c=new Element("link",{rel:"stylesheet",href:"data:text/css,"+escape(b)});document.getElementsByTagName("head")[0].appendChild(c)}}};RegisterGlobal("SpotlightSpace.Util");SpotlightSpace.Const=function(){};SpotlightSpace.Const.prototype={BASE_DIR:"http://spotlight.spacash.com/",AJAX_DIR:"ajax/",TEMPLATES_DIR:"templates/",PICS_DIR:"pics/",CSS_DIR:"css/",TEMPLATE_LOADER_URL:"templates/templateLoader.php",SEARCH_GET_PARAMS:{type:"type",search:"subject"}};RegisterGlobal("SpotlightSpace.Const");SpotlightSpace.LocalTemplates=function(){};SpotlightSpace.LocalTemplates.prototype={CATEGORY:{DEFAULT:"<div class='spot_header'>#{name}</div>"},FOOTER:{DEFAULT:"<div class='spot_footer' style='cursor : pointer'>#{text}</div>"},ITEM:{DEFAULT:"",WEBCAMS:"<div class='spot_items'><div class='spot_thumb_pic' style='float: left'><a href='#{link_url}'><img src='#{image_url}' class='shadow' alt='' style='width:40px; height:30px' /></a></div><div class='spot_info' style='float: left'><span class='spot_title'><a href='#{link_url}'>#{nick}</a></span><br /><span class='spot_subtitle grey'><img src='#{status_icon_url}' class='state' alt='' /><a href='#{link_url}'>#{status}</a></span></div><div class='clear'></div></div>",VIDEOS:"<div class='spot_items'><div class='spot_thumb_pic' style='float: left'><a href='#{link_url}'><img src='#{image_url}' class='shadow' alt='' /></a></div><div class='spot_info' style='float: left'><span class='spot_title'><a href='#{link_url}'>#{name}</a></span><br /><span class='spot_subtitle'>#{desc}</span></div><div class='clear'></div></div>"}};RegisterGlobal("SpotlightSpace.LocalTemplates");SpotlightSpace.Templates=function(){};SpotlightSpace.Templates.prototype={WEBCAMS:{css:"spotlight_webcams shadow",category:{remote:"dvdstore.com/category.html",local:SpotlightSpace.LocalTemplates.CATEGORY.DEFAULT},item:{remote:"dvdstore.com/webcams/item.html",local:SpotlightSpace.LocalTemplates.ITEM.WEBCAMS},footer:{remote:"dvdstore.com/footer.html",local:SpotlightSpace.LocalTemplates.FOOTER.DEFAULT}},VIDEOS:{css:"spotlight shadow",category:{remote:"dvdstore.com/category.html",local:SpotlightSpace.LocalTemplates.CATEGORY.DEFAULT},item:{remote:"dvdstore.com/videos/item.html",local:SpotlightSpace.LocalTemplates.ITEM.VIDEOS},footer:{remote:"dvdstore.com/footer.html",local:SpotlightSpace.LocalTemplates.FOOTER.DEFAULT}}};RegisterGlobal("SpotlightSpace.Templates");SpotlightSpace.Events=function(){};SpotlightSpace.Events.prototype={CLICK:"click",OVER:"mouseover",OUT:"mouseout",FOCUS:"focus",BLUR:"blur",KEYUP:"keyup",KEYDOWN:"keydown"};RegisterGlobal("SpotlightSpace.Events");SpotlightSpace.Align=function(){};SpotlightSpace.Align.prototype={RIGHT:"right",LEFT:"left"};RegisterGlobal("SpotlightSpace.Align");String.prototype.replaceAll=function(b,a){var c=this;while(c.indexOf(b)!=-1){c=c.replace(b,a)}return c};String.prototype.toDOMElement=function(){var a=new Element("div");a.update(this);return Element.firstDescendant(a)};getIEVersion=function(){try{var c=navigator.userAgent;var b=c.indexOf("MSIE ");if(b==-1){return 0}else{return parseFloat(c.substring(b+5,c.indexOf(";",b)))}}catch(a){}};Function.__typeName="Function";Function.__class=true;Function.createDelegate=function Function$createDelegate(a,b){return function(){return b.apply(a,arguments)}};