
function xtractFile(data){
var m = data.match(/(.*)\/([^\/\\]+)(\.\w+)$/);
if(m == null) { m = "null"; }
return {path: m[1], file: m[2], extension: m[3]}
}

jQuery.noConflict();

jQuery(document).ready(function() {

    //jQuery(".subBanner").length > 0 ? jQuery(".catTitle").hide() : null;

    jQuery("img.jqzoom").jqueryzoom({
        xzoom: 300, //zooming div default width(default width value is 200)
        yzoom: 300, //zooming div default width(default height value is 200)
        offset: 10 //zooming div default offset(default offset value is 10)
        //position: "right" //zooming div position(default position value is "right")
    });

    // Assign Zebra Cols to Product List
    var i = 0;
    jQuery(".maincontent li, .form_table tr").each(function(i) {
        i % 2 == 0 ? jQuery(this).addClass("zebra_row_0") : jQuery(this).addClass("zebra_row_1");
        i++;
    });

    // Apply 0px to first product panel + apply 10px margin to other 3 product panels
    i = 0;
    jQuery(".categoriesWrapper .productItem").each(function(i) {
        i % 4 == 0 ? jQuery(this).addClass("margin0px") : jQuery(this).addClass("margin10px");
    });

    // To handle multiple repeaters on the same page
    i = 0;
    jQuery(".productsWrapper .productItem").each(function(i) {
        i % 4 == 0 ? jQuery(this).addClass("margin0px") : jQuery(this).addClass("margin10px");
    });

    // Apply alternating titles to category nav
    i = 0;
    jQuery(".sidebarTitle").each(function(i) {
        i % 2 == 0 ? jQuery(this).addClass("defaultColour") : jQuery(this).addClass("altColour");
    });

    // Equal product panel heights
    jQuery(".productItem").equalHeights();
    jQuery(".upSellItem").equalHeights();
    jQuery("ul.product-tabs:first").tabs("div.product-panes:first > div");



    // advance to the next tab
    //	jquery("aReview").click(function () {
    //		// get handle to the api (must have been constructed before this call)
    //		alert('api');
    //		var api = jQuery("ul.product-tabs:first").tabs();
    //		
    //		api.next();
    //		return false;
    //	});
    var scrollTo = scrollTo = jQuery(".product-tabs").offset().top;
    jQuery('.readReview').click(function() {
        var api = jQuery('ul.product-tabs:first').tabs('div.product-panes:first > div');
        api.click(1);
        jQuery("html, body").animate({ scrollTop: scrollTo }, "fast");

        return false;
    });

    jQuery('.moreinformation').click(function() {
        var api = jQuery('ul.product-tabs:first').tabs('div.product-panes:first > div');
        api.click(0);

        //get the full url - like mysitecom/index.htm#home
        var full_url = this.href;

        //split the url by # and get the anchor target name - home in mysitecom/index.htm#home
        var parts = full_url.split("#");
        var trgt = parts[1];

        //get the top offset of the target anchor
        var target_offset = jQuery("#" + trgt).offset();
        var target_top = target_offset.top;

        //goto that anchor by setting the body scroll top to anchor top
        jQuery('html, body').animate({ scrollTop: target_top }, 500);

        return false;
    });

    // Create fancybox
    jQuery("div.imgThumb a").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'titlePosition': 'outside'
    });

    jQuery.PreloadImg = function() {
        for (var i = 0; i < arguments.length; i++) {
            jQuery("<img>").attr("src", arguments[i]);
        }
    }


    //show / hide nested sub menus		
    jQuery('#menu_container ul li ul').hide();

    if (document.getElementById("menu_container")) {
        var sublinks = document.getElementById("menu_container").getElementsByTagName("a");
        for (var i = 0; i < sublinks.length; i++) {
            if (sublinks[i].href == document.location.href) {
                sublinks[i].parentNode.className += "currentNode";
                sublinks[i].parentNode.parentNode.parentNode.className += "currentNode";
                //check if there's a nested list and display it
                jQuery('#menu_container ul li.currentNode ul').show();
            }
        }

    }

});
