var $j = jQuery.noConflict();

// jquery test
/*
$j(document).ready(function(){
	$j("a.discover")
		.hide();
});
*/
//<!--:en-->Search now...<!--:--><!--:zh-->搜查<--:-->
// clear default search value
$j(document).ready(function(){
	$j("#s")
			.val("Search now...")
			.css("color", "#9d9d9d")
			.focus(function(){
				$j(this).css("color", "black");
				if ($j(this).val() == "Search now...") {
						$j(this).val("");
				}
			})
			.blur(function(){
				$j(this).css("color", "#cccccc");
				if ($j(this).val() == "") {
						$j(this).val("Search now...");
				}
	});
});

// clear default newsletter value
$j(document).ready(function(){
	$j("#mce-EMAIL")
			.val("Enter your emaill address")
			.css("color", "#9d9d9d")
			.focus(function(){
				$j(this).css("color", "black");
				if ($j(this).val() == "Enter your emaill address") {
						$j(this).val("");
				}
			})
			.blur(function(){
				$j(this).css("color", "#cccccc");
				if ($j(this).val() == "") {
						$j(this).val("Enter your emaill address");
				}
	});
});

// call to action hover animation
$j(document).ready(function() {
	$j("p.feature-cta a")
		.css({'backgroundPosition': '0 0'
		})
		.hover(
			function(){
				$j(this)
					.stop()
					.animate({
						'opacity': 0.3
							}, 650);
			},
			function(){
				$j(this)
					.stop()
					.animate({
						'opacity': 1
							}, 650);
			}
		);
});

// product hover animation
$j(document).ready(function() {
	$j("ul.product-categories li a")
/*
		.css({'backgroundPosition': '0 0'
		})
*/
		.hover(
			function(){
				$j(this)
					.stop()
					.animate({'opacity': 0.5
						}, 650);
			},
			function(){
				$j(this)
					.stop()
					.animate({'opacity': 1
					}, 650);
			}
		);
});

/*
$j(document).ready(function() {
	$j("ul.product-categories li.cat-item-13 a")
		.css({'backgroundPosition': '-120px 0'
		})
		.hover(
			function(){
				$j(this)
					.stop()
					.animate({'opacity': 0
						}, 650);
			},
			function(){
				$j(this)
					.stop()
					.animate({'opacity': 1
					}, 650);
			}
		);
});
*/

// background image transition
$j(document).ready(function(){
	/* var imageSrc = "http://localhost/princesslife/cms/wp-content/themes/princesslife/images/"; */
	var imgArr = new Array(
		'cms/wp-content/themes/princesslife/images/feature01.jpg',
		'cms/wp-content/themes/princesslife/images/feature02.jpg',
		'cms/wp-content/themes/princesslife/images/feature03.jpg'
	);
	
	var preloadArr = new Array();
	var i;
				
	/* preload images */
	for(i=0; i < imgArr.length; i++){
		preloadArr[i] = new Image();
		preloadArr[i].src = imgArr[i];
	}
				
	var currImg = 1;
	var intID = setInterval(changeImg, 5000);
				
	function changeImg(){
		$j("#feature-banner")
			.animate({opacity: 0}, 1000, function(){
				$j(this)
					.css('background-image', 'url(' + preloadArr[currImg++%preloadArr.length].src +')');
			})
					.animate({opacity: 1}, 1000);
	}
});
