
var gameidseo = $('#gameid').val();
var carrieridseo = $('#carrierid').val()==''?'0':$('#carrierid').val();
var gtidseo = $('#gtid').val()==''?'0':$('#gtid').val();
var groupidseo = $('#groupid').val()==''?'0':$('#groupid').val();
var serveridseo = $('#serverid').val()==''?'0':$('#serverid').val();
var currentNo = $('#currentNo').val()==''?'0':$('#currentNo').val();
var evsseo = $('#evsseo').val()==''?'0':$('#evsseo').val(); 
var evsid = $('#evsseo').val();
var tradetypeseo = $('#tradetypeall').val()==''?'0':$('#tradetypeall').val();
var sorttypeseo = $('#sorttypeValue').val()==''?'0':$('#sorttypeValue').val();
var depositseo = $('#deposit').val(); 
var priceSeo = ($('#priceCeiling').val()==''&&$('#priceFloor').val()=='')?'0':$('#priceFloor').val()+'a'+$('#priceCeiling').val();
var istradesecurityseo = $('#istradesecurity').val()==''?'0':$('#istradesecurity').val();
function hiden(divId,hidtime){
	  $(divId).hide(hidtime);//hide()函数,实现隐藏,括号里还可以带一个时间参数(毫秒)例如hide(2000)以2000毫秒的速度隐藏,还可以带slow,fast
}
	
function slide(divId){
	  $(divId).slideDown();//窗帘效果展开
}

function initForm() {
if ($('#tradetype').val() == 'js') {
	$('#chk_js').attr('checked', true);
} else if ($('#tradetype').val() == 'db') {
	$('#chk_db').attr('checked', true);
}
if($('#status').val()=='1'){
	$('#chk_fa').attr('checked', true);
}
if($('#payoutdelay').val()=='1'){
	$('#chk_an').attr('checked', true);
}

if ($('#deposit').val() == 1) {
	$('#chk_deposit').attr('checked', true);
}
if ($('#istradesecurity').val() == 1) {
	$('#chk_trade').attr('checked', true);
}

if ($('#sorttypeValue').val() == 'priceDesc') {
	$('#sorttype').get(0).selectedIndex = 1;
} else if ($('#sorttypeValue').val() == 'priceAsc') {
	$('#sorttype').get(0).selectedIndex = 2;
} else if ($('#sorttypeValue').val() == 'unitPriceAsc') {
	$('#sorttype').get(0).selectedIndex = 3;
} else if ($('#sorttypeValue').val() == 'unitPriceDesc') {
	$('#sorttype').get(0).selectedIndex = 4;
}
}

Array.prototype.remove=function(dx) 
{ 
if(isNaN(dx)||dx>this.length){return false;} 
for(var i=0,n=0;i<this.length;i++) 
{ 
if(this[i]!=this[dx]) 
{ 
   this[n++]=this[i] 
} 
} 
this.length-=1 
}


function shousuopro(menuid){
	$('#div_topTree_hidden'+menuid).toggle();
	if ($('#img_topTree_toggle'+menuid).attr('src') == 'http://pic.ofcard.com/7881/market/images/buy/buy_zhan.png') {
		$('#img_topTree_toggle'+menuid).attr('src', 'http://pic.ofcard.com/7881/market/images/buy/buy_suo.png');
	} else {
		$('#img_topTree_toggle'+menuid).attr('src', 'http://pic.ofcard.com/7881/market/images/buy/buy_zhan.png');
	}
}

function query_js_db_pf(em) {
var boo = false;
var seo = '0';
if($(em).attr('id')=='chk_js'&&$('#chk_js').attr('checked')){
	seo='js';
	boo = true;
}else if($(em).attr('id')=='chk_db'&&$('#chk_db').attr('checked')){
	seo='db';
	boo = true;
}
var deposit=false;
if ($(em).attr('id')=='chk_deposit'&&$('#chk_deposit').attr('checked')) {
	$('#deposit').val('1');
	depositseo = '1';
	deposit=true;
}
if($(em).attr('id')=='chk_deposit'&&!$('#chk_deposit').attr('checked')){
	$('#deposit').val('0');
	depositseo = '0';
	deposit=true;
}
var istradesecurity = false;
if($(em).attr('id')=='chk_trade'&&!$('#chk_trade').attr('checked')){
	$('#istradesecurity').val('0');
	istradesecurityseo = '0';
	istradesecurity=true;
}
$(':checkbox').each(function(i,item){
	if($(item).attr('checked')){
		if(boo&&$(item).attr('id')=='chk_db'){
			return;
		}
		if($(item).attr('id')=='chk_js'&&boo){
			return;
		}
		if(!deposit){
			if ($(item).attr('id')=='chk_deposit') {
				$('#deposit').val('1');
				depositseo = '1';
			}else if(deposit){
				$('#deposit').val('0');
				depositseo = '0';
			}
		}
		
		if(!istradesecurity){
			if ($(item).attr('id')=='chk_trade') {
				$('#istradesecurity').val('1');
				istradesecurityseo = '1';
			}else{
				$('#istradesecurity').val('0');
				istradesecurityseo = '0';
			}
		}
		
		if($(item).attr('id')=='chk_js'){
			seo='js';
			boo = true;
		}
		if($(item).attr('id')=='chk_db'){
			seo = 'db';
			boo=true;
		}
		if($(item).attr('id')=='chk_an'){
			if(boo){
				seo += 'xan'
			}else{
				seo='an';
				boo = true;
			}
		}
		if($(item).attr('id')=='chk_fa'){
			if(boo){
				seo +='xfa'
			}else{
				seo='fa';
				boo = true;
			}
		}
	}
});
$('#tradetype').val(seo);
tradetypeseo=seo;

var	 url = '/buy-'+gameidseo+'-'+carrieridseo+'-'+gtidseo+'-'+groupidseo+'-'+serveridseo+'-0-'+evsseo+'-'+tradetypeseo+'-'+sorttypeseo+'-'+depositseo+'-'+priceSeo+'-'+istradesecurityseo+'.html'; 
window.location.href= url;
return false;
}

function sortClick(em){
	sorttypeseo = em;
	goSort('prices','0')
}

$(function(){

	//获取要定位元素距离浏览器顶部的距离

	var navH = $(".Sort_bottom").offset().top;

	//滚动条事件

	$(window).scroll(function(){

	//获取滚动条的滑动距离

	var scroH = $(this).scrollTop();

	//滚动条的滑动距离大于等于定位元素距离浏览器顶部的距离，就固定，反之就不固定

	if(scroH>=navH){

	$(".Sort_bottom").addClass('fixer');

	}else if(scroH<navH){

	$(".Sort_bottom").removeClass('fixer');

	}

	});

	});

$(document).ready(function(){
	restrict_price_input($('#priceFloor'));
	restrict_price_input($('#priceCeiling'));
	$('#group_strHref').click(function(){
		$('#div_group_hidden').toggle();
		if ($('#img_group_toggle').attr('src') == 'http://pic.ofcard.com/7881/market/images/buy/buy_zhan.png') {
			$('#img_group_toggle').attr('src', 'http://pic.ofcard.com/7881/market/images/buy/buy_suo.png');
		} else {
			$('#img_group_toggle').attr('src', 'http://pic.ofcard.com/7881/market/images/buy/buy_zhan.png');
		}
	});
	//列表页区服
	$(".serviceshow").click(function(){
		var id = $(this).attr("common");
		$("#"+$(this).attr("common")).toggleClass("overflow");
		$(this).toggleClass("servicehide");
		$(this).html("精简显示");
		 if( $("#"+$(this).attr("common")).hasClass("overflow") ) 
		   {
			 $(this).html("精简显示"); 
		   }else{
			   $(this).html("全部显示"); 
		     }    
	  }); 
	$('#p_clear').click(function(){
		$('#currentNo').val(0);
		window.location.href = '/buy-'+$('#gameid').val()+'.html';
		return false;
	});
	$('#btnServerSearch').click(function(){
		if ($('#ul_serverid_selected .gameservice dd').length < 1) {
			return false;
		}
		var txt = $.trim($('#txtServerSearch').val());
		if (txt == '') {
			return false;
		}
		txt = txt.toLowerCase();
		var _txt = '';
		$.each(txt, function(i, item){
			if (/[\u4e00-\u9fa5\d]/.test(item)) {
				_txt += Character.getPinyinOfChar(item);
			} else {
				_txt += item;
			}
		});
		if(_txt==''){
			return ;
		}
		var _flag = '';
		//$('#div_server_hidden').show();
		$.each($('#ul_serverid_selected .gameservice dd'), function(i, item){
			if (Character.testPinyinAbbrByPinyin(Character.getPinyin2($.trim($(item).find('a').text())).pinyin, _txt)) {
				_flag = '1';
			}
		});
		if(_flag=='1'){
			$.each($('#ul_serverid_selected .gameservice dd'), function(i, item){
				var _flag = '';
					if (Character.testPinyinAbbrByPinyin(Character.getPinyin2($.trim($(item).find('a').text())).pinyin, _txt)) {
						if ($(item).is(':hidden')) {
							$(item).show();
						}
					} else {
						if ($(item).is(':visible')) {
							$(item).hide();
						}
					}
			});
			$('#div_server_hidden dd').hide();
			$('#server_strHref').hide();
		}
		return false;
	});
	
	$('.pxtop_r a[type="pageSize"][size='+$('#pageSize').val()+']').addClass('size_selected');
	$('.pxtop_r a[type="pageSize"]').click(function(){
		var pageSize = $(this).attr('size');
		$('#pageSize').val(pageSize);
		$('#currentNo').val(0);
		doSubmit();
	});
	$('#btnOK').click(function(){
		var priceFloor = $('#priceFloor').val();
		var priceCeiling = $('#priceCeiling').val();
		if($('#priceFloor').val()==''&&$('#priceCeiling').val()==''){
			priceSeo = 0;
		}else{
			
			if(priceFloor!=''&& priceFloor.indexOf('.')!=-1){
				priceFloor = priceFloor.substring(0,priceFloor.indexOf('.'));
			}
			if(priceCeiling!=''&&priceCeiling.indexOf('.')!=-1){
				priceCeiling = priceCeiling.substring(0,priceCeiling.indexOf('.'));
			}
			
			priceSeo = priceFloor+'a'+priceCeiling;
		}
		window.location.href='/buy-'+gameidseo+'-'+carrieridseo+'-'+gtidseo+'-'+groupidseo+'-'+serveridseo+'-0-'+evsseo+'-'+tradetypeseo+'-'+sorttypeseo+'-'+depositseo+'-'+priceSeo+'-'+istradesecurityseo+'.html';
		//doSubmit();
	});
	$('#hlk_unitprice').click(function(){
			if ($('#hlk_unitprice').attr('class') == 'down_light') {
				$('#hlk_unitprice').css('up_light');
				$('#sorttypeValue').val('unitPriceDesc');
			} else if ($('#hlk_unitprice').attr('class') == 'up_light') {
				$('#hlk_unitprice').css('down_light');
				$('#sorttypeValue').val('unitPriceAsc');
			}else if($('#hlk_unitprice').attr('class') == 'up_gray'){
				$('#hlk_unitprice').css('up_light');
				$('#sorttypeValue').val('unitPriceDesc');
			}
			//$('#hlk_price').attr('class', 'down_light');
		sorttypeseo = ($('#sorttypeValue').val()==''?0:$('#sorttypeValue').val());
		window.location.href='/buy-'+gameidseo+'-'+carrieridseo+'-'+gtidseo+'-'+groupidseo+'-'+serveridseo+'-0-'+evsseo+'-'+tradetypeseo+'-'+sorttypeseo+'-'+depositseo+'-'+priceSeo+'-'+istradesecurityseo+'.html';

	});
	
	$('#hlk_price').click(function(){
		     if( $('#hlk_price').attr('class') == 'up_gray'){
				$('#hlk_price').attr('class', 'up_light');
				var dorder = 1;
			} else if ($('#hlk_price').attr('class') == 'up_light') {
				$('#hlk_price').attr('class', 'down_light');
				var dorder = 2;
			}else if ($('#hlk_price').attr('class') == 'down_light') {
				$('#hlk_price').attr('class', 'up_light');
				var dorder = 1;
			}
			$('#hlk_unitprice').css('down_gray');
		   goSort('prices',dorder);
	});

	$('#moren').click(function(){
		   $('#moren').attr('class', 'rank_up');
		   goSort('prices',0);
	});

	
	$('#hlk_discount').click(function(){
		if ($('#hlk_discount').attr('class') == 'down_light') {
			$('#hlk_discount').css('up_light');
			$('#sorttypeValue').val('discountAsc');
		} else if ($('#hlk_discount').attr('class') == 'up_light') {
			$('#hlk_discount').attr('class', 'down_light');
			$('#sorttypeValue').val('discountDesc');
		}else if( $('#hlk_discount').attr('class') == 'up_gray'){
			$('#hlk_discount').css('up_light');
			$('#sorttypeValue').val('discountAsc');
		}
		sorttypeseo = ($('#sorttypeValue').val()==''?0:$('#sorttypeValue').val());
		window.location.href='/buy-'+gameidseo+'-'+carrieridseo+'-'+gtidseo+'-'+groupidseo+'-'+serveridseo+'-0-'+evsseo+'-'+tradetypeseo+'-'+sorttypeseo+'-'+depositseo+'-'+priceSeo+'-'+istradesecurityseo+'.html';
	
	});
	
	
	
	$('.tp').click(function(){
		window.open('/goods-'+ $(this).parent().attr('goodsid')+'.html');
	});
	//initGame();
	//initGameEquip();
	initForm();
});
$(function(){
	var gtid = $('#hlk_gtid_selected').attr('gtid');
	if(gtid=='100116'||gtid=='100131'||gtid=='100106'||gtid=='100115'||gtid=='100120'){
		$("#ul_groupid_selected").hide();
	}
});

//pricesort
function cookiesave(n, v, mins, dn, path)
{
    if(n)
    {
		
	    if(!mins) mins = 365 * 24 * 60;
		if(!path) path = "/";
	    var date = new Date();
		
	    date.setTime(date.getTime() + (mins * 60 * 1000));
		
	    var expires = "; expires=" + date.toGMTString();
		
	    if(dn) dn = "domain=" + dn + "; ";
	    document.cookie = n + "=" + v + expires + "; " + dn + "path=" + path;
    }
}
function cookieget(n)
{
    var name = n + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
	}
	return "";
}
function closeclick(){
	document.getElementById('note').style.display='none';
	document.getElementById('note2').style.display='none';
	cookiesave('closeclick','closeclick','','','');
}
function clickclose(){
	if(cookieget('closeclick')=='closeclick'){
		document.getElementById('note').style.display='none';
		document.getElementById('note2').style.display='none';
	}else{
		document.getElementById('note').style.display='block';
		document.getElementById('note2').style.display='block';
	}
}
window.onload=clickclose;


