var $j=jQuery.noConflict();


/* 
 * To Title Case 2.0.1 – http://individed.com/code/to-title-case/
 * Copyright © 2008–2012 David Gouch. Licensed under the MIT License. 
 */







$j(document).ready(function() {
	$j("#coming-soon-products-list li:last-child, #featured-products-list-table li:last-child, #new-products-list-table li:last-child").addClass("last");
	$j('#mycarousel').jcarousel();

    

});


  $j(document).ready(function() {
        $j(".capMe").keydown(function(e) {
            if (e.keyCode >= 65 & e.keyCode <= 90) {
                val1 = $j(".capMe").val();
                $j(".capMe").val(val1 + String.fromCharCode(e.keyCode));
                return false;
            }
        });
    });


jQuery.fn.titlecase = function() {
    return this.each(function() {
        var newText = jQuery(this).text().replace(/([\w&`'‘’"“.@:\/\{\(\[<>_]+-? *)/g,
        function(match, p1, index, title) {
            if (index > 0 && title.charAt(index - 2) !== ":" && match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i) > -1) return match.toLowerCase();
            if (title.substring(index - 1, index + 1).search(/['"_{(\[]/) > -1) return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
            if (match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/) > -1 || title.substring(index - 1, index + 1).search(/[\])}]/) > -1) return match;
            return match.charAt(0).toUpperCase() + match.substr(1);
        });
        jQuery(this).text(newText)
    });
};


(function($) {
$.fn.toTitleCase = function() {
	$(this).each(function(){
	var headline = $(this).text();
	$(this).text(headline.replace(/([\w&`'‘’"“.@:\/\{\(\[<>_]+-? *)/g,function(match, pl, index, title){
		if (index > 0 && title.charAt(index - 2) !== ":" && match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i) > -1)
			return match.toLowerCase();
		if (title.substring(index - 1, index + 1).search(/['"_{(\[]/) > -1)
			return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
		if (match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/) > -1 || title.substring(index - 1, index + 1).search(/[\])}]/) > -1)
			return match;
		return match.charAt(0).toUpperCase() + match.substr(1);
	}));
	});
};
})(jQuery);




$j(document).ready(function(){
	
  
		  
		   $j(function() {
    $j( 'input.toTitleCase' ).yitihit(
      {
        'format' : 'title',
        'event'  : 'blur'
      }
    );
  }); 
  
  
				
	});
	



function capitalizeMe(obj) {
        val = obj.value;
        newVal = '';
        val = val.split(' ');
        for(var c=0; c < val.length; c++) {
                newVal += val[c].substring(0,1).toUpperCase() +
val[c].substring(1,val[c].length) + ' ';
        }
        obj.value = newVal.substring(0,(newVal.length-1));
}


$j(function()
{
    // check placeholder browser support
    if (!Modernizr.input.placeholder)
    {
 
        // set placeholder values
        $j(this).find('[placeholder]').each(function()
        {
            $j(this).val( $j(this).attr('placeholder') );
        });
 
        // focus and blur of placeholders
        $j('[placeholder]').focus(function()
        {
            if ($j(this).val() == $j(this).attr('placeholder'))
            {
                $j(this).val('');
                $j(this).removeClass('placeholder');
            }
        }).blur(function()
        {
            if ($j(this).val() == '' || $j(this).val() == $j(this).attr('placeholder'))
            {
                $j(this).val($j(this).attr('placeholder'));
                $j(this).addClass('placeholder');
            }
        });
 
        // remove placeholders on submit
        $j('[placeholder]').closest('form').submit(function()
        {
            $j(this).find('[placeholder]').each(function()
            {
                if ($j(this).val() == $j(this).attr('placeholder'))
                {
                    $j(this).val('');
                }
            })
        });
 
    }
});



	    //PLACEHOLDER SUPPRT
	   /** if (!Modernizr.input.placeholder){
          $j(function() {
             if(!$j.support.placeholder) {
                var active = document.activeElement;
                $j(':text').focus(function () {
                   if ($j(this).attr('placeholder') != '' && $j(this).val() == $j(this).attr('placeholder')) {
                      $j(this).val('').removeClass('hasPlaceholder');
                   }
                }).blur(function () {
                   if ($j(this).attr('placeholder') != '' && ($j(this).val() == '' || $j(this).val() == $j(this).attr('placeholder'))) {
                      $j(this).val($j(this).attr('placeholder')).addClass('hasPlaceholder');
                   }
                });
                $j(':text').blur();
                $j(active).focus();
                $j('form:eq(0)').submit(function () {
                   $j(':text.hasPlaceholder').val('');
                });
             }
          });
        } **/
        
        
        

/**$j(document).ready(function() {	

		var id = '#dialog';
	
		//Get the screen height and width
		var maskHeight = $j(document).height();
		var maskWidth = $j(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$j('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$j('#mask').fadeIn(1000);	
		$j('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $j(window).height();
		var winW = $j(window).width();
              
		//Set the popup window to center
		$j(id).css('top',  winH/2-$(id).height()/2);
		$j(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$j(id).fadeIn(2000); 	
	
	//if close button is clicked
	$j('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$j('#mask').hide();
		$j('.window').hide();
	});		
	
	//if mask is clicked
	$j('#mask').click(function () {
		$j(this).hide();
		$j('.window').hide();
	});		
	
});**/
