var myLytebox;var update_shop_cart;var close_lytebox;var doLogOutFunction;var doLoggedinFunction;var current_category;var productRM;var historykey='perlas';var firstload=true;function inArray(arrayObj,value){for(var index=0;index<arrayObj.length;index++){if(arrayObj[index]==value){return index;}}return false;}var build_monperla=function(){var activeMainMenuItem=null;var currentPage=0;var selectedFilters=null;var selectedProduct=null;var selectedSellProperties=null;var pageTracker;var gaJsHost=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");new Asset.javascript(gaJsHost+"google-analytics.com/ga.js",{onload:function(){pageTracker=_gat._getTracker("UA-3241656-1");pageTracker._initData();pageTracker._trackPageview();}});initLytebox();function add_to_cart(productid,selectedSellProperties){var requestParams=(selectedSellProperties!=null)?'sellProperties='+JSON.encode(selectedSellProperties):'';var request=new Request.JSON({url:baseurl+'index.php/shopcart/add/'+productid+'/'+currentlang,data:requestParams,onComplete:function(jsonObj){update_shop_cart();var link=document.createElement("a");link.setAttribute('rel','lyteframe');link.setAttribute('rev','width:600px;height:500px;scrolling: auto;');link.setAttribute('href',baseurl+'index.php/shopcart/show_detailed/'+currentlang);link.setAttribute('title','');myLytebox.start(link,false,true);pageTracker._trackPageview("/cart/add_producto/");}}).send();}function doLoggedin(){var request=new Request.JSON({url:baseurl+'index.php/system/isloggedin/'+currentlang,onSuccess:function(jsonObj){if(jsonObj.authenticated==true){var loginBox=$('yoo-login');if($defined(loginBox)){loginBox.dispose();}var userinfo=$('user-info');if($defined(userinfo)){userinfo.dispose();}var userName=jsonObj.userName;if(userName){var nameParts=userName.split(' ');userName=nameParts[0];}var userMenu=new Element('div',{'id':'user-info','html':'<div style="float:left;margin:auto 10px; color:#FFFFFF; font-weight:bold;">'+lang['userinfo_hello']+' '+userName+'!!! </div>'+'<div style="float:left;margin:auto 5px;"> | <a href="'+baseurl+'index.php/client/personal_data/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 500px; scrolling: auto;">'+lang['userinfo_mydata']+'</a></div>'+'<div style="float:left;margin:auto 5px;"> | <a href="'+baseurl+'index.php/client/mis_pedidos/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 500px; scrolling: auto;">'+lang['userinfo_myorders']+'</a></div>'+'<div style="float:left;margin:auto 5px;"> | <a href="'+baseurl+'index.php/shopcart/show_detailed/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 500px; scrolling: auto;">'+lang['userinfo_mycart']+'</a></div>'+'<div style="float:left;margin:auto 5px;"> | <a href="#" id="logout">'+lang['userinfo_logout']+'</a></div>'});var topModule=$('topmodule');topModule.grab(userMenu);var logoutBtn=$('logout');logoutBtn.addEvent('click',doLogout);myLytebox.updateLyteboxItems();}}}).send();}function doLogin(e){e.stop();var userName=$('mod_login_username');var userPasswd=$('mod_login_password');var request=new Request.JSON({url:baseurl+'index.php/system/login/'+currentlang,data:'username='+userName.get('value')+'&passwd='+userPasswd.get('value'),onSuccess:function(jsonObj){if(jsonObj.authenticated==1){var loginBox=$('yoo-login');if($defined(loginBox)){loginBox.dispose();}var userName=jsonObj.userName;if(userName){var nameParts=userName.split(' ');userName=nameParts[0];}var userMenu=new Element('div',{'id':'user-info','html':'<div style="float:left;margin:auto 10px; color:#FFFFFF; font-weight:bold;">'+lang['userinfo_hello']+' '+userName+'!!! </div>'+'<div style="float:left;margin:auto 5px;"> | <a href="'+baseurl+'index.php/client/personal_data/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 500px; scrolling: auto;">'+lang['userinfo_mydata']+'</a></div>'+'<div style="float:left;margin:auto 5px;"> | <a href="'+baseurl+'index.php/client/mis_pedidos/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 500px; scrolling: auto;">'+lang['userinfo_myorders']+'</a></div>'+'<div style="float:left;margin:auto 5px;"> | <a href="'+baseurl+'index.php/shopcart/show_detailed/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 500px; scrolling: auto;">'+lang['userinfo_mycart']+'</a></div>'+'<div style="float:left;margin:auto 5px;"> | <a href="#" id="logout">'+lang['userinfo_logout']+'</a></div>'});var topModule=$('topmodule');topModule.grab(userMenu);var logoutBtn=$('logout');logoutBtn.addEvent('click',doLogout);myLytebox.updateLyteboxItems();pageTracker._trackPageview("/usuario/login");}else{alert(jsonObj.errorMsg);}}}).send();}function doLogout(e){e.stop();var request=new Request.JSON({url:baseurl+'index.php/system/logout/'+currentlang,onComplete:function(jsonObj){if(jsonObj.success){var userInfo=$('user-info');if($defined(userInfo)){userInfo.dispose();}update_top_menu();build_homepage();pageTracker._trackPageview("/usuario/logout");}}}).send();}doLogOutFunction=doLogout;doLoggedinFunction=doLoggedin;function build_mainmenu(){var menu=$('tabs');if($defined(menu)){var menuItems=$('mainmenu_items');if($defined(menuItems))menuItems.dispose();menuItems=new Element('ul',{'id':'mainmenu_items'});var lists=$$('tabs ul');lists.each(function(list){if($defined(list)){list.dispose();}});menu.grab(menuItems);var create_mainmenu_item=function(items){var index=0;items.each(function(itemData){var listItem=new Element('li',{'html':'<a id="mainmenuitem_'+index+'" href="'+itemData.url+'" '+(itemData.target?'target="'+itemData.target+'" ':' ')+(itemData.lightbox?'rel="lyteframe" rev="width: 710px; height: 480px; scrolling: auto;"':'')+' title="'+itemData.title+'" class="'+itemData.classname+'"><span>'+itemData.title+'</span></a>'});menuItems.grab(listItem);index++;});myLytebox.updateLyteboxItems();};var request=new Request.JSON({url:baseurl+'index.php/get/mainmenu/'+currentlang,onComplete:function(jsonObj){create_mainmenu_item(jsonObj.menuitems);}}).send();}}function show_search(text_to_search,page){if(!page){page=0;}delete selectedFilters;selectedFilters=new Array();if(text_to_search==''){alert(lang['error_notext']);}else{var content=$('homepage');if($defined(content)){var content=$('content');var content_items=$('content_items');if($defined(content_items))content_items.dispose();content_items=new Element('div',{'id':'content_items'});content.grab(content_items);var content_wrap=$('content_wrap');if($defined(content_wrap))content_wrap.dispose();var center_layer=new Element('div',{'id':'center'});var right_layer=new Element('div',{'id':'right'});center_layer.grab(new Element('div',{'id':'center_content'}));center_layer.grab(new Element('div',{'id':'last_products_seen','html':'<div class="div_big_top2"></div>'+'<div style="clear:both"></div>'+'<div class="big_tab">'+'  <div style="padding-left:10px;">'+'    <div id="last_products_seen_list" style="padding-left:9px; padding-right:10px; text-align:left; height: 80px;"></div>'+'  </div>'+'</div>'+'<div style="clear:both"></div>'+'<div class="div_big_bottom2">'+'  <div class="small_txt" style="float:right; padding-right:10px; width:180px; ">'+lang['catalog_productsseen']+'</div>'+'</div>'}));content_items.grab(center_layer);content_items.grab(right_layer);show_shopping_cart_panel(right_layer);show_banners_panel(right_layer);show_search_filters_panel(text_to_search,right_layer);show_searched_products(text_to_search,page,selectedFilters,'center_content');show_last_seen_products('last_products_seen_list');}else{show_searched_products(text_to_search,page,selectedFilters,'center_content');update_shop_cart();var right_layer=$('right');show_search_filters_panel(text_to_search,right_layer);}}}function show_searched_products(text_to_search,page,filters,container){var category_items=$('category_content');if($defined(category_items))category_items.dispose();var show_searched_products_list=function(category){var totalPages=0;currentPage=page;var right_layer=$('right');var related_products_panel=$('related_products_panel');if($defined(related_products_panel)&&related_products_panel.getStyle('display')!='none'){show_search_filters_panel(text_to_search,right_layer);}var containerElements=$$('div#'+container+' div');containerElements.each(function(el){el.dispose();});var containerEl=$(container);var category_items=$('category_content');if($defined(category_items))category_items.dispose();category_items=new Element('div',{'id':'category_content'});category_items.set('opacity',0);if(!category||category.products.length==0){alert(lang['catalog_noresult']);}if(!category||category.products.length>0){var top_nav_bar=new Element('div',{'class':'navigation','html':'<div class="anterior"><a href="#">&lt;&lt; '+lang['catalog_prev']+'</a></div>'+'<div class="pendientes">'+lang['catalog_category']+': '+category.title+' </div>'+'<div class="siguiente"><a href="#">'+lang['catalog_next']+' &gt;&gt;</a></div>'});var separator=new Element('div',{'styles':{'clear':'both'}});containerEl.grab(top_nav_bar);totalPages=category.totalPages;var pageList=$$('div.navigation div.pendientes');for(var index=0;index<category.totalPages;index++){var pageLink;if(index==category.page){pageLink=new Element('a',{'href':'#','class':'selected','html':index+1});}else{pageLink=new Element('a',{'href':'#','html':index+1});}pageList[0].grab(pageLink);}}containerEl.grab(category_items);if(separator&&$defined(separator)){category_items.grab(separator.clone());}index=0;category.products.each(function(productInfo){var product;var cornnerprice=0;var normalprice=productInfo.price;var cornnerhtml='';var oldpriceclass='';if(productInfo.before_price&&productInfo.before_price!='0'){normalprice=productInfo.before_price;cornnerprice=productInfo.price;cornnerhtml='<div  id="cornnerLink_'+productInfo.id+'" class="cornnerprice">'+lang['catalog_offer']+' '+cornnerprice+'&euro;</div>';oldpriceclass='oldprice';}var model=productInfo.model?'['+productInfo.model+'] ':'';initLytebox();if(index%2==0){if(productInfo.gotocontact!=1){product=new Element('div',{'id':'categoryProduct_'+productInfo.id,'class':'categoria_tab','html':'<div class="categoryProduct"><a id="showDetailsImage_'+productInfo.id+'" href="#" style="display:block;border:3px solid #FFFFFF; width:264px; height:198px"><img src="'+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_2.png')+'" alt="" width="264" height="198" /></a>'+cornnerhtml+'</div>'+'<div class="btnlink2"><a   id="buynow_'+productInfo.id+'" href="#"></a></div>'+'<div class="btnlink"><a   id="showDetails_'+productInfo.id+'" href="#">'+lang['catalog_details']+'</a></div>'+'<div class="div_fill">'+'  <div class="div_fill_text">'+model+productInfo.name+'</div>'+'</div>'+'<div class="div_bottom">'+'  <div style="float:right">'+'    <div class="pinkbg2"></div>'+'    <div class="pinkbg"></div>'+'    <div class="graybgbutton '+oldpriceclass+'">'+normalprice+'&euro;</div>'+'  </div>'+'</div>'});}else{product=new Element('div',{'id':'categoryProduct_'+productInfo.id,'class':'categoria_tab','html':'<div class="categoryProduct"><a id="showDetailsImage_'+productInfo.id+'" href="#" style="display:block;border:3px solid #FFFFFF; width:264px; height:198px"><img src="'+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_2.png')+'" alt="" width="264" height="198" /></a>'+cornnerhtml+'</div>'+'<div class="btnlink2contact"><a id="contactnow_'+productInfo.id+'" rel="lyteframe" rev="width:700px;height:450px;scrolling: auto;" href="'+baseurl+'resources/information/'+currentlang+'/productcontact.php?id='+productInfo.id+'&name='+productInfo.name+'&reference='+productInfo.reference+'&model='+productInfo.model+'" style="color:#ffffff; text-decoration:none"></a></div>'+'<div class="btnlinkcontact"><a id="showDetails_'+productInfo.id+'" href="#">'+lang['catalog_details']+'</a></div>'+'<div class="div_fill">'+'  <div class="div_fill_text">'+model+productInfo.name+'</div>'+'</div>'+'<div class="div_bottom">'+'  <div style="float:right">'+'    <div class="pinkbg2contact"></div>'+'    <div class="pinkbgcontact"></div>'+'  </div>'+'</div>'});}}else{if(productInfo.gotocontact!=1){product=new Element('div',{'id':'categoryProduct_'+productInfo.id,'class':'categoria_tab','html':'<div class="categoryProduct"><a id="showDetailsImage_'+productInfo.id+'" href="#" style="display:block;border:3px solid #FFFFFF; width:264px; height:198px"><img src="'+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_2.png')+'" alt="" width="264" height="198" /></a>'+cornnerhtml+'</div>'+'<div class="btnlink2"><a   id="buynow_'+productInfo.id+'" href="#"></a></div>'+'<div class="btnlink"><a   id="showDetails_'+productInfo.id+'" href="#">'+lang['catalog_details']+'</a></div>'+'<div class="div_fill">'+'  <div class="div_fill_text">'+model+productInfo.name+'</div>'+'</div>'+'<div class="div_bottom">'+'  <div style="float:right">'+'    <div class="pinkbg2"></div>'+'    <div class="pinkbg"></div>'+'    <div class="graybgbutton '+oldpriceclass+'">'+normalprice+'&euro;</div>'+'  </div>'+'</div>','styles':{'margin-right':'0px'}});}else{product=new Element('div',{'id':'categoryProduct_'+productInfo.id,'class':'categoria_tab','html':'<div class="categoryProduct"><a id="showDetailsImage_'+productInfo.id+'" href="#" style="display:block;border:3px solid #FFFFFF; width:264px; height:198px"><img src="'+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_2.png')+'" alt="" width="264" height="198" /></a>'+cornnerhtml+'</div>'+'<div class="btnlink2contact"><a id="contactnow_'+productInfo.id+'" rel="lyteframe" rev="width:700px;height:450px;scrolling: auto;" href="'+baseurl+'resources/information/'+currentlang+'/productcontact.php?id='+productInfo.id+'&name='+productInfo.name+'&reference='+productInfo.reference+'&model='+productInfo.model+'" style="color:#ffffff; text-decoration:none"></a></div>'+'<div class="btnlinkcontact"><a   id="showDetails_'+productInfo.id+'" href="#">'+lang['catalog_details']+'</a></div>'+'<div class="div_fill">'+'  <div class="div_fill_text">'+model+productInfo.name+'</div>'+'</div>'+'<div class="div_bottom">'+'  <div style="float:right">'+'    <div class="pinkbg2contact"></div>'+'    <div class="pinkbgcontact"></div>'+'  </div>'+'</div>','styles':{'margin-right':'0px'}});}}category_items.grab(product);var productDetailsLink=$('showDetails_'+productInfo.id);if($defined(productDetailsLink)){productDetailsLink.set('style','color:#ffffff; text-decoration:none');productDetailsLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}var productDetailsLink=$('showDetailsImage_'+productInfo.id);if($defined(productDetailsLink)){productDetailsLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}var buynowLink=$('buynow_'+productInfo.id);if($defined(buynowLink)){if(productInfo.hassellprops){buynowLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}else{buynowLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);add_to_cart(productID,'');});}}var cornnerLink=$('cornnerLink_'+productInfo.id);if($defined(cornnerLink)){cornnerLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}if(index%2!=0){var separator8px=separator.clone();separator8px.set('style','clear:both; height:8px;');category_items.grab(separator8px);}index++;});if(category.products.length>0){var bottom_nav_bar=top_nav_bar.clone();bottom_nav_bar.set('style','padding-top: 10px');category_items.grab(separator.clone());category_items.grab(separator.clone());category_items.grab(bottom_nav_bar);category_items.grab(separator.clone());var prevBtns=$$('div.navigation div.anterior a');prevBtns.each(function(btn){if(currentPage!=0){btn.set('opacity',1);btn.addEvent('click',function(e){e.stop();show_searched_products(text_to_search,currentPage-1,selectedFilters,'center_content');productRM.setValues(['buscar_joyas',text_to_search,currentPage-1]);});}else{btn.set('opacity',0);}});var nextBtns=$$('div.navigation div.siguiente a');nextBtns.each(function(btn){if(currentPage+1<totalPages){btn.set('opacity',1);btn.addEvent('click',function(e){e.stop();show_searched_products(text_to_search,currentPage+1,selectedFilters,'center_content');productRM.setValues(['buscar_joyas',text_to_search,currentPage+1]);});}else{btn.set('opacity',0);}});var pageLinks=$$('div.navigation div.pendientes a');pageLinks.each(function(btn){btn.addEvent('click',function(e){e.stop();var linkIDParts=this.get('html');var linkID=parseInt(linkIDParts,10)-1;show_searched_products(text_to_search,linkID,selectedFilters,'center_content');productRM.setValues(['buscar_joyas',text_to_search,linkID]);});});category_items.fade('in');}}var requestParams='operator='+searchOp+((selectedFilters!=null)?'&filters='+JSON.encode(selectedFilters):'');var request=new Request.JSON({url:baseurl+'index.php/categories/show_search/'+text_to_search+'/'+page+'/'+currentlang,data:requestParams,onComplete:function(jsonObj){show_searched_products_list(jsonObj);if(page==0){if(searchOp!='all'){pageTracker._trackPageview("/catalog/busqueda_interna.html?s="+text_to_search);}else{pageTracker._trackPageview("/catalog/busqueda_adwords");}}else{if(searchOp!='all'){pageTracker._trackPageview("/catalog/busqueda_interna.html?s="+text_to_search+'&p='+page);}else{pageTracker._trackPageview("/catalog/busqueda_adwords/"+page);}}}}).send();}function show_search_filters_panel(text_to_search,containerEl){delete selectedFilters;selectedFilters=new Array();var related_products_panel=$('related_products_panel');if($defined(related_products_panel)){related_products_panel.set('style','display:none');}var filters_panel=$('filters_panel');if(!$defined(filters_panel)){var filters_panel=new Element('div',{'id':'filters_panel','html':'<div class="div_compra_top"></div>'+'<div class="compra_tab">'+'  <div class="compra_title">'+lang['catalog_filters']+'</div>'+'  <div class="compra_list" id="properties">'+'  </div>'+'</div>'+'<div style="clear:both"></div>'+'<div class="div_compra_bottom"></div>'});filters_panel.set('opacity',0);containerEl.grab(filters_panel);}filters_panel.set('style','');var filtersList=$$('div#properties div');filtersList.each(function(filter){filter.dispose();});filtersList=$('properties');var create_filters=function(properties){properties.each(function(property){var propertyFilter=new Element('div',{'html':'    <div class="compra_right3">'+property.name+' (<a class="pink" style="text-decoration:none;" href="'+baseurl+'index.php/properties/info/'+property.id+'" rel="lyteframe" rev="width:'+((property.width=='')?'300':property.width)+'px; height:'+((property.height=='')?'250':property.height)+'px; scrolling:auto;" id="showpropinfo_'+property.id+'">'+lang['catalog_moreinfo']+'</a>)</div>'+'    <div style="clear:both"></div>'+'    <div class="compra_border"></div>'+'    <div id="property_'+property.id+'_fields"">'+'    </div>'+'    <div style="clear:both; height:10px;"></div>'});filtersList.grab(propertyFilter);if(property.type==1){var fields=$('property_'+property.id+'_fields');var propertyItem=new Element('div',{'id':'property_'+property.id,'class':'gutter','html':'<div id="minKnobA_'+property.id+'" class="knob"></div>'+'<div id="maxKnobA_'+property.id+'" class="knob"></div>'});fields.grab(new Element('label',{'id':'propertylabel_'+property.id,'for':'property_'+property.id}));fields.grab(propertyItem);$('propertylabel_'+property.id).set('html',lang['catalog_between']+'Entre: '+property.min+lang['catalog_and']+property.max);var mySlideA=new Slider2($('property_'+property.id),$('minKnobA_'+property.id),{start:parseInt(property.min,10),end:parseInt(property.max,10),offset:0,knobheight:16,onChange:function(pos){var nameParts=this.element.id.split('_');var propertyID=parseInt(nameParts[1],10);$('propertylabel_'+propertyID).set('html',lang['catalog_between']+pos.minpos+lang['catalog_and']+pos.maxpos);},onComplete:function(pos){var nameParts=this.element.id.split('_');var propertyID=parseInt(nameParts[1],10);$('propertylabel_'+propertyID).set('html',lang['catalog_between']+pos.minpos+lang['catalog_and']+pos.maxpos);var filterObj={'propertyid':propertyID,'datatype':1,'min':pos.minpos,'max':pos.maxpos};selectedFilters[propertyID]=filterObj;show_searched_products(text_to_search,0,selectedFilters,'center_content');}},$('maxKnobA_'+property.id));}else if(property.type==3){var fields=$('property_'+property.id+'_fields');var inputData;property.items.each(function(item){if(property.selectionType==0){inputData='<input name="property_'+property.id+'[]" id="property_'+property.id+'_'+item.id+'" type="radio" value="'+item.id+'" />'+item.name}else{inputData='<input name="property_'+property.id+'[]" id="property_'+property.id+'_'+item.id+'" type="checkbox" value="'+item.id+'" />'+item.name}var propertyItem=new Element('div',{'html':inputData,'styles':{'float':'left','margin-right':'10px','white-space':'nowrap'}});fields.grab(propertyItem);var field=$('property_'+property.id+'_'+item.id);field.addEvent('click',function(e){var nameParts=this.id.split('_');var propertyID=parseInt(nameParts[1],10);var fieldID=parseInt(nameParts[2],10);if(selectedFilters[propertyID]==null){var filterObj={'propertyid':propertyID,'datatype':3,'fields':[]};selectedFilters[propertyID]=filterObj;}var indexOfField=inArray(selectedFilters[propertyID].fields,fieldID);if(this.checked){if(indexOfField===false){selectedFilters[propertyID].fields.push(fieldID);}}else{if(indexOfField!==false){selectedFilters[propertyID].fields.splice(indexOfField,1);}}show_searched_products(text_to_search,0,selectedFilters,'center_content');});});}});myLytebox.updateLyteboxItems();if(properties.length==0){filters_panel.set('style','display:none');}filters_panel.fade('in');};var request=new Request.JSON({url:baseurl+'index.php/categories/properties/-1/'+currentlang,onComplete:function(jsonObj){create_filters(jsonObj.properties);}}).send();}function show_category(categoryID,page){if(!page){page=0;}delete selectedFilters;selectedFilters=new Array();if(categoryID==0){build_homepage();pageTracker._trackPageview("/catalog/home_page");}else{var content=$('homepage');if($defined(content)){var content=$('content');var content_items=$('content_items');if($defined(content_items))content_items.dispose();content_items=new Element('div',{'id':'content_items'});content.grab(content_items);var content_wrap=$('content_wrap');if($defined(content_wrap))content_wrap.dispose();var center_layer=new Element('div',{'id':'center'});var right_layer=new Element('div',{'id':'right'});center_layer.grab(new Element('div',{'id':'center_content'}));center_layer.grab(new Element('div',{'id':'last_products_seen','html':'<div class="div_big_top2"></div>'+'<div style="clear:both"></div>'+'<div class="big_tab">'+'  <div style="padding-left:10px;">'+'    <div id="last_products_seen_list" style="padding-left:9px; padding-right:10px; text-align:left; height: 80px;"></div>'+'  </div>'+'</div>'+'<div style="clear:both"></div>'+'<div class="div_big_bottom2">'+'  <div class="small_txt" style="float:right; padding-right:10px; width:180px; ">'+lang['catalog_productsseen']+'</div>'+'</div>'}));content_items.grab(center_layer);content_items.grab(right_layer);show_shopping_cart_panel(right_layer);show_banners_panel(right_layer);show_filters_panel(categoryID,right_layer);show_category_products(categoryID,page,selectedFilters,'center_content');show_last_seen_products('last_products_seen_list');}else{show_category_products(categoryID,page,selectedFilters,'center_content');update_shop_cart();var right_layer=$('right');show_filters_panel(categoryID,right_layer);}}}function category_layout(){delete selectedFilters;selectedFilters=new Array();var content=$('homepage');if($defined(content)){var content=$('content');var content_items=$('content_items');if($defined(content_items))content_items.dispose();content_items=new Element('div',{'id':'content_items'});content.grab(content_items);var content_wrap=$('content_wrap');if($defined(content_wrap))content_wrap.dispose();var center_layer=new Element('div',{'id':'center'});var right_layer=new Element('div',{'id':'right'});center_layer.grab(new Element('div',{'id':'center_content'}));center_layer.grab(new Element('div',{'id':'last_products_seen','html':'<div class="div_big_top2"></div>'+'<div style="clear:both"></div>'+'<div class="big_tab">'+'  <div style="padding-left:10px;">'+'    <div id="last_products_seen_list" style="padding-left:9px; padding-right:10px; text-align:left; height: 80px;"></div>'+'  </div>'+'</div>'+'<div style="clear:both"></div>'+'<div class="div_big_bottom2">'+'  <div class="small_txt" style="float:right; padding-right:10px; width:180px; ">'+lang['catalog_productsseen']+'</div>'+'</div>'}));content_items.grab(center_layer);content_items.grab(right_layer);show_shopping_cart_panel(right_layer);show_banners_panel(right_layer);show_last_seen_products('last_products_seen_list');}}function show_filters_panel(categoryID,containerEl){delete selectedFilters;selectedFilters=new Array();var related_products_panel=$('related_products_panel');if($defined(related_products_panel)){related_products_panel.set('style','display:none');}var filters_panel=$('filters_panel');if(!$defined(filters_panel)){var filters_panel=new Element('div',{'id':'filters_panel','html':'<div class="div_compra_top"></div>'+'<div class="compra_tab">'+'  <div class="compra_title">'+lang['catalog_filters']+'</div>'+'  <div class="compra_list" id="properties">'+'  </div>'+'</div>'+'<div style="clear:both"></div>'+'<div class="div_compra_bottom"></div>'});filters_panel.set('opacity',0);containerEl.grab(filters_panel);}filters_panel.set('style','');var filtersList=$$('div#properties div');filtersList.each(function(filter){filter.dispose();});filtersList=$('properties');var create_filters=function(properties){properties.each(function(property){var propertyFilter=new Element('div',{'html':'    <div class="compra_right3">'+property.name+' (<a class="pink" style="text-decoration:none;" href="'+baseurl+'index.php/properties/info/'+property.id+'/'+currentlang+'" rel="lyteframe" rev="width:'+((property.width=='')?'300':property.width)+'px; height:'+((property.height=='')?'250':property.height)+'px; scrolling:auto;" id="showpropinfo_'+property.id+'">'+lang['catalog_moreinfo']+'</a>)</div>'+'    <div style="clear:both"></div>'+'    <div class="compra_border"></div>'+'    <div id="property_'+property.id+'_fields"">'+'    </div>'+'    <div style="clear:both; height:10px;"></div>'});filtersList.grab(propertyFilter);if(property.type==1){var fields=$('property_'+property.id+'_fields');var propertyItem=new Element('div',{'id':'property_'+property.id,'class':'gutter','html':'<div id="minKnobA_'+property.id+'" class="knob"></div>'+'<div id="maxKnobA_'+property.id+'" class="knob"></div>'});fields.grab(new Element('label',{'id':'propertylabel_'+property.id,'for':'property_'+property.id}));fields.grab(propertyItem);$('propertylabel_'+property.id).set('html','Entre: '+property.min+' y '+property.max);var mySlideA=new Slider2($('property_'+property.id),$('minKnobA_'+property.id),{start:parseInt(property.min,10),end:parseInt(property.max,10),offset:0,knobheight:16,onChange:function(pos){var nameParts=this.element.id.split('_');var propertyID=parseInt(nameParts[1],10);$('propertylabel_'+propertyID).set('html',lang['catalog_between']+pos.minpos+lang['catalog_and']+pos.maxpos);},onComplete:function(pos){var nameParts=this.element.id.split('_');var propertyID=parseInt(nameParts[1],10);$('propertylabel_'+propertyID).set('html',lang['catalog_between']+pos.minpos+lang['catalog_and']+pos.maxpos);var filterObj={'propertyid':propertyID,'datatype':1,'min':pos.minpos,'max':pos.maxpos};selectedFilters[propertyID]=filterObj;show_category_products(categoryID,0,selectedFilters,'center_content');}},$('maxKnobA_'+property.id));}else if(property.type==3){var fields=$('property_'+property.id+'_fields');var inputData;property.items.each(function(item){if(property.selectionType==0){inputData='<input name="property_'+property.id+'[]" id="property_'+property.id+'_'+item.id+'" type="radio" value="'+item.id+'" />'+item.name}else{inputData='<input name="property_'+property.id+'[]" id="property_'+property.id+'_'+item.id+'" type="checkbox" value="'+item.id+'" />'+item.name}var propertyItem=new Element('div',{'html':inputData,'styles':{'float':'left','margin-right':'10px','white-space':'nowrap'}});fields.grab(propertyItem);var field=$('property_'+property.id+'_'+item.id);field.addEvent('click',function(e){var nameParts=this.id.split('_');var propertyID=parseInt(nameParts[1],10);var fieldID=parseInt(nameParts[2],10);if(selectedFilters[propertyID]==null){var filterObj={'propertyid':propertyID,'datatype':3,'fields':[]};selectedFilters[propertyID]=filterObj;}var indexOfField=inArray(selectedFilters[propertyID].fields,fieldID);if(this.checked){if(indexOfField===false){selectedFilters[propertyID].fields.push(fieldID);}}else{if(indexOfField!==false){selectedFilters[propertyID].fields.splice(indexOfField,1);}}show_category_products(categoryID,0,selectedFilters,'center_content');});});}});myLytebox.updateLyteboxItems();if(properties.length==0){filters_panel.set('style','display:none');}filters_panel.fade('in');};var request=new Request.JSON({url:baseurl+'index.php/categories/properties/'+categoryID+'/'+currentlang,onComplete:function(jsonObj){create_filters(jsonObj.properties);}}).send();}function show_banners_panel(containerEl){var banners_panel=new Element('div',{'id':'banners_panel','html':'<div class="div_compra_top"></div>'+'<div class="compra_tab">'+'  <div style="text-align:center" ><a href="'+baseurl+'index.php/'+currentlang+'/coupons" rel="lyteframe" rev="width: 650px; height: 500px; scrolling: auto;" style="text-decoration:none; font-size:10px;" class="pink"><img src="'+baseurl+'images/bannerf.gif" alt="'+lang['catalog_shopcart']+'" style="padding-bottom:0px" /></a>'+'  </div><br/>'+'  <div style="text-align:center" ><a href="'+baseurl+'resources/information/'+currentlang+'/faqs.html" rel="lyteframe" rev="width: 650px; height: 500px; scrolling: auto;" style="text-decoration:none; font-size:10px;" class="pink"><img src="'+baseurl+'images/faqs.gif" alt="Faqss" style="padding-bottom:0px" /></a>'+'  </div><br/>'+'  <div style="text-align:center" ><a target="_blank" href="http://www.youtube.com/user/Monperla"  style="text-decoration:none; font-size:10px;" class="pink"><img src="'+baseurl+'images/youtube.gif" alt="youtube monperla" style="padding-bottom:0px" /></a>'+'  </div><br/>'+'  <div style="text-align:center" ><a target="_blank" href="http://perlascultivadas.es"  style="text-decoration:none; font-size:10px;" class="pink"><img src="'+baseurl+'images/blog.gif" alt="blog monperla" style="padding-bottom:0px" /></a>'+'  </div>'+'<br/><div  style="text-align:center" >Bolet&iacute;n de Ofertas</div>'+'<div  style="text-align:center" >'+'<form target="_blank" method="post" action="http://visitor.constantcontact.com/d.jsp" name="ccoptin">'+'Email: <input type="text" style="border: 1px solid rgb(153, 153, 153); font-family: Arial; font-size: 10px;" value="" size="14" name="ea"/> <input type="submit" style="font-family: Arial,Helvetica,sans-serif; font-size: 11px;" value="Ãšnase" name="go"/>'+'<input type="hidden" value="1102359044589" name="m"/>'+'<input type="hidden" value="oi" name="p"/>'+'</form>'+'</div>'+'</div>'+'<div style="clear:both"></div>'+'<div class="div_compra_bottom"></div>'+'<div style="clear:both; padding-bottom:6px;"></div>'});containerEl.grab(banners_panel);myLytebox.updateLyteboxItems();}function show_shopping_cart_panel(containerEl){var shop_cart=new Element('div',{'id':'shop_cart_panel','html':'<div class="div_compra_top"></div>'+'<div class="compra_tab">'+'  <div class="btnconfirmlink"><a href="'+baseurl+'index.php/request/confirm/'+currentlang+'" rel="lyteframe" rev="width:600px; height:500px; scrolling: auto;" style="z-index: 100000000;">'+lang['catalog_confirmorder']+'</a></div>'+'  <div style="float:right; padding-right:10px;"><a href="'+baseurl+'index.php/shopcart/show_detailed/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 500px; scrolling: auto;" style="text-decoration:none; font-size:10px;" class="pink"><img src="'+baseurl+'images/cart.gif" alt="'+lang['catalog_shopcart']+'" /></a></div>'+'  <div class="compra_title">'+lang['catalog_bag']+' (<a href="'+baseurl+'index.php/shopcart/show_detailed/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 500px; scrolling: auto;" style="text-decoration:none; font-size:10px;" class="pink">'+lang['catalog_viewcart']+'</a>)</div>'+'  <div class="compra_list">'+'    <div class="compra_left">'+lang['catalog_model']+'</div>'+'    <div class="compra_middle">'+lang['catalog_qty']+'</div>'+'    <div class="compra_right">'+lang['catalog_price']+'</div>'+'    <div style="clear:both"></div>'+'    <div class="compra_border"></div>'+'    <div id="shop_cart_products_list">'+'    </div>'+'    <div class="compra_border"></div>'+'    <div class="compra_left">'+lang['catalog_total']+'</div>'+'    <div class="compra_middle">&nbsp;</div>'+'    <div class="compra_right" id="cart_import"></div>'+'    <div style="clear:both; padding-bottom:10px;"></div>'+'  </div>'+'  <div class="confirmar"></div>'+'</div>'+'<div style="clear:both"></div>'+'<div class="div_compra_bottom"></div>'+'<div style="clear:both; padding-bottom:6px;"></div>'});shop_cart.set('style','display:none');shop_cart.set('opacity',0);containerEl.grab(shop_cart);myLytebox.updateLyteboxItems();update_shop_cart();}function show_category_products(categoryID,page,filters,container){var category_items=$('category_content');if($defined(category_items))category_items.dispose();var show_category_products_list=function(category){var totalPages=0;currentPage=page;var right_layer=$('right');var related_products_panel=$('related_products_panel');if($defined(related_products_panel)&&related_products_panel.getStyle('display')!='none'){show_filters_panel(categoryID,right_layer);}var containerElements=$$('div#'+container+' div');containerElements.each(function(el){el.dispose();});var containerEl=$(container);var category_items=$('category_content');if($defined(category_items))category_items.dispose();category_items=new Element('div',{'id':'category_content'});category_items.set('opacity',0);if(category.products.length>0){var top_nav_bar=new Element('div',{'class':'navigation','html':'<div class="anterior"><a href="#">&lt;&lt; '+lang['catalog_prev']+'</a></div>'+'<div class="pendientes">'+lang['catalog_category']+': '+category.title+' </div>'+'<div class="siguiente"><a href="#">'+lang['catalog_next']+' &gt;&gt;</a></div>'});var separator=new Element('div',{'styles':{'clear':'both'}});containerEl.grab(top_nav_bar);totalPages=category.totalPages;var pageList=$$('div.navigation div.pendientes');for(var index=0;index<category.totalPages;index++){var pageLink;if(index==category.page){pageLink=new Element('a',{'href':'#','class':'selected','html':index+1});}else{pageLink=new Element('a',{'href':'#','html':index+1});}pageList[0].grab(pageLink);}}containerEl.grab(category_items);if(separator&&$defined(separator)){category_items.grab(separator.clone());}index=0;category.products.each(function(productInfo){var product;var cornnerprice=0;var normalprice=productInfo.price;var cornnerhtml='';var oldpriceclass='';if(productInfo.before_price&&productInfo.before_price!='0'){normalprice=productInfo.before_price;cornnerprice=productInfo.price;cornnerhtml='<div  id="cornnerLink_'+productInfo.id+'" class="cornnerprice">'+lang['catalog_offer']+' '+cornnerprice+'&euro;</div>';oldpriceclass='oldprice';}var soldout='';if(productInfo.stock<=0){soldout='<div  class="soldout">'+lang['product_soldout']+'</div>';cornnerhtml='';}var model=productInfo.model?'['+productInfo.model+'] ':'';initLytebox();if(index%2==0){if(productInfo.gotocontact!=1&&productInfo.stock>0){product=new Element('div',{'id':'categoryProduct_'+productInfo.id,'class':'categoria_tab','html':'<div class="categoryProduct"><a id="showDetailsImage_'+productInfo.id+'" href="#" style="display:block;border:3px solid #FFFFFF; width:264px; height:198px"><img src="'+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_2.png')+'" alt="" width="264" height="198" /></a>'+cornnerhtml+soldout+'</div>'+'<div class="btnlink2"><a   id="buynow_'+productInfo.id+'" href="#"></a></div>'+'<div class="btnlink"><a   id="showDetails_'+productInfo.id+'" href="#">'+lang['catalog_details']+'</a></div>'+'<div class="div_fill">'+'  <div class="div_fill_text">'+model+productInfo.name+'</div>'+'</div>'+'<div class="div_bottom">'+'  <div style="float:right">'+'    <div class="pinkbg2"></div>'+'    <div class="pinkbg"></div>'+'    <div class="graybgbutton '+oldpriceclass+'">'+normalprice+'&euro;</div>'+'  </div>'+'</div>'});}else{product=new Element('div',{'id':'categoryProduct_'+productInfo.id,'class':'categoria_tab','html':'<div class="categoryProduct"><a id="showDetailsImage_'+productInfo.id+'" href="#" style="display:block;border:3px solid #FFFFFF; width:264px; height:198px"><img src="'+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_2.png')+'" alt="" width="264" height="198" /></a>'+cornnerhtml+soldout+'</div>'+'<div class="btnlink2contact"><a id="contactnow_'+productInfo.id+'" rel="lyteframe" rev="width:700px;height:450px;scrolling: auto;" href="'+baseurl+'resources/information/'+currentlang+'/productcontact.php?id='+productInfo.id+'&name='+productInfo.name+'&reference='+productInfo.reference+'&model='+productInfo.model+'" style="color:#ffffff; text-decoration:none"></a></div>'+'<div class="btnlinkcontact"><a id="showDetails_'+productInfo.id+'" href="#">'+lang['catalog_details']+'</a></div>'+'<div class="div_fill">'+'  <div class="div_fill_text">'+model+productInfo.name+'</div>'+'</div>'+'<div class="div_bottom">'+'  <div style="float:right">'+'    <div class="pinkbg2contact"></div>'+'    <div class="pinkbgcontact"></div>'+'  </div>'+'</div>'});}}else{if(productInfo.gotocontact!=1&&productInfo.stock>0){product=new Element('div',{'id':'categoryProduct_'+productInfo.id,'class':'categoria_tab','html':'<div class="categoryProduct"><a id="showDetailsImage_'+productInfo.id+'" href="#" style="display:block;border:3px solid #FFFFFF; width:264px; height:198px"><img src="'+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_2.png')+'" alt="" width="264" height="198" /></a>'+cornnerhtml+soldout+'</div>'+'<div class="btnlink2"><a   id="buynow_'+productInfo.id+'" href="#"></a></div>'+'<div class="btnlink"><a   id="showDetails_'+productInfo.id+'" href="#">'+lang['catalog_details']+'</a></div>'+'<div class="div_fill">'+'  <div class="div_fill_text">'+model+productInfo.name+'</div>'+'</div>'+'<div class="div_bottom">'+'  <div style="float:right">'+'    <div class="pinkbg2"></div>'+'    <div class="pinkbg"></div>'+'    <div class="graybgbutton '+oldpriceclass+'">'+normalprice+'&euro;</div>'+'  </div>'+'</div>','styles':{'margin-right':'0px'}});}else{product=new Element('div',{'id':'categoryProduct_'+productInfo.id,'class':'categoria_tab','html':'<div class="categoryProduct"><a id="showDetailsImage_'+productInfo.id+'" href="#" style="display:block;border:3px solid #FFFFFF; width:264px; height:198px"><img src="'+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_2.png')+'" alt="" width="264" height="198" /></a>'+cornnerhtml+soldout+'</div>'+'<div class="btnlink2contact"><a id="contactnow_'+productInfo.id+'" rel="lyteframe" rev="width:700px;height:450px;scrolling: auto;" href="'+baseurl+'resources/information/'+currentlang+'/productcontact.php?id='+productInfo.id+'&name='+productInfo.name+'&reference='+productInfo.reference+'&model='+productInfo.model+'" style="color:#ffffff; text-decoration:none"></a></div>'+'<div class="btnlinkcontact"><a   id="showDetails_'+productInfo.id+'" href="#">'+lang['catalog_details']+'</a></div>'+'<div class="div_fill">'+'  <div class="div_fill_text">'+model+productInfo.name+'</div>'+'</div>'+'<div class="div_bottom">'+'  <div style="float:right">'+'    <div class="pinkbg2contact"></div>'+'    <div class="pinkbgcontact"></div>'+'  </div>'+'</div>','styles':{'margin-right':'0px'}});}}category_items.grab(product);var productDetailsLink=$('showDetails_'+productInfo.id);if($defined(productDetailsLink)){productDetailsLink.set('style','color:#ffffff; text-decoration:none');productDetailsLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}var productDetailsLink=$('showDetailsImage_'+productInfo.id);if($defined(productDetailsLink)){productDetailsLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}var buynowLink=$('buynow_'+productInfo.id);if($defined(buynowLink)){if(productInfo.hassellprops){buynowLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}else{buynowLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);add_to_cart(productID,'');});}}var cornnerLink=$('cornnerLink_'+productInfo.id);if($defined(cornnerLink)){cornnerLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}if(index%2!=0){var separator8px=separator.clone();separator8px.set('style','clear:both; height:8px;');category_items.grab(separator8px);}index++;});if(category.products.length>0){var bottom_nav_bar=top_nav_bar.clone();bottom_nav_bar.set('style','padding-top: 10px');category_items.grab(separator.clone());category_items.grab(separator.clone());category_items.grab(bottom_nav_bar);category_items.grab(separator.clone());var prevBtns=$$('div.navigation div.anterior a');prevBtns.each(function(btn){if(currentPage!=0){btn.set('opacity',1);btn.addEvent('click',function(e){e.stop();show_category_products(categoryID,currentPage-1,selectedFilters,'center_content');productRM.setValues(['joyas',categoryID,currentPage-1]);});}else{btn.set('opacity',0);}});var nextBtns=$$('div.navigation div.siguiente a');nextBtns.each(function(btn){if(currentPage+1<totalPages){btn.set('opacity',1);btn.addEvent('click',function(e){e.stop();show_category_products(categoryID,currentPage+1,selectedFilters,'center_content');productRM.setValues(['joyas',categoryID,currentPage+1]);});}else{btn.set('opacity',0);}});var pageLinks=$$('div.navigation div.pendientes a');pageLinks.each(function(btn){btn.addEvent('click',function(e){e.stop();var linkIDParts=this.get('html');var linkID=parseInt(linkIDParts,10)-1;show_category_products(categoryID,linkID,selectedFilters,'center_content');productRM.setValues(['joyas',categoryID,linkID]);});});category_items.fade('in');}}var requestParams=(selectedFilters!=null)?'filters='+JSON.encode(selectedFilters):'';var request=new Request.JSON({url:baseurl+'index.php/categories/show/'+categoryID+'/'+page+'/'+currentlang,data:requestParams,onComplete:function(jsonObj){show_category_products_list(jsonObj);pageTracker._trackPageview("/catalog/categoria/"+jsonObj.title);}}).send();}function show_last_seen_products(container){var containerEl=$(container);var show_products_seen=function(data){var links=$$('div#'+container+' a');links.each(function(link){var linkIDParts=link.id.split('_');linkID=parseInt(linkIDParts[1],10);if(!inArray(data.ids,linkID))link.dispose();});if(data.products.length>0){data.products.each(function(product){var thumbs=$(container);if(!$defined($('productseen_'+product.id))){var thumbnail=new Element('a',{'id':'productseen_'+product.id,'href':'#','html':'<img src="'+baseurl+((product.image!=false)?'resources/products/'+product.image:'images/no_image_4.png')+'" width="104" height="78" alt=""/>','styles':{'margin-left':'3px','margin-right':'3px'}});thumbs.grab(thumbnail);var productDetailsLink=$('productseen_'+product.id);if($defined(productDetailsLink)){productDetailsLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}}});}};var request=new Request.JSON({url:baseurl+'index.php/get/products_seen/'+currentlang,onComplete:function(jsonObj){show_products_seen(jsonObj);}}).send();}function show_related_products(productID,container){var containerEl=$(container);var oldthumbs=$$('.related_product');if($defined(oldthumbs))oldthumbs.dispose();var related_products_panel=$('related_products_panel');if(!$defined(related_products_panel)){var related_products_panel=new Element('div',{'id':'related_products_panel','html':'<div class="div_compra_top"></div>'+'<div class="compra_tab">'+'  <div class="compra_title">'+lang['catalog_crosssell']+'</div>'+'  <div id="thumb">'+'  </div>'+'</div>'+'<div style="clear:both"></div>'+'<div class="div_compra_bottom"></div>'});related_products_panel.set('opacity',0);containerEl.grab(related_products_panel);}related_products_panel.set('style','');var thumbs=$$('div#related_products_panel div#thumb img');thumbs.each(function(thumb){thumb.dispose();});var show_thumbs=function(thumbList){if(thumbList.length>0){var thumbs=$$('div#related_products_panel div#thumb');thumbList.each(function(thumbItem){var product_related=$('productrelated_'+thumbItem.id);if(!$defined(product_related)){var thumbnail=new Element('a',{'id':'productrelated_'+thumbItem.id,'class':'related_product','href':'#','html':'<img src="'+baseurl+((thumbItem.image!=false)?'resources/products/'+thumbItem.image:'images/no_image_3.png')+'" width="194" height="145" alt="thumbnail"></img>'});thumbs[0].grab(thumbnail);var productDetailsLink=$('productrelated_'+thumbItem.id);if($defined(productDetailsLink)){productDetailsLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var productID=parseInt(linkIDParts[1],10);productRM.setValues(['joya',productID,0]);show_product(productID);});}}});}};var request=new Request.JSON({url:baseurl+'index.php/products/show_related/'+productID+'/'+currentlang,onComplete:function(jsonObj){if(jsonObj!=null){show_thumbs(jsonObj.thumbnails);}var related_products=$('related_products_panel');related_products.fade('in');}}).send();}function show_product(productID){delete selectedProduct;delete selectedSellProperties;selectedSellProperties=new Array();var show_details=function(productInfo){selectedProduct=productInfo;var timer;var timer1;var check_filters_panel_opacity=function(){var filtersPanel=$('filters_panel');if($defined(filtersPanel)&&filtersPanel.get('opacity')==0){filtersPanel.set('style','display:none');clearInterval(timer);}};var filters_panel=$('filters_panel');if($defined(filters_panel)){filters_panel.fade('out');timer=setInterval(check_filters_panel_opacity,300);}var check_content_panel_opacity=function(){var categoryContentPanel=$('category_content');if($defined(categoryContentPanel)&&categoryContentPanel.get('opacity')==0){categoryContentPanel.dispose();clearInterval(timer1);}};var categoryContentPanel=$('category_content');if($defined(categoryContentPanel)){categoryContentPanel.fade('out');timer1=setInterval(check_content_panel_opacity,300);}var product_soldout='';var estilo_agotado='';if(productInfo.stock==0){estilo_agotado='_agotado';product_soldout='<div id="ver_producto_agotado" class="ver_producto_agotado"><div class="ver_producto_agotado_wrapper">'+lang['product_soldout']+'</div></div>';}var productImageBox=$('product_image_box');if(!$defined(productImageBox)){productImageBox=new Element('div',{'id':'product_image_box','html':'<div class="div_big_top"></div>'+'<div class="big_tab">'+'  <div style="text-align: center;">'+'    <div class="big_image_product" id="product_image">'+product_soldout+'      <div class="ver_position'+estilo_agotado+'">'+'        <div class="ver_album" id="show_album_div"><a class="show_album" href="#" id="show_photo_album">'+lang['catalog_viewalbum']+'</a></div>'+'      </div>'+'    </div>'+'  </div>'+'</div>'+'<div style="clear: both;"></div>'+'<div class="div_big_bottom"></div>'+'<div style="clear: both; padding-bottom: 20px;"></div>'});}var productPropertiesBox=$('product_properties_box');if($defined(productPropertiesBox)){productPropertiesBox.dispose();}if(productInfo.gotocontact!=1&&productInfo.stock>0){var productPropertiesBox=new Element('div',{'id':'product_properties_box','html':'<div class="div_big_top"></div>'+'<div class="big_tab" style="text-align:left;">'+'<div class="btnbuylink"><a id="buyproduct_'+productInfo.id+'" href="#" style="color:#ffffff; text-decoration:none">'+lang['catalog_buynow']+'</a></div>'+'  <div style="padding-left: 10px; padding-bottom: 20px;">'+'    <h4 style="margin:0px; margin-bottom: 5px; padding:0px;"><span id="prodmodel">'+((productInfo.model!=null)?'['+productInfo.model+']':'')+'</span> '+productInfo.name+'</h4>'+((productInfo.description!='')?'<strong>'+lang['catalog_description']+': </strong>'+productInfo.description:'')+'<div style="">'+'(<a   class="pink" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Collar_01_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_necklace']+'" >'+lang['boxes_view']+'</a>)'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_02_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_03_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_04_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_05_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_06_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuches_01_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_set']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_ Nuevo_02_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_set']+'" >image #2</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_ Nuevo_03_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_set']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_ Nuevo_01_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_set']+'" >image #3</a>'+'</div>'+'  </div>'+'  <div style="width:560px;padding:0px 10px; display:block; padding-bottom:10px; display: table-cell;" id="product_properties"></div>'+'  <div style="padding:0px 0px; display:block;" " id="product_shop_properties"></div>'+'  <div style="clear: both;"></div>'+'  <div id="pricewrapper" style="float: right; padding-top:20px; padding-right: 20px;">'+'    <div class="graybg" id="product_price"></div>'+'    <div class="pinkbg"></div>'+'  </div>'+'</div>'+'<div style="clear: both;"></div>'+'<div class="div_big_bottom"></div>'+'<div style="clear: both; padding-bottom: 20px;"></div>','styles':{'display':'block'}});}else{var productPropertiesBox=new Element('div',{'id':'product_properties_box','html':'<div class="div_big_top"></div>'+'<div class="big_tab" style="text-align:left;">'+'<div class="btnbuylink"><a id="contactproduct_'+productInfo.id+'" rel="lyteframe" rev="width:700px;height:450px;scrolling: auto;" href="'+baseurl+'resources/information/'+currentlang+'/productcontact.php?id='+productInfo.id+'&name='+productInfo.name+'&reference='+productInfo.reference+'&model='+productInfo.model+'" style="color:#ffffff; text-decoration:none">'+lang['catalog_gotocontact']+'</a></div>'+'  <div style="padding-left: 10px; padding-bottom: 20px;">'+'    <h4 style="margin:0px; margin-bottom: 5px; padding:0px;"><span id="prodmodel">'+((productInfo.model!=null)?'['+productInfo.model+']':'')+'</span> '+productInfo.name+'</h4>'+((productInfo.description!='')?'<strong>'+lang['catalog_description']+': </strong>'+productInfo.description:'')+'<div style="">'+'(<a   class="pink" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Collar_01_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_necklace']+'" >'+lang['boxes_view']+'</a>)'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_02_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_03_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_04_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_05_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_Pendiente_06_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_earring']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuches_01_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_set']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_ Nuevo_02_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_set']+'" >image #2</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_ Nuevo_03_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_set']+'" >image #3</a>'+'<a style="display:none" href="'+baseurl+'/resources/information/'+currentlang+'/images/Estuche_ Nuevo_01_R.jpg" rel="lytebox[estuches]" title="'+lang['boxes_set']+'" >image #3</a>'+'</div>'+'  </div>'+'  <div style="width:560px;padding:0px 10px; display:block; padding-bottom:10px; display: table-cell;" id="product_properties"></div>'+'  <div style="padding:0px 0px; display:block;" " id="product_shop_properties"></div>'+'  <div style="clear: both;"></div>'+'  <div id="pricewrapper" style="float: right; padding-top:20px; padding-right: 20px;">'+'    <div class="pinkbg"></div>'+'  </div>'+'</div>'+'<div style="clear: both;"></div>'+'<div class="div_big_bottom"></div>'+'<div style="clear: both; padding-bottom: 20px;"></div>','styles':{'display':'block'}});}var centerPanel=$('center_content');if($defined(centerPanel)){centerPanel.grab(productImageBox);centerPanel.grab(productPropertiesBox);}var i=1;if(productInfo.properties.length>0){productInfo.properties.each(function(propertyData){var productProperties=$('product_properties');var productProperty=$('property'+propertyData.id);if($defined(productProperty))productProperty.dispose();if($defined(productProperties)){if(propertyData.value!=undefined){if(propertyData.value!=''){if((i%3)==1){var propertyDiv=new Element('div',{'id':'property'+propertyData.id,'html':'<a href="'+baseurl+'index.php/properties/info/'+propertyData.id+'/'+currentlang+'#" rel="lyteframe" rev="width:'+((propertyData.width=='')?'300':propertyData.width)+'px; height:'+((propertyData.height=='')?'250':propertyData.height)+'px; scrolling:auto;" id="showpropinfo_'+propertyData.id+'"><img border="0" src="'+baseurl+'images/info.gif" alt="'+lang['catalog_info']+'"/></a><strong> '+propertyData.name+': </strong>'+propertyData.value,'styles':{'float':'left','padding':'3px','width':'180px'}});}if((i%3)==2){var propertyDiv=new Element('div',{'id':'property'+propertyData.id,'html':'<a href="'+baseurl+'index.php/properties/info/'+propertyData.id+'/'+currentlang+'#" rel="lyteframe" rev="width:'+((propertyData.width=='')?'300':propertyData.width)+'px; height:'+((propertyData.height=='')?'250':propertyData.height)+'px; scrolling:auto;" id="showpropinfo_'+propertyData.id+'"><img border="0" src="'+baseurl+'images/info.gif" alt="'+lang['catalog_info']+'"/></a><strong> '+propertyData.name+': </strong>'+propertyData.value,'styles':{'float':'left','padding':'3px','width':'180px'}});}if((i%3)==0){var propertyDiv=new Element('div',{'id':'property'+propertyData.id,'html':'<a href="'+baseurl+'index.php/properties/info/'+propertyData.id+'/'+currentlang+'#" rel="lyteframe" rev="width:'+((propertyData.width=='')?'300':propertyData.width)+'px; height:'+((propertyData.height=='')?'250':propertyData.height)+'px; scrolling:auto;" id="showpropinfo_'+propertyData.id+'"><img border="0" src="'+baseurl+'images/info.gif" alt="'+lang['catalog_info']+'"/></a><strong> '+propertyData.name+': </strong>'+propertyData.value,'styles':{'float':'left','padding':'3px','width':'180px'}});}productProperties.grab(propertyDiv);i++;}}}});myLytebox.updateLyteboxItems();}if(productInfo.sellProperties.length>0){productInfo.sellProperties.each(function(propertyData){var productShopProperties=$('product_shop_properties');if($defined(productShopProperties)){var propertyDiv=new Element('div',{'id':'property_'+propertyData.id,'html':'<div class="three_detail_title">'+propertyData.name+' (<a class="pink" style="text-decoration:none;" href="'+baseurl+'index.php/properties/info/'+propertyData.id+'/'+currentlang+'" rel="lyteframe" rev="width:'+((propertyData.width=='')?'300':propertyData.width)+'px; height:'+((propertyData.height=='')?'250':propertyData.height)+'px; scrolling:auto;" id="showpropinfo_'+propertyData.id+'">'+lang['catalog_moreinfo']+'</a>)'+' (<a class="show_album" style="color:#AB4B93;font-size:11px;" href="#" >'+lang['catalog_propalbum']+' '+propertyData.name+'</a>)'+'</div>'+'<div id="property_'+propertyData.id+'_fields" style="padding:0px 5px; padding-bottom:20px; display:block; clear:both;"></div>'+'<div style="clear: both;"></div>'});productShopProperties.grab(propertyDiv);var fields=$('property_'+propertyData.id+'_fields');var inputData;if(propertyData.items&&propertyData.items.length>0){var index=0;propertyData.items.each(function(item){var checked='';if(index==0&&propertyData.selectionType==0){var propertyObj={'propertyid':propertyData.id,'itemid':item.id,'model':item.model,'value':item.value};checked='checked="true" ';selectedSellProperties[propertyData.id]=propertyObj;update_selected_product_price();}index++;if(propertyData.selectionType==0){inputData='<input name="property_'+propertyData.id+'[]" id="property_'+propertyData.id+'_'+item.id+'_'+item.model+'" type="radio" value="'+item.value+'" '+checked+'/>'+item.name}else{inputData='<input name="property_'+propertyData.id+'[]" id="property_'+propertyData.id+'_'+item.id+'_'+item.model+'" type="checkbox" value="'+item.value+'" />'+item.name}var propertyItem=new Element('div',{'html':inputData,'styles':{'float':'left','margin-right':'10px','white-space':'nowrap'}});fields.grab(propertyItem);var inputItem=$('property_'+propertyData.id+'_'+item.id+'_'+item.model);if($defined(inputItem)){inputItem.addEvent('click',function(e){var itemIDParts=this.id.split('_');var propertyID=parseInt(itemIDParts[1],10);var itemID=parseInt(itemIDParts[2],10);var model='';if(itemIDParts[3]&&itemIDParts[3]!=''&&itemIDParts[3]!='null'&&itemIDParts[3]!='undefined'){model=itemIDParts[3];}if(this.type=='radio'){var propertyObj={'propertyid':propertyID,'itemid':itemID,'model':model,'value':this.value};selectedSellProperties[propertyID]=propertyObj;}if(this.type=='checkbox'){if(selectedSellProperties[propertyID]==null){var propertyObj={'propertyid':propertyID,'fields':[]};selectedSellProperties[propertyID]=propertyObj;}var indexOfField=inArray(selectedSellProperties[propertyID].fields,itemID);if(this.checked){if(indexOfField===false){selectedSellProperties[propertyID].fields.push(itemID);}}else{if(indexOfField!==false){selectedSellProperties[propertyID].fields.splice(indexOfField,1);}}}update_selected_product_price()});}});fields.grab(new Element('div',{'styles':{'clear':'both'}}));}}});myLytebox.updateLyteboxItems();}var request=new Request.JSON({url:baseurl+'index.php/products/album/'+productInfo.id+'/'+currentlang,onComplete:function(jsonObj){if(jsonObj==null){var photoAlbumLink=$('show_album_div');if($defined(photoAlbumLink)){photoAlbumLink.dispose();}}}}).send();var photoAlbumLinks=$$('a.show_album');photoAlbumLinks.each(function(photoAlbumLink){if($defined(photoAlbumLink)){photoAlbumLink.set('rev',"{'id': '"+productInfo.id+"', 'name': '"+productInfo.name+"', 'price': '"+productInfo.price+"'}");if(!photoAlbumLink.getProperty('style'))photoAlbumLink.set('style','color: #FFFFFF; text-decoration:none');photoAlbumLink.addEvent('click',function(e){e.stop();var productData=this.get('rev');productData=JSON.decode(productData)var request=new Request.JSON({url:baseurl+'index.php/products/album/'+productData.id+'/'+currentlang,onComplete:function(jsonObj){if(jsonObj!=null&&jsonObj.images.length>0){var galleryLinks=new Element('div',{'id':'product_gallery_links'});galleryLinks.set('style','display: none');jsonObj.images.each(function(image){var imageLink=new Element('a',{'id':'albumimage_'+image.id,'href':baseurl+'resources/products/'+image.url,'rel':'lytebox[productGallery]','title':image.description});galleryLinks.grab(imageLink);});var objBody=document.getElementsByTagName("body").item(0);var body=$(objBody);if($defined(body)){body.grab(galleryLinks);myLytebox.updateLyteboxItems();myLytebox.onClose=function(){var galleryLinks=$('product_gallery_links');if($defined(galleryLinks)){galleryLinks.dispose();}myLytebox.updateLyteboxItems();};var firstLink=$('albumimage_'+jsonObj.images[0].id);if($defined(firstLink)){myLytebox.start(firstLink,false,false);}}}pageTracker._trackPageview("/catalog/album/"+productData.name);}}).send();});}});var bigImageProduct=$('product_image');if($defined(bigImageProduct)){bigImageProduct.set('style','background: url('+baseurl+((productInfo.image!=false)?'resources/products/'+productInfo.image:'images/no_image_1.png')+') center no-repeat');}var buyProductLink=$('buyproduct_'+productInfo.id);if($defined(buyProductLink)){buyProductLink.set('rev',"{'id': '"+productInfo.id+"', 'name': '"+productInfo.name+"', 'price': '"+productInfo.price+"'}");buyProductLink.addEvent('click',function(e){e.stop();var productData=this.get('rev');productData=JSON.decode(productData);add_to_cart(productData.id,selectedSellProperties);});}update_selected_product_price();};var request=new Request.JSON({url:baseurl+'index.php/products/show/'+productID+'/'+currentlang,onComplete:function(jsonObj){show_details(jsonObj);show_related_products(productID,'right');show_last_seen_products('last_products_seen_list');pageTracker._trackPageview("/catalog/producto/"+jsonObj.name);}}).send();}function update_selected_product_price(){var price=parseFloat(selectedProduct.price);var before_price=0;var has_before_price=false;if(selectedProduct.before_price&&selectedProduct.before_price!='0'){before_price=parseFloat(selectedProduct.before_price);has_before_price=true;}var model='';var price=parseFloat(selectedProduct.price);if(selectedSellProperties.length>0){selectedSellProperties.each(function(property){if($defined(property)){if($defined(property.value)){price+=parseFloat(property.value);before_price+=parseFloat(property.value);model=property.model;}else if(property.fields&&property.fields.length>0){property.fields.each(function(itemid){var field=$('property_'+property.propertyid+'_'+itemid);if($defined(field)){price+=parseFloat(field.value);before_price+=parseFloat(field.value);model=field.model;}});}}});}if(!model){model=selectedProduct.model;}var productPriceDiv=$('product_price');if($defined(productPriceDiv)){productPriceDiv.set('html',price+'&euro; *'+lang['catalog_ivaexc']+'');}var prodmodelDiv=$('prodmodel');if($defined(prodmodelDiv)){prodmodelDiv.set('html','['+model+'] ');}var producto_agotado=$('ver_producto_agotado');if(has_before_price&&!$defined(producto_agotado)){var product_before_price_wrapper=$('product_before_price_wrapper');if(!$defined(product_before_price_wrapper)){var productBeforePriceBox=new Element('div',{'id':'product_before_price_wrapper','class':'graybg','html':lang['catalog_before']+': <span style="text-decoration: line-through;" id="product_before_price"></span>','styles':{'display':'block'}});var pricewrapper=$('pricewrapper');pricewrapper.grab(productBeforePriceBox,'top');}var productBeforePriceDiv=$('product_before_price');if($defined(productBeforePriceDiv)){productBeforePriceDiv.set('html',before_price+'&euro;');}}}close_lytebox=function(){myLytebox.end();};update_shop_cart=function(){var request=new Request.JSON({url:baseurl+'index.php/shopcart/show/'+currentlang,onComplete:function(jsonObj){var shopCartPanel;shopCartPanel=$('shop_cart_panel');var productsList=$$('div#shop_cart_products_list div');if(productsList.length>0){productsList.each(function(el){el.dispose();});}if(jsonObj.products.length>0){jsonObj.products.each(function(product){var model='';if(product.attributes){attr_text='';product.attributes.each(function(attr){if(attr['model']){model=attr['model'];}attr_text=attr_text+'<br/><i> -'+attr['name']+': '+attr['value']+'</i>';});if(!model){model=product.model;}}var cartProductInfo=new Element('div',{'id':'cartproduct_'+product.id,'html':'<div class="compra_left">'+'['+model+'] '+product.name+attr_text+'</div>'+'<div class="compra_middle">'+product.count+'</div>'+'<div class="compra_right">'+product.price.toFloat().toFixed(2)+'&euro;</div>'+'<div style="clear: both;"/>'+'<div class="compra_border2"/>'});var cartPanelProductsList=$('shop_cart_products_list');var productDiv=$('cartproduct_'+product.id);if(!$defined(productDiv)){cartPanelProductsList.grab(cartProductInfo);}});var cartImport=$('cart_import');if($defined(cartImport)){cartImport.set('html',jsonObj.total.toFloat().toFixed(2)+' &euro;');}if($defined(shopCartPanel)){panelOpacity=shopCartPanel.get('opacity');if(0==panelOpacity){shopCartPanel.set('style','');shopCartPanel.fade('in');}}}else{if($defined(shopCartPanel)){panelOpacity=shopCartPanel.get('opacity');if(1==panelOpacity){shopCartPanel.fade('out');shopCartPanel.set('style','display:none');}}}}}).send();};function build_categories_menu2(categoryID){var lists=$$('.menuitem');lists.each(function(item){item.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var linkID=parseInt(linkIDParts[1],10);productRM.setValues(['joyas',linkID,0]);show_category(linkID);});item.addEvents({'mouseenter':function(e){if($defined(current_category)){current_category.fade('out');}var linkIDParts=this.id.split('_');var linkID=parseInt(linkIDParts[1],10);current_category=$('subcategories_'+linkID);if($defined(current_category)){current_category.fade('in');}},'mouseleave':function(e){}});});}function build_categories_menu(categoryID){var menu=$('categories_menu');var menuItems=$('categories_menu_items');if($defined(menuItems))menuItems.dispose();menuItems=new Element('ul',{'id':'categories_menu_items'});var index=0;var create_mainmenu_item=function(items){items.each(function(itemData){var listItem=new Element('li');var itemLink=new Element('a',{'id':'category_'+itemData.id,'href':'#','title':itemData.title});itemLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var linkID=parseInt(linkIDParts[1],10);productRM.setValues(['joyas',linkID,0]);show_category(linkID);});itemLink.grab(new Element('span',{'html':itemData.title}));itemLink.addEvents({'mouseenter':function(e){if($defined(current_category)){current_category.fade('out');}var linkIDParts=this.id.split('_');var linkID=parseInt(linkIDParts[1],10);current_category=$('subcategories_'+linkID);if($defined(current_category)){current_category.fade('in');}},'mouseleave':function(e){}});listItem.grab(itemLink);menuItems.grab(listItem);if(itemData.subcategories.length>0){submenuItems=new Element('ul',{'id':'subcategories_'+itemData.id,'style':'left:'+(listItem.getPosition(menuItems).x)+'px'});submenuItems.addEvent('mouseleave',function(e){if(this==current_category){this.fade('out');current_category=undefined;}});itemData.subcategories.each(function(subitemData){var sublistItem=new Element('li');var subitemLink=new Element('a',{'id':'subcategory_'+subitemData.id,'href':'#','title':subitemData.title});subitemLink.addEvent('click',function(e){e.stop();var linkIDParts=this.id.split('_');var linkID=parseInt(linkIDParts[1],10);productRM.setValues(['joyas',linkID,0]);show_category(linkID);});subitemLink.grab(new Element('span',{'html':subitemData.title}));sublistItem.grab(subitemLink);submenuItems.grab(sublistItem);});menuItems.grab(submenuItems);}index++;});};var request=new Request.JSON({url:baseurl+'index.php/get/categories/'+((categoryID!=0)?categoryID:'0')+'/'+currentlang,onComplete:function(jsonObj){create_mainmenu_item(jsonObj.menuitems);}}).send();menu.grab(menuItems);}function update_top_menu(){var topModule=$('topmodule');var loginBox=$('yoo-login');if(!$defined(loginBox)){loginBox=new Element('div',{'id':'yoo-login','html':'<div style="float:left;margin:auto 5px;"><a href="'+baseurl+'index.php/system/register/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 400px; scrolling: auto;">'+lang['topmenu_register']+'</a> | </div>'+'<div style="float:left;margin:auto 5px;"><a href="'+baseurl+'index.php/system/gorememberpw/'+currentlang+'" rel="lyteframe" rev="width: 600px; height: 300px; scrolling: auto;">'+lang['topmenu_pwrecover']+'</a></div>'+'<div class="yoo-username">'+'  <input type="text" value="email" title="Username" size="10" class="inputbox" id="mod_login_username" name="username"/>'+'</div>'+'<div class="yoo-password">'+'  <input type="password" value="password" title="Password" size="10" class="inputbox" name="passwd" id="mod_login_password"/>'+'</div>'+'<div class="yoo-login-button">'+'  <a href="#" id="do_login_button"></a>'+'</div>'+'<div class="yoo-break"></div>'});topModule.grab(loginBox);myLytebox.updateLyteboxItems();var doLoginBtn=$('do_login_button');if($defined(doLoginBtn)){doLoginBtn.addEvent('click',doLogin);}var input_user=$('mod_login_username');if($defined(input_user)){input_user.addEvent('blur',function(e){if(this.value=='')this.value='email';});input_user.addEvent('focus',function(e){if(this.value==='email')this.value='';});}var input_password=$('mod_login_password');if($defined(input_password)){input_password.addEvent('blur',function(e){if(this.value==='')this.value='password';});input_password.addEvent('focus',function(e){if(this.value=='password')this.value='';});input_password.addEvent('keypress',function(e){if(e.key=='enter'){doLogin(e);}});}}var submit_search=$('submit_search');var input_search=$('input_search');myLytebox.onClose=function(){input_search.focus();};submit_search.addEvent('click',function(e){e.stop();show_search(input_search.getProperty('value'));productRM.setValues(['buscar_joyas',input_search.getProperty('value'),0]);});input_search.addEvent('keypress',function(e){if(e.key=='enter'){show_search(input_search.getProperty('value'));productRM.setValues(['buscar_joyas',input_search.getProperty('value'),0]);}});input_search.addEvent('blur',function(e){if(this.value==='')this.value=lang['userinfo_search'];});input_search.addEvent('focus',function(e){if(this.value==lang['userinfo_search'])this.value='';});}function build_homepage(){var content=$('content');var content_items=$('content_items');if($defined(content_items))content_items.dispose();content_items=new Element('div',{'id':'content_items','html':'<div id="homepage"></div>'});content.grab(content_items);content_items=$('homepage');var content_wrap=$('content_wrap');if($defined(content_wrap))content_wrap.dispose();content_wrap=new Element('div',{'id':'content_wrap','styles':{'clear':'both'}});content.grab(content_wrap);var tabIndex=0;var timer;var animate_categories=function(){var imageTab=$('imageTab_'+tabIndex);if($defined(imageTab)){imageTab.fade('in');}tabIndex++;if(tabIndex==3){clearInterval(timer);}};var create_category_preview=function(categories){var index=0;var lastimg=null;var mouseOverEvent=function(e){e.stop();var img=this.getFirst('img');if(lastimg){lastimg.fade(0.2);}img.fade(1);lastimg=img;};var mouseOutEvent=function(e){e.stop();};categories.each(function(category){var imageTab;if(index>1){imageTab=new Element('div',{'id':'imageTab_'+index,'class':'img_tab','styles':{'margin':'0px'}});}else{imageTab=new Element('div',{'id':'imageTab_'+index,'class':'img_tab'});}var tabTop=new Element('div',{'class':'div_top'});var tabCenter=new Element('div',{'styles':{'background':'#000'}});var tabBottom=new Element('div',{'class':'div_bottom'});var tabTitle=new Element('div',{'class':'div_titles'});var categoryImage=new Element('img',{'src':baseurl+'resources/categories/'+category.image,'alt':category.title});if(index==1){lastimg=categoryImage;categoryImage.set('opacity',1);}else{categoryImage.set('opacity',0.2);}var clickEvent=function(e){e.stop();var linkIDParts=this.id.split('_');var linkID=parseInt(linkIDParts[1],10);productRM.setValues(['joyas',linkID,0]);show_category(linkID);};var categoryImageLink=new Element('a',{'id':'homepagelink_'+category.id,'href':'#','title':category.title});categoryImageLink.addEvent('mouseover',mouseOverEvent);categoryImageLink.addEvent('mouseout',mouseOutEvent);categoryImageLink.addEvent('click',clickEvent);categoryImageLink.grab(categoryImage);tabCenter.grab(categoryImageLink);var categoryLink=new Element('a',{'id':'homepagelink1_'+category.id,'href':'#','title':category.title,'html':category.title});categoryLink.addEvent('click',clickEvent);tabTitle.grab(categoryLink);tabBottom.grab(tabTitle);imageTab.grab(tabTop);imageTab.grab(tabCenter);imageTab.grab(tabBottom);imageTab.set('opacity',0);content_items.grab(imageTab);index++;});timer=setInterval(animate_categories,300);};var request=new Request.JSON({url:baseurl+'index.php/get/homepage_categories/'+currentlang,onComplete:function(jsonObj){create_category_preview(jsonObj.categories);}}).send();}update_top_menu();doLoggedin();build_categories_menu2(0);build_homepage();var defaultpage=['home'];if(start_product){defaultpage=['joya',start_product];}else if(start_category){defaultpage=['joyas',start_category];}else if(searchkey){defaultpage=['buscar_joyas',searchkey];}productRM=HistoryManager.register(historykey,defaultpage,function(values){switch(values[0]){case'home':show_category(0);break;case'joyas':show_category(values[1],values[2]);break;case'joya':if(firstload){category_layout();}show_product(values[1]);break;case'buscar_joyas':show_search(values[1],values[2]);break;}firstload=false;},function(values){return historykey+'-'+values[0]+'-'+values[1]+'-'+values[2];},historykey+'-([\\w_-]*)-([\\w_-]*)-([\\w_-]*)',{iframeSrc:baseurl+'blank.html'});HistoryManager.start();};window.addEvent('domready',build_monperla);