/*	All YUI library methods migrated to jQuery.
 *  Lee Daffen -
 */

var sHeight,
	alsolikesHeight,
	elements,
	alsolikeelements,
	thumbsPos = [],
	thumbsPosDown = [],
	divthumbsPos = [],
	divthumbsPosDown = [],
	divthumbsPosPast = [],
	divthumbsPosDownPast = [],
	imgAmount,
	divAmount,
	i = 0,
	idc = 0,
	dividc = 0,
	dividcPast = 0,
	delay = 0,
	str = window.location,
	nr,
	issueNumber,
	pageNumber,
	images,
	scrollHeight,
	alsolikescrollHeight,
	eventscrollHeight;

//Number of items displayed for thumbnails/may also like/etc before scrolling is enabled
var numberOfItemsDisplayedBeforeScrolling = 4;

function initProductPage() {

        /*you may also like*/
        $("#up-arrow-like").click(moveRecommendedLeft);
        $("#down-arrow-like").click(moveRecommendedRight);

        var oUpArrowlike = document.getElementById("up-arrow-like"),
            oDownArrowlike = document.getElementById("down-arrow-like");


        $("#sizes").addClass("script-loaded");

        if (document.cookie.indexOf("view:lite") == -1) {
            // new 'add to wish list' button functionality
            $(".has-context-menu .product-wishlist").hover(function() {
                if(navigator.appVersion.indexOf("MSIE") != -1) $("#add-bookmark-link").hide();
                $("#custom-context-container").show();
            }, function() {
                if(navigator.appVersion.indexOf("MSIE") != -1) $("#add-bookmark-link").show();
                $("#custom-context-container").hide();
            });
            $(".has-context-menu input").click(function(e){
                e.preventDefault();
            });
        }

        // survey init workaround
        try {
            attachRemoteScript();
        } catch(e){
            // do nothing
        }
}

function initReverse() {
	sHeight = 90;
	pastHeight = 300;

	$("#up-arrow").click(moveThumbnailsLeft);
	$("#down-arrow").click(moveThumbnailsRight);
	/*past sales*/
	$("#up-arrow-past").click(movePastLeft);
	$("#down-arrow-past").click(movePastRight);

	countsImages('thumbnails-mask');
	countsImagespast('past-flash-mask');

	$("#sizes").addClass("script-loaded");
}

function initGiveaway() {
	sHeight = 345;

	var eventLength = countsImages('coming-up-mask', 1);

	$("#up-arrow-coming-up").click(moveThumbnailsLeft);
	$("#down-arrow-coming-up").click(moveThumbnailsRight);
}

function initEventsPage() {
	eventsHeight = 270;
	pastHeight = 270;

	var eventLength = countsImagesevents('coming-up-mask');
	var pastLength = countsImagespast('past-flash-mask');

	if(eventLength > 3) {
		$("#up-arrow-coming-up").click(moveEventsLeft);
		$("#down-arrow-coming-up").click(moveEventsRight);
	}
	if(pastLength > 3) {
		$("#up-arrow-past").click(movePastLeft);
		$("#down-arrow-past").click(movePastRight);
	}

		// survey init workaround
	try {
		attachRemoteScript();
	} catch(e){
		// do nothing
	}

}

/* scroll thumbnails start */
function countsImages(element_id,visible) {
var numberOfItems = visible || numberOfItemsDisplayedBeforeScrolling;

	if (document.getElementById(element_id) != undefined) {
		images = document.getElementById(element_id).getElementsByTagName('IMG');

		bufferToLeft = 0;
		if (images.length > numberOfItems) {
			bufferToLeft = 1;
		}

		for ( var d = 0; d < images.length; d++) {
			thumbsPos.push(sHeight * (d - bufferToLeft));
			thumbsPosDown.unshift(sHeight * (d - 1));
			document.getElementById(images[d].id).style.left = thumbsPos[d] + 'px';
		}
	}
}

function countsImagesevents(element_id) {
	if(document.getElementById(element_id) != undefined) {
		var containerEl = document.getElementById(element_id);
		divs = containerEl.getElementsByTagName('DIV');

		bufferToLeft = 0;
		if (divs.length > 3) {
			bufferToLeft = 1;
		}
		for ( var d = 0; d < divs.length; d++) {
			divthumbsPos.push(eventsHeight * (d - bufferToLeft));
			divthumbsPosDown.unshift(eventsHeight * (d - 1));
			document.getElementById(divs[d].id).style.left = divthumbsPos[d] + 'px';
		}
		return divs.length;
	} else {
		return 0;
	}
}
function countsImagespast(element_id) {
	if(document.getElementById(element_id) != undefined) {
		pastdivs = document.getElementById(element_id).getElementsByTagName('DIV');

		bufferToLeft = 0;
		if (pastdivs.length > 3) {
			bufferToLeftPast = 1;
		}
		for ( var d = 0; d < pastdivs.length; d++) {
			divthumbsPosPast.push(pastHeight * (d - bufferToLeft));
			divthumbsPosDownPast.unshift(pastHeight * (d - 1));
			document.getElementById(pastdivs[d].id).style.left = divthumbsPosPast[d] + 'px';
		}
		return pastdivs.length;
	} else {
		return 0;
	}
}
// scroll functionality

/*
 * Responsible for moving the thumbnail viewing area to the left
 */
function moveThumbnailsLeft(e) {
	idc = moveLeft(idc, images, thumbsPos, sHeight);
}

/*
 * Responsible for moving the 'you may also like' viewing area to the left
 */
function moveRecommendedLeft(e) {
	/*continuousscroll set to false*/
	dividc = moveLeft(dividc, divs, divthumbsPos, alsolikesHeight, false);
}

/*
 * Responsible for moving the events viewing area to the left
 */
function moveEventsLeft(e) {
	dividc = moveLeft(dividc, divs, divthumbsPos, eventsHeight);
}
/*
 * Responsible for moving the events viewing area to the left
 */
function movePastLeft(e) {
	dividcPast = moveLeft(dividcPast, pastdivs, divthumbsPosPast, pastHeight);
}

/*
 * Responsible for moving the thumbnail viewing area to the Right
 */
function moveThumbnailsRight(e) {
	idc = moveRight(idc, images, thumbsPos, sHeight);
}

/*
 * Responsible for moving the 'you may also like' viewing area to the Right
 */
function moveRecommendedRight(e) {
	/*continuousscroll set to false*/
	dividc = moveRight(dividc, divs, divthumbsPos, alsolikesHeight, false);
}

/*
 * Responsible for moving the events viewing area to the left
 */
function moveEventsRight(e) {
	dividc = moveRight(dividc, divs, divthumbsPos, eventsHeight);
}

/*
 * Responsible for moving the 'you may also like' viewing area to the Right
 */
function movePastRight(e) {
	dividcPast = moveRight(dividcPast, pastdivs, divthumbsPosPast, pastHeight);
}


/*
 * Used by the for scrolling thumbnails, may also like items, etc
 * - Moves and animates the items
 */



function moveLeft(idxOfLeftItem, imageArray, posArray, spacing, continuousscroll) {
	/*arrow hidden when not in use and displayed when they're clickable*/
	if(idxOfLeftItem != imageArray.length - 1){
	$("#down-arrow-like").removeClass("disabled-arrow");
	}

	if(idxOfLeftItem == 1) {
	$("#up-arrow-like").addClass("disabled-arrow");
	}

	/*if the carousel shouldn't have a continuous scroll and the index of the left item is 0 don't move anything*/
	if(continuousscroll == false && idxOfLeftItem == 0){
			return idxOfLeftItem;
	}
	else{
		idxOfLeftItem--;
		if (idxOfLeftItem < 0) {
			idxOfLeftItem = imageArray.length - 1;
		}

		// remove the first element
		var tempPoss = posArray.shift();
		// add the element to the end of the array
		posArray.push(tempPoss);

		// moves this element off the screen
		//**if image is still in view then it will disapear and not animate off to the right**
		document.getElementById(imageArray[idxOfLeftItem].id).style.left = -spacing + 'px';

		var moves = [];

		for (d = 0; d < imageArray.length; d++) {
			$(imageArray[d]).animate({
				left: posArray[d]
			}, 350);
		}
		return idxOfLeftItem;
	}
}

function moveRight(idxOfLeftItem, imageArray, posArray, spacing, continuousscroll) {
	/*if the carousel shouldn't have a continuous scroll and the index of the left item is the number of images - the amount of images visible(4) don't move anything*/
imageAmount = imageArray.length - 1;

lastimage = imageArray.length - 4;

/*arrow hidden when not in use and displayed when they're clickable*/
$("#up-arrow-like").removeClass("disabled-arrow");

if(idxOfLeftItem == lastimage - 1){
$("#down-arrow-like").addClass("disabled-arrow");
}

if(continuousscroll == false && idxOfLeftItem == lastimage){
	return idxOfLeftItem;
}
else{
	// current left item will move to the far right
	if (document.getElementById(imageArray[idxOfLeftItem].id).offsetTop < spacing) {
		document.getElementById(imageArray[idxOfLeftItem].id).style.left = (imageAmount * spacing) + 'px';
	}

	// shift the counter
	if (idxOfLeftItem < (imageArray.length - 1)) {
		idxOfLeftItem++;
	} else {
		idxOfLeftItem = 0;
	}

	//take last item off
	var tempPos = posArray.pop();
	//put last item on the front
	posArray.unshift(tempPos);

	var moves = [];

	for ( var d = 0; d < imageArray.length; d++) {
		$(imageArray[d]).animate({
			left: posArray[d]
		}, 350);
	}
	return idxOfLeftItem;
}
}

/* product page */
function choosesize() {
	var sizelist = document.getElementsByName("sku");
	for ( var i = 0; i < sizelist.length; i++) {
		var labelid = sizelist[i].value;
		if (sizelist[i].checked == true) {
			document.getElementById(labelid + "label").className = "selected";
		} else if (sizelist[i].checked == false) {
			document.getElementById(labelid + "label").className = "";
		}
	}
}

function rollover(borderId, borderClass) {
	document.getElementById(borderId).className = borderClass;
}

function changetabs(tabButtonId, tabButtonsParentId) {
     $('#' + tabButtonsParentId).children().each(function() {
        var thisTabButton = $(this);
        var thisTabButtonId = thisTabButton.attr("id");
        var thisTabContent = $("#" + thisTabButtonId.replace("-tab", ""));

        if(thisTabButtonId == tabButtonId) {
            thisTabButton.addClass("selected");
            thisTabContent.css("display", "block");
        } else {
            thisTabButton.removeClass("selected");
            thisTabContent.css("display", "none");
        }
    });
}

sfHover = function() {
	var containerEl = document.getElementById("nav");
	if(containerEl != undefined) {
		var sfEls = containerEl.getElementsByTagName("LI");
		for ( var i = 0; i < sfEls.length; i++) {
			sfEls[i].onmouseover = function() {
				this.className += (this.className.length > 0 ? " " : "")
						+ "sfhover";
			};
			sfEls[i].onmouseout = function() {
				this.className = this.className.replace(new RegExp(
						"( ?|^)sfhover\\b"), "");
			};
		}
	}
};
mcAccessible = function() {
	var containerEl = document.getElementById("nav");
	if(containerEl != undefined) {
		var mcEls = document.getElementById("nav").getElementsByTagName("A");
		for ( var i = 0; i < mcEls.length; i++) {
			mcEls[i].onfocus = function() {
				this.className += (this.className.length > 0 ? " " : "")
						+ "sffocus"; // a:focus
				this.parentNode.className += (this.parentNode.className.length > 0 ? " "
						: "")
						+ "sfhover"; // li < a:focus
				if (this.parentNode.parentNode.parentNode.nodeName == "LI") {
					this.parentNode.parentNode.parentNode.className += (this.parentNode.parentNode.parentNode.className.length > 0 ? " "
							: "")
							+ "sfhover"; // li < ul < li < a:focus
					if (this.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "LI") {
						this.parentNode.parentNode.parentNode.parentNode.parentNode.className += (this.parentNode.parentNode.parentNode.parentNode.parentNode.className.length > 0 ? " "
								: "")
								+ "sfhover"; // li < ul < li < ul < li < a:focus
					}
				}
			};
			mcEls[i].onblur = function() {
				this.className = this.className.replace(new RegExp(
						"( ?|^)sffocus\\b"), "");
				this.parentNode.className = this.parentNode.className.replace(
						new RegExp("( ?|^)sfhover\\b"), "");
				if (this.parentNode.parentNode.parentNode.nodeName == "LI") {
					this.parentNode.parentNode.parentNode.className = this.parentNode.parentNode.parentNode.className
							.replace(new RegExp("( ?|^)sfhover\\b"), "");
					if (this.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "LI") {
						this.parentNode.parentNode.parentNode.parentNode.parentNode.className = this.parentNode.parentNode.parentNode.parentNode.parentNode.className
								.replace(new RegExp("( ?|^)sfhover\\b"), "");
					}
				}
			};
		}
	}
};

// only ie needs the sfHover script. all need the accessibility script...
// thanks http://www.brothercake.com/site/resources/outnet/styles/onload/

if (window.addEventListener) {
	window.addEventListener("load", mcAccessible, false); // gecko, safari, konqueror and standard
} else if (document.addEventListener) {
	document.addEventListener("load", mcAccessible, false); // opera 7
} else if (window.attachEvent) { // win/ie
	window.attachEvent("onload", sfHover);
	window.attachEvent("onload", mcAccessible);
} else { // mac/ie5
	if (typeof window.onload == "function") {
		var existing = onload;
		window.onload = function() {
			existing();
			sfHover();
			mcAccessible();
		};
	} else {
		window.onload = function() {
			sfHover();
			mcAccessible();
		};
	}
}

/**
 * Useful function for processing query parameters
 */

function getParameterValue(parameterName) {
	var queryString = window.location.search.substring(1);
	var parameters = [];
	parameters = queryString.split('&');
	for ( var i = 0; i < parameters.length; i++) {
		if (parameters[i].indexOf(parameterName) >= 0) {
			var parameterValue = [];
			parameterValue = parameters[i].split('=');
			return parameterValue[1];
		}
	}
	return "";
}

/**
 * Javascript for the productlisting pages (filters, etc)
 */

function ToggleFilter(newUrl) {
	window.location = newUrl;
}

/*rotating banner on sitemap */
var action_re = /([^\/]+).gif$/;

function questionAction() {
    var currenttext =  document.getElementById("questionAction").innerHTML; /*source of image*/
	help(actionList[currenttext].loc);
}

function setfaqs() {
    document.getElementById("questionAction").innerHTML = actionList[0];
}

function validateEmail() {
    if(!isGoodEmail(document.emailreg.email.value, false)) {
		alert("Please make sure that you\ninput a valid e-mail address");
		document.emailreg.email.focus();
		return false;
    }
    return true;
}

function isGoodEmail(emailStr, thankyouflag) {
    if (thankyouflag == null) {
            thankyouflag=true;
    }
    var emailPat=/^(.+)@(.+)$/;
    var specialChars="\\(\\)<>@,;:\!\\\\\\\"\\.\\[\\]";
    var validChars="\[^\\s" + specialChars + "\]";
    var firstChars=validChars;
    var quotedUser="(\"[^\"]*\")";
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom="(" + firstChars + validChars + "*" + ")";
    var word="(" + atom + "|" + quotedUser + ")";
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
    var matchArray=emailStr.match(emailPat);
    if (matchArray==null) {
            return false;
    }
    var user=matchArray[1];
    var domain=matchArray[2];

    // See if "user" is valid
    if (user.match(userPat)==null) {
            return false;
    }
    var IPArray=domain.match(ipDomainPat);
    if (IPArray!=null) {
            // this is an IP address
            for (var i=1;i<=4;i++) {
				if(IPArray[i]>255) {
						return false;
				}
            }
            return true;
    }

    // Domain is symbolic name
    var domainArray=domain.match(domainPat);
    if (domainArray==null) {
            return false;
    }
    var atomPat=new RegExp(atom,"g");
    var domArr=domain.match(atomPat);
    var len=domArr.length;
    if(domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
       // the address must end in a two letter or three letter word.
       return false;
    }
    if (domArr[domArr.length-1].length==3 && len<2) {
       return false;
    }

    // default behavior - keep existing uses continue to work
    if(thankyouflag) {
    // Everything's valid:
       window.open("Thank You", "newFormWindow", "width=340,height=260");
    }
    return true;
}

function launchGenericPopUp(winName, url, w, h, incScroll) {

    // url#name  > url?exclude=T#name
    if (url!=null) {
        var tmp = url.split('#');
        url = tmp[0];
        url += url.indexOf('?') == -1 ? '?' : '&';
        url += 'exclude=T';
        if (tmp.length>1) {
            url += '#' + tmp[1];
        }
    }

	var newWindow = window.open(url, '_blank', 'width='+w+',height='+h+',menubar=no,location=no,resizable=1,status=no,scrollbars='+incScroll);
	if (window.focus) {
		newWindow.focus();
	}
}

//The following are wrappers to the above launchGenericPopUp.
//launchGenericPopup isn't called directly and is instead
//called via one of the following 4 methods.

function launchPopUp(name, url, w, h) {
	launchGenericPopUp(name, url, w, h, 1);
}

/**
 * Used by SizeChart duplicated in NAP global.js
 */
function showtab(tabname, pagename) {
    $(".tabButton").removeClass("selected");
    $(".tabBody").hide();

    //set target tab as selected
    $("#" + tabname).addClass("selected");

    // Show the selected tab
    $("#" + pagename).show();
}

function clearDefaultSearch(el) {
    if (el.defaultValue == el.value) el.value = "";
}

function logout() {
    document.logOutForm.submit();
}

function checkSearchForm(f) {
    if (!f.keywords.value) {
        return false;
    }
    return true;
}

function help(url,w,h) {
	var popupWidth = (w == undefined) ? 750 : w ;
	var popupHeight = (h == undefined) ? 580 : h ;
	if (url) {
		launchPopUp('Help', url, popupWidth, popupHeight);
	}
}

function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = "";
}

//Convert Sizes (product details radio buttons)
function convertSizes(theseSizes, otherSizes, currenltyShowingOriginalSizes) {
    var sizesUl = document.getElementById("sizes");
    var sizeRadioButtons = sizesUl.getElementsByTagName("LI");

    for (var i=0; i<sizeRadioButtons.length; i++) {
        if ( otherSizes[i] != '') {
            var thisSizeLi = sizeRadioButtons[i];
            var thisSizeRadioLabel = thisSizeLi.getElementsByTagName('LABEL')[0];
            var thisSizeRadioText = otherSizes[i];

            thisSizeRadioLabel.innerHTML = '<span>' + thisSizeRadioText + '</span>'
        }
    }

    var sizeAnchor = document.getElementById('convert-size-link');
    //If we are currenltyShowingOriginalSizes, we are now changing to show US sizes, so update
    //the link to allow the user to change back to original sizing
    var sizeAnchorText = 'Show ' + (currenltyShowingOriginalSizes? 'original': 'US') + ' sizes';

    sizeAnchor.innerHTML = sizeAnchorText;
    sizeAnchor.onclick = function() { return convertSizes(otherSizes, theseSizes, !currenltyShowingOriginalSizes); }

    //We don't want to use the anchors href if the user has javascript enabled.
    return false;
}

function rollOverImage(imageElem, cache_image_url, event) {
	var e = window.event || event;

	function changeImageOver() {
		imageElem.src = cache_image_url;
	}

	function changeImageOut() {
		imageElem.src = cache_image_url;
	}

	if(imageElem) {
		if(e.type == "mouseover") {
			imageTimeout = setTimeout(changeImageOver, 200);
		} else if(e.type == "mouseout") {
			clearTimeout(imageTimeout);
			changeImageOut();
		}
	}
}

function reloadPopupParentWindow() {
    window.opener.top.location.reload();
}

/**
 * TON-5 : wishlist functionality copied from NAP
 *
 */
function submitAddToWishList(listId) {
    document.getElementById("customListId").value = listId;
    document.forms["productForm"].submit();
}

function checkWishListCookie() {

    var domainStr;
    var domainPrefix = "www";
    var domainSuffix = ".theoutnet.com";

	var subDomainRegExp = /\/\/([a-zA-Z0-9.]+)\.theoutnet.com/,
	   subDomainMatch = window.parent.location.href.match(subDomainRegExp),
	   subDomain;

	if (subDomainMatch && subDomainMatch.length > 0) {
		domainPrefix = subDomainMatch[1];
        domainStr = domainPrefix + domainSuffix;

	} else {
        // FOR DEV ONLY SO NOT TO DEFAULT URL TO 'WWW'. IF NO MATCH TO 10.3.XXX.XXX (INTERNAL IP)
        // THEN DOMAINSTR WILL BE 'WWW.NET...'
        var ipRegExp = /10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/,
	    ipMatch = window.parent.location.href.match(ipRegExp),
	    ipAddress;

        if (ipMatch && ipMatch.length>0) {
            domainStr = ipMatch[0];

        } else {
		    domainStr = domainPrefix + domainSuffix;

        }
	}

    // find the wish list cookie in the document cookie string
    var wishlistCookieValues = {},
        wishlistCatUrl = "http://"+domainStr+"/"+channel+"/catwishlist.chic",
        wishlistGridUrl = "http://"+domainStr+"/"+channel+"/gridwishlist.chic",
        wishlistLiteUrl = "http://"+domainStr+"/"+channel+"/wishlist.chic";

    var _cID1=document.cookie.indexOf("wishlist_settings");
    // return null if it's not there
    if (_cID1==-1) {
        window.parent.location.href = wishlistCatUrl;
    } else {
        var _cID2=document.cookie.indexOf("=",_cID1),
            _cID3=document.cookie.indexOf(";",_cID2);

        if (_cID3==-1) _cID3=document.cookie.length;

        var cookieVal = document.cookie.substring(_cID2+1,_cID3),
            cookieArr = cookieVal.split(","),
            thisPair,
            thisKey,
            thisValue;

        // convert the cookie string into key:value pairs
        for(var key in cookieArr) {
            thisPair = cookieArr[key].split(":");
            thisKey = thisPair[0];
            thisValue = thisPair[1];

            // write this key:value pair to the cookie object
            wishlistCookieValues[thisKey] = thisValue;
        }
    }

    var wishlistView = wishlistCookieValues["view"];

    // change the parent frame's href based on the value 'view' in the wish list cookie
    switch(wishlistView) {
        case "grid":
            window.parent.location.href = wishlistGridUrl;
            break;
        case "lite":
            window.parent.location.href = wishlistLiteUrl;
            break;
        default:
            window.parent.location.href = wishlistCatUrl;
    }
}



/*************************************************
NEW FUNCTIONALITY

Duytan Hoang

namespace to keep new code clean
eventually migrate old code into the namespace
*************************************************/

var global_outnet = {

    /*************************************************
    main nav drop down
    *************************************************/
    mainNavDropdown: function() {
        var showTimeout,
            hideTimeout;

        $("li.main-menu div").hide();
        $("li.main-menu").hover(function(e) {

            var that = $(this);

            clearTimeout(hideTimeout);
            showTimeout = setTimeout(function () {
                $("li.main-menu div").hide();
                $("li.main-menu").removeClass("hovered");

                var menuID = that.find("a").html();

                if (menuID) menuID = menuID.toLowerCase()+"-menu";
                menuID = menuID.replace(/ /, "-");

                $("#"+menuID).show();
                that.addClass("hovered");
            }, 300);
        }, function(e) {
            hideTimeout = setTimeout(function () {
                $("li.main-menu div").hide();
                $("li.main-menu").removeClass("hovered");
            }, 300);
            clearTimeout(showTimeout);
        });
    },

    /*************************************************
    auto populate field from select options
    *************************************************/
    selectPopulate: function() {
        var dropdown = $(".message-dropdown");

        if (dropdown.length > 0) {
            dropdown.each(function() {
                var $that = $(this);

                $that.change(function() {
                    var $msgBox = $that.next(".message-auto");

                    $that.find("option:selected").each(function () {
                        var $msgOpt = $(this).val();

                        $msgBox.val($msgOpt);
                    });
                });

            });
        }
    },

    /*************************************************
    redirect pages for thank you states
    *************************************************/
    autoRedirect: function(marker, url) {
        var autoSpeed = 4000;

        setTimeout(function() {
            window.location.href = url;
        }, autoSpeed );
    },

    /*****************************************
    create "previous" & "next" controls for
    carousel
    *****************************************/
    carouselControls: function(target, nextButton, prevButton) {
        var carouselNextHolder = $(target).find(".carousel-next-btn"),
            carouselPrevHolder = $(target).find(".carousel-prev-btn"),
            carouselNext = "<span class='"+ nextButton +"'>Next</span>",
            carouselPrev = "<span class='"+ prevButton +"'>Previous</span>";

        $(carouselNextHolder).append(carouselNext);
        $(carouselPrevHolder).append(carouselPrev);
    },

    /*****************************************
    increase the size of the search bar
    *****************************************/
    searchBar: function() {
        var $searchBar = $(".search-bar"),
            smallWidth = "120px",
            largeWidth = "160px",
            $navLinks = $("#top-nav");

        $navLinks.addClass("expand-nav");

        $searchBar
            .css("width", smallWidth)
            .focus(function() {
                $navLinks.removeClass("expand-nav");
                $searchBar.animate({
                    width: largeWidth
                });
            })
            .blur(function() {
                $searchBar.animate({
                    width: smallWidth
                }, 500, function() {
                    $navLinks.addClass("expand-nav");
                });
            })
    }
}

/*************************************************
loadlist
*************************************************/
$(document).ready(function() {
    initProductPage();
    global_outnet.selectPopulate();
//    global_outnet.searchBar();
});
