jQuery(document).ready( function () {
	var $ = jQuery;
	
	var searchBox = jQuery('#search');
	
	var initSearchText = searchBox.val();
	
	searchBox.bind({
		keyup: function() {
			if(searchBox.val() === initSearchText) {
				searchBox.val('');
			}
		},
		focus: function() {
			if(searchBox.val() === initSearchText) {
				searchBox.val('');
			}
		},
		blur: function() {
			if(searchBox.val() === '') {
				searchBox.val(initSearchText);
			}
		}
	});
	
	$('#aside-1 li.more-link a').click(function () {
		var me = $(this);
		var ul = me.parent().parent();
		ul.find('li.extra-hidden').toggle();
		if(me.text() == 'More...') {
			me.text('Less...');
		} else {
			me.text('More...');
		}
		
		return false;
	});;
	
	
	//open link in a new window with custom sizing///////////////////
	$('a.new-window').click(function(){
		var uri = this.href;
		var name = this.title;
		
		var size = this.rel;
		var width = "450";
		var height = "600";
		if (size == "large"){
			width = "700";
			height = "720";
		}else if (size == "small"){
			width = "250";
			height = "325";
		}
		
		
		var attr = "'location=no, resizable=0, ,left=100, top=50, scrollbars=yes, width=" + width + ",height=" + height;
		 
        window.open(uri, name, attr);
        return false;
    }); 
	///////////////////////////////////////////////
    
	$('#shop-by-brand').change(function(){
			
		    $url = $('#shop-by-brand').val();
			//alert($url);
			window.location = '/index.php/' + $url;
		
	}); 
	
	
	$('#emp-login-btn').click(function(){
			
		    $('.employee-form').toggle();
		
	}); 
	
	
$(function(){ $('#slides li:gt(0)').hide(); setInterval(function(){ $('#slides li:first').fadeOut().next('li').fadeIn(1000).end().appendTo('#slides'); },6000); });


}); 
	

//////////////////carousel//////////////////
/*var mycarousel_itemList = [
    {url: skinUrl + "images/products/carousel-1.jpg", title: "Bianchi Holsters", href:"bianc"},
    {url: skinUrl + "images/products/carousel-2.jpg", title: "Blackhawk Holsters", href:"black"},
    {url: skinUrl + "images/products/carousel-3.jpg", title: "Fobus Holsters", href:"fobus"},
    {url: skinUrl + "images/products/carousel-4.jpg", title: "Galco Holsters", href:"galco"},
    {url: skinUrl + "images/products/carousel-1.jpg", title: "Don Hume Holsters", href:"dun_h"},
    {url: skinUrl + "images/products/carousel-2.jpg", title: "ASP Holsters", href:"asp"},
    {url: skinUrl + "images/products/carousel-3.jpg", title: "Safariland Holsters" , href:"safar"},
    {url: skinUrl + "images/products/carousel-4.jpg", title: "Desantis Holsters", href:"desan" }
];



function mycarousel_itemLoadCallback(carousel, state)
{
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1]));
    }
};
*/
/**
 * Item html creation helper.
 */
/*function mycarousel_getItemHTML(item)
{
    return '<div class="product-image"><a href="'+ item.href +'"><img src="' + item.url + '" width="75" height="75" alt="' + item.url + '" /></a><div class="product-description"><a href="#">' + item.title + '</a></div></div>';
};

jQuery(document).ready(function() {
		jQuery('#product-carousel').html('');
    jQuery('#product-carousel').jcarousel({
        size: mycarousel_itemList.length,
        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback},
				visible:4
    });
});

function equalHeights() {
	var $ = jQuery;
	var maxH = 0;
	var els = [];
	$('#featured-products-home div.product').each( function () {
		var me = $(this);
		els.push(me);
		if(me.height() > maxH) {
			maxH = me.height();
		}
	});
	for(var i=0; i<els.length; i++) {
		els[i].height(maxH);
	}
}

window.onload = equalHeights;
///////////end carousel////////////////////////
*/
