
namespacing={init:function(namespace){var spaces=[];namespace.split('.').each(function(space){var curSpace=window,i;spaces.push(space);for(i=0;i<spaces.length;i++){if(typeof curSpace[spaces[i]]==='undefined'){curSpace[spaces[i]]={};}
curSpace=curSpace[spaces[i]];}});}};namespacing.init('istock');istock.Storage=Class.create({initialize:function(type){if(type!=='local'&&type!=='session'){throw'Storage type not supported. Expected "local" or "session".';}
this._determineSupport(type);if(!this._features.storage){throw'Storage is not supported';}},getItem:function(key){var val;if(!key){return null;}
if(this._features.getItem){val=this._storage.getItem(key);}else{val=this._storage[key];if(typeof val!=='string'){try{val=val.toString();}catch(e){return null;}}}
return val;},setItem:function(key,value){if(!key){return null;}
if(this._features.setItem.overwrite){this._storage.setItem(key,value);}else if(this._features.setItem.write){this.removeItem(key);this._storage.setItem(key,value);}else{this._storage[key]=value;}},removeItem:function(key){if(!key){return null;}
if(this._features.removeItem){this._storage.removeItem(key);}else{delete this._storage[key];}},clear:function(namespace){var clear=function(){var key;for(key in this._storage){if(this._storage.hasOwnProperty(key)&&(!namespace||(namespace&&key.indexOf(namespace)>=0))){if(key!=='length'){this.removeItem(key);}}}}.bind(this);if(this._features.clear){try{if(!namespace){this._storage.clear();}else{clear();}}catch(e){clear();}}else{clear();}},_determineSupport:function(type){type=type+'Storage';this._storageSupport(type);this._setItemSupport();this._getItemSupport();this._removeItemSupport();this._clearSupport();},_storageSupport:function(type){if(window[type]){this._storage=window[type];this._features.storage=true;}},_setItemSupport:function(){var storage=this._storage,randKey=Math.floor(Math.random()*101),randVal=function(){var chars='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@##$%^^&*()-=_+',min=2500,max=3000,len=Math.floor(Math.random()*(max-min+1)+min),arrStr=[],rnum,i;for(i=0;i<len;i++){rnum=Math.floor(Math.random()*chars.length);arrStr.push(chars.substring(rnum,rnum+1));}
return arrStr.join('');};if(storage.setItem){try{storage.setItem(randKey,randVal());this._features.setItem.write=true;storage.setItem(randKey,randVal());this._features.setItem.overwrite=true;}catch(e){}
this.removeItem(randKey);}},_getItemSupport:function(){var storage=this._storage,randKey=Math.floor(Math.random()*101),keyVal='';if(storage.getItem){this.setItem(randKey,'someVal');try{keyVal=storage.getItem(randKey);if(typeof keyVal==='string'&&keyVal==='someVal'){this._features.getItem=true;}}catch(e){}
this.removeItem(randKey);}},_removeItemSupport:function(){var storage=this._storage,randKey=Math.floor(Math.random()*101);if(storage.removeItem){this.setItem(randKey,'someVal');try{storage.removeItem(randKey);if(typeof this.getItem(randKey)!=='undefined'){this._features.removeItem=true;}}catch(e){}
this.removeItem(randKey);}},_clearSupport:function(){if(this._storage.clear){this._features.clear=true;}},_features:{storage:false,getItem:false,setItem:{write:false,overwrite:false},removeItem:false,clear:false}});try{istock.localStorage=new istock.Storage('local');}catch(e){}
try{istock.sessionStorage=new istock.Storage('session');}catch(e2){}
Object.extend(Prototype.Browser,{Version:(function(){var ua=navigator.userAgent.toLowerCase(),versionSplit=((ua.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1]).split(/[^0-9]/g),version=[];versionSplit.each(function(part){version.push(parseInt(part,10));});return version;})()});Number.prototype.toHex=function(padding){var negative=this<0,hex=Math.abs(this).toString(16);padding=padding||2;while(hex.length<padding){hex='0'+hex;}
if(negative){hex='-'+hex;}
return hex;};namespacing={init:function(namespace){var spaces=[];namespace.split('.').each(function(space){var curSpace=window,i;spaces.push(space);for(i=0;i<spaces.length;i++){if(typeof curSpace[spaces[i]]==='undefined'){curSpace[spaces[i]]={};}
curSpace=curSpace[spaces[i]];}});}};var istock=istock||{};istock.LazyLoad={loadJS:function(url,callback,customEvt){if(!url){return;}
if(navigator.userAgent.match(/MSIE 6.0/)){var llIE=new istock.LazyLoadIE6(url,callback,customEvt);llIE.load();}else{var script=new Element("script",{type:"text/javascript",src:url});if(callback&&customEvt){document.stopObserving(customEvt);document.observe(customEvt,callback);}else if(customEvt){document.stopObserving(customEvt);};Element.insert($$('body').pop(),{bottom:script});};},loadCSS:function(url){if(url.search('istockimg.com')===-1){url=url.replace(/[^a-zA-Z0-9.\-_\/]/g,"");if(!url){return;}}
var head=$$("head")[0];var css=new Element("link",{type:"text/css",rel:"stylesheet",href:url});head.appendChild(css);}};istock.cookie={getCookie:function(key){var searchKey=key+"=";var value=null;document.cookie.split(';').invoke('strip').each(function(element){if(element.startsWith(searchKey)){value=element.substring(searchKey.length,element.length);throw $break;}});return value;}};istock.LazyLoadIE6=Class.create();istock.LazyLoadIE6.prototype={initialize:function(url,callback,customEvt){this.maxTries=3;this.numTries=0;this.callback=callback;this.customEvt=customEvt;this.url=url;},load:function(){var script=new Element("script",{type:"text/javascript",src:this.url});script.onreadystatechange=function(){if(script.readyState==="loaded"||script.readyState==="complete"){try{this.callback(this.customEvt);}catch(e){if(this.maxTries<=this.numTries){return;}
this.numTries++;this.load();};};}.bind(this);Element.insert($$('body').pop(),{bottom:script});}};var ajaxWin={contents:'',json:[],loaded:false,show:function(json){ajaxWin.json=json;ajaxWin.buildContents();if(this.loaded){ajaxWin.activateWindow();}else{Event.observe(window,'load',ajaxWin.activateWindow);};},buildContents:function(){var json=ajaxWin.json;ajaxWin.contents='<a onclick="'+(json.cnclFunc?json.cnclFunc:'')+' ajaxWin.cancelWindow(); return false" class="close_btn" title="'+(json.cnclText?json.cnclText:'Cancel')+'" ></a>';ajaxWin.contents+='<div class="hdr" id="ajaxWinHdr">';if(json.title){ajaxWin.contents+=json.title;};ajaxWin.contents+='</div>';ajaxWin.contents+='<div id="ajaxWinBody">';if(json.hdrTxt||json.hdrIcon){ajaxWin.contents+='<table class="ndnt">';ajaxWin.contents+='<tr>';if(json.hdrIcon){ajaxWin.contents+='<td class="m"><img src="'+json.hdrIcon+'" alt="" style="padding-right:6px" /></td>';};ajaxWin.contents+='<td class="m"><strong class="'+json.hdrTxtClass+'">'+json.hdrTxt+'</strong></td>';ajaxWin.contents+='</tr>';ajaxWin.contents+='</table>';};ajaxWin.contents+=json.cntnt;ajaxWin.contents+='</div>';if(json.footer){ajaxWin.contents+='<div class="clear"></div>';ajaxWin.contents+='<div id="ajaxWinFtr" class="ftr">';ajaxWin.contents+=json.footer;ajaxWin.contents+='</div>';};},activateWindow:function(){var json=ajaxWin.json;var ins;if(!json.contentDiv){var content='cntnt';}else{var content=json.contentDiv;}
if(!$('ajaxWin')){ins=new Insertion.Bottom(content,'<div id="ajaxWinBG" style="display:none;" ></div>');ins=new Insertion.Bottom(content,'<div id="ajaxWin" class="dropshadow" style="display:none;" ><div id = "ajaxWinWrapper">'+ajaxWin.contents+'</div></div>');}else{$('ajaxWin').hide();$('ajaxWinWrapper').update(ajaxWin.contents);};if(typeof(json.wdth)!='undefined'){$('ajaxWin').style.width=json.wdth+10+'px';};var w=$('ajaxWin').getWidth();var h=$('ajaxWin').getHeight();var viewportDims=document.viewport.getDimensions();var scrollOffsets=document.viewport.getScrollOffsets();$('ajaxWinBG').style.width=(viewportDims.width*3)+scrollOffsets.left+'px';$('ajaxWinBG').style.height=(viewportDims.height*3)+scrollOffsets.top+'px';$('ajaxWin').style.top=Math.max(0,parseInt((viewportDims.height/2)-(h/2)+scrollOffsets.top,10))+'px';$('ajaxWin').style.left=Math.max(0,parseInt((viewportDims.width/2)-(w/2)+scrollOffsets.left,10))+'px';$('ajaxWinBG').show();$('ajaxWin').show();var draggable=new Draggable('ajaxWin',{handle:'ajaxWinHdr'});if(draggable){$('ajaxWinHdr').setStyle('cursor:move');}
Event.observe(document,'keypress',function(e){if(e.keyCode==27){ajaxWin.cancelWindow();}});document.fire('ajax_widget_window:open');},cancelWindow:function(){if($('ajaxWin')){$('ajaxWin').remove();}
if($('ajaxWinBG')){$('ajaxWinBG').remove();}
document.fire('ajax_widget_window:closed');Event.stopObserving(document,'keypress');}};Event.observe(window,'load',function(){ajaxWin.loaded=true;});try{document.fire('ajax_widget_window:loaded');}catch(e){}
var efCntrlr={DEFAULT_DELAY:0.7,DEFAULT_EFFECT:'fade',additionalCleanup:null,closeCallback:null,_delay:null,_effect:null,_id:null,_lyr:'bgEfDiv',init:function(id,delay,effect){var self=efCntrlr;if(!id){alert('ID required for efCntrlr class');return;};if(typeof delay!=='undefined'&&delay!==null){self._delay=delay;}else{self._delay=self.DEFAULT_DELAY;};if(typeof effect!='undefined'&&effect!==null){self._effect=effect;}else{self._effect=self.DEFAULT_EFFECT;};self._id=id;self._createBG();self._addObsv();return self;},forceClose:function(){var self=efCntrlr;self._close();},repositionTopOffset:function(){var self=efCntrlr;var body=$$('body')[0].identify();var scroll=$(body).cumulativeScrollOffset();if(self&&$(self._lyr)){$(self._lyr).setStyle({top:scroll[1]+'px'});};},_createBG:function(){var self=efCntrlr,showLyr;$(self._id).setStyle({zIndex:5001});if(!$(self._lyr)){var body=$$('body')[0].identify();var dims=$(body).getDimensions();var scroll=$(body).cumulativeScrollOffset();Element.insert(body,{bottom:'<div id="'+self._lyr+'" style="display:none"></div>'});if(0===dims.height){dims.height=$(body).firstDescendant().getHeight();}
$(self._lyr).setStyle({width:dims.width+'px',height:dims.height+'px',zIndex:5000,position:'absolute',top:scroll[1]+'px',left:0,backgroundColor:'#000',opacity:0});var popupScroll=self.repositionTopOffset.bind(self);Event.observe(window,'scroll',popupScroll);};showLyr=function(){if($(self._lyr)){$(self._lyr).show();}}.bind(this);if(Prototype.Browser.IE){$(self._lyr).show();$(self._id).show();}else if(self._effect=='blind'){$(self._id).blindDown({duration:0.25,scaleFrom:18,scaleTo:90,afterFinish:showLyr});}else{$(self._id).appear({duration:0.2,afterFinish:showLyr});};},_addObsv:function(){var self=efCntrlr;Event.observe(self._lyr,'click',self._close);Event.observe(self._lyr,'mouseover',self._timerStart);Event.observe(self._id,'mouseover',self._timerClear);},_stopObsv:function(){var self=efCntrlr;Event.stopObserving(self._lyr,'click',self._close);Event.stopObserving(self._lyr,'mouseover',self._timerStart);Event.stopObserving(self._id,'mouseover',self._timerClear);self._timerClear();},_close:function(){var self=efCntrlr;self._stopObsv();if($(self._lyr)){$(self._lyr).remove();};if(self.additionalCleanup!==null){self.additionalCleanup();self.additionalCleanup=null;};if($(self._id)){if(Prototype.Browser.IE){$(self._id).hide();}else if(self._effect=='blind'){$(self._id).blindUp({duration:0.5,scaleTo:18,scaleFrom:90});}else{$(self._id).fade({duration:0.15});};};if(self.closeCallback!==null){self.closeCallback();self.closeCallback=null;};},_timer:null,_timerStart:function(){var self=efCntrlr;if(null!==self._timer){return;};self._timer=self._close.delay(self._delay);},_timerClear:function(){var self=efCntrlr;window.clearTimeout(self._timer);self._timer=null;}};var eventCtrl={evt:'',elm:'',id:'',clss:'',debug:0,positioned:[],mX:0,mY:0,obsrv:function(e){var classes=$w(e.element().className),self=eventCtrl;if(classes[0]&&classes[0].startsWith('e_')){self.clss=classes[0];self.setNfo(e);switch(self.clss){case'e_toggle1':if(e.type==='click'){e.stop();self.toggleDisplay('div','span');};break;case'e_toggle2':if(e.type==='click'){e.stop();self.toggleDisplayNested('div','div');};break;case'e_toggle3':if(e.type==='click'){e.stop();if(self.elm.tagName==='IMG'){self.elm=self.elm.up();self.id=$(self.elm).identify();};self.toggleNextDiv();};break;case'e_toggle3':if(e.type==='click'){e.stop();if(self.elm.tagName==='IMG'){self.elm=self.elm.up();self.id=$(self.elm).identify();};self.toggleNextDiv();};break;case'e_dropdown':if(e.type==='mouseover'){self.toggleDisplayDrpdownIframe(1);};if(e.type==='mouseout'){self.toggleDisplayDrpdownIframe(0);};break;case'e_loupe':if(e.type==='mouseover'&&window.showLoupe){showLoupe();}else if(e.type==='mouseout'&&window.hideLoupe){hideLoupe();};break;case'e_lbAdd':case'e_lbDel':case'e_lbAddAll':if(e.type==='click'){e.stop();if(self.clss==='e_lbAdd'&&window.lbox){lbox.init('add');}else if(self.clss==='e_lbDel'&&window.lbox){lbox.init('remove');}else if(self.clss==='e_lbAddAll'&&window.lbox){lbox.init('addAll');};};break;case'e_lbRemoveAdmin':if(e.type=='click'){var nameProperty='lbName'+$(self.elm).id,ownerProperty='lbOwner'+$(self.elm).id,ajw=ajaxWin.show({cntnt:translations.removeAdmin.replace('%s',translations[nameProperty]),wdth:400,footer:'<button class="btn_orange fl" id=noBtn href="#">No</button>'+'<button class="btn_orange" href="#" id=yesBtn>Yes</button>'+'<div class="clear"></div>'});$('yesBtn').observe('click',function(){ajaxWin.cancelWindow();window.location='/my_lightbox.php?action=removeAdminFromLightbox&lightboxID='+$(self.elm).id+'&userID='+translations[ownerProperty]+'&lightboxName='+translations[nameProperty];});$('noBtn').observe('click',ajaxWin.cancelWindow);};break;case'e_custom':if(classes.length<4){return;};classes.shift();var eventType=classes.shift();var className=classes.shift();var methodName=classes.shift();var evalCode;var aCode=[];var code;if(e.type==eventType){e.stop();try{aCode.push("var objHandler = new "+className+"();");aCode.push("objHandler."+methodName+"('"+classes.join("','")+"');");evalCode=new Function(aCode.join("\n"));evalCode();}catch(exception){code=className+"."+methodName+"('"+classes.join("','")+"');";evalCode=new Function(code);evalCode();};};break;case'e_popupTitle':if(e.type=='mouseover'&&window.popupTitle){popupTitle.displayPopUp(self.mX,self.mY,self.elm);};if(e.type=='mouseout'&&window.popupTitle){popupTitle.hidePopUp(self.elm);};break;case'e_keywordsCopySpace':if(e.type=='click'){if(keywordsCopySpace.keywordsCSObj){if((keywordsCopySpace.keywordsCSlist.indexOf(self.id)!=-1)&&(self.id.indexOf('ajax_cs_')!=-1)){keywordsCopySpace.changebox(self.id);};};};break;case'e_QuickSignup_Login':case'e_QuickSignup_Signup':if(e.type=='click'){var controller='login';if(self.clss=='e_QuickSignup_Signup'){controller='signup';};e.stop();if(!window.quickSignupIframeHandler){istock.LazyLoad.loadCSS(istock.cookielessUrl+'/static/'+cachekey+'/css/quicksignup.css');istock.LazyLoad.loadJS(istock.cookielessUrl+"/static/"+cachekey+"/js/quicksignup-bundle.js",function(){quickSignupIframeHandler.loadWindow(controller);},"quickSignUp:loaded");}else{quickSignupIframeHandler.loadWindow(controller);document.fire('quickSignUp:loaded');};};break;case'e_QuickSignup_LoadSignup':if(e.type=='click'){e.stop();quickSignupIframeHandler.redirectParent('signup');};break;case'e_International':var config={},internationalHeader,ajx;if(e.type!=='click'){return;};e.stop();ajx=new Ajax.Request('/json/language/',{onSuccess:function(languages){var text='<ul>',container=$('intl'),header=container.select('.menuSelector-header')[0],languages=languages.responseText.evalJSON(true),ms;self.languages=languages;languages.all.each(function(lang){text+='<li';if(languages.currentLanguage.locale===lang[0]){text+=' class="active">';text+='<span>'+lang[1]+'</span>';}else{text+='>';text+='<a href="#"  class="e_languageOpt">'+lang[1]+'</a>';};text+='</li>'});text+='</ul>';container.select('.menuSelector-content')[0].update(text);header.update(header.innerHTML.gsub('e_International',''));container.addClassName('menuSelector ims-click');ms=new istock.widget.MenuSelector(container);ms.show();document.fire('omniture:language');observeLanguage();}});break;case'e_languageOpt':if(e.type!=='click'){return;};e.stop();self._languageOpt();break;case'e_more_news':if(e.type=='click'){e.stop();self._newsTickerDropdown();};break;case'e_disp_settings':if(e.type!=='click'){return;};e.stop();istock.search.displaySettings.show();break;case'e_accordionMenu':var config={},elm=$(self.elm.identify()),parentLiElm,parentLiMenu,submenu,submenuArrow;if(e.type!=='click'){return;};e.stop();parentLiElm=$(elm).up();parentLiMenu=parentLiElm.siblings();parentLiElm.addClassName('np');parentLiMenu.each(function(item){item.removeClassName('np');accordionMenu=item.select('[class="e_accordionMenu btnCta4Down"]');if(accordionMenu.length>0){accordionMenu[0].addClassName('btnCta4');accordionMenu[0].removeClassName('btnCta4Down');divElm=accordionMenu[0].siblings().first();divElm.addClassName('dn');arrow=accordionMenu[0].childElements()[0];if(arrow){arrow.removeClassName('ctaGreyArrowDown');arrow.addClassName('ctaGreyArrowRight');};};});$(elm).toggleClassName('btnCta4Down');$(elm).toggleClassName('btnCta4');submenu=elm.siblings().first();submenu.toggleClassName('dn');if(submenu.tagName.toUpperCase()=='SPAN'){submenu.toggleClassName('btnCta4');};break;case'e_navSubMenu':var parentLi=self.elm.up('li.localNavMenuHeader');if(e.type!=='click'){return;};e.stop();if(parentLi.className.indexOf('active')>=0){parentLi.toggleClassName('active');parentLi.toggleClassName('activeHidden');}else{parentLi.select('ul')[0].toggleClassName('localNavSubMenu');};parentLi.select('img')[0].toggleClassName('ctaGreyArrowDown');parentLi.select('img')[0].toggleClassName('ctaGreyArrowUp');break;case'e_back':if(e.type!=='click'){return;};e.stop();window.history.go(-1);break;case'e_removeUser':var userId=classes[1];if(e.type!=='click'){return;};e.stop();if(typeof userId==='undefined'||isNaN(parseInt(userId,10))){return;};window.open('/user_creativenetwork_remove.php?ID='+userId,'popup','height=400,width=400,scrollbars=yes');break;case'e_viewRequest':var userId=classes[1];if(e.type!=='click'){return;};e.stop();if(typeof userId==='undefined'||isNaN(parseInt(userId,10))){return;};window.open('/user_creativenetwork_response.php?FromID='+userId,'popup','height=400,width=400,scrollbars=yes');break;case'e_priceBar':if(e.type!=='click'){return;};elm=$(self.elm.identify());if(elm.hasClassName('tabActive')){return;};$$('#'+elm.up().identify()+' .tabActive').each(function(elm){elm.removeClassName('tabActive');});elm.addClassName('tabActive');self._generatePriceBarContent(elm);break;case'e_tab':if(e.type!=='click'){return;};e.stop();elm=$(self.elm.identify());if(elm.hasClassName('tabActive')){return;};tabsAjax.showTab(elm);break;case'e_userPref':if(e.type!=='click'){return;};if(userSettings.updateInProgress){e.stop();return;};elm=$(self.elm.identify());if(elm.type.toUpperCase()=='HIDDEN'){elm=$$('input[id="'+elm.name+'"]')[0];self.elm=elm;};if((elm.tagName.toUpperCase()==='SELECT')){return;};elmValue=elm.value;if((elm.type.toUpperCase()==='CHECKBOX')&&!elm.checked){elmValue=$$('input[name="'+elm.identify()+'"]&input[type="hidden"]')[0].value;};if((elm.type.toUpperCase())==='SUBMIT'||(elm.type.toUpperCase())==='BUTTON'){userSettings.setOptions('file');self._checkUserPrefButton(elm,classes);return;};if((elm.identify()==="siteSettings_FilterContent-0")||(elm.identify()==="siteSettings_FilterContent-1")){settingId="FilterContent";}else{settingId=self.elm.identify().replace(/sitesettings_([0-9]+).*/i,"$1");}
if(settingId=='filterContent'){userSettings.setOptions('search');}else{userSettings.setOptions('site');}
userSettings.update(elm,settingId,elmValue);break;case'e_toggle_fma':if(e.type!=='click'){return;};e.stop();var fma=self.elm.up(2);if(typeof self.fma!=='undefined'&&self.fma!==null&&self.fma!==fma){self._toggleFma(self.fma);if(self.pe!==null){self.pe.stop();self.pe=null;};}else if(self.fma===fma){self.fma=null;if(self.pe!==null){self.pe.stop();self.pe=null;};self._toggleFma(fma);return;};self.fma=fma;self._fmaTimeout(fma,self);self.fma.observe('mouseout',function(e){self._fmaTimeout(fma,self);});self.fma.observe('mouseover',function(e){if(typeof self.pe!=='undefined'&&self.pe!==null){self.pe.stop();self.pe=null;};});self._toggleFma(fma);break;case'e_uploadTip':if(e.type==='mouseover'){namespacing.init('istock.editorials');if(!istock.editorials.tipinfo){var editorialInfo=$('editorialInfo').remove();editorialInfo.removeClassName('dn');istock.editorials.tipinfo=new istock.Infotip({anchor:$(self.elm.identify()),contents:editorialInfo,attachOptions:{anchor:{horizontal:'right',vertical:'middle',ignore:'margin'},attachee:{horizontal:'left',vertical:'middle'}}});}
istock.editorials.tipinfo.show();var container=istock.editorials.tipinfo._infoTip;container.observe('mouseover',function(){istock.editorials.tipinfo._clearTimeout();});container.observe('mouseout',function(){istock.editorials.tipinfo._setTimeout(500);});}
break;case'e_newsTickerLink':if(e.type==='click'){document.fire("omniture:newsTickerEvent",e.element().innerHTML);}
break;case'e_datePicker':if(e.type==='mouseover'){namespacing.init('istock.editorials');if(!istock.editorials.datePicker){if($('countryString')==null){return;}
var countryString=$('countryString').getValue();if(!countryString){countryString='EN';}
istock.editorials.datePicker=new istock.widgets.datepicker.Picker({dateFormat:new istock.widgets.datepicker.Formatter(['yyyy','mm','dd'],'-'),relative:self.elm.identify(),language:countryString,disableFutureDate:true});}}
break;}}},_initLocalNavListener:function(){$('lclnv').descendants().each(function(el){el.observe('mouseover',function(e){var elm=e.element(),child;if(elm.tagName!=='LI'){elm=elm.up('li');};if(typeof elm!=='undefined'){if(elm.select('div.h2withline').length>0||elm.select('div.h3withline').length>0){return;};elm.addClassName('hl');child=elm.select('ul');if(child.length>0){child[0].style.backgroundColor='white';};};});el.observe('mouseout',function(e){var elm=e.element();if(elm.tagName!=='LI'){elm=elm.up('li');};if(typeof elm!=='undefined'){if(elm.select('div.h2withline').length>0||elm.select('div.h3withline').length>0){return;};elm.removeClassName('hl');};});});},_generatePriceBarContent:function(elm){var elmId=elm.identify(),divContainerId=$(elmId).up(1).identify(),typeId=elmId.gsub('tab_priceBar_','').split('_'),priceBarValues=window['priceBarValues_'+divContainerId.gsub('priceBar_','')][typeId[0]][typeId[1]],borderStyle=' nb',html='<div id="content_priceBar_'+typeId[0]+'_'+typeId[1]+'">',pbItems=$$('#'+elm.up(1).identify()+' .priceBarItem'),itemsTotalWidth=0,itemWidth=0,newItemCount=Object.values(priceBarValues).length,item,pF,pI;if(newItemCount===pbItems.length){itemWidth=parseInt(pbItems[0].getStyle('width'),10);}else{itemsTotalWidth+=parseInt(pbItems[0].getStyle('width'),10)*pbItems.length;itemWidth=Math.floor((itemsTotalWidth/newItemCount));};for(pI in priceBarValues){for(pF in priceBarValues[pI]){item=priceBarValues[pI][pF];html+='<div class="priceBarItem" style="width:'+itemWidth+'px">'+'<a href="/buy-stock-credits-pay-as-you-go.php"><span class="priceBarType">';html+=item.name;html+='</span><div class="priceBarItemPrice">'+item.price+'</div> ';html+='<span class="priceBarName">'+translations.priceBarCredits+'</span>';html+='</a></div>';};};html+='</div></div>';if($$('.priceBarBubbleContainer').length){var priceDisplay=$$('.priceBarBubbleContainer')[0].clone();var priceContent=$$('.priceBarBubbleContainer')[0].innerHTML;($$('#'+divContainerId+' div.priceBar')[0]).update(html);Element.insert(divContainerId,priceDisplay);$$('.priceBarBubbleContainer')[0].update(priceContent);}else{$$('#'+divContainerId+' div.priceBar')[0].update(html);};},_toggleFma:function(fma){if(fma===null){return;};var moreBox=fma.select('.moreBox')[0],visFlagClass='moreVisible',animationType='appear',toggleElements=$$('#'+fma.identify()+' .toggle'),border={on:'#e3e3e3',off:'#ffffff'},speed=0.2;if(moreBox.hasClassName(visFlagClass)){moreBox.morph('border-color:'+border.off,{duration:speed});}else{moreBox.setStyle({borderColor:border.off});moreBox.morph('border-color:'+border.on,{duration:speed});};moreBox.toggleClassName(visFlagClass);toggleElements.each(function(ele){var elId=ele.identify();if(ele.tagName==='DIV'){new Effect.toggle(elId,animationType,{duration:speed});}else{ele.toggle('');};});},_fmaTimeout:function(fma,self){if(typeof self.pe==='undefined'||self.pe===null){self.pe=new PeriodicalExecuter(function(pe){self._toggleFma(self.fma);pe.stop();self.pe=null;self.fma=null;},3);};},_checkUserPrefButton:function(elm,classes){var self=eventCtrl,title='',text='',value=null;switch(classes[1]){case'EXTENDED_LICENSE_ALL_TRUE':title=translations.settingsExtLicTitleAllOn;text=translations.settingsExtLicBody;value=1;break;case'EXTENDED_LICENSE_ALL_FALSE':title=translations.settingsExtLicTitleAllOff;text=translations.settingsExtLicBody;value=0;break;default:return;};userSettings.confirmPopup(elm.identify(),value,text,title,userSettings.update,null);},_newsTickerDropdown:function(){if(!$('viewMoreNews')){Element.insert($($$('body')[0].identify()),'<div id="viewMoreNews" class="bggrey" style="display:none;"></div>');var linksContent='<div class="fr mt5"><a href="#" class="e_more_news moreNewsLink">'+
translations.newsLessText+'</a>&nbsp;<img class="e_more_news ctaGreyArrowUp m cp" src="'+istock.cookielessUrl+'/static/images/blank.gif"/> <img src="'+istock.cookielessUrl+'/static/images/blank.gif" class="sptWhiteSeparatorVertical m ml10 mr10"> '+'<a href="/webservices/feeds/?feedFormat=IStockATOM_0_3&feedName=istockfeed.news.communityNews&xml=1"><img src="'+istock.cookielessUrl+'/static/images/blank.gif" class="icoWhiteRss m"></a></div>';Element.insert($('viewMoreNews'),linksContent);newsTickerNewsList.each(function(newsItem){var content='<p id="newsItem_'+newsItem.itemId+'">'+' <a href="/forum_messages.php?threadid='+newsItem.talkAboutId+'"><time>'+newsItem.postDate+'</time></a> &mdash;'+' <a href="user_view.php?id='+newsItem.userId+'">('+newsItem.userName+')</a> '+'<a class="e_newsTickerLink" href="/forum_messages.php?threadid='+newsItem.talkAboutId+'">'+newsItem.title+'</a></p>';Element.insert($('viewMoreNews'),content);});var elmPos=$('newsTicker').cumulativeOffset();var elmWidth=$('newsTicker').getWidth();$('viewMoreNews').setStyle({width:elmWidth+'px',top:elmPos.top+'px',left:elmPos.left+'px'});};if($('viewMoreNews').visible()){efCntrlr.forceClose();}else{if(window.efCntrlr){efCntrlr.init('viewMoreNews',null,'blind');};};},_languageOpt:function(elm){var self=eventCtrl,languages=self.languages,reqLanguage='',i=0;var url=window.location.href.replace(window.location.protocol+'//','').replace(window.location.hostname+'/','');reqLanguage=$(self.id).innerHTML;for(i=0;i<languages.all.length;i++){if(reqLanguage===languages.all[i][1]){document.fire('menuSelector:close',{elm:$(self.id)});window.location.href=languages.all[i][2]+url;return;};};},setNfo:function(e){var self=eventCtrl;self.mX=Event.pointerX(e);self.mY=Event.pointerY(e);self.elm=e.element();self.evt=e.type;self.id=$(self.elm).identify();if(self.debug&&window.console){console.log('EVT:'+self.evt+' - ID:'+self.id+' - CLASS: '+self.clss+' - ELM:'+self.elm);};},toggleDisplay:function(parnt,chldn){var self=eventCtrl,prntElm=$(self.elm).up(parnt);prntElm.down(chldn).toggle();prntElm.down(chldn).next(chldn).toggle();},toggleDisplayNested:function(parnt,chldn){var self=eventCtrl,childElm=$(self.elm).up(chldn),prntElm=childElm.up(parnt);prntElm.down(chldn).toggle();prntElm.down(chldn).next(chldn).toggle();},toggleNextDiv:function(){var self=eventCtrl,trgtDiv=$(self.elm).next('div');$(self.elm).toggleClassName('moreArrowDown').toggleClassName('lessArrowUp');Effect.toggle(trgtDiv,'blind',{duration:.3});},toggleDisplayDrpdownIframe:function(toggle){var self=eventCtrl,dropdownID=self.id+"Dropdown";iFrameID=self.id+"Iframe";if(!$(dropdownID)){return;};if(toggle&&!self.positioned[self.id]){if(!$(iFrameID)){$('wrapper').insert({bottom:'<iframe id="'+iFrameID+'" style="display:none; z-index:5000; position:absolute; border:0; background:#fff"></iframe>'});};if(Prototype.Browser.IE){Element.clonePosition(dropdownID,self.id,{setWidth:false,setHeight:false,offsetLeft:-3,offsetTop:20});}else{Element.clonePosition(dropdownID,self.id,{setWidth:false,setHeight:false,offsetLeft:0,offsetTop:20});};var dw=$(dropdownID).getWidth()+'px';var ddDims=$(dropdownID).getDimensions();$(dropdownID).setStyle({width:ddDims['width']+'px',height:ddDims['height']+'px'});Element.clonePosition(iFrameID,self.id,{setWidth:false,setHeight:false,offsetLeft:0,offsetTop:20});var ieWidthFix=(Prototype.Browser.IE)?4:5;$(iFrameID).setStyle({width:ddDims['width']+ieWidthFix+'px',height:ddDims['height']+'px'});var ieFixW=(Prototype.Browser.IE)?0:6;var barWidth=$(dropdownID).getWidth()-$(self.id).getWidth()+ieFixW;$(dropdownID).insert({top:'<div style="float:right; height:0; line-height:0; width:'+barWidth+'px; border-top:solid 3px #f2f2f2; margin-right:-10px; z-index:5000"></div>'});self.positioned[self.id]=true;};if(toggle&&!$(dropdownID).visible()){$(dropdownID).show();$(iFrameID).show();Event.observe($(dropdownID),'mouseover',function(){$(self.id).addClassName('headerTabActive');$(dropdownID).show();$(iFrameID).show();});Event.observe($(dropdownID),'mouseout',function(ev){if((Prototype.Browser.IE)&&(ev.element().tagName.toLowerCase()!='span')){return;};$(self.id).removeClassName('headerTabActive');$(dropdownID).hide();$(iFrameID).hide();});}else if($(dropdownID).visible()){$(dropdownID).hide();$(iFrameID).hide();};}};trnltn={getTranslatedMsg:function(messageKey){message=translations[messageKey];if(message==undefined){message=translations.isEmpty;};return message;}};document.observe("dom:loaded",function(){if(window.ajaxWin){ajaxWin.loaded=true;};Event.observe(document,'click',eventCtrl.obsrv);Event.observe(document,'mouseover',eventCtrl.obsrv);Event.observe(document,'mouseout',eventCtrl.obsrv);if($('lclnv')!==null){eventCtrl._initLocalNavListener();};});if(typeof istock==='undefined'){istock={};}
Element.addMethods({getHook:function(element,options){var defOptions={vertical:'top',horizontal:'left',ignore:false,absolutePosition:true,scroll:false},height='',width='',layout={},pos={top:0,left:0},absPos={},scrollPos={},wasHidden=false,h={};if(!(element=$(element))){return;}
options=Object.deepExtend(defOptions,options);switch(options.ignore){case'margin':height='border-box-height';width='border-box-width';break;case'border':height='padding-box-height';width='padding-box-width';break;case'padding':height='height';width='width';break;default:height='margin-box-height';width='margin-box-width';break;}
if(!element.visible()){element.show();wasHidden=true;}
if(options.absolutePosition){absPos=element.cumulativeOffset();pos.top+=absPos.top;pos.left+=absPos.left;}
if(options.scroll){scrollPos=element.cumulativeScrollOffset();pos.top+=scrollPos.top;pos.left+=scrollPos.left;}
layout=new Element.Layout(element);switch(options.vertical){case'middle':pos.top+=(layout.get(height)/2).round();break;case'bottom':pos.top+=layout.get(height);break;default:break;}
switch(options.horizontal){case'middle':pos.left+=(layout.get(width)/2).round();break;case'right':pos.left+=layout.get(width);break;default:break;}
if(wasHidden){element.hide();}
return pos;},attach:function(element,attachee,options){var match,a1Hk,a2Hk,h,top,left,vp;var quickExpr=/^([a-zA-Z][\w\-]+)$/,body=$$('body')[0],defOptions={anchor:{vertical:'bottom',horizontal:'left'},attachee:{vertical:'top',horizontal:'left',absolutePosition:false,scroll:false},offset:{top:0,left:0},style:{display:'none',position:'absolute',zIndex:6000},viewport:{stayInside:false}},fn;if(!(element=$(element))){return;}
if(Object.isString(attachee)){match=quickExpr.exec(attachee);if(match&&match[1]){if(!(attachee=$(match[2]))){return;}
attachee.remove();}}else{if(!(attachee=$(attachee))){return;}
if($(attachee.identify())){attachee.remove();}}
body.insert({bottom:attachee});attachee=$(body.lastChild);options=Object.deepExtend(defOptions,options);attachee.setStyle(options.style);attachee.anchorOptions=options;a1Hk=element.getHook(options.anchor);a2Hk=attachee.getHook(options.attachee);element.previousPos=a1Hk;a2Hk.top=a2Hk.top*-1;if(options.anchor.horizontal==='right'||options.attachee.horizontal!=='left')
{a2Hk.left=a2Hk.left*-1;}
top=(a1Hk.top+a2Hk.top+options.offset.top);left=(a1Hk.left+a2Hk.left+options.offset.left);if(options.viewport.stayInside){attachee.stayInViewport(options.viewport);}
options.style.left=left+'px';options.style.top=top+'px';attachee.setStyle(options.style);if(!element.attachedChildren){element.attachedChildren=[];}
element.attachedChildren.push(attachee);attachee.attachedTo=element;document.fire('element:attached',{anchor:element,attachee:attachee});return attachee;},hasAttachedChildren:function(element){if(!(element=$(element))){return;}
if(!element.attachedChildren||element.attachedChildren.length<=0){return false;}
return true;},hasAttachedChild:function(element,child){if(!(element=$(element))){return;}
if(!(child=$(child))){return;}
if(!element.hasAttachedChildren()){return false;}
for(var i=0;i<element.attachedChildren.length;i++){if(element.attachedChildren[i]===child){return child;}}
return false;},detach:function(element,attachees,removeFromDom){if(!(element=$(element))){return;}
if(!(element.attachedChildren)){return;}
if(typeof attachees==='undefined'||attachees===null){attachees=element.attachedChildren;}else if(!Object.isArray(attachees)){attachees=[attachees];}
for(var i=0;i<attachees.length;i++){if(removeFromDom){attachees[i].detach(attachees[i].attachedChildren,true);attachees[i].remove();}
element.attachedChildren=element.attachedChildren.without(attachees[i]);attachees[i].attachedTo=null;}
document.fire('element:detached',{anchor:element});},_changeAttachedState:function(element,options){var i,aChild,defOptions={display:'show',effect:'',effectOptions:{}};if(!(element=$(element))){return;}
options=Object.extend(defOptions,options);if(options.effect==='blind'||options.effect==='slide'){options.effect+=(options.display==='show'?'Down':'Up');}else if(options.effect===''){options.effect=options.display;}
for(i=0;i<element.attachedChildren.length;i++){aChild=element.attachedChildren[i];aChild[options.effect](options.effectOptions);if(aChild.anchorOptions.viewport.stayInside){aChild.stayInViewport(aChild.anchorOptions.viewport);}
aChild.fire('element:'+options.display+'Attached',{anchor:element});}},showAttached:function(element,options){if(!(element=$(element))){return;}
if(!options){options={};}
options.display='show';element._changeAttachedState(options);},hideAttached:function(element,options){if(!(element=$(element))){return;}
if(!options){options={};}
options.display='hide';element._changeAttachedState(options);},flipAttachment:function(element,flipType){var aOptns,anchor;if(!(element=$(element))){return;}
if(!(anchor=element.attachedTo)){return;}
if(!flipType){flipType='both';}
aOptns=element.anchorOptions;if(flipType!=='horizontal'){if(aOptns.anchor.horizontal==='bottom'){aOptns.anchor.horizontal='top';}
else if(aOptns.anchor.horizontal==='top'){aOptns.anchor.horizontal='bottom';}
if(aOptns.attachee.horizontal==='top'){aOptns.attachee.horizontal='bottom';}
else if(aOptns.attachee.horizontal==='bottom'){aOptns.attachee.horizontal='top';}
if(aOptns.offset&&!isNaN(aOptns.offset.top)){aOptns.offset.top*=-1;}}
if(flipType!=='vertical'){if(aOptns.anchor.horizontal==='right'){aOptns.anchor.horizontal='left';}
else if(aOptns.anchor.horizontal==='left'){aOptns.anchor.horizontal='right';}
if(aOptns.attachee.horizontal==='left'){aOptns.attachee.horizontal='right';}
else if(aOptns.attachee.horizontal==='right'){aOptns.attachee.horizontal='left';}
if(aOptns.offset&&!isNaN(aOptns.offset.left)){aOptns.offset.left*=-1;}}
anchor.detach(element);anchor.attach(element,aOptns).show();},stayInViewport:function(element,options){var vp,vpo,width,height,top,left,layout,oTop,oLeft,hPos,vPos,anchor,attachee,aOptns,fn,defOptions={stickToAnchor:{vertical:false,horizontal:false}},style={},BEYOND_VIEWPORT=1,BEFORE_VIEWPORT=-1,WITHIN_VIEWPORT=0,isOutsideViewport=function(pos,dim,scroll,maxDim){if(pos+dim-scroll>maxDim){return BEYOND_VIEWPORT;}else if(pos<scroll){return BEFORE_VIEWPORT;}else{return WITHIN_VIEWPORT;}};if(!(element=$(element))){return;}
options=Object.deepExtend(defOptions,options);if(options.stickToAnchor&&!(anchor=element.attachedTo)){return;}
else{aOptns=element.anchorOptions;}
if(anchor&&element._viewport&&(anchor.previousPos.left!==element._viewport.originalLocation.left||anchor.previousPos.top!==element._viewport.originalLocation.top)){anchor.detach(element);element=anchor.attach(element,aOptns).show();element._viewport.originalLocation={top:parseInt(element.getStyle('top'),10),left:parseInt(element.getStyle('left'),10)};}
top=parseInt(element.getStyle('top'),10);left=parseInt(element.getStyle('left'),10);if(!element._viewport||!element._viewport.setup){if(!element._viewport){element._viewport={};}
element._viewport.setup=true;element._viewport.originalLocation={top:top,left:left};}
if(!element.visible()){return;}
vp=document.viewport.getDimensions();vpo=document.viewport.getScrollOffsets();oTop=element._viewport.originalLocation.top;oLeft=element._viewport.originalLocation.left;layout=element.getLayout();height=layout.get('margin-box-height');width=layout.get('margin-box-width');hPos=isOutsideViewport(oLeft,width,vpo.left,vp.width);if(hPos===BEYOND_VIEWPORT){if(!options.stickToAnchor.horizontal){style.left=(left-(left+width-(vp.width-vpo.left)))+'px';}else if(aOptns.anchor.horizontal==='right'||aOptns.attachee.horizontal==='left'){element.flipAttachment('horizontal');}}else if(hPos===BEFORE_VIEWPORT){if(!options.stickToAnchor.horizontal){style.left=vpo.left+'px';}else if(aOptns.anchor.horizontal==='left'||aOptns.attachee.horizontal==='right'){element.flipAttachment('horizontal');}}else{style.left=oLeft+'px';}
vPos=isOutsideViewport(oTop,height,vpo.top,vp.height);if(vPos===BEYOND_VIEWPORT){if(!options.stickToAnchor.vertical){style.top=(top-(top+height-vp.height)+vpo.top)+'px';}else if(aOptns.anchor.vertical==='bottom'||aOptns.attachee.vertical==='top'){element.flipAttachment('vertical');}}else if(vPos===BEFORE_VIEWPORT){if(!options.stickToAnchor.vertical){style.top=vpo.top+'px';}else if(aOptns.anchor.vertical==='top'||aOptns.attachee.vertical==='bottom'){element.flipAttachment('vertical');}}else{style.top=oTop+'px';}
if(style.top||style.left){element.setStyle(style);}},truncate:function(element,width,lines){var span,start,middle,end,str,len,result,div;if(!(element=$(element))){return;}
if(!lines){lines=1;}
str=element.innerHTML;div=new Element('div',{style:'visibility:hidden; padding:0; position:absolute; width: 10000px;'});element.up().insert(div);span=new Element('span',{style:'visibility: hidden; padding:0;'}).update(str);div.insert(span);if(span.measure('margin-box-width')>(width*lines)){start=0;end=str.length;while(len=Math.floor((end-start)/2)){middle=start+len;span.update(str.substring(0,middle)+'&hellip;');if(span.measure('margin-box-width')>(width*lines)){end=middle;}else{start=middle;}}
result='<span class="truncatedText" title="'+str+'">'+str.substring(0,(start-lines)-3)+'&hellip;'+"</span>";element.update(result);}
div.remove();},isInViewport:function(element,offset){var elOff,vpOff=document.viewport.getScrollOffsets(),elDim,vpDim=document.viewport.getDimensions(),defaultOffset={top:0,left:0};if(!(element=$(element))){return false;}
elOff=element.cumulativeOffset();elDim=element.getDimensions();Object.extend(defaultOffset,offset);offset=defaultOffset;if((elOff.top+elDim.height<vpOff.top-offset.top||elOff.top>vpOff.top+vpDim.height+offset.top)||(elOff.left+elDim.width<vpOff.left-offset.left||elOff.left>vpOff.left+vpDim.width+offset.left)){return false;}
return true;},getOuterHTML:function(element){if(!(element=$(element))){return;}
if(typeof document.documentElement.outerHTML==='string'){return element.outerHTML;}else{return Element.wrap(element.clone(true)).innerHTML;}},addInputBlocker:function(element,fadeSelectorList){var section=$(element),dim={height:section.getLayout().get('border-box-height')+'px',width:section.getLayout().get('border-box-width')+'px'},overlay=new Element('div',{id:'disable_'+element.identify(),style:'filter:alpha(opacity = 0);opacity:0;position:absolute;width:'+dim.width+';height:'+dim.height+';background-color:gray;'}),fadeSelectors='input, select, canvas, a, img';if(Object.isArray(fadeSelectorList)&&fadeSelectorList.length>0){fadeSelectors+=', '+fadeSelectorList.join(', ');}
section.select('div').invoke('addClassName','disabled');section.select(fadeSelectors).each(function(ele){ele.setStyle({'opacity':0.5,'filter':'alpha(opacity = 50)'});});section.attach(overlay,{anchor:{vertical:'top',horizontal:'left'},attachee:{vertical:'top',horizontal:'left'}});section.showAttached();},removeInputBlocker:function(element,fadeSelectorList){var section=$(element),overlay=$('disable_'+element.identify()),fadeSelectors='input, select, canvas, a, img';if(Object.isArray(fadeSelectorList)&&fadeSelectorList.length>0){fadeSelectors+=', '+fadeSelectorList.join(', ');}
if(section.hasAttachedChildren()){section.detach(overlay,true);}
section.select('div').invoke('removeClassName','disabled');section.select(fadeSelectors).each(function(ele){ele.setStyle({'opacity':1,'filter':'alpha(opacity = 100)'});});}});Object.deepExtend=function(destination,source){for(var property in source){if(source[property]&&source[property].constructor&&source[property].constructor===Object)
{destination[property]=destination[property]||{};arguments.callee(destination[property],source[property]);}else{destination[property]=source[property];}}
return destination;};Autocomplete=function(el,options){this.el=$(el);this.id=this.el.identify();this.el.setAttribute('autocomplete','off');this.suggestions=[];this.data=[];this.membernames=[];this.membernamedata=[];this.badQueries=[];this.selectedIndex=-1;this.currentValue=this.el.value;this.intervalId=0;this.cachedResponse={};this.instanceId=null;this.onChangeInterval=null;this.ignoreValueChange=false;this.serviceUrl=options.serviceUrl;this.suggestionsDisplayed=0;this.membernamesDisplayed=0;this.ignoreRespone=false;this.options={autoSubmit:false,maxSuggestions:0,maxMembernames:0,minChars:3,maxHeight:300,deferRequestBy:0,width:0,wrapperClass:null,container:null};if(options){Object.extend(this.options,options);}
this.initialize();};Autocomplete.instances=[];Autocomplete.isDomLoaded=false;Autocomplete.getInstance=function(id){var instances=Autocomplete.instances,i=instances.length;while(i--){if(instances[i].id===id){return instances[i];}}};Autocomplete.highlight=function(value,re){var hi=value.replace(re,function(match){return'<strong>'+match+'<\/strong>';});return hi;};Autocomplete.prototype={killerFn:null,initialize:function(){var me=this,div=null;this.killerFn=function(e){if(!$(Event.element(e)).up('.autocomplete')){me.killSuggestions();me.disableKillerFn();}}.bindAsEventListener(this);if(!this.options.width){this.options.width=this.el.getWidth();}
div=new Element('div',{style:'position:absolute;z-index:1;'});div.update('<div class="autocomplete '+this.options.wrapperClass+'" id="Autocomplete_'+this.id+'"></div>');this.options.container=$(this.options.container);if(this.options.container){this.options.container.appendChild(div);this.fixPosition=function(){};}else{document.body.appendChild(div);}
this.mainContainerId=div.identify();this.container=$('Autocomplete_'+this.id);this.fixPosition();Event.observe(this.el,window.opera?'keypress':'keydown',this.onKeyPress.bind(this));Event.observe(this.el,'keyup',this.onKeyUp.bind(this));Event.observe(this.el,'blur',this.enableKillerFn.bind(this));Event.observe(this.el,'focus',this.fixPosition.bind(this));Event.observe(this.el,'click',function(){if(!$('Autocomplete_'+this.id).visible()){this.onValueChange();}}.bind(this));this.adjustWidth();this.container.hide();this.container.setStyle({maxHeight:this.options.maxHeight+'px'});this.instanceId=Autocomplete.instances.push(this)-1;},adjustWidth:function(){var width,offset,layout=this.container.getLayout();width=this.el.getLayout().get('border-box-width');offset=layout.get('margin-box-width')-layout.get('padding-box-width');width=width-offset;if(isNaN(width)){width='auto';}
else{width=width+'px';}
this.container.setStyle({width:width});},fixPosition:function(){var hook=this.el.getHook({vertical:'bottom',ignore:'border'});$(this.mainContainerId).setStyle({top:hook.top+'px',left:hook.left+'px'});},enableKillerFn:function(){Event.observe(document.body,'click',this.killerFn);Event.observe(document,'menuSelector:opening',this.killerFn);},disableKillerFn:function(){Event.stopObserving(document.body,'click',this.killerFn);},killSuggestions:function(){this.stopKillSuggestions();this.intervalId=window.setInterval(function(){this.hide();this.stopKillSuggestions();}.bind(this),300);},stopKillSuggestions:function(){window.clearInterval(this.intervalId);},onKeyPress:function(e){if(!this.enabled){return;}
switch(e.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:if(this.selectedIndex===-1){this.hide();return;}
this.select(this.selectedIndex);if(e.keyCode===Event.KEY_TAB){return;}
break;case Event.KEY_UP:this.moveUp();break;case Event.KEY_DOWN:this.moveDown();break;default:this.hide();return;}
Event.stop(e);},onKeyUp:function(e){if(e.keyCode===Event.KEY_UP||e.keyCode===Event.KEY_DOWN){return;}
clearInterval(this.onChangeInterval);if(this.currentValue!==this.el.value){if(this.options.deferRequestBy>0){this.onChangeInterval=setInterval((function(){this.onValueChange();}).bind(this),this.options.deferRequestBy);}else{this.onValueChange();}}},onValueChange:function(){clearInterval(this.onChangeInterval);this.currentValue=this.el.value;this.selectedIndex=-1;if(this.ignoreValueChange){this.ignoreValueChange=false;return;}
if(this.currentValue===''||this.currentValue.length<this.options.minChars){this.hide();}else{this.getSuggestions();}},getCachedResults:function(){var self=this,key='',suggestions,membernames,filteredResults={},i=0;if(this.currentValue===''||this.currentValue.length<this.options.minChars){return filteredResults;}
for(key in this.cachedResponse){if(this.cachedResponse.hasOwnProperty(key)){if(this.currentValue.toLowerCase().indexOf(key.toLowerCase())>=0){filteredResults.language=self.cachedResponse[key].language;filteredResults.query=self.cachedResponse[key].query;filteredResults.suggestions=[];filteredResults.data=[];filteredResults.membernames=[];filteredResults.membernamedata=[];suggestions=this.cachedResponse[key].suggestions;for(i=0;i<suggestions.length;i++){if(suggestions[i].toLowerCase().indexOf(self.currentValue.toLowerCase())>=0){filteredResults.suggestions.push(suggestions[i]);filteredResults.data.push(self.cachedResponse[key].data[i]);}}
membernames=this.cachedResponse[key].membernames;if(typeof membernames!=='undefined'){for(i=0;i<membernames.length;i++){if(membernames[i].toLowerCase().indexOf(self.currentValue.toLowerCase())>=0){filteredResults.membernames.push(membernames[i]);filteredResults.membernamedata.push(self.cachedResponse[key].membernamedata[i]);}}}
return filteredResults;}}}
return filteredResults;},getSuggestions:function(){var cr=this.getCachedResults(),obj=null;if(cr.suggestions!==undefined&&Object.isArray(cr.suggestions)){this.suggestions=cr.suggestions;this.data=cr.data;this.membernames=cr.membernames;this.membernamedata=cr.membernamedata;this.suggest();}else if(!this.isBadQuery(this.currentValue)){obj=new Ajax.Request(this.serviceUrl,{parameters:{query:this.currentValue},onComplete:this.processResponse.bind(this),method:'get'});}},isBadQuery:function(q){var i=this.badQueries.length;while(i--){if(q.indexOf(this.badQueries[i])===0){return true;}}
return false;},hide:function(){this.enabled=false;this.selectedIndex=-1;this.container.hide();},suggest:function(){var content=[],re=new RegExp('\\b'+this.currentValue.match(/\w+/g).join('|\\b'),'gi'),div='<div',index=0;if(this.suggestions.length===0&&(this.membernames.length===0||this.options.maxMembernames===0)){this.hide();return;}
this.suggestions.each(function(value,i){if((this.options.maxSuggestions>0)&&(i>=this.options.maxSuggestions)){throw $break;}
if(this.selectedIndex===i){div+=' class="selected"';}
content.push(div,' class="trnct" title="',value,'" onclick="Autocomplete.instances[',this.instanceId,'].select(',i,');" onmouseover="Autocomplete.instances[',this.instanceId,'].activate(',i,');">',Autocomplete.highlight(value,re),'</div>');index++;}.bind(this));this.suggestionsDisplayed=index;this.membernames.each(function(value,i){if(this.options.maxMembernames>0&&i>=this.options.maxMembernames){throw $break;}else if(this.options.maxMembernames===0){return;}
if(this.selectedIndex===index){div+=' class="selected"';}
content.push(div,' title="',value,'" onclick="Autocomplete.instances[',this.instanceId,'].select(',index,');" onmouseover="Autocomplete.instances[',this.instanceId,'].activate(',index,');">',Autocomplete.highlight(value,re),'</div>');index++;}.bind(this));this.membernamesDisplayed=index-this.suggestionsDisplayed;this.enabled=true;this.container.update(content.join('')).show();this.adjustWidth();},processResponse:function(xhr){var response;try{response=xhr.responseText.evalJSON();if(!Object.isArray(response.data)){response.data=[];}
if(!Object.isArray(response.membernamedata)){response.membernamedata=[];}}catch(err){return;}
this.cachedResponse[response.query]=response;if(response.suggestions.length===0){this.badQueries.push(response.query);}
if(response.query===this.currentValue){this.suggestions=response.suggestions;this.data=response.data;this.membernames=response.membernames;this.membernamedata=response.membernamedata;if(this.ignoreResponse){this.ignoreResponse=false;return;}
this.suggest();}},activate:function(index){var divs=this.container.childNodes,activeItem;if(this.selectedIndex!==-1&&divs.length>this.selectedIndex){divs[this.selectedIndex].className='';}
this.selectedIndex=index;if(this.selectedIndex!==-1&&divs.length>this.selectedIndex){activeItem=divs[this.selectedIndex];activeItem.className='selected';}
return activeItem;},deactivate:function(div,index){div.className='';if(this.selectedIndex===index){this.selectedIndex=-1;}},select:function(i){var selectedValue;if(this.suggestionsDisplayed>0&&i<this.suggestionsDisplayed){selectedValue=this.suggestions[i];}else{selectedValue=this.membernames[i-this.suggestionsDisplayed];}
if(selectedValue){this.el.value=selectedValue;if(this.options.autoSubmit&&this.el.form){this.el.form.submit();}
this.ignoreValueChange=true;this.hide();this.onSelect(i);}},moveUp:function(){if(this.selectedIndex===-1){return;}
if(this.selectedIndex===0){this.container.childNodes[0].className='';this.selectedIndex=-1;this.el.value=this.currentValue;return;}
this.adjustScroll(this.selectedIndex-1);},moveDown:function(){var maxLength=this.suggestionsDisplayed+this.membernamesDisplayed;if(this.selectedIndex===(maxLength-1)){return;}
this.adjustScroll(this.selectedIndex+1);},adjustScroll:function(i){var container=this.container,activeItem=this.activate(i),offsetTop=activeItem.offsetTop,upperBound=container.scrollTop,lowerBound=upperBound+this.options.maxHeight-25;if(offsetTop<upperBound){container.scrollTop=offsetTop;}else if(offsetTop>lowerBound){container.scrollTop=offsetTop-this.options.maxHeight+25;}
if(this.suggestionsDisplayed>0&&i<this.suggestionsDisplayed){this.el.value=this.data[i].string;}else{this.el.value=this.membernamedata[i-this.suggestionsDisplayed].string;}},onSelect:function(i){var item,itemData;if(this.suggestionsDisplayed>0&&i<this.suggestionsDisplayed){item=this.suggestions[i];itemData=this.data[i];}else{item=this.membernames[i-this.suggestionsDisplayed];itemData=this.membernamedata[i-this.suggestionsDisplayed];}
(this.options.onSelect||Prototype.emptyFunction)(item,itemData);}};var Slideshow=Class.create({TIMER_DELAY:8,initialize:function(){this._chicklet=[];if(this._hasFrames()){this._hideAll(true);this._slideShow().first().show();this._waitForImageLoad();};},start:function(){this.pe=new PeriodicalExecuter(function(pe){this._nextFrame();}.bind(this),this.TIMER_DELAY);},stop:function(){if(this.pe!=undefined){this.pe.stop();};},_waitForImageLoad:function(){this._slideShowImages().each(function(ele,index){if(ele.complete){this._loaded(index);}else{this._loadImage(ele,index);};}.bind(this));},_loadImage:function(ele,index){var img=new Image();img.src=ele.src;if(img.complete){this._loaded(index);};$(img).observe('load',function(e){this._loaded(index);}.bind(this));},_loaded:function(index){if(++this._loadedCount>=this._slideShow().size()){this._beginShow();};},_beginShow:function(){this._setupChicklets();this.start();},_setupChicklets:function(){this._slideShow().reverse().each(function(ele,index){this._setupChicklet(index++);}.bind(this));this._select(this._chicklet.first());},_setupChicklet:function(index){var top=this._calcTopEdge(-39);var d=new Element('div',{'style':'position:relative;width:11px;float:left;top:'+top+'px;left:'+this._calcLeftEdge(this._inverse(index))+'px;'});var e=new Element('img',{'class':'chicklet','src':istock.cookielessUrl+'/static/images/blank.gif'});d.insert({bottom:e});e.observe('click',function(event){this.stop();this._gotoFrame(index);}.bind(this));Element.insert(this._slideShow().last(),{after:d});this._chicklet.push(e);},_inverse:function(index){return this._slideShow().size()-index-1;},_gotoFrame:function(num){if(this._currentFrame!==num){this._hideAll();this._currentFrame=num;this._showFrame(this._slideShow()[num]);}},_showFrame:function(ele){if(this._isHidden(ele)){ele.appear({duration:0.5,from:0,to:1,afterUpdate:function(){if(this._isVisible(ele)){this._showChicklets();};}.bind(this)});this._select(this._chicklet[this._currentFrame]);};},_hideAll:function(noAnimation){this._slideShow().each(function(ele){if(!this._isHidden(ele)){if(noAnimation){ele.hide();}else{ele.fade({duration:0.6});};};}.bind(this));this._chicklet.each(function(ele){this._deselect(ele);ele.hide();}.bind(this));},_showChicklets:function(){this._chicklet.each(function(ele){ele.show();}.bind(this));},_select:function(ele){ele.removeClassName(this._cssChicklet);ele.addClassName(this._cssChickletSelected);},_deselect:function(ele){ele.removeClassName(this._cssChickletSelected);ele.addClassName(this._cssChicklet);},_slideShow:function(){return $$('.slideShow');},_slideShowImages:function(){return $$('.slideShow img');},_hasFrames:function(){return this._slideShow().size()>1;},_nextFrame:function(){if(!this._isHidden(this._slideShow().last())){this._hideAll();this._currentFrame=0;this._showFrame(this._slideShow().first());}else{this._hideAll();this._showFrame(this._slideShow()[++this._currentFrame]);};},_isHidden:function(ele){return!ele.visible();},_isVisible:function(ele){return ele.visible()&&ele.getStyle('opacity')>0.01;},_calcLeftEdge:function(offset){var distFromEdge=32,paddingBetween=26;return(this._slideShow().first().getWidth()-distFromEdge)-((paddingBetween*offset));},_calcTopEdge:function(offset){var ssImg=this._slideShow().first(),height=parseInt(ssImg.getHeight(),10);return(height+offset);},_currentFrame:0,_chicklet:[],_cssChicklet:'chicklet',_cssChickletSelected:'chickletSelected',_loadedCount:0});document.fire('slideshow:loaded');namespacing.init('istock.widgets.datepicker');istock.widgets.datepicker.Formatter=Class.create();istock.widgets.datepicker.Formatter.prototype={initialize:function(format,separator){if(Object.isUndefined(format)){format=["yyyy","mm","dd"];}
if(Object.isUndefined(separator)){separator="-";}
this._format=format;this.separator=separator;this._formatYearIndex=format.indexOf("yyyy");this._formatMonthIndex=format.indexOf("mm");this._formatDayIndex=format.indexOf("dd");this._yearRegexp=/^\d{4}$/;this._monthRegexp=/^0\d|1[012]|\d$/;this._dayRegexp=/^0\d|[12]\d|3[01]|\d$/;},match:function(str){var d=str.split(this.separator),year,month,day;if(d.length<3){return false;}
year=d[this._formatYearIndex].match(this._yearRegexp);if(year){year=year[0];}else{return false;}
month=d[this._formatMonthIndex].match(this._monthRegexp);if(month){month=month[0];}else{return false;}
day=d[this._formatDayIndex].match(this._dayRegexp);if(day){day=day[0];}else{return false;}
return[year,month,day];},currentDate:function(){var d=new Date();return this.dateToString(d.getFullYear(),d.getMonth()+1,d.getDate());},dateToString:function(year,month,day,separator){var a=[0,0,0];if(Object.isUndefined(separator)){separator=this.separator;}
a[this._formatYearIndex]=year;a[this._formatMonthIndex]=month.toPaddedString(2);a[this._formatDayIndex]=day.toPaddedString(2);return a.join(separator);}};istock.widgets.datepicker.Filter=Class.create();istock.widgets.datepicker.Filter.prototype={initialize:function(dateFilterFunction,monthFilterFunction){if(dateFilterFunction){this.badDates=dateFilterFunction;}
if(monthFilterFunction){this.validMonthP=monthFilterFunction;}},badDates:null,validMonthP:null,append:function(nextFilter){var firstBadDates,results1,results2,firstValidMonthP;if(!this.badDates){this.badDates=nextFilter.badDates;}else if(nextFilter.badDates){firstBadDates=this.badDates;this.badDates=function(year,month){results1=firstBadDates(year,month);results2=nextFilter.badDates(year,month);for(var i=0;i<results1.length;i++){results1[i]=results1[i]||results2[i];}
return results1;};}
if(!this.validMonthP){this.validMonthP=nextFilter.validMonthP;}else if(nextFilter.validMonthP){firstValidMonthP=this.validMonthP;this.validMonthP=function(year,month){return firstValidMonthP(year,month)&&nextFilter.validMonthP(year,month);};}
return this;}};istock.widgets.datepicker.utils={oneDayInMs:24*3600*1000,_daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],getMonthDays:function(year,month){if(((0===(year%4))&&((0!==(year%100))||(0===(year%400))))&&(month===1))
{return 29;}
return this._daysInMonth[month];},parseDate:function(dateString){var dateObj=istock.widgets.datepicker.utils.ansiDateToObject(dateString),relDate;if(!dateObj){relDate=parseFloat(dateString);dateObj=new Date();dateObj.setTime(dateObj.getTime()+dateString*this.oneDayInMs);}
return dateObj;},dateObjectToAnsi:function(dateObj){var obj;if(!dateObj){return null;}
obj=dateObj.getFullYear().toPaddedString(4)+'-'+
(dateObj.getMonth()+1).toPaddedString(2)+'-'+
dateObj.getDate().toPaddedString(2);return obj;},ansiDateToObject:function(ansiDate){var dateObj=null,parsedDate=String(ansiDate).match(/^(\d+)-0*(\d+)-0*(\d+)$/);if(parsedDate){dateObj=new Date(parsedDate[1],parsedDate[2]-1,parsedDate[3]);}
return dateObj;},yearMonthToAnsiStub:function(year,month){return year.toPaddedString(4)+'-'+(month+1).toPaddedString(2)+'-';},noDatesBefore:function(firstDate){var utils=istock.widgets.datepicker.utils;return new istock.widgets.datepicker.Filter(function(year,month){var testDate=utils.dateObjectToAnsi(utils.parseDate(firstDate)),dateFilter=[],monthDays=utils.getMonthDays(year,month),calDate=utils.yearMonthToAnsiStub(year,month),i;for(i=1;i<=monthDays;i++){dateFilter[i]=(testDate>(calDate+i.toPaddedString(2)));}
return dateFilter;},function(year,month){var testDate=utils.dateObjectToAnsi(utils.parseDate(firstDate)),calDate=utils.yearMonthToAnsiStub(year,month)+utils.getMonthDays(year,month);return(testDate<=calDate);});},noDatesAfter:function(firstDate){var utils=istock.widgets.datepicker.utils;return new istock.widgets.datepicker.Filter(function(year,month){var testDate=utils.dateObjectToAnsi(utils.parseDate(firstDate)),dateFilter=[],monthDays=utils.getMonthDays(year,month),calDate=utils.yearMonthToAnsiStub(year,month),i;for(i=1;i<=monthDays;i++){dateFilter[i]=(testDate<(calDate+i.toPaddedString(2)));}
return dateFilter;},function(year,month){var testDate=utils.dateObjectToAnsi(utils.parseDate(firstDate)),calDate=utils.yearMonthToAnsiStub(year,month)+'01';return(testDate>=calDate);});},noWeekends:function(){return new istock.widgets.datepicker.Filter(function(year,month){var dateFilter=[],monthDays=istock.widgets.datepicker.utils.getMonthDays(year,month),calDate=new Date(year,month,1),i;for(i=1;i<=monthDays;calDate.setFullYear(year,month,++i)){dateFilter[i]=((calDate.getDay()%6)===0);}
return dateFilter;},null);}};istock.widgets.datepicker.Picker=Class.create();istock.widgets.datepicker.Picker.prototype={Version:'1.0.1',_relative:null,_div:null,_zindex:1,_keepFieldEmpty:false,_dateFormat:null,_language:'en',_language_month:$H({'FR':['Janvier','F&#233;vrier','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','D&#233;cembre'],'EN':['January','February','March','April','May','June','July','August','September','October','November','December'],'ES':['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],'IT':['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],'DE':['Januar','Februar','M&#228;rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],'pt':['Janeiro','Fevereiro','Mar&#231;o','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],'HU':['Janu&#225;r','Febru&#225;r','M&#225;rcius','&#193;prilis','M&#225;jus','J&#250;nius','J&#250;lius','Augusztus','Szeptember','Okt&#243;ber','November','December'],'LT':['Sausis','Vasaris','Kovas','Balandis','Gegu&#382;&#279;','Bir&#382;elis','Liepa','Rugj&#363;tis','Rus&#279;jis','Spalis','Lapkritis','Gruodis'],'NL':['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december'],'DK':['Januar','Februar','Marts','April','Maj','Juni','Juli','August','September','Oktober','November','December'],'NO':['Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember'],'LV':['Janv&#257;ris','Febru&#257;ris','Marts','Apr&#299;lis','Maijs','J&#363;nijs','J&#363;lijs','Augusts','Septembris','Oktobris','Novembris','Decemberis'],'JA':['1&#26376;','2&#26376;','3&#26376;','4&#26376;','5&#26376;','6&#26376;','7&#26376;','8&#26376;','9&#26376;','10&#26376;','11&#26376;','12&#26376;'],'FI':['Tammikuu','Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kes&#228;kuu','Hein&#228;kuu','Elokuu','Syyskuu','Lokakuu','Marraskuu','Joulukuu'],'RO':['Ianuarie','Februarie','Martie','Aprilie','Mai','Junie','Julie','August','Septembrie','Octombrie','Noiembrie','Decembrie'],'ZH':['1&#32;&#26376;','2&#32;&#26376;','3&#32;&#26376;','4&#32;&#26376;','5&#32;&#26376;','6&#32;&#26376;','7&#32;&#26376;','8&#32;&#26376;','9&#32;&#26376;','10&#26376;','11&#26376;','12&#26376;'],'SV':['Januari','Februari','Mars','April','Maj','Juni','Juli','Augusti','September','Oktober','November','December'],'PL':['Stycze\u0144','Luty','Marzec','Kwiecie\u0144','Maj','Czerwiec','Lipiec','Sierpie\u0144','Wrzesie\u0144','Pa\u017adziernik','Listopad','Grudzie\u0144'],'ZH_CN':['January','February','March','April','May','June','July','August','September','October','November','December'],'RU':['&#1103;&#1085;&#1074;&#1072;&#1088;&#1103;','&#1092;&#1077;&#1074;&#1088;&#1072;&#1083;&#1103;','&#1084;&#1072;&#1088;&#1090;&#1072;','&#1072;&#1087;&#1088;&#1077;&#1083;&#1103;','&#1084;&#1072;&#1103;','&#1080;&#1102;&#1085;&#1103;','&#1080;&#1102;&#1083;&#1103;','&#1072;&#1074;&#1075;&#1091;&#1089;&#1090;&#1072;','&#1089;&#1077;&#1085;&#1090;&#1103;&#1073;&#1088;&#1103;','&#1086;&#1082;&#1090;&#1103;&#1073;&#1088;&#1103;','&#1085;&#1086;&#1103;&#1073;&#1088;&#1103;','&#1076;&#1077;&#1082;&#1072;&#1073;&#1088;&#1103;'],'PT_PT':['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],'PT_BR':['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],'KO':['1&#50900;','2&#50900;','3&#50900;','4&#50900;','5&#50900;','6&#50900;','7&#50900;','8&#50900;','9&#50900;','10&#50900;','11&#50900;','12&#50900;'],'ZH_HK':['1&#26376;','2&#26376;','3&#26376;','4&#26376;','5&#26376;','6&#26376;','7&#26376;','8&#26376;','9&#26376;','10&#26376;','11&#26376;','12&#26376;'],'TR':['Ocak','&#350;ubat','Mart','Nisan','May&#305;s','Haziran','Temmuz','A&#287;ustos','Eyl&#252;l','Ekim','Kas&#305;m','Aral&#305;k']}),_language_day:$H({'FR':['Lun','Mar','Mer','Jeu','Ven','Sam','Dim'],'EN':['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],'ES':['Lun','Mar','Mie','Jue','Vie','S&#224;b','Dom'],'IT':['Lun','Mar','Mer','Gio','Ven','Sab','Dom'],'DE':['Mon','Die','Mit','Don','Fre','Sam','Son'],'PT':['Seg','Ter','Qua','Qui','Sex','S&#225;','Dom'],'HU':['H&#233;','Ke','Sze','Cs&#252;','P&#233;','Szo','Vas'],'LT':['Pir','Ant','Tre','Ket','Pen','&Scaron;e&scaron;','Sek'],'NL':['ma','di','wo','do','vr','za','zo'],'DK':['Man','Tir','Ons','Tor','Fre','L&#248;r','S&#248;n'],'NO':['Man','Tir','Ons','Tor','Fre','L&#248;r','Sun'],'LV':['P','O','T','C','Pk','S','Sv'],'JA':['&#26376;','&#28779;','&#27700;','&#26408;','&#37329;','&#22303;','&#26085;'],'FI':['Ma','Ti','Ke','To','Pe','La','Su'],'RO':['Lun','Mar','Mie','Joi','Vin','Sam','Dum'],'ZH':['&#21608;&#19968;','&#21608;&#20108;','&#21608;&#19977;','&#21608;&#22235;','&#21608;&#20116;','&#21608;&#20845;','&#21608;&#26085;'],'SV':['M&#229;n','Tis','Ons','Tor','Fre','L&#246;r','S&#246;n'],'PL':['Pon','Wt','\u015ar','Czw','Pt','Sob','Nie'],'ZH_CN':['&#21608;&#19968;','&#21608;&#20108;','&#21608;&#19977;','&#21608;&#22235;','&#21608;&#20116;','&#21608;&#20845;','&#21608;&#26085;'],'RU':['&#1055;&#1085;','&#1042;&#1090;','&#1057;&#1088;','&#1063;&#1090;','&#1055;&#1090;','&#1057;&#1073;','&#1042;&#1089;'],'PT_PT':['seg','ter','qua','qui','sex','s&#225;b','dom'],'PT_BR':['seg','ter','qua','qui','sex','s&#225;b','dom'],'KO':['&#50900;','&#54868;','&#49688;','&#47785;','&#44552;','&#53664;','&#51068;'],'ZH_HK':['&#21608;&#19968;','&#21608;&#20108;','&#21608;&#19977;','&#21608;&#22235;','&#21608;&#20116;','&#21608;&#20845;','&#21608;&#26085;'],'TR':['Pzt','Sal','&#199;ar','Per','Cum','Cmt','Paz']}),_language_close:$H({'FR':'fermer','EN':'close','SP':'cierre','IT':'fine','DE':'schliessen','PT':'fim','HU':'bez&#225;r','LT':'u&#382;daryti','NL':'sluiten','DK':'luk','NO':'lukk','LV':'aizv&#275;rt','JA':'&#38281;&#12376;&#12427;','FI':'sulje','RO':'inchide','ZH':'&#20851;&#32;&#38381','SV':'st&#228;ng','PL':'zamknij','ZH_CN':'close','RU':'close','PT_PT':'close','PT_BR':'close','KO':'close','ZH_HK':'close','TR':'close'}),_language_date_format:$H({'EN':[["mm","dd","yyyy"],"/"],'LT':[["yyyy","mm","dd"],"-"],'FR':[["dd","mm","yyyy"],"/"],'SP':[["dd","mm","yyyy"],"/"],'IT':[["dd","mm","yyyy"],"/"],'DE':[["dd","mm","yyyy"],"/"],'PT':[["dd","mm","yyyy"],"/"],'HU':[["dd","mm","yyyy"],"/"],'NL':[["dd","mm","yyyy"],"/"],'DK':[["dd","mm","yyyy"],"/"],'NO':[["dd","mm","yyyy"],"/"],'LV':[["dd","mm","yyyy"],"/"],'JA':[["yyyy","mm","dd"],"-"],'FI':[["dd","mm","yyyy"],"."],'RO':[["dd","mm","yyyy"],"/"],'ZH':[["yyyy","mm","dd"],"-"],'SV':[["dd","mm","yyyy"],"/"],'PL':[["yyyy","mm","dd"],"-"],'ZH_CN':[["mm","dd","yyyy"],"/"],'RU':[["mm","dd","yyyy"],"/"],'PT_PT':[["mm","dd","yyyy"],"/"],'PT_BR':[["mm","dd","yyyy"],"/"],'KO':[["mm","dd","yyyy"],"/"],'ZH_HK':[["mm","dd","yyyy"],"/"],'TR':[["mm","dd","yyyy"],"/"]}),_todayDate:new Date(),_currentDate:null,_clickCallback:Prototype.emptyFunction,_cellCallback:Prototype.emptyFunction,_dateFilter:new istock.widgets.datepicker.Filter(),_id_datepicker:null,_topOffset:30,_leftOffset:0,_isPositionned:false,_relativePosition:true,_setPositionTop:0,_setPositionLeft:0,_bodyAppend:false,_showEffect:"appear",_showDuration:0.2,_enableShowEffect:true,_closeEffect:"fade",_closeEffectDuration:0.2,_enableCloseEffect:true,_closeTimer:null,_enableCloseOnBlur:false,_afterClose:Prototype.emptyFunction,_afterChange:Prototype.emptyFunction,getMonthLocale:function(month){return this._language_month.get(this._language)[month];},getLocaleClose:function(){return this._language_close.get(this._language);},_initCurrentDate:function(){var a_date;if(!this._dateFormat){this._dateFormat=this._language_date_format.get(this._language);}
this._df=new istock.widgets.datepicker.Formatter(this._dateFormat[0],this._dateFormat[1]);this._currentDate=$F(this._relative);if(!this._df.match(this._currentDate)){this._currentDate=this._df.currentDate();if(!this._keepFieldEmpty){$(this._relative).value=this._currentDate;}}
a_date=this._df.match(this._currentDate);this._currentYear=Number(a_date[0]);this._currentMonth=Number(a_date[1])-1;this._currentDay=Number(a_date[2]);},initialize:function(h_p){this._relative=h_p.relative;if(h_p.language){this._language=h_p.language;}
this._zindex=(h_p.zindex)?parseInt(h_p.zindex,10):1;if(!Object.isUndefined(h_p.keepFieldEmpty)){this._keepFieldEmpty=h_p.keepFieldEmpty;}
if(Object.isFunction(h_p.clickCallback)){this._clickCallback=h_p.clickCallback;}
if(!Object.isUndefined(h_p.leftOffset)){this._leftOffset=parseInt(h_p.leftOffset,10);}
if(!Object.isUndefined(h_p.topOffset)){this._topOffset=parseInt(h_p.topOffset,10);}
if(!Object.isUndefined(h_p.relativePosition)){this._relativePosition=h_p.relativePosition;}
if(!Object.isUndefined(h_p.showEffect)){this._showEffect=h_p.showEffect;}
if(!Object.isUndefined(h_p.enableShowEffect)){this._enableShowEffect=h_p.enableShowEffect;}
if(!Object.isUndefined(h_p.showDuration)){this._showDuration=h_p.showDuration;}
if(!Object.isUndefined(h_p.closeEffect)){this._closeEffect=h_p.closeEffect;}
if(!Object.isUndefined(h_p.enableCloseEffect)){this._enableCloseEffect=h_p.enableCloseEffect;}
if(!Object.isUndefined(h_p.closeEffectDuration)){this._closeEffectDuration=h_p.closeEffectDuration;}
if(Object.isFunction(h_p.afterClose)){this._afterClose=h_p.afterClose;}
if(Object.isFunction(h_p.afterChange)){this._afterChange=h_p.afterChange;}
if(!Object.isUndefined(h_p.externalControl)){this._externalControl=h_p.externalControl;}
if(!Object.isUndefined(h_p.dateFormat)){this._dateFormat=h_p.dateFormat;}
if(Object.isFunction(h_p.cellCallback)){this._cellCallback=h_p.cellCallback;}
this._setPositionTop=(h_p.setPositionTop)?parseInt(Number(h_p.setPositionTop),10):0;this._setPositionLeft=(h_p.setPositionLeft)?parseInt(Number(h_p.setPositionLeft),10):0;if(!Object.isUndefined(h_p.enableCloseOnBlur)&&h_p.enableCloseOnBlur){this._enableCloseOnBlur=true;}
if(!Object.isUndefined(h_p.dateFilter)&&h_p.dateFilter){this._dateFilter=h_p.dateFilter;}
if(!Object.isUndefined(h_p.disablePastDate)&&h_p.disablePastDate){this._dateFilter.append(istock.widgets.datepicker.utils.noDatesBefore(0));}else if(!Object.isUndefined(h_p.disableFutureDate)&&h_p.disableFutureDate){this._dateFilter.append(istock.widgets.datepicker.utils.noDatesAfter(0));}
this._id_datepicker='datepicker-'+this._relative;this._id_datepicker_prev=this._id_datepicker+'-prev';this._id_datepicker_next=this._id_datepicker+'-next';this._id_datepicker_hdr=this._id_datepicker+'-header';this._id_datepicker_ftr=this._id_datepicker+'-footer';this._div=new Element('div',{id:this._id_datepicker,className:'datepicker',style:'display: none; z-index:'+this._zindex});this._div.update('<table><thead><tr><th width="10px" id="'+this._id_datepicker_prev+'" class="datepickerPrev">&lt;&lt</th><th id="'+this._id_datepicker_hdr+'" colspan="5"></th><th width="10px" id="'+this._id_datepicker_next+'" class="datepickerNext">&gt;&gt;</th></tr></thead><tbody id="'+this._id_datepicker+'-tbody"></tbody><tfoot><tr><td colspan="7" id="'+this._id_datepicker_ftr+'"></td></tr></tfoot></table>');Event.observe(this._relative,'click',this.click.bindAsEventListener(this),false);document.observe('dom:loaded',this.load.bindAsEventListener(this),false);if(this._enableCloseOnBlur){Event.observe(this._relative,'blur',function(e){if(!this._closeTimer){this._closeTimer=this.close.bind(this).delay(1);}}.bindAsEventListener(this));Event.observe(this._div,'click',function(e){this._relative.focus();this.checkClose.bind(this).delay(0.1);}.bindAsEventListener(this));}},load:function(){var a_pos,body;if(this._externalControl){Event.observe(this._externalControl,'click',this.click.bindAsEventListener(this),false);}
if(this._relativeAppend){if($(this._relative).parentNode){this._div.innerHTML=this._wrap_in_iframe(this._div.innerHTML);$(this._relative).parentNode.appendChild(this._div);}}else{body=document.getElementsByTagName("body").item(0);if(body){this._div.innerHTML=this._wrap_in_iframe(this._div.innerHTML);body.appendChild(this._div);}
if(this._relativePosition){a_pos=Element.cumulativeOffset($(this._relative));this.setPosition(a_pos[1],a_pos[0]);}else{if(this._setPositionTop||this._setPositionLeft){this.setPosition(this._setPositionTop,this._setPositionLeft);}}}
this._initCurrentDate();$(this._id_datepicker_ftr).innerHTML=this.getLocaleClose();Event.observe($(this._id_datepicker_prev),'click',this.prevMonth.bindAsEventListener(this),false);Event.observe($(this._id_datepicker_next),'click',this.nextMonth.bindAsEventListener(this),false);Event.observe($(this._id_datepicker_ftr),'click',this.close.bindAsEventListener(this),false);Event.observe($(document),'click',this.documentClick.bindAsEventListener(this),false);},_wrap_in_iframe:function(content){return(Prototype.Browser.IE)?"<div style='height:167px;width:185px;background-color:white;align:left'><iframe width='100%' height='100%' marginwidth='0' marginheight='0' frameborder='0' src='about:blank' style='filter:alpha(Opacity=50);'></iframe><div style='position:absolute;background-color:white;top:2px;left:2px;width:180px'>"+content+"</div></div>":content;},visible:function(){return $(this._id_datepicker).visible();},click:function(){if($(this._id_datepicker)===null){this.load();}
if(!this._isPositionned&&this._relativePosition){var a_lt=Element.cumulativeOffset($(this._relative));$(this._id_datepicker).setStyle({'left':Number(a_lt[0]+this._leftOffset)+'px','top':Number(a_lt[1]+this._topOffset)+'px'});this._isPositionned=true;}
if(!this.visible()){this._initCurrentDate();this._redrawCalendar();}
this._clickCallback();if(this._enableShowEffect){Effect.toggle(this._id_datepicker,this._showEffect,{duration:this._showDuration});}else{$(this._id_datepicker).show();}},close:function(){if(!this.visible()){return;}
this.checkClose();if(this._enableCloseEffect){switch(this._closeEffect){case'puff':Effect.Puff(this._id_datepicker,{duration:this._closeEffectDuration});break;case'blindUp':Effect.BlindUp(this._id_datepicker,{duration:this._closeEffectDuration});break;case'dropOut':Effect.DropOut(this._id_datepicker,{duration:this._closeEffectDuration});break;case'switchOff':Effect.SwitchOff(this._id_datepicker,{duration:this._closeEffectDuration});break;case'squish':Effect.Squish(this._id_datepicker,{duration:this._closeEffectDuration});break;case'fold':Effect.Fold(this._id_datepicker,{duration:this._closeEffectDuration});break;case'shrink':Effect.Shrink(this._id_datepicker,{duration:this._closeEffectDuration});break;default:Effect.Fade(this._id_datepicker,{duration:this._closeEffectDuration});break;};}else{$(this._id_datepicker).hide();}
this._afterClose();},checkClose:function(){if(this._closeTimer){window.clearTimeout(this._closeTimer);this._closeTimer=null;}},documentClick:function(event){var source=event.element();if(source!==this._div&&source!==$(this._relative)&&source!==$(this._externalControl)&&!source.descendantOf(this._div))
{this.close();}},setDateFormat:function(format,separator){if(Object.isUndefined(format)){format=this._dateFormat[0];}
if(Object.isUndefined(separator)){separator=this._dateFormat[1];}
this._dateFormat=[format,separator];},setPosition:function(t,l){var h_pos={'top':'0px','left':'0px'};if(!Object.isUndefined(t)){h_pos.top=Number(t)+this._topOffset+'px';}
if(!Object.isUndefined(l)){h_pos.left=Number(l)+this._leftOffset+'px';}
$(this._id_datepicker).setStyle(h_pos);this._isPositionned=true;},_buildCalendar:function(){var _self=this,tbody=$(this._id_datepicker+'-tbody'),trDay,j,i,a_d,currentMonth,currentYear,d,startIndex,nbDaysInMonth,daysIndex,badDates,a_prevMY,nbDaysInMonthPrev,switchNextMonth,tr,td,h_ij,id;try{while(tbody.hasChildNodes()){tbody.removeChild(tbody.childNodes[0]);}}catch(e){};trDay=new Element('tr');this._language_day.get(this._language).each(function(item){var td=new Element('td');td.innerHTML=item;td.className='wday';trDay.appendChild(td);});tbody.appendChild(trDay);a_d=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]];currentMonth=this._currentMonth;currentYear=this._currentYear;d=new Date(currentYear,currentMonth,1,12);startIndex=(d.getDay()+6)%7;nbDaysInMonth=istock.widgets.datepicker.utils.getMonthDays(currentYear,currentMonth);daysIndex=1;badDates=(this._dateFilter.badDates)?this._dateFilter.badDates(currentYear,currentMonth):[];for(j=startIndex;j<7;j++){a_d[0][j]={d:daysIndex,m:currentMonth,y:currentYear,b:badDates[daysIndex]};daysIndex++;}
a_prevMY=this._prevMonthYear();nbDaysInMonthPrev=istock.widgets.datepicker.utils.getMonthDays(a_prevMY[1],a_prevMY[0]);for(j=0;j<startIndex;j++){a_d[0][j]={d:Number(nbDaysInMonthPrev-startIndex+j+1),m:Number(a_prevMY[0]),y:a_prevMY[1],c:'outbound',b:true};}
switchNextMonth=false;for(i=1;i<6;i++){for(j=0;j<7;j++){a_d[i][j]={d:daysIndex,m:currentMonth,y:currentYear,c:(switchNextMonth)?'outbound':(((daysIndex===this._todayDate.getDate())&&(currentMonth===this._todayDate.getMonth())&&(currentYear===this._todayDate.getFullYear()))?'today':null),b:switchNextMonth||badDates[daysIndex]};daysIndex++;if(daysIndex>nbDaysInMonth){daysIndex=1;switchNextMonth=true;if(this._currentMonth+1>11){currentMonth=0;currentYear+=1;}else{currentMonth+=1;}}}}
for(i=0;i<6;i++){tr=new Element('tr');for(j=0;j<7;j++){h_ij=a_d[i][j];td=new Element('td');id=$A([this._relative,this._df.dateToString(h_ij.y,h_ij.m+1,h_ij.d,'-')]).join('-');td.setAttribute('id',id);if(h_ij.c){td.className=h_ij.c;}
this._bindCellOnClick(td,h_ij.b,h_ij.c);td.innerHTML=h_ij.d;tr.appendChild(td);}
tbody.appendChild(tr);}
return tbody;},_bindCellOnClick:function(td,badDateP,cellClass){var _self=this;if(badDateP){td.className=(cellClass)?'nclick_'+cellClass:'nclick';}else{td.onclick=function(){var existingValue=$(_self._relative).value;$(_self._relative).value=String($(this).readAttribute('id')).replace(_self._relative+'-','').replace(/-/g,_self._df.separator);if(_self._cellCallback){_self._cellCallback(this);}
if(existingValue!=$(_self._relative).value){if(_self._afterChange){_self._afterChange();}}
_self.close();};}},_nextMonthYear:function(){var c_mon=this._currentMonth,c_year=this._currentYear;if(c_mon+1>11){c_mon=0;c_year+=1;}else{c_mon+=1;}
return[c_mon,c_year];},nextMonth:function(){this._maybeRedrawMonth(this._nextMonthYear());},_prevMonthYear:function(){var c_mon=this._currentMonth,c_year=this._currentYear;if(c_mon-1<0){c_mon=11;c_year-=1;}else{c_mon-=1;}
return[c_mon,c_year];},prevMonth:function(){this._maybeRedrawMonth(this._prevMonthYear());},_maybeRedrawMonth:function(a_new){var _newMon=a_new[0],_newYear=a_new[1];if(!this._dateFilter.validMonthP||this._dateFilter.validMonthP(_newYear,_newMon))
{this._currentMonth=_newMon;this._currentYear=_newYear;this._redrawCalendar();}},_redrawCalendar:function(){this._setLocaleHdr();this._buildCalendar();},_setLocaleHdr:function(){var a_next,a_prev;a_next=this._nextMonthYear();$(this._id_datepicker_next).setAttribute('title',this.getMonthLocale(a_next[0])+' '+a_next[1]);a_prev=this._prevMonthYear();$(this._id_datepicker_prev).setAttribute('title',this.getMonthLocale(a_prev[0])+' '+a_prev[1]);$(this._id_datepicker_hdr).update('&nbsp;&nbsp;&nbsp;'+this.getMonthLocale(this._currentMonth)+'&nbsp;'+this._currentYear+'&nbsp;&nbsp;&nbsp;');}};namespacing.init('istock.widget');istock.widget.MenuSelector=Class.create({initialize:function(element){var height,hiddenBorder;if(!element.hasClassName('menuSelector')){throw'Container must have menuSelector class';}
this._container=element;this._header=element.select('.menuSelector-header')[0];this._content=element.select('.menuSelector-content')[0];this._options={open:{backgroundColor:this._content.getStyle('background-color'),borderColor:this._content.getStyle('border-right-color'),color:this._content.getStyle('color')},closed:{backgroundColor:this._header.getStyle('background-color'),borderColor:this._header.getStyle('border-right-color'),color:this._header.getStyle('color'),height:this._header.getLayout().get('padding-box-height')+'px'},delay:500};if(this._container.hasClassName('ims-up')){this._options.open.height=this._header.getLayout().get('padding-box-height')+'px';}else{this._options.open.height=this._header.getLayout().get('border-box-height')+'px';}
this._setupStyle();this._addObservers();},show:function(){this._open();},_open:function(){var style=this._options.open;if(this._state==='closing'){this._effect.effects.each(function(effect){effect.cancel();});this._state=' closed';}
if(this._state==='closed'){if(this._container.hasClassName('ims-transparentHeader')){style=this._options.closed;}
this._header.setStyle({zIndex:6001});this._content.setStyle({zIndex:6000});if(Prototype.Browser.IE&&Prototype.Browser.Version[0]<8){this._header.setStyle(style);this._content.show();this._container.addClassName('active');this._state='open';return;}
this._effect=new Effect.Parallel([new Effect.Appear(this._content),new Effect.Morph(this._header,{style:style})],{duration:0.25,beforeStart:function(){this._state='opening';this._container.fire('menuSelector:opening');}.bind(this),afterFinish:function(){this._state='open';this._container.addClassName('active');this._header.setStyle({zIndex:6001});this._content.setStyle({zIndex:6000});}.bind(this)});}},_close:function(){var tid,afterFinished=function(){this._state='closed';this._container.removeClassName('active');this._header.setStyle({zIndex:1});this._content.setStyle({zIndex:1});}.bind(this);if(this._state==='open'){if(Prototype.Browser.IE&&Prototype.Browser.Version[0]<8){this._header.setStyle(this._options.closed);this._content.hide();this._container.removeClassName('active');this._state='closed';}else{this.effect=new Effect.Parallel([new Effect.Fade(this._content),new Effect.Morph(this._header,{style:this._options.closed})],{beforeStart:function(){this._state='closing';}.bind(this),afterFinish:afterFinished,duration:0.25});}}else if(this._state==='opening'){this._effect.effects.each(function(effect){effect.cancel();});this._header.setStyle(this._options.closed);this._content.hide();afterFinished();}},_addObservers:function(){var openBehaviour='mouseover';if(this._container.hasClassName('ims-click')){openBehaviour='click';}
this._container.observe(openBehaviour,function(evt){var el;if(openBehaviour==='click'&&this._state==='open'){el=evt.element();if(el===this._header||el.descendantOf(this._header)){this._close();evt.stop();}}else{this._open();evt.stop();}}.bind(this));this._container.observe('mouseout',function(evt){var el=evt.relatedTarget||evt.toTarget,pe;if(el&&!el.descendantOf(this._container)){this._closeTimerId=setTimeout(this._close.bind(this),this._options.delay);}}.bind(this));this._container.observe('mouseover',function(){if(this._closeTimerId){clearTimeout(this._closeTimerId);this._closeTimerId=null;}}.bind(this));document.observe('menuSelector:opening',function(evt){if(this._container!==evt.srcElement&&(this._state==='open'||this._state==='opening')){this._state='opening';this._close();}}.bind(this));document.observe('menuSelector:close',function(evt){if(evt.memo.elm&&evt.memo.elm.descendantOf(this._container)){this._close();}}.bind(this));},_setupStyle:function(){if(!Prototype.Browser.IE){this._content.setStyle({left:'-999px'});}
this._content.show();this._header.setStyle(this._options.closed);this._fixWidth();this._fixPositions();this._content.hide();},_fixWidth:function(){var layout=this._content.getLayout(),hdrLayout=this._header.getLayout();if(layout.get('padding-box-width')<hdrLayout.get('padding-box-width')){this._content.setStyle({width:hdrLayout.get('padding-box-width')+'px'});}},_fixPositions:function(){var layout,hdrLayout=this._header.getLayout(),top,height,left=0,position='top',style={};if(this._container.hasClassName('ims-right')){layout=this._content.getLayout();left=(layout.get('width')-hdrLayout.get('width'))*-1;}
if(this._container.hasClassName('ims-up')){position='bottom';}
top=hdrLayout.get('border-box-height');style.left=left+'px';style[position]=top+'px';this._content.setStyle(style);},_container:null,_header:null,_content:null,_options:null,_state:'closed',_effect:null,_closeTimerId:null});Event.observe(document,'dom:loaded',function(){$$('.menuSelector').each(function(menu){var ms=new istock.widget.MenuSelector(menu);});});namespacing.init('istock.widget');istock.widget.SearchBar=Class.create({PORTFOLIO_URL:'search/portfolio/#{id}',SEARCH_URL:'search/text/#{string}#{filetype}#{disambiguation}#{source}',BROWSE_URL:'browse/latest#{section}',COMPONENTS:{container:'_container',input:'_input'},initialize:function(element,searchBarSource){var form;if(!(element=$(element))){throw'SearchBar widget requires a valid element container';}
this._source=searchBarSource||'';this._container=element;this._input=this._container.select('.searchBar-input input[type="text"]').first();this._defaultInputValue=this._input.defaultValue;this._submit=this._container.select('.searchBar-submit input[type="submit"]').first();this._container.observe('click',this._observe.bind(this));this._container.observe('keypress',this._observe.bind(this));this._input.observe('focus',this._observe.bind(this));this._input.observe('blur',this._observe.bind(this));if(Prototype.Browser.IE){this._container.wrap(new Element('form').observe('submit',function(e){e.stop();return false;}));}},get:function(component){if(this.COMPONENTS[component]){return this[this.COMPONENTS[component]];}
return null;},search:function(value){var url;if(!Object.isString(value)&&value.userId){url=this._portfolioUrl(value.userId);}else{url=this._searchUrl(value);}
window.location=istock.url+url;},_portfolioUrl:function(id){return this.PORTFOLIO_URL.interpolate({id:id});},_searchUrl:function(data){var source='';if(typeof data==='string'){data={string:data};}
if(this._source){data.source='/source/'+this._source;}
if(data.string===''){return'search/';}
return this.SEARCH_URL.interpolate(data);},_browseLatestUrl:function(){var path=window.location.pathname,section='';if(path in istock.widget.SearchBar.LANDING_PAGES){section=path;}
return this.BROWSE_URL.interpolate({section:section});},_getInputValue:function(){var text=$F(this.get('input'));if(text===this._defaultInputValue){return'';}
return text;},_observe:function(evt){var target=evt.element(),action='_'+evt.type;switch(target){case this._input:action+='Input';break;case this._submit:action+='Submit';break;default:return true;}
if(this[action]){this[action](evt);}},_clickSubmit:function(){this.search(this._getInputValue());},_keypressInput:function(evt){if(evt.keyCode===Event.KEY_RETURN){this._clickSubmit();}},_blurInput:function(){if($F(this._input).blank()){this._input.value=this._defaultInputValue;}},_focusInput:function(){if($F(this._input)===this._defaultInputValue){this._input.value='';}}});Object.extend(istock.widget.SearchBar,{LANDING_PAGES:{'/photo':'photos','/illustration':'illustrations','/video':'video','/audio':'audio','/flash':'flash'}});namespacing.init('istock.widget.SearchBar');istock.widget.SearchBar.TypeSelector=Class.create({NUM_DISPLAYED_TYPES:2,STORAGE_KEY:'typesSelected',TYPES_SELECTED:'',initialize:function(selector,storage){if(!selector){throw'No selector has been passed to SearchBar TypeSelector';}
this._selector=selector;this._container=selector._container;this._header=selector._header.select('span').first();this._allFiles=this._container.select('input[value="all-files"]').first();this._checkboxes=this._container.select('input[type="checkbox"]:not([value="all-files"])');this.TYPES_SELECTED=translations.widget.SearchBar.fileTypes;if(storage){this._storage=storage;}
this._setSelectedTypes();this._updateLabel();this._container.observe('click',this._observe.bind(this));},getTypes:function(){var types=[];this._getCheckedBoxes().each(function(box){types.push(box.value);});return types;},saveTypes:function(){var boxes=[];if(!this._storage){return;}
boxes=this.getTypes();this._storage.setItem(this.STORAGE_KEY,Object.toJSON(boxes));},_observe:function(evt){var target=evt.element(),type=evt.type;if(type!=='click'){return;}
if(target.type!=='checkbox'){target=target.select('input[type=checkbox]').first();if(!target){return;}
target.checked=!target.checked;}
if((target===this._allFiles&&target.checked)||this._checkboxes.length===this._getCheckedBoxes().length||this._getCheckedBoxes().length===0){this._selectAllFiles();}else{this._allFiles.checked=false;}
this._updateLabel();},_selectAllFiles:function(){this._allFiles.checked=true;this._checkboxes.each(function(box){box.checked=false;});},_getCheckedBoxes:function(){return this._checkboxes.filter(function(box){return box.checked;});},_getLabel:function(box){return box.up().select('span').first().innerHTML;},_updateLabel:function(){var boxes=this._getCheckedBoxes(),label=[];if(boxes.length<=0){this._header.update(this._getLabel(this._allFiles));}else if(boxes.length<=this.NUM_DISPLAYED_TYPES){boxes.each(function(box){label.push(this._getLabel(box));}.bind(this));this._header.update(label.join(', '));}else{this._header.update(this.TYPES_SELECTED.gsub('%u',boxes.length));}
document.fire('TypeSelector:labelUpdated',{selector:this});},_setSelectedTypes:function(){var selectedTypes;if(this._selectHomePage()){return;}
if(this._selectLandingPage()){return;}
this._selectTypes(this._getUserSelected());},_selectTypes:function(types){if(!types||!Object.isArray(types)||(Object.isArray(types)&&types.length===0)){this._selectAllFiles();return;}
this._checkboxes.each(function(box){box.checked=!!(~types.indexOf(box.value));});},_getUserSelected:function(){var s=this._storage,types=[];if(s&&(types=s.getItem(this.STORAGE_KEY))){types=types.evalJSON(true);}
return types||[];},_selectHomePage:function(){var path=window.location.pathname.gsub('/','');if(!path.blank()){return false;}
this._selectAllFiles();return true;},_selectLandingPage:function(){var path=window.location.pathname,ftBox,type,header;if(!(path in istock.widget.SearchBar.LANDING_PAGES)){return false;}
type=istock.widget.SearchBar.LANDING_PAGES[path];ftBox=this._container.select('input[value="'+type+'"]').first();ftBox.checked=true;this._allFiles.checked=false;return true;}});namespacing.init('istock.widget');istock.widget.SimpleSearch=Class.create(istock.widget.SearchBar,{initialize:function($super,element,source,options){var o,ac,msContainer,selector;if(!source){source='basic';}
$super(element,source);o={maxSuggestions:7,maxMembernames:4,serviceUrl:'/json/hints',onSelect:function(value,data){this._suggestSelected=true;if(data.userId||data.disambiguation){value=data;}else{value={string:value};}
if(data.disambiguation){data.disambiguation='/textDisambiguation/'+Object.toJSON(data.disambiguation);}
this.search(value);}.bind(this)};Object.extend(options||{},o);document.observe('TypeSelector:labelUpdated',this._updateInputWidth.bind(this));msContainer=this.get('container').select('.menuSelector').first();selector=new istock.widget.MenuSelector(msContainer);this._selector=new istock.widget.SearchBar.TypeSelector(selector,istock.localStorage||null);o.width=this.get('input').getLayout().get('width')-2;ac=new Autocomplete(this.get('input'),o);},search:function($super,value){this._clearSearchCache();this._selector.saveTypes();$super(value);},_keypressInput:function($super,evt){if(evt.keyCode===Event.KEY_RETURN&&!this._suggestSelected){$super(evt);}},_updateInputWidth:function(evt){var divs=this._container.select('> div:not(.clear):not(.searchBar-input)'),maxWidth=parseInt(this._container.getLayout().get('padding-box-width'),10),widthTaken=0;if(evt.memo.selector._container!==this._container.select('.menuSelector').first()){return;}
divs.each(function(div){widthTaken+=parseInt(div.getLayout().get('margin-box-width'),10);});this.get('input').setStyle({width:(maxWidth-widthTaken-13)+'px'});},_clearSearchCache:function(){if(istock.sessionStorage){istock.sessionStorage.clear();istock.sessionStorage.setItem('new_search',true);}},_searchUrl:function($super,data){var selectedTypes=[],ft='';if(typeof data==='string'){data={string:data};}
if(this._selector){selectedTypes=this._selector.getTypes();if(selectedTypes.length===1){data.filetype='/filetype/'+selectedTypes.first();}else if(selectedTypes.length>1){data.filetype='/filetypes/'+selectedTypes.join(',');}}
return $super(data);},_suggestSelected:false});Event.observe(document,'dom:loaded',function(){$$('.searchBar.simple').each(function(menu){var searchBar=new istock.widget.SimpleSearch(menu);});});var tabsAjax={showTab:function(elm){contantContainerName=this._getContantContainerName(elm);if(!$(contantContainerName)){this.loadTabContent(elm);}else{this.switchTab(elm.identify());};},_getBasicName:function(elm){var split=elm.identify().split('_');var basicName=split[1];if(split[2]){basicName=basicName+'_'+split[2];};return basicName;},_getContantContainerName:function(elm){var split=elm.identify().split('_');var contantContainerName='content_'+this._getBasicName(elm);var optionsTab=this._getOptionsName(elm);if($(optionsTab)){$$('#'+optionsTab+' .additional-options').each(function(currentElm){contantContainerName=contantContainerName+'_'+currentElm.name+'_'+currentElm.value;});};return contantContainerName;},_getTabName:function(elm){return'tab_'+this._getBasicName(elm);},_getOptionsName:function(elm){return'options_'+this._getBasicName(elm);},_getActionName:function(elm){var split=elm.identify().split('_');return split[1];},loadTabContent:function(elm){var currentTab=this._getContantContainerName(elm);var parametersToPass={'jsonAction':this._getBasicName(elm)};var optionsTab=this._getOptionsName(elm);if($(optionsTab)){$$('#'+optionsTab+' .additional-options').each(function(currentElm){parametersToPass[currentElm.name]=currentElm.value;});};var tabAjax=new Ajax.Request('/json/'+this._getActionName(elm),{method:'post',parameters:parametersToPass,onSuccess:function(response){tabsAjax.updateTabContent(response.responseText.evalJSON(true),currentTab)},onFailure:function(response){alert('Error loading, please refresh your page!');}});},updateTabContent:function(response,currentTab){if(response.result){Element.insert($$('div.tabContentContainer')[0].identify(),{bottom:'<div id="'+currentTab+'"></div>'});Element.insert(currentTab,{bottom:response.content});this.switchTab(currentTab);switch(this._getActionName($(currentTab))){case'Settings':userSettings.observeSelects(currentTab);break;default:return;};};},switchTab:function(elm){var elm=$(elm);$$('.tabHeaders .tabHead.tabActive')[0].removeClassName('tabActive');$(this._getTabName(elm)).addClassName('tabActive');$$('.tabContentContainer')[0].childElements().each(function(node){node.hide();});$(this._getContantContainerName(elm)).show();if($$('.tabOptions')[0]){$$('.tabOptions')[0].childElements().each(function(node){node.hide();});};var optionsTab=this._getOptionsName(elm);if($(optionsTab)){$(optionsTab).show()};}};namespacing.init('istock');istock.Infotip=Class.create({initialize:function(options){if(options.id){this._id=options.id;}
this._title=options.title;this._anchor=options.anchor;this._contents=options.contents;this._customClass=' '+options.customClass||'';this._attachOptions=options.attachOptions;this._fnClose=function(){this.close();};this._closeTimeoutId=null;},show:function(){istock.Infotip.closeAllOpen();if(this._anchor&&!this._anchor.hasAttachedChildren()){this._build();}
this._anchor.showAttached({effect:'appear',effectOptions:{duration:0.2}});this._anchor.attachedChildren[0].showAttached({effect:'appear',effectOptions:{duration:0.2}});this._timestamp=new Date();document.fire('Infotip:Opening',{timestamp:this._timestamp});},close:function(){if(this._anchor){this._anchor.detach(null,true);}},hide:function(){this._anchor.hideAttached();this._anchor.attachedChildren[0].hideAttached();},_clearTimeout:function(){if(this._closeTimeoutId){window.clearTimeout(this._closeTimeoutId);this._closeTimeoutId=null;}},_setTimeout:function(time){this._clearTimeout();this._closeTimeoutId=setTimeout(function(){this.close();}.bind(this),time);},_build:function(){var notch=new Element('img',{src:istock.cookielessUrl+'/static/images/blank.gif','class':'infotipNotch'}),container=new Element('div',{'id':this._id,'class':'infotipContainer'+this._customClass}),content=new Element('div',{'class':'infotipContent'}),title=null;if(this._title){title=this._buildTitle();}
content.update(this._contents);container.insert(title);container.insert(content);this._anchor.attach(notch,this._attachOptions);notch.attach(container,{anchor:{horizontal:'right',vertical:'top'},attachee:{horizontal:'left',vertical:'top'},offset:{left:-3,top:-15},style:{zIndex:5999}});this._infoTip=container;return container;},_buildTitle:function(){var container=new Element('div',{'class':'infotipTitleContainer'}),header=new Element('span',{'class':'infotipTitle'}),closeButtonContainer=new Element('div',{'class':'infotipCloseContainer'});closeButton=new Element('img',{'class':'infotipClose',src:istock.cookielessUrl+'/static/images/blank.gif'});header.insert(this._title);container.insert(header);closeButtonContainer.insert(closeButton);container.insert(closeButtonContainer);closeButton.observe('click',this._fnClose.bind(this));return container;},_timestamp:null,_infoTip:null});Object.extend(istock.Infotip,{_registry:[],addToRegistry:function(infotip){this._registry.push(infotip);},closeAllOpen:function(){this._registry.each(function(infotip){infotip.close();});}});namespacing.init('istock.templates');istock.templates.spinner=new Template('<img id="#{id}" src="/static/images/loading.gif" class="#{cls}">');
