$(document).ready(function() { var page = document.location.pathname.toLowerCase(); var target = getCurrentTarget(); var c = readCookie('style'); if (c) { switchStylestyle(c); } else { switchStylestyle('blue'); } if (target == "" || target == null) { SetTargetURL("notarget", "/Home"); } else { /* if (page == "/home" && (target != "" && target != "notarget")) { if (lp != "/home" && lp != "") { document.location.href = lp; return; } }*/ DisplayCarousel(); if (showLatestView) $("#divLastViewsBox").show(); else $("#divLastViewsBox").hide(); switch (showRelatedArticles) { case "0": if ($("#divRelatedArticlesBox").size() > 0) { $("#divRelatedArticlesBox").hide(); } break; case "1": if ($("#divRelatedArticlesBox").size() > 0) { $("#divRelatedArticlesBox").show(); } break; case "2": if ($("#divRelatedArticlesBox").size() > 0) { var sRelatedArticles = $("#box-articles-holder").size(); if (sRelatedArticles > 1) $("#divRelatedArticlesBox").show(); else $("#divRelatedArticlesBox").hide(); } break; } /*$('link[rel*=style][title]').each(function(i) { if (this.getAttribute('href') == companyContentUri + 'Html/Style/comex.css') { this.setAttribute('title', 'comex'); this.disabled = false; } });*/ showMenu(); showFlash(); if (page == "/home") { showMainAd(); } else { hideMainAdInContent(); } showFooter(); if (showTargetSelector) { $('#targetSelector').load(companyContentUri + 'Html/General/Pages/SubContent/targetSelector.all.html', function() { if ($("#targetMenu").value != undefined) { $("#targetMenu").position({ "of": $("#submenu"), "my": "left bottom", "at": "left top" }); if ($("#divFlash").size() > 0) { $("#targetMenu").css("top", "217px"); } else { $("#targetMenu").css("top", "130px"); } $("#targetMenu").hide(); } }); } $(".logo").click(function() { eraseCookie('target'); eraseCookie('style'); window.location = "/Home"; }); $('.storelocator-drop').css({ 'display': 'block' }); $("#mainCarousel").jcarousel({ scroll: 1, initCallback: mycarousel_initCallback, buttonNextHTML: null, buttonPrevHTML: null }); closeTab("storelocator"); } }); function DisplayCarousel(){ if ($("#wp_ul li").size() > 4){ $(".wp_back").show(); $(".wp_forward").show(); } else { $(".wp_back").hide(); $(".wp_forward").hide(); $(".wp_content").css('margin-left','25px'); } } function switchStylestyle(styleName) { var colour = companyContentUri + 'Html/Style/' + styleName + '.css'; if (checkCssExist(colour) == false) addCss(colour, styleName); $('link[rel*=style][title]').each(function(i) { if (this.getAttribute('title') != 'default' && this.getAttribute('title') != "base") this.disabled = true; if (this.getAttribute('title') == "base") this.disabled = false; if (this.getAttribute('title') == styleName) this.disabled = false; }); createCookie('style', styleName, 365); } function addCss(file, styleName) { var fileref = document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("title", styleName); fileref.setAttribute("href", file); if (typeof fileref != "undefined") document.getElementsByTagName("head")[0].appendChild(fileref); } function checkCssExist(filename) { var exists = 0; var targetelement = "link"; //determine element type to create nodelist from var targetattr = "href"; //determine corresponding attribute to test for var allsuspects = document.getElementsByTagName(targetelement) if (allsuspects.length > 26) { for (var i = allsuspects.length; i >= 0; i--) { //search backwards within nodelist for matching elements to remove if (allsuspects[i] && allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].getAttribute('href') != filename && allsuspects[i].getAttribute('title') != "default" && allsuspects[i].getAttribute('title') != "base") allsuspects[i].parentNode.removeChild(allsuspects[i]); //remove element by calling parentNode.removeChild() } } for (var i = allsuspects.length; i >= 0; i--) { //search backwards within nodelist for matching elements to remove if (allsuspects[i] && allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].getAttribute('href') == filename) exists = 1; } if (exists == 1) return true; else return false; } function getCurrentStyleSheet() { var c = readCookie('style'); if (c) return c; else return 'base'; return null; } function SetCurrentMod(mod) { createCookie('mod', mod, 365) } function getCurrentMod() { var c = readCookie('mod'); if (c) return c; else return ''; return null; } function SetMusicSwitch(value) { createCookie('music', value, 365) } function getMusicSwitch() { var c = readCookie('music'); if (c) return c; else return 'on'; } /*================================================================================================================================================*/ /* TargetSelector.js */ /*================================================================================================================================================*/ function showFlash() { var target = getCurrentTarget(); if (target == "notarget") { target = ""; } if (target != "") { var styleSheet = getCurrentStyleSheet(); var firstMod = getCurrentMod(); var flashvars = { contentTarget: target, activeColor: styleSheet, firstMod: firstMod }; var params = { wmode: "opaque" }; var attributes = {}; swfobject.embedSWF(companyContentUri + "Html/Flash/homes.swf", "flashContainer", "970", "330", "9.0.45.0", "", flashvars, params, attributes); } else { if ($("#divFlash").size() > 0) { $('#divFlash').load(companyContentUri + 'Html/NoFlash/notarget.html'); } } } function SetTargetURL(selectedTarget, url) { $.ajax({ type: "POST", cache: false, url: "/Services/TargetSelector", data: "action=TargetSelection&value=" + selectedTarget, // + "&pipo=" + dt.toString(), success: function(data) { if (data == 'ok') { createCookie('target', selectedTarget, 365); window.location = url; } else { alert(data); } } }); } /* function SetTargetTool(selectedTarget, url) { $.ajax({ type: "POST", url: "/Services/TargetSelector", data: "action=TargetSelection&value=" + selectedTarget, success: function(data) { createCookie('target', selectedTarget, 365); OpenTool(url); } }); } function SetContextTarget(selectedTarget, reload) { $.ajax({ type: "POST", url: "/Services/TargetSelector", data: "action=TargetSelection&value=" + selectedTarget, success: function(data) { createCookie('target', selectedTarget, 365); window.location = "/Home"; } }); } */ function showMenu() { $("#menu-header").load(companyContentUri + "Html/General/Pages/SubContent/menu." + getCurrentTarget() + "." + defaultLanguage + ".html", function() { $('.styleswitch').click(function() { switchStylestyle($(this).attr("rel")); showFlash(); }); accordion(); }); } function showFooter() { var target = getCurrentTarget(); $("#footer").load(companyContentUri + "Html/General/Pages/SubContent/footer." + getCurrentTarget() + "." + defaultLanguage + ".html", function() { $("#footerLink").click(function() { $.ajax({ type: "POST", url: "/Services/TargetSelector", data: "action=TargetSelection&value=notarget", success: function(data) { createCookie("target", "notarget", 365); window.location = "/Home"; } }); }); }); } function getCurrentTarget() { var c = readCookie('target'); if (c) return c; else return ''; return null; } function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } function eraseCookie(name) { createCookie(name, "", -1); } /*Ads*/ function getAdsFileName() { var t = getCurrentTarget(); if (t == "") { t = 'notarget'; } return 'http://www.comex.com.mx/Content/Comex/Html/Images/Ads/Promo_'+t+'_'+adsMode+'.swf'; } function targetAdContainer() { if (req.readyState == 4) { if (req.status == 200) { var ad = getAdsFileName(); var oAd = document.getElementById('gallery-ad'); if (oAd != null) { var newObj = document.createElement('div'); newObj.setAttribute('id', 'flash-ad'); oAd.appendChild(newObj); var params = { wmode: "transparent" }; var attributes = {}; var aHeight; var aWidth; if (adsMode == "FS") { $('#gallery-ad').css({ 'height': adsFSHeight }); $('#gallery-ad').css({ 'width': adsFSWidth }); $('#gallery-ad').css({ 'left': adsFSLeft }); $('#gallery-ad').css({ 'top': adsFSTop }); aHeight = adsFSHeight; aWidth = adsFSWidth; } else //"SD" { $('#gallery-ad').css({ 'height': adsSDHeight }); $('#gallery-ad').css({ 'width': adsSDWidth }); $('#gallery-ad').css({'left': adsSDLeft }); $('#gallery-ad').css({ 'top': adsSDTop }); aHeight = adsSDHeight; aWidth = adsSDWidth; } swfobject.embedSWF(ad, "flash-ad", aWidth, aHeight, "9.0.45.0", "", "", params, attributes); $('#gallery-ad').css({ 'z-index': '3000' }); } } else { $('#gallery-ad').css({ 'z-index': '-1' }); } } } function showMainAd() { var ad = getAdsFileName(); if (window.XMLHttpRequest) { req = new XMLHttpRequest; req.onreadystatechange = targetAdContainer; try { req.open("GET", ad, true) } catch (e) { alert(e) } req.send(null); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = targetAdContainer; req.open("GET",ad,true); req.send(); } } } function hideMainAd() { var oAd = document.getElementById('gallery-ad'); var flashAd = document.getElementById('flash-ad'); oAd.removeChild(flashAd); $('#gallery-ad').css({ 'z-index': '-1' }); } function hideMainAdInContent() { $('#gallery-ad').css({ 'z-index': '-1' }); } /* navigation.js */ function initMenu() { var nodes = document.getElementById("menu-navigation").getElementsByTagName("li"); for (var i = 0; i < nodes.length; i++) { nodes[i].onmouseover = function() { this.className += " hover"; } nodes[i].onmouseout = function() { this.className = this.className.replace(" hover", ""); } } } if (document.all && !window.opera) attachEvent("onload", initMenu); /*Accordion*/ function accordion() { var _holdName = '.subnav' var _hold = $(_holdName); var _animSpeed = 500; var _actClass = 'active'; var _collapsible = true; _hold.each(function() { var _this = $(this); _this.find('li').each(function() { if (!$(this).hasClass(_actClass)) { $(this).find('ul:eq(0)').hide(); } }) var _link = $('a', _this); _link.click(function() { var _thisParent = $(this).parents('li:eq(0)'); var _ul = _thisParent.children('ul:eq(0)'); var _ind = _link.index($(this)); if (_ul.length) { if (_ul.is(':hidden')) { collapse(_this, _ind, function() { _this.find('a:eq(' + _ind + ')').parents('li:eq(0)').children('ul:eq(0)').slideDown(_animSpeed, function() { _this.find('a:eq(' + _ind + ')').parents('li:eq(0)').addClass(_actClass); }); }) } else { if (_collapsible) { _ul.slideUp(_animSpeed, function() { _thisParent.removeClass(_actClass); }); } else { return false; } } return false; } }) }) function collapse(obj, _index, func) { var _thislink = obj.find('a:eq(' + _index + ')'); var _li = obj.find('>li'); _thislink.Parent = _thislink.parents('li:eq(0)'); _thislink.Parent.ul = _thislink.Parent.children('ul:eq(0)'); _thislink.actIndex = _li.index(_thislink.parents(_holdName + '>li')); if (_li.index(_li.filter('.' + _actClass)) != _thislink.actIndex) { _li.eq(_li.index(_li.filter('.' + _actClass))).find('ul:eq(0)').slideUp(_animSpeed, function() { _li.eq(_li.index(_li.filter('.' + _actClass))).find('ul').hide(); _li.eq(_li.index(_li.filter('.' + _actClass))).find('li').removeClass(_actClass); _li.eq(_li.index(_li.filter('.' + _actClass))).removeClass(_actClass); }); } function applyThis(func, obj) { if (typeof func == "function") { func.apply(obj); } } return applyThis(func, obj); } } /* SWFObject v2.2 is released under the MIT License */ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab 4) { $('#arrow_back').css({ 'display': 'inline' }); $('#arrow_forward').css({ 'display': 'inline' }); auto_slide = 1; /*move he last list item before the first item. The purpose of this is if the user clicks to slide left he will be able to see the last item.*/ $('#wp_ul li:first').before($('#wp_ul li:last')); if (auto_slide == 1) { /*set the interval (loop) to call function slide with option 'right' and set the interval time to the variable we declared previously */ var timer = setInterval('slide("right")', auto_slide_seconds); /*and change the value of our hidden field that hold info about the interval, setting it to the number of milliseconds we declared previously*/ $('#hidden_auto_slide_seconds').val(auto_slide_seconds); } if (hover_pause == 1) { $('#wp_ul').hover(function() { clearInterval(timer) }, function() { timer = setInterval('slide("right")', auto_slide_seconds); }); $('.wp_back').hover(function() { clearInterval(timer) }, function() { timer = setInterval('slide("right")', auto_slide_seconds); }); $('.wp_forward').hover(function() { clearInterval(); }, function() { timer = setInterval('slide("right")', auto_slide_seconds); }); } if (key_slide == 1) { $(document).bind('keypress', function(e) { if (e.keyCode == 37) { slide('left'); } else if (e.keyCode == 39) { slide('right'); } }); } } }); function slide(where) { var item_width = $('#wp_ul li').outerWidth(); /* using a if statement and the where variable check we will check where the user wants to slide (left or right)*/ if (where == 'left') { var left_indent = parseInt($('#wp_ul').css('left')) + item_width; } else { var left_indent = parseInt($('#wp_ul').css('left')) - item_width; } $('#wp_ul:not(:animated)').animate({ 'left': left_indent }, 800, function() { /* when the animation finishes use the if statement again, and make an ilussion of infinity by changing place of last or first item*/ if (where == 'left') { $('#wp_ul li:first').before($('#wp_ul li:last')); } else { $('#wp_ul li:last').after($('#wp_ul li:first')); } $('#wp_ul').css({ 'left': '0px' }); }); } /* ready.js */ $(document).ready(function() { $(".box").each( function(i) { var box = this; $("a:first", this).bind("click", function() { if (jQuery(box).attr("class") == "box") { var height = jQuery(box).height(); jQuery(box).attr("size", height); jQuery(box).addClass("toggle"); size = "28px"; $(box).animate({ height: size }, { queue: false, duration: "normal" }); $("h3", box).css({ 'background': '#e0e0e0 url(http://www.comex.com.mx/Content/Common/Html/Images/sep-sidebar.gif) no-repeat 220px 50%' }); } else { size = jQuery(box).attr("size"); $(box).animate({ height: size }, { queue: false, duration: "normal" }); jQuery(box).removeClass("toggle"); $("h3", box).css({ 'background': '#e0e0e0 url(http://www.comex.com.mx/Content/Common/Html/Images/sep-sidebar-down.gif) no-repeat 220px 50%' }); } return false; } ); } ) $("#txtSearch").focus(function() { this.value = ''; }); $('#RegisterStep2').css({ 'display': 'none' }); $('#ProfileStep2').css({ 'display': 'none' }); if ($('#showerror').val() == '1') ShowLogInError(); }); function mycarousel_initCallback(carousel) { $('.storeList img').bind('click', function() { carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr("name"))); }); }; function openurl(url, windowname, popH, popW) { var w = 800, h = 600; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } if (popH == 0 && popW == 0) { popW = screen.availWidth; popH = screen.availHeight; } var leftPos = (w - popW) / 2, topPos = (h - popH) / 2; wOpen = window.open(url, windowname, 'location=no,resizable=no,alwaysraised, scrollbars=1,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); } function openexternallink(url) { var w = 800, h = 600, popH = 0, popW = 0; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } if (popH == 0 && popW == 0) { popW = screen.availWidth; popH = screen.availHeight; } var leftPos = (w - popW) / 2, topPos = (h - popH) / 2; window.open(url, 'link', 'width='+popW+',height='+popH+',top='+topPos+',left='+leftPos); } function ShowLogInError() { ensure({ js: 'http://www.comex.com.mx/Content/Comex/Html/Scripts/tabs.js' }, function() { openTab('membership'); }); } function LogOut() { $.getJSON("http://www.comex.com.mx/Services/Membership", { action: "LogOut" }, function(data) { var result = eval(data); if (result.logout == 'ok') { window.location.href = '/home'; } }); } /* ContentSearcher.js */ function SearchContent() { var word = document.getElementById("txtSearch").value; if (word != "Search: " && word != "") { $('#SearcherFound').html(""); openTab("searcher"); $('#loading').css({ 'display': 'block' }); $.ajax({ url: "/Services/ContentService", data: "action=searchContent&word=" + word, type: "GET", dataType: "json", success: function(data) { var result = eval(data); $('#SearcherFound').html(data.content); $('.divScrollSearcher > div:odd').addClass('searcher-found'); $('.divScrollSearcher > div:odd').removeClass('even'); $('.divScrollSearcher > div:even').addClass('searcher-foundGrey'); $('#loading').hide('slow'); }, error: function() { $('#SearcherFound').html("
No se encontraron resultados para los criterios de búsqueda dados
por favor verifique su ortografía e inténtelo de nuevo
"); $('.divScrollSearcher > div:odd').addClass('searcher-found'); $('.divScrollSearcher > div:odd').removeClass('even'); $('.divScrollSearcher > div:even').addClass('searcher-foundGrey'); $('#loading').hide('slow'); } }); } } function wipeTextbox() { $('#txtSearch').val(""); } function initializeTextbox() { var a = document.getElementById("txtSearch").value; if (a == "") { $('#txtSearch').val("Buscar:"); } } function openTab(tab) { closeTab('contactus'); closeTab('membership'); closeTab('storelocator'); closeTab('searcher'); $('.' + tab + '-drop').css({ 'display': 'block' }); } function closeTab(tab) { $('.' + tab + '-drop').css({ 'display': 'none' }); } /* tools.js */ function OpenTool(name) { var caracteristicas = "height=750,width=950,scrollTo,top=0,left=0,resizable=1,scrollbars=0,location=0"; switch (name) { case "VD": caracteristicas = "height=635,width=1040,scrollTo,top=0,left=0,resizable=1,scrollbars=0,location=0"; window.open("/workspace-decorador-virtual", 'Popup', caracteristicas); break; case "CF": window.open("/Tools/Cenefas/default.aspx", 'Popup', caracteristicas); break; case "CS": caracteristicas = "height=635,width=1040,scrollTo,top=0,left=0,resizable=1,scrollbars=0,location=0"; window.open("/workspace-buscador-colores", 'Popup', caracteristicas); break; case "MC": caracteristicas = "height=635,width=1040,scrollTo,top=0,left=0,resizable=1,scrollbars=0,location=0"; window.open("/workspace-calculador-materiales", 'Popup', caracteristicas); break; case "PL": caracteristicas = "height=635,width=1040,scrollTo,top=0,left=0,resizable=1,scrollbars=0,location=0"; window.open("/workspace-plugins", 'Popup', caracteristicas); break; case "IR": window.open("/files/flash/InteractiveRack/default.aspx", 'Popup', caracteristicas); break; default: caracteristicas = "height=635,width=1040,scrollTo,top=0,left=0,resizable=1,scrollbars=0,location=0"; window.open("/workspace", 'Popup', caracteristicas); } } function OpenToolFooter(src) { window.open(src, 'tool', 'top=0,left=0,location=no,resizable=auto,scrollbars=yes,width=950,height=750,alwaysraised'); } function openToolPage(name) { var caracteristicas = "height=700,width=800,scrollTo,resizable=1,scrollbars=0,location=0"; window.open(this.href, 'Popup', caracteristicas); window.location.replace("/Tools/VirtualDecorator/default.aspx") } function getParameterByName(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) return ""; else return results[1]; } function opentutienda(url, windowname, popH, popW) { var w = 800, h = 600; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } if (popH == 0 && popW == 0) { popW = screen.availWidth; popH = screen.availHeight; } var leftPos = (w - popW) / 2, topPos = (h - popH) / 2; wOpen = window.open(url, windowname, 'location=no,resizable=no,scrollbars=yes,alwaysraised,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); } /* Ensure.js */ /* Script: Ensure.js Ensure library A tiny javascript library that provides a handy function "ensure" which allows you to load Javascript, HTML, CSS on-demand and then execute your code. Ensure ensures that relevent Javascript and HTML snippets are already in the browser DOM before executing your code that uses them. To download last version of this script use this link: Version: 1.0 - Initial release Compatibility: FireFox - Version 2 and 3 Internet Explorer - Version 6 and 7 Opera - 9 (probably 8 too) Safari - Version 2 and 3 Konqueror - Version 3 or greater Dependencies: Credits: - Global Javascript execution - Author: Omar AL Zabir - http://msmvps.com/blogs/omar License: >Copyright (C) 2008 Omar AL Zabir - http://msmvps.com/blogs/omar > >Permission is hereby granted, free of charge, >to any person obtaining a copy of this software and associated >documentation files (the "Software"), >to deal in the Software without restriction, >including without limitation the rights to use, copy, modify, merge, >publish, distribute, sublicense, and/or sell copies of the Software, >and to permit persons to whom the Software is furnished to do so, >subject to the following conditions: > >The above copyright notice and this permission notice shall be included >in all copies or substantial portions of the Software. > >THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, >INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. >IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, >DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, >ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE >OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ (function(){ window.ensure = function( data, callback, scope ) { if( typeof jQuery == "undefined" && typeof Sys == "undefined" && typeof Prototype == "undefined" ) return alert("jQuery, Microsoft ASP.NET AJAX or Prototype library not found. One must be present for ensure to work"); if( typeof data.test != "undefined" ) { var test = function() { return data.test }; if( typeof data.test == "string" ) { test = function() { return !(eval( "typeof " + data.test ) == "undefined" && document.getElementById(data.test) == null); } } else if( typeof data.test == "function" ) { test = data.test; } if( test() === false || typeof test() == "undefined" || test() == null ) new ensureExecutor(data, callback, scope); else callback(); } else { new ensureExecutor(data, callback, scope); } } window.ensureExecutor = function(data, callback, scope) { this.data = this.clone(data); this.callback = (typeof scope == "undefined" || null == scope ? callback : this.delegate(callback, scope)); this.loadStack = []; if( data.js && data.js.constructor != Array ) this.data.js = [data.js]; if( data.html && data.html.constructor != Array ) this.data.html = [data.html]; if( data.css && data.css.constructor != Array ) this.data.css = [data.css]; if( typeof data.js == "undefined" ) this.data.js = []; if( typeof data.html == "undefined" ) this.data.html = []; if( typeof data.css == "undefined" ) this.data.css = []; this.init(); this.load(); } window.ensureExecutor.prototype = { init : function() { if( typeof jQuery != "undefined" ) { this.getJS = HttpLibrary.loadJavascript_jQuery; this.httpGet = HttpLibrary.httpGet_jQuery; } else if( typeof Prototype != "undefined" ) { this.getJS = HttpLibrary.loadJavascript_Prototype; this.httpGet = HttpLibrary.httpGet_Prototype; } else if( typeof Sys != "undefined" ) { this.getJS = HttpLibrary.loadJavascript_MSAJAX; this.httpGet = HttpLibrary.httpGet_MSAJAX; } else { throw "jQuery, Prototype or MS AJAX framework not found"; } }, getJS : function(data) { }, httpGet : function(url, callback) { }, load : function() { this.loadJavascripts( this.delegate( function() { this.loadCSS( this.delegate( function() { this.loadHtml( this.delegate( function() { this.callback() } ) ) } ) ) } ) ); }, loadJavascripts : function(complete) { var scriptsToLoad = this.data.js.length; if( 0 === scriptsToLoad ) return complete(); this.forEach(this.data.js, function(href) { if( HttpLibrary.isUrlLoaded(href) || this.isTagLoaded('script', 'src', href) ) { scriptsToLoad --; } else { this.getJS({ url: href, success: this.delegate(function(content) { scriptsToLoad --; HttpLibrary.registerUrl(href); }), error: this.delegate(function(msg) { scriptsToLoad --; if(typeof this.data.error == "function") this.data.error(href, msg); }) }); } }); this.until({ test: function() { return scriptsToLoad === 0; }, delay: 50, callback: this.delegate(function() { complete(); }) }); }, loadCSS : function(complete) { if( 0 === this.data.css.length ) return complete(); var head = HttpLibrary.getHead(); this.forEach(this.data.css, function(href) { if( HttpLibrary.isUrlLoaded(href) || this.isTagLoaded('link', 'href', href) ) { } else { var self = this; try { (function(href, head) { var link = document.createElement('link'); link.setAttribute("href", href); link.setAttribute("rel", "Stylesheet"); link.setAttribute("type", "text/css"); head.appendChild(link); HttpLibrary.registerUrl(href); }).apply(window, [href, head]); } catch(e) { if(typeof self.data.error == "function") self.data.error(href, e.message); } } }); complete(); }, loadHtml : function(complete) { var htmlToDownload = this.data.html.length; if( 0 === htmlToDownload ) return complete(); this.forEach(this.data.html, function(href) { if( HttpLibrary.isUrlLoaded(href) ) { htmlToDownload --; } else { this.httpGet({ url: href, success: this.delegate(function(content) { htmlToDownload --; HttpLibrary.registerUrl(href); var parent = (this.data.parent || document.body.appendChild(document.createElement("div"))); if( typeof parent == "string" ) parent = document.getElementById(parent); parent.innerHTML = content; }), error: this.delegate(function(msg) { htmlToDownload --; if(typeof this.data.error == "function") this.data.error(href, msg); }) }); } }); this.until({ test: function() { return htmlToDownload === 0; }, delay: 50, callback: this.delegate(function() { complete(); }) }); }, clone : function(obj) { var cloned = {}; for( var p in obj ) { var x = obj[p]; if( typeof x == "object" ) { if( x.constructor == Array ) { var a = []; for( var i = 0; i < x.length; i ++ ) a.push(x[i]); cloned[p] = a; } else { cloned[p] = this.clone(x); } } else cloned[p] = x; } return cloned; }, forEach : function(arr, callback) { var self = this; for( var i = 0; i < arr.length; i ++ ) callback.apply(self, [arr[i]]); }, delegate : function( func, obj ) { var context = obj || this; return function() { func.apply(context, arguments); } }, until : function(o /* o = { test: function(){...}, delay:100, callback: function(){...} } */) { if( o.test() === true ) o.callback(); else window.setTimeout( this.delegate( function() { this.until(o); } ), o.delay || 50); }, isTagLoaded : function(tagName, attName, value) { var tag = document.createElement(tagName); tag[attName] = value; var tagFound = false; var tags = document.getElementsByTagName(tagName); this.forEach(tags, function(t) { if( tag[attName] === t[attName] ) { tagFound = true; return false } }); return tagFound; } } var userAgent = navigator.userAgent.toLowerCase(); var HttpLibrary = { browser : { version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1], safari: /webkit/.test( userAgent ), opera: /opera/.test( userAgent ), msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) }, loadedUrls : {}, isUrlLoaded : function(url) { return HttpLibrary.loadedUrls[url] === true; }, unregisterUrl : function(url) { HttpLibrary.loadedUrls[url] = false; }, registerUrl : function(url) { HttpLibrary.loadedUrls[url] = true; }, createScriptTag : function(url, success, error) { var scriptTag = document.createElement("script"); scriptTag.setAttribute("type", "text/javascript"); scriptTag.setAttribute("src", url); scriptTag.onload = scriptTag.onreadystatechange = function() { if ( (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) { success(); } }; scriptTag.onerror = function() { error(data.url + " failed to load"); }; var head = HttpLibrary.getHead(); head.appendChild(scriptTag); }, getHead : function() { return document.getElementsByTagName("head")[0] || document.documentElement }, globalEval : function(data) { var script = document.createElement("script"); script.type = "text/javascript"; if ( HttpLibrary.browser.msie ) script.text = data; else script.appendChild( document.createTextNode( data ) ); var head = HttpLibrary.getHead(); head.appendChild( script ); }, loadJavascript_jQuery : function(data) { if( HttpLibrary.browser.safari ) { return jQuery.ajax({ type: "GET", url: data.url, data: null, success: function(content) { HttpLibrary.globalEval(content); data.success(); }, error: function(xml, status, e) { if( xml && xml.responseText ) data.error(xml.responseText); else data.error(url +'\n' + e.message); }, dataType: "html" }); } else { HttpLibrary.createScriptTag(data.url, data.success, data.error); } }, loadJavascript_MSAJAX : function(data) { if( HttpLibrary.browser.safari ) { var params = { url: data.url, success: function(content) { HttpLibrary.globalEval(content); data.success(content); }, error : data.error }; HttpLibrary.httpGet_MSAJAX(params); } else { HttpLibrary.createScriptTag(data.url, data.success, data.error); } }, loadJavascript_Prototype : function(data) { if( HttpLibrary.browser.safari ) { var params = { url: data.url, success: function(content) { HttpLibrary.globalEval(content); data.success(content); }, error : data.error }; HttpLibrary.httpGet_Prototype(params); } else { HttpLibrary.createScriptTag(data.url, data.success, data.error); } }, httpGet_jQuery : function(data) { return jQuery.ajax({ type: "GET", url: data.url, data: null, success: data.success, error: function(xml, status, e) { if( xml && xml.responseText ) data.error(xml.responseText); else data.error("Error occured while loading: " + url +'\n' + e.message); }, dataType: data.type || "html" }); }, httpGet_MSAJAX : function(data) { var _wRequest = new Sys.Net.WebRequest(); _wRequest.set_url(data.url); _wRequest.set_httpVerb("GET"); _wRequest.add_completed(function (result) { var errorMsg = "Failed to load:" + data.url; if (result.get_timedOut()) { errorMsg = "Timed out"; } if (result.get_aborted()) { errorMsg = "Aborted"; } if (result.get_responseAvailable()) data.success( result.get_responseData() ); else data.error( errorMsg ); }); var executor = new Sys.Net.XMLHttpExecutor(); _wRequest.set_executor(executor); executor.executeRequest(); }, httpGet_Prototype : function(data) { new Ajax.Request(data.url, { method: 'get', evalJS: false, // Make sure prototype does not automatically evan scripts onSuccess: function(transport, json) { data.success(transport.responseText || ""); }, onFailure : data.error }); } }; })(); /*! * jCarousel - Riding carousels with jQuery * http://sorgalla.com/jcarousel/ * * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com) * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * Built on top of the jQuery library * http://jquery.com * * Inspired by the "Carousel Component" by Bill Scott * http://billwscott.com/carousel/ */ /*global window, jQuery */ (function($) { var defaults = { vertical: false, rtl: false, start: 1, offset: 1, size: null, scroll: 3, visible: null, animation: 'normal', easing: 'swing', auto: 0, wrap: null, initCallback: null, setupCallback: null, reloadCallback: null, itemLoadCallback: null, itemFirstInCallback: null, itemFirstOutCallback: null, itemLastInCallback: null, itemLastOutCallback: null, itemVisibleInCallback: null, itemVisibleOutCallback: null, animationStepCallback: null, buttonNextHTML: '
', buttonPrevHTML: '
', buttonNextEvent: 'click', buttonPrevEvent: 'click', buttonNextCallback: null, buttonPrevCallback: null, itemFallbackDimension: null }, windowLoaded = false; $(window).bind('load.jcarousel', function() { windowLoaded = true; }); /** * The jCarousel object. * * @constructor * @class jcarousel * @param e {HTMLElement} The element to create the carousel for. * @param o {Object} A set of key/value pairs to set as configuration properties. * @cat Plugins/jCarousel */ $.jcarousel = function(e, o) { this.options = $.extend({}, defaults, o || {}); this.locked = false; this.autoStopped = false; this.container = null; this.clip = null; this.list = null; this.buttonNext = null; this.buttonPrev = null; this.buttonNextState = null; this.buttonPrevState = null; if (!o || o.rtl === undefined) { this.options.rtl = ($(e).attr('dir') || $('html').attr('dir') || '').toLowerCase() == 'rtl'; } this.wh = !this.options.vertical ? 'width' : 'height'; this.lt = !this.options.vertical ? (this.options.rtl ? 'right' : 'left') : 'top'; var skin = '', split = e.className.split(' '); for (var i = 0; i < split.length; i++) { if (split[i].indexOf('jcarousel-skin') != -1) { $(e).removeClass(split[i]); skin = split[i]; break; } } if (e.nodeName.toUpperCase() == 'UL' || e.nodeName.toUpperCase() == 'OL') { this.list = $(e); this.clip = this.list.parents('.jcarousel-clip'); this.container = this.list.parents('.jcarousel-container'); } else { this.container = $(e); this.list = this.container.find('ul,ol').eq(0); this.clip = this.container.find('.jcarousel-clip'); } if (this.clip.size() === 0) { this.clip = this.list.wrap('
').parent(); } if (this.container.size() === 0) { this.container = this.clip.wrap('
').parent(); } if (skin !== '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1) { this.container.wrap('
'); } this.buttonPrev = $('.jcarousel-prev', this.container); if (this.buttonPrev.size() === 0 && this.options.buttonPrevHTML !== null) { this.buttonPrev = $(this.options.buttonPrevHTML).appendTo(this.container); } this.buttonPrev.addClass(this.className('jcarousel-prev')); this.buttonNext = $('.jcarousel-next', this.container); if (this.buttonNext.size() === 0 && this.options.buttonNextHTML !== null) { this.buttonNext = $(this.options.buttonNextHTML).appendTo(this.container); } this.buttonNext.addClass(this.className('jcarousel-next')); this.clip.addClass(this.className('jcarousel-clip')).css({ position: 'relative' }); this.list.addClass(this.className('jcarousel-list')).css({ overflow: 'hidden', position: 'relative', top: 0, margin: 0, padding: 0 }).css((this.options.rtl ? 'right' : 'left'), 0); this.container.addClass(this.className('jcarousel-container')).css({ position: 'relative' }); if (!this.options.vertical && this.options.rtl) { this.container.addClass('jcarousel-direction-rtl').attr('dir', 'rtl'); } var di = this.options.visible !== null ? Math.ceil(this.clipping() / this.options.visible) : null; var li = this.list.children('li'); var self = this; if (li.size() > 0) { var wh = 0, j = this.options.offset; li.each(function() { self.format(this, j++); wh += self.dimension(this, di); }); this.list.css(this.wh, (wh + 100) + 'px'); if (!o || o.size === undefined) { this.options.size = li.size(); } } this.container.css('display', 'block'); this.buttonNext.css('display', 'block'); this.buttonPrev.css('display', 'block'); this.funcNext = function() { self.next(); }; this.funcPrev = function() { self.prev(); }; this.funcResize = function() { if (self.resizeTimer) { clearTimeout(self.resizeTimer); } self.resizeTimer = setTimeout(function() { self.reload(); }, 100); }; if (this.options.initCallback !== null) { this.options.initCallback(this, 'init'); } /*if (!windowLoaded && $.browser.safari) { this.buttons(false, false); $(window).bind('load.jcarousel', function() { self.setup(); }); } else { this.setup(); }*/ this.setup(); }; var $jc = $.jcarousel; $jc.fn = $jc.prototype = { jcarousel: '0.2.8' }; $jc.fn.extend = $jc.extend = $.extend; $jc.fn.extend({ /** * Setups the carousel. * * @method setup * @return undefined */ setup: function() { this.first = null; this.last = null; this.prevFirst = null; this.prevLast = null; this.animating = false; this.timer = null; this.resizeTimer = null; this.tail = null; this.inTail = false; if (this.locked) { return; } this.list.css(this.lt, this.pos(this.options.offset) + 'px'); var p = this.pos(this.options.start, true); this.prevFirst = this.prevLast = null; this.animate(p, false); $(window).unbind('resize.jcarousel', this.funcResize).bind('resize.jcarousel', this.funcResize); if (this.options.setupCallback !== null) { this.options.setupCallback(this); } }, /** * Clears the list and resets the carousel. * * @method reset * @return undefined */ reset: function() { this.list.empty(); this.list.css(this.lt, '0px'); this.list.css(this.wh, '10px'); if (this.options.initCallback !== null) { this.options.initCallback(this, 'reset'); } this.setup(); }, /** * Reloads the carousel and adjusts positions. * * @method reload * @return undefined */ reload: function() { if (this.tail !== null && this.inTail) { this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail); } this.tail = null; this.inTail = false; if (this.options.reloadCallback !== null) { this.options.reloadCallback(this); } if (this.options.visible !== null) { var self = this; var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0; this.list.children('li').each(function(i) { wh += self.dimension(this, di); if (i + 1 < self.first) { lt = wh; } }); this.list.css(this.wh, wh + 'px'); this.list.css(this.lt, -lt + 'px'); } this.scroll(this.first, false); }, /** * Locks the carousel. * * @method lock * @return undefined */ lock: function() { this.locked = true; this.buttons(); }, /** * Unlocks the carousel. * * @method unlock * @return undefined */ unlock: function() { this.locked = false; this.buttons(); }, /** * Sets the size of the carousel. * * @method size * @return undefined * @param s {Number} The size of the carousel. */ size: function(s) { if (s !== undefined) { this.options.size = s; if (!this.locked) { this.buttons(); } } return this.options.size; }, /** * Checks whether a list element exists for the given index (or index range). * * @method get * @return bool * @param i {Number} The index of the (first) element. * @param i2 {Number} The index of the last element. */ has: function(i, i2) { if (i2 === undefined || !i2) { i2 = i; } if (this.options.size !== null && i2 > this.options.size) { i2 = this.options.size; } for (var j = i; j <= i2; j++) { var e = this.get(j); if (!e.length || e.hasClass('jcarousel-item-placeholder')) { return false; } } return true; }, /** * Returns a jQuery object with list element for the given index. * * @method get * @return jQuery * @param i {Number} The index of the element. */ get: function(i) { return $('>.jcarousel-item-' + i, this.list); }, /** * Adds an element for the given index to the list. * If the element already exists, it updates the inner html. * Returns the created element as jQuery object. * * @method add * @return jQuery * @param i {Number} The index of the element. * @param s {String} The innerHTML of the element. */ add: function(i, s) { var e = this.get(i), old = 0, n = $(s); if (e.length === 0) { var c, j = $jc.intval(i); e = this.create(i); while (true) { c = this.get(--j); if (j <= 0 || c.length) { if (j <= 0) { this.list.prepend(e); } else { c.after(e); } break; } } } else { old = this.dimension(e); } if (n.get(0).nodeName.toUpperCase() == 'LI') { e.replaceWith(n); e = n; } else { e.empty().append(s); } this.format(e.removeClass(this.className('jcarousel-item-placeholder')), i); var di = this.options.visible !== null ? Math.ceil(this.clipping() / this.options.visible) : null; var wh = this.dimension(e, di) - old; if (i > 0 && i < this.first) { this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px'); } this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px'); return e; }, /** * Removes an element for the given index from the list. * * @method remove * @return undefined * @param i {Number} The index of the element. */ remove: function(i) { var e = this.get(i); if (!e.length || (i >= this.first && i <= this.last)) { return; } var d = this.dimension(e); if (i < this.first) { this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px'); } e.remove(); this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px'); }, /** * Moves the carousel forwards. * * @method next * @return undefined */ next: function() { if (this.tail !== null && !this.inTail) { this.scrollTail(false); } else { this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size !== null && this.last == this.options.size) ? 1 : this.first + this.options.scroll); } }, /** * Moves the carousel backwards. * * @method prev * @return undefined */ prev: function() { if (this.tail !== null && this.inTail) { this.scrollTail(true); } else { this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size !== null && this.first == 1) ? this.options.size : this.first - this.options.scroll); } }, /** * Scrolls the tail of the carousel. * * @method scrollTail * @return undefined * @param b {Boolean} Whether scroll the tail back or forward. */ scrollTail: function(b) { if (this.locked || this.animating || !this.tail) { return; } this.pauseAuto(); var pos = $jc.intval(this.list.css(this.lt)); pos = !b ? pos - this.tail : pos + this.tail; this.inTail = !b; this.prevFirst = this.first; this.prevLast = this.last; this.animate(pos); }, /** * Scrolls the carousel to a certain position. * * @method scroll * @return undefined * @param i {Number} The index of the element to scoll to. * @param a {Boolean} Flag indicating whether to perform animation. */ scroll: function(i, a) { if (this.locked || this.animating) { return; } this.pauseAuto(); this.animate(this.pos(i), a); }, /** * Prepares the carousel and return the position for a certian index. * * @method pos * @return {Number} * @param i {Number} The index of the element to scoll to. * @param fv {Boolean} Whether to force last item to be visible. */ pos: function(i, fv) { var pos = $jc.intval(this.list.css(this.lt)); if (this.locked || this.animating) { return pos; } if (this.options.wrap != 'circular') { i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i); } var back = this.first > i; var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first; var c = back ? this.get(f) : this.get(this.last); var j = back ? f : f - 1; var e = null, l = 0, p = false, d = 0, g; while (back ? --j >= i : ++j < i) { e = this.get(j); p = !e.length; if (e.length === 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); c[back ? 'before' : 'after'](e); if (this.first !== null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) { g = this.get(this.index(j)); if (g.length) { e = this.add(j, g.clone(true)); } } } c = e; d = this.dimension(e); if (p) { l += d; } if (this.first !== null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size === null || j <= this.options.size)))) { pos = back ? pos + d : pos - d; } } var clipping = this.clipping(), cache = [], visible = 0, v = 0; c = this.get(i - 1); j = i; while (++visible) { e = this.get(j); p = !e.length; if (e.length === 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); if (c.length === 0) { this.list.prepend(e); } else { c[back ? 'before' : 'after'](e); } if (this.first !== null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) { g = this.get(this.index(j)); if (g.length) { e = this.add(j, g.clone(true)); } } } c = e; d = this.dimension(e); if (d === 0) { throw new Error('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...'); } if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size) { cache.push(e); } else if (p) { l += d; } v += d; if (v >= clipping) { break; } j++; } for (var x = 0; x < cache.length; x++) { cache[x].remove(); } if (l > 0) { this.list.css(this.wh, this.dimension(this.list) + l + 'px'); if (back) { pos -= l; this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px'); } } var last = i + visible - 1; if (this.options.wrap != 'circular' && this.options.size && last > this.options.size) { last = this.options.size; } if (j > last) { visible = 0; j = last; v = 0; while (++visible) { e = this.get(j--); if (!e.length) { break; } v += this.dimension(e); if (v >= clipping) { break; } } } var first = last - visible + 1; if (this.options.wrap != 'circular' && first < 1) { first = 1; } if (this.inTail && back) { pos += this.tail; this.inTail = false; } this.tail = null; if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) { var m = $jc.intval(this.get(last).css(!this.options.vertical ? 'marginRight' : 'marginBottom')); if ((v - m) > clipping) { this.tail = v - clipping - m; } } if (fv && i === this.options.size && this.tail) { pos -= this.tail; this.inTail = true; } while (i-- > first) { pos += this.dimension(this.get(i)); } this.prevFirst = this.first; this.prevLast = this.last; this.first = first; this.last = last; return pos; }, /** * Animates the carousel to a certain position. * * @method animate * @return undefined * @param p {Number} Position to scroll to. * @param a {Boolean} Flag indicating whether to perform animation. */ animate: function(p, a) { if (this.locked || this.animating) { return; } this.animating = true; var self = this; var scrolled = function() { self.animating = false; if (p === 0) { self.list.css(self.lt, 0); } if (!self.autoStopped && (self.options.wrap == 'circular' || self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size === null || self.last < self.options.size || (self.last == self.options.size && self.tail !== null && !self.inTail))) { self.startAuto(); } self.buttons(); self.notify('onAfterAnimation'); if (self.options.wrap == 'circular' && self.options.size !== null) { for (var i = self.prevFirst; i <= self.prevLast; i++) { if (i !== null && !(i >= self.first && i <= self.last) && (i < 1 || i > self.options.size)) { self.remove(i); } } } }; this.notify('onBeforeAnimation'); if (!this.options.animation || a === false) { this.list.css(this.lt, p + 'px'); scrolled(); } else { var o = !this.options.vertical ? (this.options.rtl ? { 'right': p} : { 'left': p }) : { 'top': p }; var settings = { duration: this.options.animation, easing: this.options.easing, complete: scrolled }; if ($.isFunction(this.options.animationStepCallback)) { settings.step = this.options.animationStepCallback; } this.list.animate(o, settings); } }, /** * Starts autoscrolling. * * @method auto * @return undefined * @param s {Number} Seconds to periodically autoscroll the content. */ startAuto: function(s) { if (s !== undefined) { this.options.auto = s; } if (this.options.auto === 0) { return this.stopAuto(); } if (this.timer !== null) { return; } this.autoStopped = false; var self = this; this.timer = window.setTimeout(function() { self.next(); }, this.options.auto * 1000); }, /** * Stops autoscrolling. * * @method stopAuto * @return undefined */ stopAuto: function() { this.pauseAuto(); this.autoStopped = true; }, /** * Pauses autoscrolling. * * @method pauseAuto * @return undefined */ pauseAuto: function() { if (this.timer === null) { return; } window.clearTimeout(this.timer); this.timer = null; }, /** * Sets the states of the prev/next buttons. * * @method buttons * @return undefined */ buttons: function(n, p) { if (n == null) { n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size === null || this.last < this.options.size); if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size !== null && this.last >= this.options.size) { n = this.tail !== null && !this.inTail; } } if (p == null) { p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1); if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size !== null && this.first == 1) { p = this.tail !== null && this.inTail; } } var self = this; if (this.buttonNext.size() > 0) { this.buttonNext.unbind(this.options.buttonNextEvent + '.jcarousel', this.funcNext); if (n) { this.buttonNext.bind(this.options.buttonNextEvent + '.jcarousel', this.funcNext); } this.buttonNext[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true); if (this.options.buttonNextCallback !== null && this.buttonNext.data('jcarouselstate') != n) { this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); }).data('jcarouselstate', n); } } else { if (this.options.buttonNextCallback !== null && this.buttonNextState != n) { this.options.buttonNextCallback(self, null, n); } } if (this.buttonPrev.size() > 0) { this.buttonPrev.unbind(this.options.buttonPrevEvent + '.jcarousel', this.funcPrev); if (p) { this.buttonPrev.bind(this.options.buttonPrevEvent + '.jcarousel', this.funcPrev); } this.buttonPrev[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true); if (this.options.buttonPrevCallback !== null && this.buttonPrev.data('jcarouselstate') != p) { this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); }).data('jcarouselstate', p); } } else { if (this.options.buttonPrevCallback !== null && this.buttonPrevState != p) { this.options.buttonPrevCallback(self, null, p); } } this.buttonNextState = n; this.buttonPrevState = p; }, /** * Notify callback of a specified event. * * @method notify * @return undefined * @param evt {String} The event name */ notify: function(evt) { var state = this.prevFirst === null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev'); this.callback('itemLoadCallback', evt, state); if (this.prevFirst !== this.first) { this.callback('itemFirstInCallback', evt, state, this.first); this.callback('itemFirstOutCallback', evt, state, this.prevFirst); } if (this.prevLast !== this.last) { this.callback('itemLastInCallback', evt, state, this.last); this.callback('itemLastOutCallback', evt, state, this.prevLast); } this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast); this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last); }, callback: function(cb, evt, state, i1, i2, i3, i4) { if (this.options[cb] == null || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation')) { return; } var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb]; if (!$.isFunction(callback)) { return; } var self = this; if (i1 === undefined) { callback(self, state, evt); } else if (i2 === undefined) { this.get(i1).each(function() { callback(self, this, i1, state, evt); }); } else { var call = function(i) { self.get(i).each(function() { callback(self, this, i, state, evt); }); }; for (var i = i1; i <= i2; i++) { if (i !== null && !(i >= i3 && i <= i4)) { call(i); } } } }, create: function(i) { return this.format('
  • ', i); }, format: function(e, i) { e = $(e); var split = e.get(0).className.split(' '); for (var j = 0; j < split.length; j++) { if (split[j].indexOf('jcarousel-') != -1) { e.removeClass(split[j]); } } e.addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i)).css({ 'float': (this.options.rtl ? 'right' : 'left'), 'list-style': 'none' }).attr('jcarouselindex', i); return e; }, className: function(c) { return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical'); }, dimension: function(e, d) { var el = $(e); if (d == null) { return !this.options.vertical ? (el.outerWidth(true) || $jc.intval(this.options.itemFallbackDimension)) : (el.outerHeight(true) || $jc.intval(this.options.itemFallbackDimension)); } else { var w = !this.options.vertical ? d - $jc.intval(el.css('marginLeft')) - $jc.intval(el.css('marginRight')) : d - $jc.intval(el.css('marginTop')) - $jc.intval(el.css('marginBottom')); $(el).css(this.wh, w + 'px'); return this.dimension(el); } }, clipping: function() { return !this.options.vertical ? this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) : this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth')); }, index: function(i, s) { if (s == null) { s = this.options.size; } return Math.round((((i - 1) / s) - Math.floor((i - 1) / s)) * s) + 1; } }); $jc.extend({ /** * Gets/Sets the global default configuration properties. * * @method defaults * @return {Object} * @param d {Object} A set of key/value pairs to set as configuration properties. */ defaults: function(d) { return $.extend(defaults, d || {}); }, intval: function(v) { v = parseInt(v, 10); return isNaN(v) ? 0 : v; }, windowLoaded: function() { windowLoaded = true; } }); /** * Creates a carousel for all matched elements. * * @example $("#mycarousel").jcarousel(); * @before
    • First item
    • Second item
    * @result * *
    *
    *
    *
      *
    • First item
    • *
    • Second item
    • *
    *
    *
    *
    *
    *
    * * @method jcarousel * @return jQuery * @param o {Hash|String} A set of key/value pairs to set as configuration properties or a method name to call on a formerly created instance. */ $.fn.jcarousel = function(o) { if (typeof o == 'string') { var instance = $(this).data('jcarousel'), args = Array.prototype.slice.call(arguments, 1); return instance[o].apply(instance, args); } else { return this.each(function() { var instance = $(this).data('jcarousel'); if (instance) { if (o) { $.extend(instance.options, o); } instance.reload(); } else { $(this).data('jcarousel', new $jc(this, o)); } }); } }; })(jQuery); /*============================================================================================================================================================*/ /*TARGET SELECTOR*/ /*============================================================================================================================================================*/ var timeout = 500; var closetimer = 0; var ddmenuitem = 0; function mopen(id) { $("#" + id).show(); } function mclose() { $("#targetMenu").hide(); } function mclosetime() { mclose(); } function mcancelclosetime() { /* if (closetimer) { window.clearTimeout(closetimer); closetimer = null; } */ } document.onclick = mclose;