jQuery(document).ready(function(){
		
	
	
	
	/* global gateway js */
	jQuery('.global-language li').click(function() {
		jQuery('.global-language li').each(function(){
			if (jQuery(this).hasClass('active')){
				jQuery(this).removeClass('active');
			}
		});
		jQuery(this).addClass('active');
		var len = jQuery(this).prevAll().length;
		jQuery('.country-select-box').hide();
		jQuery('.country-select-box:eq('+len+')').show();
		
	});
	jQuery(function () {
		var tabContainers = jQuery('div.product_tabs .tab-box');
		
		jQuery('div.product_tabs ul.product-tabs-list a').click(function () {
			tabContainers.hide().filter(this.hash).show();
			
			jQuery('div.product_tabs ul.product-tabs-list a').removeClass('active');
			jQuery(this).addClass('active');
			
			return false;
		}).filter(':first').click();
	});
	
	jQuery('.sortby select, .itemsperpage select, .addtocart .quanity select, .selectaddress-box select').styledSelect({
		containerClass: 'sortby-select'
	});
	jQuery('.editpreferences select').styledSelect({
		containerClass: 'commonforms-select'
	});
	/*jQuery(function () {
		var rotateBoxes = jQuery('.color .swatchesdisplay strong, .innerpalette ul li strong');
		//rotateBoxes.css('rotate', '135deg');
		rotateBoxes.each(function(){
			jQuery.cssHooks.rotate.set(this,'135deg');
		});
	});*/
	
	jQuery('.cat-landing-subcategories-holder ul li .cat-title:has(.cat-text)').mouseenter(function(){
		jQuery(this).stop().animate({
			top: "0"
		}, 500 );
	});
	jQuery('.cat-landing-subcategories-holder ul li .cat-title:has(.cat-text)').mouseleave(function(){
		jQuery(this).stop().animate({
			top: "135"
		}, 500); 
	});
	var liWidth = 0;
	var liCount = 0;
	jQuery('.product-tabs-list li').each(function(){
		liWidth = liWidth + jQuery(this).width();
		liCount++;
	});
	var liTail = (470 - liWidth + liCount) % (liCount *2);
	var liPadding = (470 - liWidth - liTail + liCount) / (liCount *2); 
	jQuery('.product-tabs-list li a').css({
		'paddingLeft': liPadding,
		'paddingRight': liPadding
	})
	
	jQuery('.product-tabs-list li:first a').css({
		'paddingLeft': liPadding + (liTail - liTail%2)/2  + liTail%2,
		'paddingRight': liPadding + (liTail - liTail%2)/2
	})
	jQuery(function(){
		jQuery('.carttable input').keydown(function(e){
			if (e.keyCode == 13) {
				return false;
			}
		});
	});
	jQuery(function() {
		var namenode = jQuery('span.username').html();
		var nameneed = 30;
		if ((namenode) && (namenode.length > nameneed)) {
			jQuery('span.username').html( namenode.slice( 0, nameneed ) + "…");
		}
	});
	jQuery(function() {
		var namenode2 = jQuery('.headercustomerinfo a.usernot').html();
		var nameneed2 = 30;
		if ((namenode2) && (namenode2.length > nameneed2)) {
			jQuery('.headercustomerinfo a.usernot').html( namenode2.slice( 0, nameneed2 ) + "…");
		}
	});
	jQuery(function() {
		var namenode4 = jQuery('.account-block .welcomemessage span').html();
		var nameneed4 = 16;
		if ((namenode4) && (namenode4.length > nameneed4)) {
			jQuery('.account-block .welcomemessage span').html( namenode4.slice( 0, nameneed4 ) + "…");
		}
	});
	jQuery(function() {
		var namenode3 = jQuery('.not-user span.username').html();
		var nameneed3 = 20;
		if ((namenode3) && (namenode3.length > nameneed3)) {
			jQuery('.not-user span.username').html( namenode3.slice( 0, nameneed3 ) + "…");
		}
	});
	jQuery('.comparisontable .product-box').css({
		'height': jQuery('.comparisontable td.product').height(),
		'paddingBottom': 105
	});
})
