window.name="ytennis";
window.focus();

function OpenSubWindow(path, name, width, height) {
	var x = (screen.width - width) / 2;
	var y = (screen.height - height) / 2;
	var option = 'width=' + width + ',height=' + height + ',left=' + x + ',top=' + y +',scrollbars=no' + ',toolbar=no' + ',status=no';
	osw = window.open(path,name,option);
	osw.focus();
	return false;
}

function openThickbox(title, path){
	tb_show(title, path, false);
	return false;
}

function ImageCache(value) {
	var images = new Array();
	for (i=0; i < value.length; i++) {
		images[i] = new Image();
		images[i].src = value[i];
	}
}

function ImgUrlChange(elm1, img, elm2, url) {
	$(elm1).src = img;
	if (elm2) { $(elm2).href = url; }
	return false;
}

function changeMenu_SD(setSDlist,setId) {
  var num = 0;
  var sd_obj = $F(setId);
  var set_sd_num_obj = $('number');
  for (i=set_sd_num_obj.options.length; 0 < set_sd_num_obj.options.length; i--) {
      set_sd_num_obj.options[i] = null;
  }
  set_sd_num_obj.options[0] = new Option('-', '');
  for (i=0; i < setSDlist.length; i++) {
	if (sd_obj == setSDlist[i][0]) {
	  num = setSDlist[i][2];
	  break;
    }
  }
  for (j=0; j < num; j++) {
    set_sd_num_obj.options[j] = new Option(j+1, j+1);
  }
}

function SwfDisplay(path, width, height, param) {
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH=' + width + ' HEIGHT=' + height + '>',
	'<PARAM NAME=movie VALUE="' + path + '">',
	'<PARAM name="wmode" value="transparent">',
	'<PARAM NAME=menu VALUE=false>',
	'<PARAM NAME=quality VALUE=high>',
	'<PARAM NAME=flashvars VALUE="' + param + '">',
	'<EMBED wmode="transparent" SRC="' + path + '" WIDTH=' + width + ' HEIGHT=' + height + ' menu=false quality=high TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" flashvars="' + param + '">',
	'</EMBED></OBJECT>');
}

function element_toggle(id,speed) {
	var speed = (!speed) ? 500 : speed-0;
	jQuery("#"+id).animate({height:"toggle", opacity:"toggle"},speed);
}

function addBookMark() { 
	if(navigator.userAgent.indexOf("MSIE") > -1){ //Internet Explorer
		window.external.addFavorite('http://www.ytennis.com','YES¥Æ¥Ë¥¹¥·¥ç¥Ã¥×');
	} else {
		window.sidebar.addPanel('YES¥Æ¥Ë¥¹¥·¥ç¥Ã¥×', 'http://www.ytennis.com', "");
	}
}

var Zipcode_flag = false;
var Zipcode = Class.create({
	check: function() {
		var word = $('word');
		var zip1 = $('_zip1');
		var zip2 = $('_zip2');
		var address1 = $('_address1');
		var address2 = $('_address2');
		var address3 = $('_address3');
		var zipcode_button = $('zipcode_button');
		var zipcodesearch_form = $('zipcodesearch_form');
		var zipcodesearch_word = $('zipcodesearch_word');
		zipcode_button.disabled = true;
		if (zipcodesearch_word && $F('zipcodesearch_word') != "") {
			var hash = $H({'word':encodeURI($F(zipcodesearch_word)), 'rand':Math.random()});
			zipcodesearch_list.innerHTML = "ÄÌ¿®Ãæ¡¥¡¥¡¥";
		} else {
			var hash = $H({'code':$F(zip1)+$F(zip2), 'rand':Math.random()});
		}
		new Ajax.Request("/tennis/operation/ac/zipcode/",{
			"method": "post",
			"parameters": hash.toQueryString(),
			onSuccess: function(request) {
				zipcode_button.disabled = false;
				var xmlDoc = request.responseXML;
				var xmlItem = xmlDoc.documentElement.getElementsByTagName("item");
				var xmlCode1 = xmlDoc.documentElement.getElementsByTagName("code1");
				var xmlCode2 = xmlDoc.documentElement.getElementsByTagName("code2");
				var xmlPrefecture = xmlDoc.documentElement.getElementsByTagName("prefecture");
				var xmlCity = xmlDoc.documentElement.getElementsByTagName("city");
				var xmlStreet = xmlDoc.documentElement.getElementsByTagName("street");
				if (xmlItem.length != 0) {
					if (zipcodesearch_word && $F('zipcodesearch_word') != "") {
						zipcodesearch_list.innerHTML = "¼«Æ°ÆþÎÏ¤¹¤ë½»½ê¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤¡£<br />";
						for (var i=0; i < xmlItem.length; i++) {
							zipcodesearch_list.innerHTML += "<a href=\"javascript:void(0);\" onClick=\"intZipcode('"+
							xmlCode1[i].firstChild.nodeValue+"', '"+
							xmlCode2[i].firstChild.nodeValue+"', '"+
							xmlPrefecture[i].firstChild.nodeValue+"', '"+
							xmlCity[i].firstChild.nodeValue+"', '"+
							xmlStreet[i].firstChild.nodeValue+"')\">"+
							xmlCode1[i].firstChild.nodeValue+'-'+
							xmlCode2[i].firstChild.nodeValue+' '+
							xmlPrefecture[i].firstChild.nodeValue+
							xmlCity[i].firstChild.nodeValue+
							xmlStreet[i].firstChild.nodeValue+"</a><br />";
						}
					} else {
						if (true == Zipcode_flag) {
							zipcodesearch_word.value = "";
							zipcodesearch_form.style.display = 'none';
						}
						zip1.value = xmlCode1[0].firstChild.nodeValue;
						zip2.value = xmlCode2[0].firstChild.nodeValue;
						address1.value = xmlPrefecture[0].firstChild.nodeValue;
						address2.value = xmlCity[0].firstChild.nodeValue;
						address3.value = xmlStreet[0].firstChild.nodeValue;
					}
				} else {
					zipcodesearch_form.style.display = 'block';
					if (false == Zipcode_flag) {
						zipcodesearch_form.style.fontSize = "13px";
						zipcodesearch_form.style.background = "#ffe99a";
						zipcodesearch_form.style.padding = "5px 5px";
						zipcodesearch_form.innerHTML = 'Í¹ÊØÈÖ¹æ¤Þ¤¿¤Ï½»½ê¤òÆþ¤ì¤Æ¡Ú½»½ê¸¡º÷¡Û¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£<br /><input type="text" id="zipcodesearch_word" size="50"><br />Îã) 5250034 ¤Þ¤¿¤Ï ¼¢²ì¸©ÁðÄÅ»ÔÁðÄÅ<br /><div id="zipcodesearch_list"></div>';
						zipcodesearch_list.style.fontWeight= 'bold';
						Zipcode_flag = true;
					} else {
						zipcodesearch_word.value = "";
						zipcodesearch_list.innerHTML = "½»½ê¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£";
					}
				}
			},
			onFailure: function(request) {
				zipcode_button.disabled = false;
				alert("¥µ¡¼¥Ð¡¼¤ÈÄÌ¿®½ÐÍè¤Þ¤»¤ó¤Ç¤·¤¿¡£")
			}
		});
	},
	display: function() {
		var zipcode_button = $('zipcode_button');
		zipcode_button.innerHTML = '¡¡<input type="button" id="zipcode_button" value="¡¡½»½ê¸¡º÷¡¡">';
		Event.observe('zipcode_button', 'click', this.check);
	}
});

document.observe('dom:loaded', function(){
if ($('zipcode_button')) {
	var setZipcode = new Zipcode();
	setZipcode.display();
}

var sd_obj = $('select_data');
var set_sd_num_obj = $('number');
if (sd_obj && set_sd_num_obj) {
	for (i=set_sd_num_obj.options.length; 0 < set_sd_num_obj.options.length; i--) {
		set_sd_num_obj.options[i] = null;
	}
	set_sd_num_obj.options[0] = new Option('1', '1');;
}

	if ($("racket")) {
		Event.observe('racket', 'mouseover', popMenu_handler);
		Event.observe('racket', 'mouseout', popMenu_close_handler);
		Event.observe('string', 'mouseover', popMenu_handler);
		Event.observe('string', 'mouseout', popMenu_close_handler);
		Event.observe('bag', 'mouseover', popMenu_handler);
		Event.observe('bag', 'mouseout', popMenu_close_handler);
		Event.observe('wear', 'mouseover', popMenu_handler);
		Event.observe('wear', 'mouseout', popMenu_close_handler);
		Event.observe('shoes', 'mouseover', popMenu_handler);
		Event.observe('shoes', 'mouseout', popMenu_close_handler);
		Event.observe('dvd', 'mouseover', popMenu_handler);
		Event.observe('dvd', 'mouseout', popMenu_close_handler);
		Event.observe('acccesary', 'mouseover', popMenu_handler);
		Event.observe('acccesary', 'mouseout', popMenu_close_handler);
		Event.observe('usability', 'mouseover', popMenu_handler);
		Event.observe('usability', 'mouseout', popMenu_close_handler);
		Event.observe('popMenu', 'mouseover', function() { $('popMenu').style.display='block'; popMenuOver = true; });
		Event.observe('popMenu', 'mouseout', function() { $('popMenu').style.display='none'; popMenuOver=false;	});

	}

}, false);

function intZipcode(zip1,zip2,prefecture,city,street) {
	$('_zip1').value = zip1;
	$('_zip2').value = zip2;
	$('_address1').value = prefecture;
	$('_address2').value = city;
	$('_address3').value = street;
	if (true == Zipcode_flag) {
		$('zipcodesearch_word').value = "";
		$('zipcodesearch_form').style.display = 'none';
	}
}

var GoldBanner = false;

// popMenu STA
var popMenuOver = false;
var popMenuOverId = '';
var popMenuSetUrl = '/tennis/stocks/ac/stocks/cat/';
document.write('<div id="popMenu" class="alphafilter"><div id="popMenu_body"></div></div>');

function popMenu_handler(event) {
	var e = Event.element(event);

	popMenuOverId = e.id;
	e.src = e.src.replace("_a\.","_b\.");

	var setHtml = '<a href="'+popMenuSetUrl+popMenuJObject[popMenuOverId][0]['cat']+'/">'+popMenuJObject[popMenuOverId][0]['name']+'</a>';
	setHtml += '<ul style="margin:10px 0; padding-left:15px;">';
	for (var i=1; i < popMenuJObject[popMenuOverId].length; i++) {
		setHtml += '<li style="color:#015623; margin:5px;"><a href="'+popMenuSetUrl+popMenuJObject[popMenuOverId][i]['cat']+'/">'+popMenuJObject[popMenuOverId][i]['name']+'</a></li>';
	}
	setHtml += '</ul>';
	$('popMenu_body').innerHTML = setHtml;
	var x = e.offsetLeft;
	var y = e.offsetTop;
	while(e = e.offsetParent){
		x += e.offsetLeft;
		y += e.offsetTop;
	}

	$('popMenu').style.display = 'block';
	$('popMenu').style.left = (150+x)+'px';
	$('popMenu').style.top = (y+8)+'px';

}

function popMenu_close_handler(event) {
	var e = Event.element(event);
	e.src = e.src.replace("_b\.","_a\.");
	popMenuOverId = '';
	if ($('popMenu').style.display=='block') {
		setTimeout("popMenu_close()",30);
	}
}

function popMenu_close() {
	if (!popMenuOver && popMenuOverId=='') {
		$('popMenu').style.display = 'none';
		popMenuOver = false;
	}
}
// popMenu END

var setThickboxPreviewItems = "";
function stockPreviewHelper() {
  var j = 0;
  var k = (imgJObj['m'].length <= 6) ? 5-imgJObj['m'].length : 0;
  setThickboxPreviewItems = '<div style="margin:8px;">¡¡';
  for (var i=0; i < imgJObj['m'].length+k+((imgJObj['m'].length+k)%2); i++) {
    if (imgJObj['m'][j]) {
      setThickboxPreviewItems += '<a href="javascript:void(0);" onMouseOver="document.getElementById(\'TB_Image\').src=\''+imgJObj['o'][j]+'\';return false;"><img src="'+imgJObj['s'][j]+'" alt="²èÁü'+(j+1)+'" border="0"></a>¡¡';
    }
    j++;
  }
  setThickboxPreviewItems += '</div>';
}

function SetCheckbox(sccList, sccId, sccChked, sccStyle) {
	// ¥Ü¥Ã¥¯¥¹¤òÉ½¼¨
	jQuery.each(sccList, function(i,val) {
		jQuery("#"+sccId).append('<span class="'+sccId+'ss"><input type="checkbox" class="'+sccId+'si" id="'+sccId+'si'+i+'" value="'+sccList[i][0]+'" /><label for="'+sccId+'si'+i+'">'+val[1]+'</label></span>');
		jQuery("."+sccId+'ss').css(sccStyle);
		if (sccChked.indexOf('-'+val[0]+'-') != -1) jQuery("#"+sccId+'si'+i).attr({"checked":"checked"});
	});
}

function GetCheckboxHashString(gchsObj) {
	var setResult = "";
	jQuery.each(gchsObj, function(key,val) {
		var itemTmp = [];
		 var kids = jQuery("#"+val).children();
		 jQuery(":checked", kids).each(function(i,val2){
			itemTmp.push(jQuery(val2).val());
		});
		if (itemTmp.length) setResult += key+"/"+itemTmp.join("-")+"/";
	});

	return (setResult) ? setResult : false;
}

jQuery(function() {
	/*
	 * ÆÃ¼ìÊ¸»úÊÑ´¹ & ¥À¥Ö¥ë¥¯¥ê¥Ã¥¯ÁË»ß
	 */
	var replace_pattern = [
	{'match':/­¡/, 'replace':"(1)"},
	{'match':/­¢/, 'replace':"(2)"},
	{'match':/­£/, 'replace':"(3)"},
	{'match':/­¤/, 'replace':"(4)"},
	{'match':/­¥/, 'replace':"(5)"},
	{'match':/­¦/, 'replace':"(6)"},
	{'match':/­§/, 'replace':"(7)"},
	{'match':/­¨/, 'replace':"(8)"},
	{'match':/­©/, 'replace':"(9)"},
	{'match':/­ª/, 'replace':"(10)"},
	{'match':/­µ/, 'replace':"I"},
	{'match':/­¶/, 'replace':"II"},
	{'match':/­·/, 'replace':"III"},
	{'match':/­¸/, 'replace':"IV"},
	{'match':/­¹/, 'replace':"V"},
	{'match':/­º/, 'replace':"VI"},
	{'match':/­»/, 'replace':"VII"},
	{'match':/­¼/, 'replace':"VIII"},
	{'match':/­½/, 'replace':"IX"},
	{'match':/­¾/, 'replace':"X"},
	{'match':/­ä/, 'replace':"TEL"},
	{'match':/­â/, 'replace':"'No."},
	{'match':/­ß/, 'replace':"Ê¿À®"},
	{'match':/­ï/, 'replace':"¾¼ÏÂ"},
	{'match':/­ê/, 'replace':"(³ô)"},
	{'match':/­ë/, 'replace':"(Í­)"},
	{'match':/­ì/, 'replace':"(Âå)"}
	];
	jQuery('form')
	.each(function() {
		jQuery('input:submit,input:image',this).removeAttr('disabled');
	})
	.submit(function() {
		var submitBtn = jQuery('input:submit,input:image',this);
		submitBtn.attr({'disabled':'true'});
		setTimeout(function(){ submitBtn.removeAttr('disabled'); }, 15*1000);
		return false;
	})
	.bind("submit",function() {
		if (navigator.userAgent.match(/win/i)) {
			jQuery('input:text,textarea',this)
			.each(function(j, item1) {
				var tmp = jQuery(item1).val();
				jQuery.each(replace_pattern, function(k, item2) {
					tmp = tmp.replace(item2.match,item2.replace);
				});
				jQuery(item1).attr({'value':tmp});
			});
		}
		if (!jQuery(this).attr('outSubmit')) { // ³°ÉôÁ÷¿®½èÍý = outSubmit:true
			jQuery(this)[0].submit();
		} else {
			jQuery('input:submit,input:image',this).removeAttr('disabled');
		}
	});

	// ¥Æ¡¼¥Ö¥ë¥«¥é¡¼
	jQuery("table.jtable").each(function(){ 
		jQuery("tr",this).addClass("jtr");
		jQuery("th",this).addClass("jth");
		jQuery("td",this).addClass("jtd");
		jQuery("tr:even",this).addClass("jeven");
	});
});