$(document).ready(function() { LoadStates($("#stateName").text()); $("div[displayContainer]").click(function() { if ($(this).attr("display") == "inline") { $(this).text("mostrar"); var row = $(this).parents("tr:first").children("td:eq(3)"); row.html(row.html().replace("row2up", "row2down")); $(this).attr("display", "hidden"); $("#" + $(this).attr("displayContainer") + "").slideUp(); } else { $(this).text("ocultar"); var row = $(this).parents("tr:first").children("td:eq(3)"); row.html(row.html().replace("row2down", "row2up")); $(this).attr("display", "inline"); $("#" + $(this).attr("displayContainer") + "").slideDown(); } }); $(".checkButtonMiddle").hover(function() { $(this).addClass("checkButtonMiddle_Over"); }, function() { $(this).removeClass("checkButtonMiddle_Over"); }); $(".checkButtonMiddle").click(function() { $(this).toggleClass("checkButtonMiddle_Checked"); $(".finalPrices").toggle(); $(".noTaxPrices").toggle(); }); }); function GoToSkill(skill) { var skillContainer = $("div[contains = '"+ skill +"']"); if (skillContainer.html() != "") { $.scrollTo("div[goto='"+ skill +"']", 500); $("a[show='"+ skill +"']").click(); } else { $.scrollTo("#skillsContainer", 500); } } function ShowSkill(skill) { var container = $("#"+ skill +"Container"); $.scrollTo("table[goto='" + skill +"']", 500); container.slideDown(); } function LoadStates(stateName) { $.getJSON("Servicios/Mi-Tienda", { action: "LoadStates", stateName: stateName }, function(data) { var result = eval(data); $("#cmbStates").html(data.states); LoadCities(data.stateId); }); $("#cmbStates").change(function() { LoadCities($(this).val()); }); } function LoadCities(stateId) { $.post("Servicios/Mi-Tienda", { action: "LoadCities", stateId: stateId, cityName: $("#cityName").text() }, function(data) { $("#cmbCities").html(data); }); } function ShowContainer(lnk) { var container = $("#" + $(lnk).attr("displayContainer") + ""); var imgRow = $(lnk).parent("td:first").next().find("img:first"); if (container.is(":visible")) { $(lnk).text("Mostrar"); container.slideUp("fast"); imgRow.attr("src", imgRow.attr("src").replace("row2up", "row2down")); } else { $(lnk).text("Ocultar"); container.slideDown("fast"); imgRow.attr("src", imgRow.attr("src").replace("row2down", "row2up")); } } function ShowEdition() { $("table[btn='editStoreName']").show(); } function HideEdition() { $("table[btn='editStoreName']").hide(); } function LoadStoreNameEdition() { $("#storeNameContainer").hide(); $("#txtStoreName").val($("#lblStoreName").text()).show(); $("table[btn='updateStoreName']").show(); $("table[btn='cancelUpdateStoreName']").show(); } function CancelStoreNameEdition() { $("#storeNameContainer").show(); $("#txtStoreName").hide(); $("table[btn='updateStoreName']").hide(); $("table[btn='cancelUpdateStoreName']").hide(); $("#lblUrlStoreName").text($("#lblStoreName").text()); } function WriteStoreName(txtStoreName) { $("#lblUrlStoreName").text($(txtStoreName).val()); } function UpdateStoreName() { var newStoreName = $("#txtStoreName").val(); var currentUrl = window.location.href; var currentStoreName = currentUrl.substring(currentUrl.lastIndexOf("/") + 1); if (currentUrl != currentStoreName) { $("#imgLoading").show(); $("table[btn='updateStoreName']").hide(); $("table[btn='cancelUpdateStoreName']").hide(); $.getJSON("Servicios/Mi-Tienda", { action: "UpdateStoreName", storeName: newStoreName }, function(data) { var result = eval(data); if (result.failures == 0) { currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf("/") + 1); window.location.href = currentUrl + newStoreName; } else { $("#lblMessage").text(result.message).show(); $("table[btn='updateStoreName']").show(); $("table[btn='cancelUpdateStoreName']").show(); $("#imgLoading").hide(); } }); } } function ShowTabContainer(contains) { $("div[tabContainer]").hide(); $("div[tabContainer='" + contains + "']").show(); $.each($("#tabsStoreInformation div"), function() { $(this).attr("class", $(this).attr("class").replace("active", "normal")); }); var currentTab = $("#tabsStoreInformation div[contains='" + contains + "']"); currentTab.attr("class", currentTab.attr("class").replace("normal", "active")); } var contactEditionDisplayed = false; function ClearTabs() { $.each($("#tabsContainer img"), function() { $(this).attr("src", $(this).attr("src").replace("active", "normal")); }); } function ClearTabContainer() { $.each($("#tabsContainer img"), function() { $(this).attr("src", $(this).attr("src").replace("active", "normal")); }); } function ShowContactEdition(divContainer) { if (!$("#tblContactInfo :text").is(":visible")) { $(divContainer).children("table:first").show(); } } function ClearContactEdition(divContainer) { $(divContainer).children("table:first").hide(); } function ContactEdition(btn) { contactEditionDisplayed = true; $(btn).hide(); $("#tblContactInfo :input").prev().hide(); $("#tblContactInfo :input").show(); $("#updateContactInfo").show(); $("#cancelUpdateContactInfo").show(); } function UpdateContactInfo() { var address = $("#txtAddress").val(); var email = $("#txtEmail").val(); var city = $("#cmbCities").text(); var cityId = $("#cmbCities").val(); var state = $("#cmbStates").text(); var stateId = $("#cmbStates").val(); var webSite = CleanWebSiteURL($("#txtWebSite").val()); var phone = $("#txtPhone").val(); var cellPhone = $("#txtCellPhone").val(); var msn = $("#txtMSN").val(); var skype = $("#txtSkype").val(); $.post("Servicios/Mi-Tienda", { action: "UpdateContactInfo", address: address, email: email, cityId: cityId, webSite: webSite, phone: phone, cellPhone: cellPhone, msn: msn, skype: skype }, function() { $.post("Servicios/Mi-Tienda", { action: "BuildContactInfo", address: address, email: email, stateId: stateId, cityId: cityId, webSite: webSite, phone: phone, cellPhone: cellPhone, msn: msn, skype: skype }, function(data) { $("#contactInfo").html(data); $("#cmbStates").change(function() { LoadCities($(this).val()); }); }); }); } function CleanWebSiteURL(url) { url = url.toLowerCase(); var patron = /http|https/i; if (url.search(patron) != -1) { url = url.substring(url.indexOf("://") + 3); } return url; } function CancelContactInfoUpdate() { contactEditionDisplayed = false; $("#tblContactInfo :input").hide(); $("#tblContactInfo :input").prev().show(); $("#updateContactInfo").hide(); $("#cancelUpdateContactInfo").hide(); } function ShowMoreQuestions(elem) { if ($("#moreQuestions").is(":visible")) { $("#moreQuestions").slideUp(); $(elem).text("Ver más"); $("#rowMoreQuestions").attr("src", $("#rowMoreQuestions").attr("src").replace("up", "down")); } else { $("#moreQuestions").slideDown(); $(elem).text("Ocultar preguntas"); $("#rowMoreQuestions").attr("src", $("#rowMoreQuestions").attr("src").replace("down", "up")); } } function ShowServices() { if ($("div[contains='services']").is(':visible')) { $("a[lnk='showServices']").text("Ver Servicios"); $("div[contains='services']").hide(); } else { $("div[contains='services']").slideDown(); $("a[lnk='showServices']").text("Ocultar Servicios"); } } function ShowCertifications() { if ($("div[contains='certifications']").is(':visible')) { $("a[lnk='showCertifications']").text("Ver Certificaciones"); $("div[contains='certifications']").hide(); } else { $("div[contains='certifications']").slideDown(); $("a[lnk='showCertifications']").text("Ocultar Certificaciones"); } } function ShowExperience() { if ($("div[contains='experience']").is(':visible')) { $("a[lnk='showExperience']").text("Ver Experiencia"); $("div[contains='experience']").hide(); } else { $("div[contains='experience']").slideDown(); $("a[lnk='showExperience']").text("Ocultar Experiencia"); } } function FilterProducts() { var query = $("#txtProduct").val(); var currentBrandFilter = ""; var currentCategoryFilter = ""; $("#products div").hide().filter("div[brand*=" + currentBrandFilter + "][category*=" + currentCategoryFilter + "][query*=" + query.toLowerCase() + "]").show(); } function ProductOver(elem) { $(elem).attr("background", $(elem).attr("background").replace("normal","over")); } function ProductOut(elem) { $(elem).attr("background", $(elem).attr("background").replace("over", "normal")); }