$.tablesorter.addParser(
{ 
	id: 'price', 
	is: function(s) {return false;}, 
	format: function(s)
			{
				i=parseInt(s);
				if(isNaN(i))
				{
					i=0;
				}
				return i;}, 
	type: 'numeric' 
}); 
function initMenu()
{
	$(".meypricemenu ul ul").hide();
	$(".meypricemenu ul li").hover
	(
		function(){$(this).find('ul').css("display","block");},
		function(){$(this).find('ul').css("display","none");});
}
function more()
{
	$("#meysearch").css('display','block');
}

function gamechange()
{
	var gameindex=0;
	for(var i=0;i<document.searchform.game.length;i++)
	{
		if(document.searchform.game.options[i].selected)
		{
			gameindex=document.searchform.game.options[i].value;
		}
	}
	 $.ajax({
		url:"http://yahoo-rmt.jp/bbs/modules/meyprice/getdata.php",
		type:"GET",
		data:{game:gameindex},
		dataType:"json",
		success:function(text){$("#search_units").html(text.gameunits);$("#search_zone").html(text.zone);},
		error:function(){return true;}
		 }); 
}
function zonechange()
{
	var gameindex=0;
	for(var i=0;i<document.searchform.zone.length;i++)
	{
		if(document.searchform.zone.options[i].selected)
		{
			zoneindex=document.searchform.zone.options[i].value;
		}
	}
	 $.ajax({
		url:"http://yahoo-rmt.jp/bbs/modules/meyprice/getdata.php",
		type:"GET",
		data:{zone:zoneindex},
		dataType:"html",
		success:function(text){$("#search_web").html(text);},
		error:function(){return true;}
		 }); 
}
function getSearchData(responseText, statusText)
{
	$("#search_sort").tablesorter(
	{ 
        headers: { 
					1: { sorter: false },
					3: { sorter: 'price' }, 
					4: { sorter: 'price'},
					5: { sorter: 'price'}, 
            		6: { sorter: false } 
            	 }
     });
	meypriceMouse();
}
function preSearch(responseText, statusText){}; 
$(document).ready(function()
	{
		initMenu();
		$('#game_sort').tabs({event: 'mouseover'});
		$('#listrssnews').tabs({event: 'mouseover'});
		// for search sort
    });
$(document).ready(function()
{
	// for search
	var searchoptions ={target:'#search_result',beforeSubmit:preSearch,success:getSearchData}; 
    $('#searchform').submit(function(){$(this).ajaxSubmit(searchoptions); return false; });
    //for viewgame
    $("#sort_cod").change(function()
	{
		var slvalue =$("#sort_cod").val();
		var sortindex=slvalue.split("&");
		var gameid=sortindex[0];
		var sortindex=sortindex[1];
		$.ajax(
		{
			url:"viewgame.php",
			type:"GET",
			data:{action:'sort',game:gameid,sort:sortindex},
			dataType:"html",
			success:function(text){$("#game_sort_data").html(text);},
			error:function(){alert("error");}
		 });
	});
	//for zone
    $("#zonesort_cod").change(function()
	{
		var slvalue =$("#zonesort_cod").val();
		var sortindex=slvalue.split("&");
		var gameid=sortindex[0];
		var zoneid=sortindex[1]
		var sortindex=sortindex[2];
		$.ajax(
		{
			url:"viewgamezone.php",
			type:"GET",
			data:{action:'sort',game:gameid,zone:zoneid,sort:sortindex},
			dataType:"html",
			success:function(text){$("#game_sort_data").html(text);},
			error:function(){alert("error");}
		 });
	});
});
$(document).ready(function()
	{
		meypriceMouse();
});
function meypriceMouse(){
//form meyprice mouse event
$(".mey_price_list tbody tr").mouseover(function(){
	$(this).addClass('overbg');
										}).mouseout(function(){
	$(this).removeClass('overbg');
										});
}