var ua = navigator.userAgent;
var checker = {
    iphone: ua.match(/(iPhone|iPod|iPad)/),
    blackberry: ua.match(/BlackBerry/),
    android: ua.match(/Android/)
};
var vid_obj = "";
var second_bar_top = 0;
var curr_pos = 0;
var curr_slide = 0;
var process_url = "";

function onBefore() {
    var b = $("#top_banner").find("div").find(".slide_container").length;
    var a = $(this).index() + 1;
    curr_slide = $(this).index();
    $("#banner_control_text").html(a + " of " + b)
}

function shop_category_go(){
	location = document.shop_categories.shop_category.value;
}

$(document).ready(function() {

	Cufon.replace('.cufon_semibold_italic', { fontFamily: 'Myriad Pro Semibold Italic', hover: true }); 
	Cufon.replace('.cufon_semibold', { fontFamily: 'Myriad Pro Semibold', hover: true }); 
	Cufon.replace('.cufon', { fontFamily: 'Myriad Pro Regular', hover: true, hoverables: { a: true } }); 		
	Cufon.replace('.cufon_condensed_italic', { fontFamily: 'Myriad Pro Condensed Italic', hover: true }); 
	Cufon.replace('.cufon_condensed', { fontFamily: 'Myriad Pro Condensed', hover: true }); 
	Cufon.replace('.cufon_bold_italic', { fontFamily: 'Myriad Pro Bold Italic', hover: true }); 
	Cufon.replace('.cufon_bold_condensed_italic', { fontFamily: 'Myriad Pro Bold Condensed Italic', hover: true }); 
	Cufon.replace('.cufon_bold_condensed', { fontFamily: 'Myriad Pro Bold Condensed', hover: true }); 
	Cufon.replace('.cufon_bold', { fontFamily: 'Myriad Pro Bold', hover: true }); 

	Cufon.replace(['ul#navlist > li', 'ul#navlist > li > a'], {
		fontFamily: 'Myriad Pro Regular',
		hover: true,
		hoverables: { li: true },
		ignore: { ul: true },
		textless: { ul: true }
	});
	 
    $("#search_query").focus(function() {
        $("#search_box").css({
            outline: "none",
            "border-color": "rgba(0, 0, 0, 0.35)",
            "-webkit-box-shadow": "0 0 8px rgba(0, 0, 0, 0.35)",
            "-moz-box-shadow": "0 0 8px rgba(0, 0, 0, 0.35)",
            "box-shadow": "0 0 8px rgba(0, 0, 0, 0.35)"
        });
    });
    $("#search_query").blur(function() {
        $("#search_box").css({
            outline: "none",
            "border-color": "none",
            "-webkit-box-shadow": "none",
            "-moz-box-shadow": "none",
            "box-shadow": "none"
        });
    });

	var j = document.URL.substring(7);
    var n = j.split("/");
    var u = n.length - 1;
    if (u > 0) {
        if (n[1] != "") {
            if (n[2]) {
                process_url = "http://" + n[0] + "/" + n[1] + "/"
            }
        }
    }
});
$(window).load(function() { $(window).resize() });
$(window).scroll(function() {
    var b = navigator.userAgent;
    var a = {
        iphone: b.match(/(iPhone|iPod|iPad)/),
        blackberry: b.match(/BlackBerry/),
        android: b.match(/Android/)
    };
    if (!a.android && !a.iphone && !a.blackberry) {
        curr_pos = $(window).scrollTop();
        if (jQuery.browser.msie) {
            if (parseInt(jQuery.browser.version) == 7) {} else {
                if ($(window).width() >= 960) {
                    $("#top_bar_container").css({
                        position: "fixed",
                        top: "0"
                    })
                } else {
                    $("#top_bar_container").css({
                        position: "relative"
                    })
                }
            }
        } else {
            if ($(window).width() >= 960) {
                $("#top_bar_container").css({
                    position: "fixed",
                    top: "0"
                })
            } else {
                $("#top_bar_container").css({
                    position: "relative"
                })
            }
        }
    }
});
$(window).resize(function() {
    if ($("#top_banner").is(".home_page_banner")) {
        var a = $(window).width();
        if (a >= 960) {
            if (jQuery.browser.msie) {
                if (parseInt(jQuery.browser.version) == 7) {} else {
                    $("#banner_slider").cycle("destroy");
                    $("#banner_slider").cycle({
                        fx: "fade",
                        timeout: 7200,
                        prev: "#prev_banner",
                        next: "#next_banner",
                        fit: 1,
                        width: a,
                        speed: 3000,
                        easing: "easeOutExpo",
                        startingSlide: curr_slide,
                        after: onBefore
                    })
                }
            } else {
                $("#banner_slider").cycle("destroy");
                $("#banner_slider").cycle({
                    fx: "fade",
                    timeout: 7200,
                    prev: "#prev_banner",
                    next: "#next_banner",
                    fit: 1,
                    width: a,
                    speed: 3000,
                    easing: "easeOutExpo",
                    startingSlide: curr_slide,
                    after: onBefore
                })
            }
        }
    }
    if (!checker.android && !checker.iphone && !checker.blackberry) {
        $("#second_bar_container").css("position", "relative");
        curr_pos = $(window).scrollTop();
        if (jQuery.browser.msie) {
            if (parseInt(jQuery.browser.version) == 7) {} else {
                if ($(window).width() >= 960) {
                    $("#top_bar_container").css({
                        position: "fixed",
                        top: "0"
                    })
                } else {
                    $("#top_bar_container").css({
                        position: "relative"
                    })
                }
            }
        } else {
            if ($(window).width() >= 960) {
                $("#top_bar_container").css({
                    position: "fixed",
                    top: "0"
                })
            } else {
                $("#top_bar_container").css({
                    position: "relative"
                })
            }
        }
    }
});
