$(document).ready(function(){

	// ロールオーバー処理
	ROfunction("rover", "");
	AOverImg("aover", 0.7, 200);

	// 検索ボタン
	var search = $('#Contents .sidemenu .search');
	search.find('.btn img').click(function(){
		var key = search.find('.keyword');
		if(key.val() == ''){
			key.focus();
			alert('検索キーワードを入力してください');
			return false;
		}
		var key = encodeURI(key.val());
		var uri = 'http://search.rakuten.co.jp/search/inshop-mall/' + key + '/-/sid.217264-st.A';
		window.open(uri, 'blank');
		return false;
	});

});

function ROfunction(classname, prefix){

	var imgNum = document.getElementsByTagName("img");
	var inputNum = document.getElementsByTagName("input");

	overNum = new Array;

	if(prefix == ''){
		prefix = '_o';
	}

	for (i = 0; i < imgNum.length; i++) {
		overNum[i] = imgNum[i];
	}

	for (i = 0; i < inputNum.length; i++) {
		overNum[i + imgNum.length] = inputNum[i];
	}

	for (i = 0; i < overNum.length; i++) {
		if (overNum[i].className.indexOf(classname) != -1 && overNum[i].src.indexOf(prefix + ".") == -1) {
			overNum[i].overimg = new Image();
			if (overNum[i].className.indexOf(":") != -1) {
				Replace = overNum[i].className.split(":");
				Replace = Replace[1].split(" ");
				overNum[i].overimg.src = Replace[0];
			}
			else {
				Replace = overNum[i].src.length;
				overNum[i].overimg.src = overNum[i].src.substring(0, Replace - 4) + prefix + overNum[i].src.substring(Replace - 4, Replace);
			}
			overNum[i].setAttribute("out", overNum[i].src);
			overNum[i].onmouseover = new Function('this.src=this.overimg.src;');
			overNum[i].onmouseout = new Function('this.src=this.getAttribute("out");');
		}
	}
}

function AOverImg(classname, alpha, time){
	$('.' + classname).hover(
		function(){
			$(this).stop().fadeTo(time, alpha);
		},
		function(){
			$(this).stop().fadeTo(time, 1);
		}
	);
}
