// JavaScript Document
$(document).ready(function() {
									
	var fade_out = 400;
	var fade_in = 700;
	
	if($('.view').length) {
		$('.view ul li:even').addClass('even');
		$('.view ul li:odd').addClass('odd');
	}
	
	$('.node-add-to-cart').each(function() {
		$(this).val('');									 
	});
	
	if($('.profile').length) {
		$('.profile h2').each(function(index) {
			$(this).addClass('title-'+index);
			
				$(this).contains('Member Profile').hide();
		});	
		
		$('dl').each(function(index) {
			$(this).addClass('profile-dl-' + index);					  
		});
	}
	
	if($('#user-register').length) {
		$('#user-register fieldset').each(function() {
			var ft = $(this).children('legend').text();
			//alert(ft);
			
			$(this).addClass(ft);
		});
		
		$('#edit-field-mobile-0-value').parent('div:first').addClass('mobile');
		$('#edit-field-sms-ok-keys-Okay-to-send-SMS').parents('div.form-item').addClass('sms');
		
	}
	
	//$('#block-nice_menus-3 li a').not($('#block-nice_menus-3 li li a')).text('');
	
	var ulh = 0;
	$('#block-nice_menus-3 li ul').each(function() {
		s = $(this).children('li').size();
		h = $(this).children('li:first').height();
		$(this).height(21 * s);
	});
	
	/* BROWSERS COMPATABILITY */
 if($.browser.msie == true) {
 $('#wrapper').addClass("msie");

 } else if($.browser.mozilla == true) {
 $('#wrapper').addClass("mozilla");

 } else if($.browser.safari == true) {
 $('#wrapper').addClass("safari");

 } else if($.browser.ie == true) {
 $('#wrapper').addClass("msie");

 } else if($.browser.msie == true) {
 $('#wrapper').addClass("msie");
 }
 
 $('.product.node .product-image-tn img').click(function() {
	var id = $(this).attr('id');
	
	$('.product.node .product-image-tn img').show(); // Showing all the thumbmails
	$(this).hide(); // Hiding this thumbmail
	
	$('.product.node .product-image-big img').hide();
	$('.product.node .product-image-big img[@id='+id+']').fadeIn(fade_in);
});
 
$('#edit-attributes-2').change(function() {
	var imgid = '-' +	$(this).val();
	
	//$('.product.node .product-image-big img').hide();
	//$('.product.node .product-image-big img[@id='+imgid+']').show();
	$('.product.node .product-image-big img').hide();
	$('.product.node .product-image-big img[@id='+imgid+']').fadeIn(fade_in);
	
	/*$('.product.node .product-image-big img').fadeOut(fade_out, function() {
			 $('.product.node .product-image-big img[@id='+imgid+']').fadeIn(fade_in);
	});*/
});

$('#block-uc_catalog-0 ul').each(function() {
	$(this).children('li:first').addClass("first");	
	$(this).children('li:last').addClass("last");
	$(this).children('li').not($('li.last')).append(' |');
});

/*if($('#uc_out_of_stock_html').length) {
	//var oos = $('#uc_out_of_stock_html');
	//oos.addClass('oos');
	$('#uc_out_of_stock_html').appendTo('.add_to_cart .form-item > form > div');
	//$('#edit-attributes-2').after(oos);
}*/
 
	
/************************************************************
*
*/

/*function cname(product) {


var fade_out = 400; // Fade out time in ms
var fade_in = 700; // Fade in time in ms
 $('#mainContentBody').fadeOut(fade_out, function() {
 $('#mainContentBody').load("products/" + product + ".html",function() {
 $(this).fadeIn(fade_in);
 $('#mainContent').css("height","auto");
 });

 });

}*/
//////////////////////////////////////////////

	$('.form-item:first').addClass('first');
	$('.form-item:last').addClass('last');
	
	$('#edit-search-type-mode').parent('.form-item').hide();
	
	$('#search-box #edit-submit').val('');
	
	$('.view-item').each(function(index) {
		//$(this).children('.view-field').addClass('index-'+index);						  
	});
	
	/*$('.category-grid-products td').each(function() {
		var Link = $(this).children('.catalog_grid_title').html();
		var Link_ = Link.wrap('<span class="click-to-buy-link"></span>');
		$(this).children('.catalog_grid_sell_price').before(Link);
		
		//alert(Link);
	});*/
	
	$('.catalog_grid_image').each(function() {
		
		if($(this).children('a:first').size() < 1) {
			$(this).addClass('no-image');	
		} else {
			$(this).addClass('has-image');	
		}							  
	});
	
//	var CardMessage = $("#up_uc_gift_wrap-pane");
	
//	$('#billing-pane').append(CardMessage);
	
});