// JavaScript Document
/*
	facebook.plugin.js 
	subscribe.page.js 
	themeCommon.js 
	common.plugin.js
	jsrender.helper.js
	language.plugin.js
	common-mob.js
	common.js
*/
/* ------------------------------START : facebook.plugin.js ---------------------------------------- */
$(function () {
    var page = '';
    if ($('#formProductPurchase').attr('id') == 'formProductPurchase') {
        page = '/cart/';
    } else {
        page = '/user/account/';
    }
    if (typeof (historyURL) != 'undefined') {
        if (historyURL != '') {
            page = '/' + historyURL + '/';
        }
    }
    window.fbAsyncInit = function () {
        FB.init({
            appId: fbApplicationID,
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true, // parse XFBML  
            oauth: true,
            channelUrl: siteUrl + '/public/api/facebook/xd_receiver.htm'
        });
        FB.Event.subscribe('edge.create', function (href, widget) {
            saveFeedLike(href);
        });
        FB.Event.subscribe('auth.login', function (response) {
            //alert(response.status);
            //window.location.href = siteUrl + page;
        });
        FB.Event.subscribe('auth.logout', function (response) {
            // window.location.href = siteUrl + '/user/logout/';
        });
        FB.Event.subscribe('comment.create', function (res) { //alert('in fb plugin..');
            saveFeedComment(res.href);
        });
    };
    (function () {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        var fbroot=document.getElementById('fb-root');
		if(fbroot!=null){
			fbroot.appendChild(e);
		}
    }());
    $('#logout-link,.logout-fb a').click(function () {
        var loc = $(this).attr('href')
        var status = false;
        FB.getLoginStatus(function (response) {
            if (response.authResponse) {
                status = true
            } else {
                status = false;
            }
        });
    });
});

function postToFeed(url) {
    var urlshare = url;
    // calling the API ...
    var obj = {
        method: 'feed',
        link: urlshare,
        actions: {
            name: 'View Product',
            link: url
        }
    };

    function callback(response) {
        if (response && response['post_id']) {
            jAlert(lblPostPublished);
        } else {
            jAlert(lblPostNotPublished);
        }
    }
    FB.ui(obj, callback);
}

function streamPublish() {
    FB.ui({
            method: 'stream.publish'
        },
        function (response) {
            if (response && response['post_id']) {
                jAlert(lblfacebookUpdate);
            } else {
                jAlert(lblUpdatePermission);
            }
        });
}

/* ------------------------------END : facebook.plugin.js ---------------------------------------- */

/* ------------------------------START : subscribe.page.js ---------------------------------------- */
// JavaScript Document
$(document).ready(function () {
   $('#ajax-loading').hide(); 
	$(document).on('click',"#subcClose",function(){
		$.ajax({
			type: "POST",
			url: GLOBAL_BASE_PATH+"/subscribe/setcookeycrossAjax/cross/yes/",
			success: function(msg){
				location.reload();
			}
		}); 
	});		
});

function fbUserLogin() {
    var e = $("#currentProductID").val();
    $(".popupSignup").hide();
    $('#fave_' + e).addClass('active');
    $.ajax({
        type: "POST",
        data: "productID=" + e,
        url: GLOBAL_BASE_PATH + "/login/ajaxCheckFBLogin/",
        success: function (e) { //alert(e);
            if (e == "success") {
                //$('#content').fadeTo('fast',1);
                location.reload()
            } else {
                $("#div_err_formCityEmailSubscription").html("<span>" + e + "</span>");
                $("#div_err_formCityEmailSubscription").show()
            }
        }
    })
}

function submitFaveForm() {
    $("#div_err_formCityEmailSubscription").hide();
    var e = $("#userEmail").val();
    var t = $("#userPassword").val();
    var n = 0;
    if (e == "" || e.match(/([\<])([^\>]{1,})*([\>])/i)) {
        $("#div_err_userEmail").show()
    } else {
        $("#div_err_userEmail").hide();
        n++
    }
    if (t == "" || t.match(/([\<])([^\>]{1,})*([\>])/i)) {
        $("#div_err_userPassword").show()
    } else {
        $("#div_err_userPassword").hide();
        n++
    }
    if (n == 2) {
        var r = $("#formSignupPopup").serialize();
        $.ajax({
            type: "POST",
            data: "formData=" + r,
            url: GLOBAL_BASE_PATH + "/login/ajaxcheckUserLogin/",
            success: function (e) {
                if (e == "success") {
                    location.reload()
                } else {
                    $("#div_err_formCityEmailSubscription").html("<span>" + e + "</span>");
                    $("#div_err_formCityEmailSubscription").show()
                }
            }
        })
    }
}
/* ------------------------------END : subscribe.page.js ---------------------------------------- */

/* ------------------------------START : themeCommon.js ---------------------------------------- */
function updateCartNotification() {
    var notificationTop = '';
    var notificationBottom = '';
    var userID = '';
  
    //alert(userID);
    if (showCartNotification != 'No') {
        userID = $("#userLogined").val();
        if(userID=='undefined' || userID==undefined) {
            userID = 0;
        }
       cart['userLogined'] = userID;
		var template = $("#CartNotificationTemplate").html();
                //alert(template);return false;
		var html= _.template(template,{"cart":cart});
		$('.cart-dropdown-box').html('').append(html);
                //alert("aa");
    } else {
        $(".cart-dropdown-box").hide();
       
    }
    $(".cart-notification-dropdown").hide();
    
}

/* ------------------------------END : themeCommon.js ---------------------------------------- */

/* ------------------------------START : common.plugin.js ---------------------------------------- */

/*
@	Author:ISPG Edp
@	Created Date:	2013-04-11 10.46 AM


	This JS file contains the common javascript functions
		
		objCount 		- 	To find the count of an Object
		
		Usage: $.objCount(object)
		____________________________________________________
		
		2.str_replace	-	This function returns a string or an array with the replaced values.
		
		Usage: $.str_replace(search, replace, subject, count)
		____________________________________________________
		
		3.stripslashes	-	Returns a string with backslashes stripped off. (\' becomes ' and so on.) Double backslashes (\\) are made into a single backslash (\).
		
		Usage: $.stripslashes(str)
		____________________________________________________
		
		4.is_array		-	return array or not
		
		Usage: $.is_array(array)
		____________________________________________________
		
		5.in_array		-	return boolean based on element found in array
		
		Usage: $.in_array((needle, haystack, argStrict)
		____________________________________________________
		
		6.objMerge		- 	To merge two objects
		
		Usage: $.objMerge(obj1, obj2)
		____________________________________________________
		
		7.delay			-	To make delay execution 
		
		Usage: $.delay(time)
		____________________________________________________
		
		8.truncate		-	TO truncate the string
		
		Usage: $.truncate(string, limit)
		____________________________________________________
		
		9.strip_tags	-	Returns the stripped string.
		
		Usage: $.strip_tags(input, allowed)
		____________________________________________________
		
*/

$.extend({
    objCount: function (obj) {
        if (typeof obj == "object") {
            var i, count = 0;
            for (i in obj) {
                if (obj.hasOwnProperty(i)) {
                    count++;
                }
            }
            return count;
        } else {
            return false;
        }
    },
    str_replace: function (search, replace, subject, count) {
        var i = 0,
            j = 0,
            temp = '',
            repl = '',
            sl = 0,
            fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = Object.prototype.toString.call(r) === '[object Array]',
            sa = Object.prototype.toString.call(s) === '[object Array]';
        s = [].concat(s);
        if (count) {
            this.window[count] = 0;
        }
        for (i = 0, sl = s.length; i < sl; i++) {
            if (s[i] === '') {
                continue;
            }
            for (j = 0, fl = f.length; j < fl; j++) {
                temp = s[i] + '';
                repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
                s[i] = (temp).split(f[j]).join(repl);
                if (count && s[i] !== temp) {
                    this.window[count] += (temp.length - s[i].length) / f[j].length;
                }
            }
        }
        return sa ? s : s[0];
    },
    stripslashes: function (str) {
        return (str + '').replace(/\\(.?)/g, function (s, n1) {
            switch (n1) {
            case '\\':
                return '\\';
            case '0':
                return '\u0000';
            case '':
                return '';
            default:
                return n1;
            }
        });
    },
    is_array: function (mixed_var) {
        var ini,
            _getFuncName = function (fn) {
                var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
                if (!name) {
                    return '(Anonymous)';
                }
                return name[1];
            },
            _isArray = function (mixed_var) {
                if (!mixed_var || typeof mixed_var !== 'object' || typeof mixed_var.length !== 'number') {
                    return false;
                }
                var len = mixed_var.length;
                mixed_var[mixed_var.length] = 'bogus';

                if (len !== mixed_var.length) {
                    mixed_var.length -= 1;
                    return true;
                }
                delete mixed_var[mixed_var.length];
                return false;
            };
        if (!mixed_var || typeof mixed_var !== 'object') {
            return false;
        }
        this.php_js = this.php_js || {};
        this.php_js.ini = this.php_js.ini || {};
        ini = this.php_js.ini['phpjs.objectsAsArrays'];
        return _isArray(mixed_var) ||
            ((!ini || (
            (parseInt(ini.local_value, 10) !== 0 && (!ini.local_value.toLowerCase || ini.local_value.toLowerCase() !== 'off')))) && (
            Object.prototype.toString.call(mixed_var) === '[object Object]' && _getFuncName(mixed_var.constructor) === 'Object'
        ));
    },
    in_array: function (needle, haystack, argStrict) {
        var key = '',
            strict = !! argStrict;

        if (strict) {
            for (key in haystack) {
                if (haystack[key] === needle) {
                    return true;
                }
            }
        } else {
            for (key in haystack) {
                if (haystack[key] == needle) {
                    return true;
                }
            }
        }
        return false;
    },
    dateFormat: function (date_format) {
        switch (date_format) {
        case "%d-%m-%Y":
            return 'dd-MM-yyyy'
            break;
        case "%m/%d/%Y":
            return 'MM/dd/yyyy';
            break;
        case "%Y-%m-%d":
            return 'yyyy-MM-dd';
            break;
        case "%l:%M %p":
            return 'h:mm a';
            break;
        case "%I:%M %p":
            return 'hh:mm a';
            break;
        case "%H:%M":
            return 'HH:mm';
            break;
        }
    },

    /* 
	Usage:
	
		var date='2012-02-02';
		var format='dd-MM-yyyy';
		$.formatDate(date,format);
		
		OR 
		
		var date='2012-02-02';
		var format='%d-%m-%Y';
		$.formatDate(date,format,true);
	*/

    formatDate: function (date, date_format, convert) {

        if (convert)
            return $.format.date(date, $.dateFormat(date_format));
        else
            return $.format.date(date, date_format);
    },
    blockDiv: function (block, message, listproductsLocked) {
        $(block).block({
            message: $(message),
            css: {
                padding: 0,
                margin: 0,
                width: '30%',
                top: '40%',
                left: '35%',
                textAlign: 'center',
                color: '#000',
                border: '0',
                backgroundColor: 'none',
                cursor: 'wait'
            },
            overlayCSS: {
                backgroundColor: '#000',
                opacity: 0.6
            },
            onBlock: function () {
                listproductsLocked = listproductsLocked;
            }
        });
    },
    objMerge: function (obj1, obj2) {
        var data = new Object();
        var key = 0;
        for (ob1 in obj1) {
            data[key] = obj1[ob1];
            key++;
        }
        for (ob2 in obj2) {
            data[key] = obj2[ob2];
            key++;
        }
        return data;
    },
    delay: function (time) {
        var d1 = new Date();
        var d2 = new Date();
        while (d2.valueOf() < d1.valueOf() + time) {
            d2 = new Date();
        }
    },
    truncate: function (string, limit) {
        var dots = "...";
        if (string.length > limit) {
            string = string.substring(0, limit) + dots;
        }
        return string;
    },
    strip_tags: function (input, allowed) {

        allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('');
        var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
            commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
        return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
            return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
        });
    },
    stringFormat: function (originalPrice) {
        return Math.round(originalPrice);
        
    },
    getFormattedCurrency: function (originalPrice, decimalType, from, to) {
        if (typeof from == 'undefined') {
            from = 0;
        }
        if (typeof to == 'undefined') {
            to = 0;
        }
        var decimalType = (decimalType == '') ? 'Rounded' : decimalType;
        if (from > 0 && to > 0 && originalPrice > 0) {
            if (from == to) {
                var originalPrice = originalPrice;
            } else {
                var defaultCurrency = _currencies[_defaultCurrency];
                if (defaultCurrency['CurrencyID'] == to) {
                    fromCurrencyDetails = _currencies[from];
                    if (defaultCurrency['currencyValue'] <= 0) {
                        originalPrice = 0;
                    } else if (fromCurrencyDetails['currencyValue'] <= 0) {
                        originalPrice = 0;
                    } else {
                        originalPrice = originalPrice / fromCurrencyDetails['currencyValue'];
                    }
                } else if (defaultCurrency['CurrencyID'] == from) {
                    toCurrencyDetails = _currencies[to];
                    originalPrice = originalPrice * toCurrencyDetails['currencyValue'];
                } else {
                    fromCurrencyDetails = _currencies[from];
                    defaultCurValue = originalPrice / fromCurrencyDetails['currencyValue'];
                    toCurrencyDetails = _currencies[to];
                    originalPrice = defaultCurValue * toCurrencyDetails['currencyValue'];
                }
            }
        }
        if (to > 0) {
            defaultCurrency = _currencies[to];
            if ($.objCount(defaultCurrency) < 1) {
                defaultCurrency = _currencies[_defaultCurrency];
            }
        } else {
            defaultCurrency = _currencies[_defaultCurrency];
        }
        if ((decimalType == "Rounded")) {
            currencyDecimalPlaces = ((defaultCurrency['currencyDecimalPlaces']) > 0) ?
                (defaultCurrency['currencyDecimalPlaces']) : 0;
            originalPrice = parseFloat(originalPrice);
            originalPrice = Math.round(originalPrice * (Math.pow(10, currencyDecimalPlaces))) / (Math.pow(10, currencyDecimalPlaces));
            originalPriceArray = (originalPrice).toString().split(".");
            if (originalPriceArray.length > 1) {
                originalPriceDecimal = originalPriceArray[1];
                originalPriceDecimalLength = originalPriceDecimal.length;

                if (originalPriceDecimalLength < currencyDecimalPlaces && originalPriceDecimal != "") {
                    originalPriceDecimalBalanceLength = currencyDecimalPlaces -
                        originalPriceDecimalLength;
                    originalPrice = originalPrice;
                }
            }

        } else if ((decimalType == "Full")) {
            originalPrice = parseFloat(originalPrice);
            currencyDecimalPlaces = ((defaultCurrency['currencyDecimalPlaces']) > 0) ? (defaultCurrency['currencyDecimalPlaces']) : 0;
            originalPrice = originalPrice.toFixed(currencyDecimalPlaces);
        }
        if (defaultCurrency['currencySymbolLeft'] != '') {
            originalPrice = defaultCurrency['currencySymbolLeft'] + originalPrice;
        } else if (defaultCurrency['currencySymbolRight'] != '') {
            originalPrice = originalPrice + defaultCurrency['currencySymbolRight'];
        } else {
            originalPrice = originalPrice + defaultCurrency['currencyCode'];
        }
        return originalPrice;
    }
});

/* ------------------------------END : common.plugin.js ---------------------------------------- */

/* ------------------------------START : language.plugin.js ---------------------------------------- */

$(document).ready(function () {
    var winWidth = Number($(window).width());
     $('.languageList li').click(function () {
        var IMGSRC = $(this).children('.flagbox').children('img').attr('src');
        var TXT = $(this).children('.languagebox').text();
        $(this).parents('ul').parents('.languageSelectionBox').children('.flagbox').children('img').attr('src', IMGSRC);
        $(this).parents('ul').parents('.languageSelectionBox').children('.languagebox').html(TXT);
        var LanguageIDString = $(this).attr("id");
        var LanguageArray = LanguageIDString.split("common_language_");
        var LanguageIDArray=LanguageArray[1].split("_");
        var LanguageID = LanguageIDArray[0];
        var LCIDString = LanguageIDArray[1];
        setLanguage(LanguageID,LCIDString,$('.language-block').attr("id"));
    });
    $(document).on("click", '.language-block', function () {
	$(".subscribe-block").slideUp();
        if ($(".languageList").is(':visible')) {
            $(".languageList").slideUp();
            $(".language-block").removeClass("active");
            $("#header-section").removeClass("index-parent");
        } else {
            $(".languageList").slideDown();
            $(".language-block").addClass("active");
            $("#header-section").addClass("index-parent");
        }
    });
});

$(document).mouseup(function (e) {
    var container = $(".languageList");
    if (container.has(e.target).length === 0) {
        container.slideUp('fast');
        $(".language-block").removeClass("active");
    }
});

function setLanguage(LanguageID,LCIDString,oldLCIDString) 
{
    var dataArray = new Array();
    dataArray[0] = LanguageID;
    dataArray[1] = LCIDString;
    dataArray[2] = oldLCIDString;
    $.ajax({
        url: GLOBAL_BASE_PATH + "/index/Ajaxresetlanguage/",
        type: "POST",
        cache: false,

        global: false,
        data: {
            ajax_request: dataArray
        },
        success: function (data) {
           // alert(data)
             if(data!='')  {            
                        var newhref=  data;
                        window.location.href = newhref;
                    }   else if(oldLCIDString!='' && LCIDString!=''){
                        var newhref=   (location.href).replace('/'+oldLCIDString+'/','/'+LCIDString+'/');   
                        window.location.href = newhref;
                    } else                           
                        window.location.reload();
        }

    });
}
/* ------------------------------END : language.plugin.js ---------------------------------------- */

/* ------------------------------START : common-mob.js ---------------------------------------- */
// JavaScript Document
$(document).mouseup(function (e) {
    var container = $(".languageList");
    if (container.has(e.target).length === 0) {
        container.slideUp();
        $("#header-section").removeClass("index-parent");
    }
});
$(document).on("click", '.register', function () {
    if ($(".register-section").is(':visible')) {
        $(".register-section").slideUp();
    } else {
        $(".register-section").slideDown();
    }
});

/*subscribe*/
$(document).on("click", '.subscribe', function () {
    $(".subscribe-block").slideUp();
    if ($(".subscribe-block").is(':visible')) {
        $(".subscribe-block").slideUp().removeClass('showing');;
        $("#header-section .wrapper").removeClass("index-parent");
    } else {
        $(".subscribe-block").slideDown().addClass('showing');
        $("#header-section .wrapper").addClass("index-parent");

    }

});



/*City selection*/
$(document).on("click", '.quicklinks', function () {
    $(".subscribe-block").slideUp();
    if ($(".quicklink-block").is(':visible')) {
        $(".quicklink-block").slideUp();
        $("#header-section").removeClass("index-parent");
    } else {
        $(".quicklink-block").slideDown();
        $("#header-section").addClass("index-parent");
    }
});
$(document).mouseup(function (f) {
    var container = $(".quicklink-block");
    if (container.has(f.target).length === 0) {
        container.slideUp();
        $("#header-section").removeClass("index-parent");
    }
});
! function ($) {
    $(document).ready(function () {
        //detect transform (https://github.com/cubiq/)
        $.support.t3transform = (function () {
            var style = document.createElement('div').style,
                vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
                transform, i = 0,
                l = vendors.length;
            for (; i < l; i++) {
                transform = vendors[i] + 'ransform';
                if (transform in style) {
                    return transform;
                }
            }
            return false;
        })();
        if ($.support.t3transform !== false) {
            var className;
            var $btn1 = $('.navbutton[data-toggle="collapse"]'),
                $btn2 = $('#AjaxProductOptionsLink,#AjaxProductOptionsForFriendLink'),
				$options = $('.buy-pop-wrapper1'),
                $this,
                $nav = null,
                $fixeditems = null;
            if (!$btn1.length) {
                return;
            }
            //mark that we have off-canvas menu
            $(document.documentElement).addClass('off-canvas-ready');
            //not all btn1-navbar is used for off-canvas
            var $navcollapse = $btn1;
            if (!$navcollapse.length) {
                $navcollapse = $($btn1.data('target') + ':first');
            }
            $navcollapse.clone().appendTo($nav);
            $btn1.click(function (e) {
                $this = $(this);
                className = 'off-canvas-enabled';
                if ($(this).data('off-canvas') == 'show') {
                    hideNav(className);
                } else {
                    showNav(className);
                }
                return false;
            });
            $btn2.click(function () {
                $this = $(this);
                className = 'buynow-pop-enabled';
                if ($(this).data('off-canvas') == 'show') {
                    hideNav(className);
                } else {
                    posNav('option');
                    showNav(className);
                }
                //return false;
            });
            var $nav = $('.navigation');

            var posNav = function (opt) {
                var t = $(window).scrollTop();
                if (t < $nav.position().top) $nav.css('top', t);
                if (t < $options.position().top) $options.css('top', t);
                if (opt == 'option') {
                    $options.css('top', t);
                }
            },
                bdHideNav = function (e) {
                    if ($(e.target).hasClass('buynow') || $(e.target).hasClass('clse-pop')) {
                        e.preventDefault();
                        hideNav();
                        // return false;
                    } else {
                        if ($('html').hasClass('off-canvas-enabled')) {
                            hideNav();
                        }
                    }
                },
                showNav = function () {
                    $options.show();
                    $('html').addClass('off-canvas');
                    $nav.css('top', $(window).scrollTop());
                    wpfix(1);
                    setTimeout(function () {
                        $this.data('off-canvas', 'show');
                        $('html').addClass(className);
                        $(window).bind('scroll touchmove', posNav);
                        // hide when click on off-canvas-nav
                        $('.navigation').bind('click', function (e) {
                            e.stopPropagation();
                        });
                        $('.navigation a').bind('click', hideNav);
                        if (className != 'buynow-pop-enabled') {
                            $('body').bind('click touch swipe', bdHideNav);
                        } else {
                            $('.clse-pop,.buynow').bind('click touch swipe', bdHideNav);
                        }
                    }, 50);
                    setTimeout(function () {
                        wpfix(2);
                    }, 1000);

                },
                hideNav = function () {
                    $(window).unbind('scroll touchmove', posNav);
                    $('#off-canvas-nav').unbind('click');
                    $('#off-canvas-nav a').unbind('click', hideNav);
                    $('html').removeClass(className);
                    $this.data('off-canvas', 'hide');
                    setTimeout(function () {
                        if (!($('html').hasClass('buynow-pop-enabled') || $('html').hasClass('off-canvas-enabled'))) {
                            $('html').removeClass('off-canvas');
                        }
                    }, 600);
                },
                wpfix = function (step) {
                    // check if need fixed
                    if ($fixeditems == -1) {
                        return; // no need to fix
                    }
                    if (!$fixeditems) {
                        $fixeditems = $('body').children().filter(function () {
                            return $(this).css('position') === 'fixed'
                        });
                        if (!$fixeditems.length) {
                            $fixeditems = -1;
                            return;
                        }
                    }
                    if (step == 1) {
                        $fixeditems.css({
                            'position': 'absolute',
                            'top': $(window).scrollTop() + 'px'
                        });
                    } else {
                        $fixeditems.css({
                            'position': '',
                            'top': ''
                        });
                    }
                };
        }

    })
}
(jQuery);
/* ------------------------------END : common-mob.js ---------------------------------------- */

/* ------------------------------START : common.js ---------------------------------------- */
// JavaScript Document

/* header menu */
$(document).ready(function () {
    $('#openlink').click(function () {
        $('.dropBx').slideDown('slow');
        $('.cityDrpdown').slideUp(function () {
            $('.citySelection').removeClass('highlight');
            $('#header').addClass('fixed_header');
        });
        $('.categoryDrpdown').slideUp(function () {
            $('.categorySelection').removeClass('highlight');
        });
    });

    $('.closeBtn').click(function () {
        $('.dropBx').slideUp();
        $('#header').removeClass('fixed_header');
    });

    $('.btn-navbar').click(function () {
        if ($(".menu").hasClass('selected')) {
            $(".menu").show();
            $(".menu").removeClass("selected");
            $("html").addClass("off-canvas-enabled");
            $("#main").addClass("fixed");
        } else {
            $("html").removeClass("off-canvas-enabled");
            $(".menu").addClass("selected")
            $(".menu").hide("slow");
            $("#main").removeClass("fixed");
        }
    });

    $('#userLink').click(function () {
        $('.loginBx').slideDown('slow');
    });
    $(document).on("click", ".AjaxStatesPopupLink", function () {
        $(".category-list").hide();
    });
    $(document).on("click", ".category-selection", function () {
        $(".AjaxStatesPopupContent").hide();
        $(".catDropdown-section").hide();
        $(".category-list").slideToggle();
    });
});
/* ------------------------------END : common.js ---------------------------------------- */

/* ------------------------------START : analytics track ---------------------------------------- */
$(window).bind("load", function() 
{
	//Ajax based log tracking
	if(__ANALYTICS_MODULE || __AFFILIATE_MODULE)
	{
		$.extend({ua: {
				version: (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) ? (navigator.userAgent.match(/.+(?:chrome)[\/: ]([\d.]+)/i) || [])[1] : ((navigator.userAgent.toLowerCase().indexOf("msie") >= 0)? (navigator.userAgent.match(/.*?msie[\/:\ ]([\d.]+)/i) || [])[1] : (navigator.userAgent.match(/.+(?:it|pera|irefox|ersion)[\/: ]([\d.]+)/i) || [])[1]),
				browser: (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) ? 'Chrome' : ($.browser.safari ? 'Safari' : ($.browser.opera ? 'Opera' : ($.browser.msie ? 'Internet Explorer' : 'Firefox'))),
				os: (navigator.platform.toLowerCase().indexOf('mac') != -1 ? 'MacOS' : (navigator.platform.toLowerCase().indexOf('win') != -1 ? 'Windows' : 'Linux')),
				language: (navigator.language ? navigator.language : (navigator.browserLanguage ? navigator.browserLanguage : (navigator.userLanguage ? navigator.userLanguage : (navigator.systemLanguage ? navigator.systemLanguage : ''))))
			} 
		});
		$.ajax({
			type:"POST",
			url:GLOBAL_BASE_PATH+'/track/ajaxStat/',
			data: {
				'url': location.href,
				'title': document.title,
				'browser_version': BrowserDetect.version,
				'browser': BrowserDetect.browser,
				'os': BrowserDetect.OS,
				'client_language': $.ua.language,
				'referrer': document.referrer,
				'targetPath': '',
				'targetPathType': '',
				'statPageName' : statPageName
			},
			beforeSend:function(){},
			complete:function(){},
			success:function(data){}
		});
	}
});
/* ------------------------------END : analytics track ---------------------------------------- */

