// LAB.js (LABjs :: Loading And Blocking JavaScript) | v1.0.2rc1 (c) Kyle Simpson | MIT License (function(j){var p="string",w="head",H="body",Y="script",t="readyState",k="preloaddone",y="loadtrigger",I="srcuri",D="preload",Z="complete",z="done",A="which",J="preserve",E="onreadystatechange",ba="onload",K="hasOwnProperty",bb="script/cache",L="[object ",bv=L+"Function]",bw=L+"Array]",e=null,h=true,i=false,s=j.document,bx=j.location,bc=j.ActiveXObject,B=j.setTimeout,bd=j.clearTimeout,M=function(a){return s.getElementsByTagName(a)},N=Object.prototype.toString,O=function(){},q={},P={},be=/^[^?#]*\//.exec(bx.href)[0],bf=/^\w+\:\/\/\/?[^\/]+/.exec(be)[0],by=M(Y),bg=j.opera&&N.call(j.opera)==L+"Opera]",bh=(function(a){a[a]=a+"";return a[a]!=a+""})(new String("__count__")),u={cache:!(bh||bg),order:bh||bg,xhr:h,dupe:h,base:"",which:w};u[J]=i;u[D]=h;q[w]=M(w);q[H]=M(H);function Q(a){return N.call(a)===bv}function R(a,b){var c=/^\w+\:\/\//,d;if(typeof a!==p)a="";if(typeof b!==p)b="";d=(c.test(a)?"":b)+a;return((c.test(d)?"":(d.charAt(0)==="/"?bf:be))+d)}function bz(a){return(R(a).indexOf(bf)===0)}function bA(a){var b,c=-1;while(b=by[++c]){if(typeof b.src===p&&a===R(b.src)&&b.type!==bb)return h}return i}function F(v,l){v=!(!v);if(l==e)l=u;var bi=i,C=v&&l[D],bj=C&&l.cache,G=C&&l.order,bk=C&&l.xhr,bB=l[J],bC=l.which,bD=l.base,bl=O,S=i,x,r=h,m={},T=[],U=e;C=bj||bk||G;function bm(a,b){if((a[t]&&a[t]!==Z&&a[t]!=="loaded")||b[z]){return i}a[ba]=a[E]=e;return h}function V(a,b,c){c=!(!c);if(!c&&!(bm(a,b)))return;b[z]=h;for(var d in m){if(m[K](d)&&!(m[d][z]))return}bi=h;bl()}function bn(a){if(Q(a[y])){a[y]();a[y]=e}}function bE(a,b){if(!bm(a,b))return;b[k]=h;B(function(){q[b[A]].removeChild(a);bn(b)},0)}function bF(a,b){if(a[t]===4){a[E]=O;b[k]=h;B(function(){bn(b)},0)}}function W(b,c,d,g,f,n){var o=b[A];B(function(){if("item"in q[o]){if(!q[o][0]){B(arguments.callee,25);return}q[o]=q[o][0]}var a=s.createElement(Y);a.type=d;if(typeof g===p)a.charset=g;if(Q(f)){a[ba]=a[E]=function(){f(a,b)};a.src=c}q[o].insertBefore(a,(o===w?q[o].firstChild:e));if(typeof n===p){a.text=n;V(a,b,h)}},0)}function bo(a,b,c,d){P[a[I]]=h;W(a,b,c,d,V)}function bp(a,b,c,d){var g=arguments;if(r&&a[k]==e){a[k]=i;W(a,b,bb,d,bE)}else if(!r&&a[k]!=e&&!a[k]){a[y]=function(){bp.apply(e,g)}}else if(!r){bo.apply(e,g)}}function bq(a,b,c,d){var g=arguments,f;if(r&&a[k]==e){a[k]=i;f=a.xhr=(bc?new bc("Microsoft.XMLHTTP"):new j.XMLHttpRequest());f[E]=function(){bF(f,a)};f.open("GET",b);f.send("")}else if(!r&&a[k]!=e&&!a[k]){a[y]=function(){bq.apply(e,g)}}else if(!r){P[a[I]]=h;W(a,b,c,d,e,a.xhr.responseText);a.xhr=e}}function br(a){if(a.allowDup==e)a.allowDup=l.dupe;var b=a.src,c=a.type,d=a.charset,g=a.allowDup,f=R(b,bD),n,o=bz(f);if(typeof c!==p)c="text/javascript";if(typeof d!==p)d=e;g=!(!g);if(!g&&((P[f]!=e)||(r&&m[f])||bA(f))){if(m[f]!=e&&m[f][k]&&!m[f][z]&&o){V(e,m[f],h)}return}if(m[f]==e)m[f]={};n=m[f];if(n[A]==e)n[A]=bC;n[z]=i;n[I]=f;S=h;if(!G&&bk&&o)bq(n,f,c,d);else if(!G&&bj)bp(n,f,c,d);else bo(n,f,c,d)}function bs(a){T.push(a)}function X(a){if(v&&!G)bs(a);if(!v||C)a()}function bt(a){var b=[],c;for(c=-1;++c -1) { cookie_start = cookie_start+name.length; cookie_end = document.cookie.indexOf(';', cookie_start); if(cookie_end == -1) { cookie_end = document.cookie.length; } return unescape(document.cookie.substring(cookie_start, cookie_end)); } } // Set a cookie function set_cookie(name, value, expires) { if(!expires) { expires = "; expires=Wed, 1 Jan 2020 00:00:00 GMT;" } else { expire = new Date(); expire.setTime(expire.getTime()+(expires*1000)); expires = "; expires="+expire.toGMTString(); } document.cookie = name+"="+escape(value)+expires; } /* Javascript functions for the products page */ var num_products_to_compare = 0; var product_option_value = ""; var CurrentProdTab = ""; function showProductImage(filename, product_id, currentImage) { var l = (screen.availWidth/2)-350; var t = (screen.availHeight/2)-300; var variationAdd = ''; if(ShowVariationThumb) { variationAdd = '&image_rule_id=' + encodeURIComponent(ShowVariationThumb); CurrentProdThumbImage = null; } UrlAddOn = ''; if(currentImage) { UrlAddOn = "¤t_image="+currentImage; } else if(CurrentProdThumbImage) { UrlAddOn = "¤t_image="+CurrentProdThumbImage; } var imgPopup = window.open(filename + "?product_id="+product_id+variationAdd+UrlAddOn, "imagePop", "toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=700,height=600,top="+t+",left="+l); imgPopup.focus(); } function CheckQuantityLimits (form) { var qty = parseInt($('#qty_').val(), 10); if (qty < productMinQty) { alert(lang.ProductMinQtyError); return false; } if (qty > productMaxQty) { alert(lang.ProductMaxQtyError); return false; } return true; } function CheckProductConfigurableFields(form) { var requiredFields = $('.FieldRequired'); var valid = true; requiredFields.each(function() { var namePart = this.name.replace(/^.*\[/, ''); var fieldId = namePart.replace(/\].*$/, ''); if(this.type=='checkbox' ) { if(!this.checked) { valid = false; alert(lang.EnterRequiredField); this.focus(); return false; } } else if(this.value == '') { if(this.type != 'file' || (this.type == 'file' && document.getElementById('CurrentProductFile_'+fieldId).value == '')) { valid = false; alert(lang.EnterRequiredField); this.focus(); return false; } } }); var fileFields = $(form).find("input[name^='ProductField']:file"); fileFields.each(function() { if(this.value != '') { var namePart = this.name.replace(/^.*\[/, ''); var fieldId = namePart.replace(/\].*$/, ''); var fileTypes = document.getElementById('ProductFileType_'+fieldId).value; fileTypes = ','+fileTypes.replace(' ', '').toLowerCase()+',' var ext = this.value.replace(/^.*\./, '').toLowerCase(); if(fileTypes.indexOf(','+ext+',') == -1) { alert(lang.InvalidFileTypeJS); this.focus(); this.select(); valid = false; } } }); return valid; } function check_add_to_cart(form, required) { var valid = true; var qtyInputs = $(form).find('input.qtyInput'); qtyInputs.each(function() { if(isNaN($(this).val()) || $(this).val() <= 0) { alert(lang.InvalidQuantity); this.focus(); this.select(); valid = false; return false; } }); if(valid == false) { return false; } if(!CheckProductConfigurableFields(form)) { return false; } // validate the attributes var attributesValidated = $('#productDetailsAddToCartForm') .validate() .form(); if (!attributesValidated) { return false; } if (!CheckQuantityLimits(form)) { return false; } if(required && !$(form).find('.CartVariationId').val()) { alert(lang.OptionMessage); var select = $(form).find('select').get(0); if(select) { select.focus(); } var radio = $(form).find('input[type=radio]').get(0); if(radio) { radio.focus(); } return false; } if (!CheckEventDate()) { return false; } // if we're using the fastcart, pop that up now if (config.FastCart) { return fastCartAction(); } return true; } function compareProducts(compare_path) { var pids = ""; if($('form').find('input[name=compare_product_ids]:checked').size() >= 2) { var cpids = document.getElementsByName('compare_product_ids'); for(i = 0; i < cpids.length; i++) { if(cpids[i].checked) pids = pids + cpids[i].value + "/"; } pids = pids.replace(/\/$/, ""); document.location.href = compare_path + pids; return false; } alert(lang.CompareSelectMessage); return false; } function product_comparison_box_changed(state) { // Increment num_products_to_compare - needs to be > 0 to submit the product comparison form if(state) num_products_to_compare++; else if (num_products_to_compare != 0) num_products_to_compare--; } function remove_product_from_comparison(id) { if(num_compare_items > 2) { for(i = 1; i < 11; i++) { document.getElementById("compare_"+i+"_"+id).style.display = "none"; } num_compare_items--; } else { alert(lang.CompareTwoProducts); } } (function($){ $.fn.captchaPlaceholder = function () { $(this).each(function(){ var $$ = $(this); if (!$$.parent().is(':visible')) { // don't do anything if this placeholder isn't visible return; } var img = $$.find('.captchaImage'); if (img.length) { // don't do anything if an image is already in the dom return; } var rand = Math.round(500 + Math.random() * 7500); img = $(''); $$.append(img); }); return this; }; })(jQuery); function show_product_review_form() { document.getElementById("rating_box").style.display = ""; if(typeof(HideProductTabs) != 'undefined' && HideProductTabs == 0) { CurrentProdTab = 'ProductReviews_Tab'; } else { document.location.href = "#write_review"; } $('.captchaPlaceholder').captchaPlaceholder(); } function jump_to_product_reviews() { if(typeof(HideProductTabs) != 'undefined' && HideProductTabs == 0) { CurrentProdTab = 'ProductReviews_Tab'; } else { document.location.href = "#reviews"; } } function g(id) { return document.getElementById(id); } function check_product_review_form() { var revrating = g("revrating"); var revtitle = g("revtitle"); var revtext = g("revtext"); var revfromname = g("revfromname"); var captcha = g("captcha"); if(revrating.selectedIndex == 0) { alert(lang.ReviewNoRating); revrating.focus(); return false; } if(revtitle.value == "") { alert(lang.ReviewNoTitle); revtitle.focus(); return false; } if(revtext.value == "") { alert(lang.ReviewNoText); revtext.focus(); return false; } if(captcha.value == "" && HideReviewCaptcha != "none") { alert(lang.ReviewNoCaptcha); captcha.focus(); return false; } return true; } function check_small_search_form() { var search_query = g("search_query"); if(search_query.value == "") { alert(lang.EmptySmallSearch); search_query.focus(); return false; } return true; } function setCurrency(currencyId) { var gotoURL = location.href; if (location.search !== '') { if (gotoURL.search(/[&|\?]setCurrencyId=[0-9]+/) > -1) gotoURL = gotoURL.replace(/([&|\?]setCurrencyId=)[0-9]+/, '$1' + currencyId); else gotoURL = gotoURL + '&setCurrencyId=' + currencyId; } else gotoURL = gotoURL + '?setCurrencyId=' + currencyId; location.href = gotoURL; } // Dummy sel_panel function for when design mode isn't enabled function sel_panel(id) {} function inline_add_to_cart(filename, product_id, quantity, returnTo) { if(typeof(quantity) == 'undefined') { var quantity = '1'; } var html = '
'; if(typeof(returnTo) != 'undefined' && returnTo == true) { var returnLocation = window.location; html += ''; } html += ''; html += ''; html += ''; html += '<\/form>'; $('body').append(html); $('#inlineCartAdd').submit(); } function ShowPopupHelp(content, url, decodeHtmlEntities) { var popupWindow = open('', 'view','height=450,width=550'); if(decodeHtmlEntities) { content = HtmlEntityDecode(content); } if (window.focus) { popupWindow.focus(); } var doc = popupWindow.document; doc.write(content); doc.close(); return false; } function HtmlEntityDecode(str) { try { var tarea=document.createElement('textarea'); tarea.innerHTML = str; return tarea.value; tarea.parentNode.removeChild(tarea); } catch(e) { //for IE add to the page document.getElementById("htmlconverter").innerHTML = ''; var content = document.getElementById("innerConverter").value; document.getElementById("htmlconverter").innerHTML = ""; return content; } } function setProductThumbHeight() { var ImageBoxDiv = $('.Content .ProductList .ProductImage'); var ImageListDiv = $('.Content .ProductList:not(.List) li'); var CurrentListHeight = ImageListDiv.height(); var ProductImageMargin = ImageBoxDiv.css('margin-left')*2; /* ImageBoxDiv.height(ThumbImageHeight); ImageBoxDiv.width(ThumbImageWidth); ImageBoxDiv.css('line-height', ThumbImageHeight+'px'); */ var ImageBoxHeight = ThumbImageHeight; if (parseInt(ImageBoxDiv.css("padding-top"), 10)) { ImageBoxHeight += parseInt(ImageBoxDiv.css("padding-top"), 10) * 2; //Total Padding Width } if(parseInt(ImageBoxDiv.css("margin-top"), 10)) { ImageBoxHeight += parseInt(ImageBoxDiv.css("margin-top"), 10) * 2; //Total Margin Width } if (parseInt(ImageBoxDiv.css("borderTopWidth"), 10)) { ImageBoxHeight += parseInt(ImageBoxDiv.css("borderTopWidth"), 10) * 2; //Total Border Width } ImageBoxDiv.height(ImageBoxHeight); ImageBoxDiv.width(ThumbImageWidth); if ($.browser.msie && $.browser.version >= 7 && $.browser.version < 8) { // this is a specific browser check because this fix is only applicable for ie7 ImageBoxDiv.css('line-height', ImageBoxHeight+'px'); } //calculate the new list container width based on the difference between the thumb image and default thumb size var ImageListWidth = ImageListDiv.width() + (ThumbImageWidth-120); ImageListDiv.width(ImageListWidth); // var ImageListHeight = ImageListDiv.height() + (ImageBoxDiv.height() - 120); // ImageListDiv.height(ImageListHeight); $('.Content .ProductList.List .ProductDetails').css('margin-left',ThumbImageWidth+2+'px'); $('.Content .ProductList.List li').height(Math.max(CurrentListHeight, ThumbImageHeight)); } // Dummy JS object to hold language strings. if (typeof lang == 'undefined') { lang = {}; } /** * A javascript equivalent of server-side getLang method with replacements support. The specified language entry must be * present in the lang object. Returns a blank string if it is not. * * Usage: * getLang('ProductMinQtyError', { qty: 10, product: 'Test Product' }); // pass the name of the language entry * * @param string name * @param object replacements * @return string */ function getLang (name, replacements) { if (!lang[name]) { return ''; } var string = lang[name]; if (typeof replacements != 'object') { return string; } $.each(replacements, function(needle, haystack){ string = string.replace(':' + needle, haystack); }); return string; } // IE 6 doesn't support the :hover selector on elements other than links, so // we use jQuery to work some magic to get our hover styles applied. if(document.all) { var isIE7 = /*@cc_on@if(@_jscript_version>=5.7)!@end@*/false; if(isIE7 == false) { $(document).ready(function() { $('.ProductList li').hover(function() { $(this).addClass('Over'); }, function() { $(this).removeClass('Over'); }); $('.ComparisonTable tr').hover(function() { $(this).addClass('Over'); }, function() { $(this).removeClass('Over'); }); }); } $('.ProductList li:last-child').addClass('LastChild'); } function ShowLoadingIndicator() { if (typeof(disableLoadingIndicator) != 'undefined' && disableLoadingIndicator) { return; } var width = $(window).width(); var position = $('#Container').css('position'); if (position == 'relative') { width = $('#Container').width(); } var scrollTop; if(self.pageYOffset) { scrollTop = self.pageYOffset; } else if(document.documentElement && document.documentElement.scrollTop) { scrollTop = document.documentElement.scrollTop; } else if(document.body) { scrollTop = document.body.scrollTop; } $('#AjaxLoading').css('position', 'absolute'); $('#AjaxLoading').css('top', scrollTop+'px'); $('#AjaxLoading').css('left', parseInt((width-150)/2)+"px"); $('#AjaxLoading').show(); } function HideLoadingIndicator() { $('#AjaxLoading').hide(); } var loadedImages = {}; // Ensure that all product lists are the same height function setProductListHeights(imgName, className) { // hack job putting this here but it needs to be reused by search ajax pager if (typeof(DesignMode) != 'undefined') { return; } if (typeof imgName != 'undefined') { if (typeof loadedImages[imgName] != 'undefined') { return; } loadedImages[imgName] = true; } setProductThumbHeight(); /** * Sets the height of the elements passed in to match that of the one that * has the greatest height. * * @param ele The element(s) to adjust the height for. * @return void */ function setHeight(ele) { var ele = $(ele), maxHeight = 0; ele // reset the height just in case it was set by the stylesheet so // we can detect it .css('height', 'auto') // get the one with the greatest height .each(function() { if ($(this).height() > maxHeight) { maxHeight = $(this).height(); } }) // and set them all to the greatest height .css('height', maxHeight); } if (!className) { className = '.Content'; } setHeight(className + ' .ProductList:not(.List) li .ProductDetails'); if (typeof imgName != 'undefined') { setHeight(className + ' .ProductList:not(.List) li .ProductPriceRating:has(img[src$=\''+imgName+'\'])'); } setHeight(className + ' .ProductList:not(.List) li'); } function fastCartAction(event) { var url = ''; var modalOptions; // Supplied URL if (typeof(event) == 'string') { var url = event; // Make sure a valid URL was supplied if (!url || url.indexOf('cart.php') == -1) { return false; } // strip protocol from url to fix cross protocol ajax access denied problem url = url.replace(/^http[s]{0,1}:\/\/[^\/]*\/?/, '/'); url += '&fastcart=1'; $.ajax({ url: url, dataType: 'json', success: function(data) { if (data.success) { modalOptions = { data: data }; _showFastCart(modalOptions); } else if (data.redirect) { window.location.href = data.redirect; } } }); } // 'Add' button on product details page else { $('#productDetailsAddToCartForm').ajaxSubmit({ data: { fastcart: 1, ajaxsubmit: 1 }, type: 'post', iframe: true, dataType: 'json', success: function(data) { if (data.success) { modalOptions = { data: data }; _showFastCart(modalOptions); } else if (data.redirect) { window.location.href = data.redirect; } } }); } return false; } function _showFastCart(modalOptions) { modalOptions = $.extend({ width: 700, closeTxt: true, onShow: function() { $("#fastCartSuggestive a[href*='cart.php?action=add']").unbind('click'); $("#fastCartSuggestive a[href*='cart.php?action=add']").click(function(event) { // attach action to suggestive products' link fastCartAction(event); }); var itemTxt = $('#fastCartNumItemsTxt').html(); if (itemTxt) { // update the view cart item count on top menu $('.CartLink span').html('(' + itemTxt + ')'); } setProductListHeights(null, '.fastCartContent'); $('.fastCartContent .ProductList:not(.List) li').width(ThumbImageWidth); }, onClose: function() { if (window.location.href.match(config.ShopPath + '/cart.php')) { // reload if we are on the cart page $('#ModalContainer').remove(); window.location = window.location.href } else { $('#ModalContainer').remove(); } } }, modalOptions); $.iModal.close(); $.iModal(modalOptions); } /** * Adds a script tag to the DOM that forces a hit to tracksearchclick. Should be called by a mousedown event as calling it by a click event can sometimes be cancelled by the browser navigating away from the page. */ function isc_TrackSearchClick (searchId) { if (!searchId) { return; } $('#SearchTracker').remove(); var trackurl = 'search.php?action=tracksearchclick&searchid=' + encodeURIComponent(searchId) + '&random=' + Math.random(); var script = document.createElement('script'); script.type = "text/javascript"; script.src = trackurl; script.id = "SearchTracker"; window.document.body.appendChild(script); } $(document).ready(function() { if($('.Rating img').length > 0) { $('.Rating img').each(function() { if($(this).height() == 0) { $(this).load(function() { // Load rating img and find the tallest product. var imgName = $(this).attr('src').split('/'); var imgKey = imgName.length-1; setProductListHeights(imgName[imgKey]); }); } else { setProductListHeights(); return false; } }); } else { setProductListHeights(); } $('.InitialFocus').focus(); $('table.Stylize tr:first-child').addClass('First'); $('table.Stylize tr:last-child').addClass('Last'); $('table.Stylize tr td:odd').addClass('Odd'); $('table.Stylize tr td:even').addClass('Even'); $('table.Stylize tr:even').addClass('Odd'); $('table.Stylize tr:even').addClass('Even'); $('.TabContainer .TabNav li').click(function() { $(this).parent('.TabNav').find('li').removeClass('Active'); $(this).parents('.TabContainer').find('.TabContent').hide(); $(this).addClass('Active'); $(this).parents('.TabContainer').find('#TabContent'+this.id).show(); $(this).find('a').blur(); return false; }); $('html').ajaxStart(function() { ShowLoadingIndicator(); }); $('html').ajaxComplete(function() { HideLoadingIndicator(); }); // generic checkbox => element visibility toggle based on id of checkbox and class names of other elements $('.CheckboxTogglesOtherElements').live('change', function(event){ if (!this.id) { return; } var className = 'ShowIf_' + this.id + '_Checked'; var elements = $('.' + className); if (this.checked) { // easy, show matching elements elements.show(); return; } // if not checked it's a little more tricky -- only hide elements if they are not showing for multiple check boxes var classExpression = /^ShowIf_(.+)_Checked$/; elements.each(function(){ var $$ = $(this); // before hiding this element, check its classes to see if it has another ShowIf_?_Checked - if it does, see if that class points to a checked box var classes = $$.attr('class').split(/\s+/); var checked = false; $.each(classes, function(key,value){ if (value === className) { // we're processing this class already so we know it's unchecked - ignore it return; } var result = classExpression.exec(value); if (result === null) { // not a ShowIf_?_Class return; } var id = result[1]; if ($('#' + id ).attr('checked')) { // found a checked box checked = true; return false; } }); if (!checked) { // found no checkbox that should be keeping this element visible $$.hide(); } }); }).change(); }); var config = {}; /** * Add a method to the Date object prototype to set the full * year using an ISO 8601 format string. * * Usage: * var d = new Date(); * d.setISO('1980-01-08'); */ if (typeof Date.prototype.setISO == 'undefined') { Date.prototype.setISO = function (isoFmt) { var dtparts = isoFmt.split('-'); this.setFullYear(dtparts[0], dtparts[1] - 1, dtparts[2]); }; }/* ISSelectReplacement */ if(typeof(ISSelectReplacement) == 'undefined') { var ISSelectReplacement = { init: function() { if(window.addEventListener) window.addEventListener('load', ISSelectReplacement.on_load, false); else window.attachEvent('onload', ISSelectReplacement.on_load); }, on_load: function() { var selects = document.getElementsByTagName('SELECT'); if(!selects) return false; for(var i = 0; i < selects.length; i++) { var select = selects[i]; if(!select.multiple || select.className.indexOf('ISSelectReplacement') == -1 || select.className.indexOf('ISSelectAlreadyReplaced') != -1) continue; // Only multiple selects are supported ISSelectReplacement.replace_select(selects[i]); } }, replace_select: function(element) { var name = element.name; element.style.visibility = 'hidden'; // Start whipping up our replacement var replacement = document.createElement('DIV'); replacement.className = "ISSelect "+element.className; replacement.className += " ISSelectAlreadyReplaced"; var hideSelectReplacement = false; // If the offsetHeight is 0, this select is hidden if(element.offsetHeight == 0) { var clone = element.cloneNode(true); clone.style.position = 'absolute'; clone.style.left = '-10000px'; clone.style.top = '-10000px'; clone.style.display = 'block'; document.body.appendChild(clone); offset_height = clone.offsetHeight+"px"; offset_width = clone.offsetWidth+"px"; clone.parentNode.removeChild(clone); if(element.style.display && element.style.display == 'none') { var hideSelectReplacement = true; } } else { offset_height = element.offsetHeight+"px"; offset_width = element.offsetWidth+"px"; } var style_offset_width = ISSelectReplacement.get_prop(element, 'width'); if(style_offset_width && style_offset_width != "auto") offset_width = style_offset_width; var style_offset_height = ISSelectReplacement.get_prop(element, 'height'); if(style_offset_height && style_offset_height != "auto") offset_height = style_offset_height; replacement.style.height = offset_height; if(parseInt(offset_width) < 200) { offset_width = '200px'; } replacement.style.width = offset_width; if(element.id) { replacement.id = element.id; element.id += "_old"; } if(hideSelectReplacement) { replacement.style.display = 'none'; } replacement.select = element; replacement.options = element.options; replacement.selectedIndex = element.selectedIndex; this.select = element; this.replacement = replacement; if(element.onchange) { replacement.onclick = function() { $(this.select).trigger('change'); } } if(element.ondblclick) { replacement.ondblclick = function() { $(this.select).trigger('dblclick'); } } var innerhtml = ''; replacement.innerHTML = innerhtml; element.parentNode.insertBefore(replacement, element); element.style.display = 'none'; }, get_prop: function(element, prop) { if(element.currentStyle) { return element.currentStyle[prop]; } else if(document.defaultView && document.defaultView.getComputedStyle) { prop = prop.replace(/([A-Z])/g,"-$1"); prop = prop.toLowerCase(); return document.defaultView.getComputedStyle(element, "").getPropertyValue(prop); } }, add_group: function(select, group, group_id) { var extraClass = ''; if(group.className) { extraClass = group.className; } group_html = '
  • ' + '
    '+group.label+'
    '; if(group.childNodes) { group_html += '
      '; for(var i = 0; i < group.childNodes.length; i++) { if(!group.childNodes[i].tagName || group.childNodes[i].nodeType == 3) continue; group_html += ISSelectReplacement.add_option(select, group.childNodes[i], [group_id, i]); } group_html += '
    '; } group_html += '
  • '; return group_html; }, add_option: function(select, option, id) { var value, element_class, checked = ''; if(option.selected) { element_class = "SelectedRow"; checked = 'checked="checked"' } else { element_class = ''; } if(option.className) { element_class += ' '+option.className; } var label = option.innerHTML; var whitespace = label.match(/^\s*( )*/); if(whitespace[0]) { label = label.replace(/^\s*( )*/, ''); } var disabled = ''; if(this.select.disabled) { var disabled = ' disabled="disabled"'; } var extraKey = ''; var extra = ''; if(option.className && option.className.indexOf('forceKey') != -1) { var start = option.className.indexOf('forceKey'); var end = option.className.indexOf(' ', start+1); if(end == -1) { var end = option.className.length; } var extraKey = option.className.substring(start+8, end); var extra = '[]'; } html = '
  • ' + whitespace[0]; if($(option).hasClass('freeform')) { html += ''; } else { html += '' + label; } html += '
  • '; return html; }, on_hover: function(element, id, action) { var id = id.split(','); // Selected an option group child if(id.length == 2) { var replacement = element.parentNode.parentNode.parentNode.parentNode.nextSibling; var option = replacement.childNodes[id[0]].childNodes[id[1]]; } else { var replacement = element.parentNode.parentNode.nextSibling; var option = replacement.childNodes[id[0]]; } if(action == 'out') { $(element).removeClass('ISSelectOptionHover'); $(option).trigger('mouseout'); } else { if(!$(element).hasClass('SelectedRow')) { $(element).addClass('ISSelectOptionHover'); } $(option).trigger('mouseover'); } }, scrollToItem: function(select_name, value, group) { var item = 'ISSelect'+select_name.replace('[]', '')+'_'+value; if(!document.getElementById(item)) return; var obj = document.getElementById(item); var top = obj.offsetTop-4; if(typeof(group) != 'undefined') { top -= 20; } while(obj && obj.tagName != 'DIV') { obj = obj.parentNode; if(obj && obj.tagName == 'DIV') { obj.scrollTop = top; break; } } }, on_click: function(element, id) { if(element.dblclicktimeout) { return false; } if(element.tagName == "INPUT") { var checkbox = element; if(checkbox.disabled) { return false; } var element = element.parentNode; } else { var checkbox = element.getElementsByTagName('input')[0]; if(checkbox.disabled) { return false; } checkbox.checked = !checkbox.checked; } element.dblclicktimeout = setTimeout(function() { element.dblclicktimeout = ''; }, 250); var id = id.split(','); // Selected an option group child if(id.length == 2) { var replacement = element.parentNode.parentNode.parentNode.parentNode.nextSibling; var option = replacement.childNodes[id[0]].childNodes[id[1]]; } else { var replacement = element.parentNode.parentNode.nextSibling; var option = replacement.childNodes[id[0]]; } option.selected = checkbox.checked; $(element).parents('div')[0].selectedIndex = replacement.selectedIndex; $(option).triggerHandler('click'); if (checkbox.checked) { $(element).addClass('SelectedRow'); } else { $(element).removeClass('SelectedRow'); } } }; ISSelectReplacement.init(); } /*! * jQuery Form Plugin * version: 2.64 (25-FEB-2011) * @requires jQuery v1.3.2 or later * * Examples and documentation at: http://malsup.com/jquery/form/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ ;(function($) { /* Usage Note: ----------- Do not use both ajaxSubmit and ajaxForm on the same form. These functions are intended to be exclusive. Use ajaxSubmit if you want to bind your own submit handler to the form. For example, $(document).ready(function() { $('#myForm').bind('submit', function(e) { e.preventDefault(); // <-- important $(this).ajaxSubmit({ target: '#output' }); }); }); Use ajaxForm when you want the plugin to manage all the event binding for you. For example, $(document).ready(function() { $('#myForm').ajaxForm({ target: '#output' }); }); When using ajaxForm, the ajaxSubmit function will be invoked for you at the appropriate time. */ /** * ajaxSubmit() provides a mechanism for immediately submitting * an HTML form using AJAX. */ $.fn.ajaxSubmit = function(options) { // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) if (!this.length) { log('ajaxSubmit: skipping submit process - no element selected'); return this; } if (typeof options == 'function') { options = { success: options }; } var action = this.attr('action'); var url = (typeof action === 'string') ? $.trim(action) : ''; if (url) { // clean url (don't include hash vaue) url = (url.match(/^([^#]+)/)||[])[1]; } url = url || window.location.href || ''; options = $.extend(true, { url: url, type: this[0].getAttribute('method') || 'GET', // IE7 massage (see issue 57) iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' }, options); // hook for manipulating the form data before it is extracted; // convenient for use with rich editors like tinyMCE or FCKEditor var veto = {}; this.trigger('form-pre-serialize', [this, options, veto]); if (veto.veto) { log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); return this; } // provide opportunity to alter form data before it is serialized if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { log('ajaxSubmit: submit aborted via beforeSerialize callback'); return this; } var n,v,a = this.formToArray(options.semantic); if (options.data) { options.extraData = options.data; for (n in options.data) { if(options.data[n] instanceof Array) { for (var k in options.data[n]) { a.push( { name: n, value: options.data[n][k] } ); } } else { v = options.data[n]; v = $.isFunction(v) ? v() : v; // if value is fn, invoke it a.push( { name: n, value: v } ); } } } // give pre-submit callback an opportunity to abort the submit if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { log('ajaxSubmit: submit aborted via beforeSubmit callback'); return this; } // fire vetoable 'validate' event this.trigger('form-submit-validate', [a, this, options, veto]); if (veto.veto) { log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); return this; } var q = $.param(a); if (options.type.toUpperCase() == 'GET') { options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; options.data = null; // data is null for 'get' } else { options.data = q; // data is the query string for 'post' } var $form = this, callbacks = []; if (options.resetForm) { callbacks.push(function() { $form.resetForm(); }); } if (options.clearForm) { callbacks.push(function() { $form.clearForm(); }); } // perform a load on the target only if dataType is not provided if (!options.dataType && options.target) { var oldSuccess = options.success || function(){}; callbacks.push(function(data) { var fn = options.replaceTarget ? 'replaceWith' : 'html'; $(options.target)[fn](data).each(oldSuccess, arguments); }); } else if (options.success) { callbacks.push(options.success); } options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg var context = options.context || options; // jQuery 1.4+ supports scope context for (var i=0, max=callbacks.length; i < max; i++) { callbacks[i].apply(context, [data, status, xhr || $form, $form]); } }; // are there files to upload? var fileInputs = $('input:file', this).length > 0; var mp = 'multipart/form-data'; var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); // options.iframe allows user to force iframe mode // 06-NOV-09: now defaulting to iframe mode if file input is detected if (options.iframe !== false && (fileInputs || options.iframe || multipart)) { // hack to fix Safari hang (thanks to Tim Molendijk for this) // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d if (options.closeKeepAlive) { $.get(options.closeKeepAlive, fileUpload); } else { fileUpload(); } } else { $.ajax(options); } // fire 'notify' event this.trigger('form-submit-notify', [this, options]); return this; // private function for handling file uploads (hat tip to YAHOO!) function fileUpload() { var form = $form[0]; if ($(':input[name=submit],:input[id=submit]', form).length) { // if there is an input with a name or id of 'submit' then we won't be // able to invoke the submit fn on the form (at least not x-browser) alert('Error: Form elements must not have name or id of "submit".'); return; } var s = $.extend(true, {}, $.ajaxSettings, options); s.context = s.context || s; var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id; var $io = $('