﻿// gamelist 
$(function(){ 

	$('.hglist li a').click(function(){ 
		
		if($(this).parent('li').hasClass('focus')){$('._tmp').remove();$(this).parent('li').removeClass('focus');return false;}
		
		var allPro = $(this).attr('pro');

		var cname = $(this).attr('cname'); 
		
		if (allPro==''){
			return true;
		} else { 
			$('.hglist li.focus').removeClass('focus');
			$(this).parent('li').addClass('focus');
			$('._tmp').remove();
			var href = $(this).attr('href');
			var gid = $(this).attr('gid');
			var P = allPro.indexOf('p')>=0 ? '<li class="_tmp power"><a href="/power_leveling.asp?gid='+gid+'">Buy PowerLeveling</a></li>':'';
			var I = allPro.indexOf('i')>=0 ? '<li class="_tmp account"><a href="/account_items.asp?gid='+gid+'">Buy Account & Items</a></li>':'';
			var C = allPro.indexOf('c')>=0 ? '<li class="_tmp cdkey"><a href="/cdkey.asp?gid='+gid+'">Buy '+(cname==''?'CDKey & TimeCard':cname)+'</a></li>':'';
			$(this).parent('li').after('<li class="_tmp gold"><a href="'+href+'">Buy Gold</a></li>'+P+I+C);
			return false;
		}
	});  
		
})

$(function(){

	$('.hotjump').change(function(){JumpTo($(this).val())})

	$('#selserver').attr("disabled",false).change(function(){
		window.location = $(this).val();													   
	});	

	if($('#pagegid').length==1&&$('#pagegid').val()!=0){ 
		var pagegid = $('#pagegid').val();
		var currentGame = $('.hglist li>a[gid='+pagegid+']');
		currentGame.addClass('current');
		if(currentGame.attr('pro')!=''){currentGame.click();}
		$('#selgame option[gid='+pagegid+']').attr('selected',true);
	}

	if($('#pagesid').length==1){ 
		var pagesid = $('#pagesid').val();
		$('#selserver option[sid='+pagesid+']').attr('selected',true);
	}

	if($('#pagerid').length==1){ 
		var pagerid = $('#pagerid').val();
		$('#selserver option[rid='+pagerid+']').attr('selected',true);
	}
	
	// currency
	$('#selcurrency').change(function(){
		var seltype = $(this).val();
		var currencyCode = $(this).children('option:selected').html();
		var nowRate = $(this).children('option:selected').attr('rate');
		setCookie('currencyID',seltype);
		$('.pro_price').each(function(){
			var price = $(this).html().split(' ')[0]; 
			var beforeCode = $(this).html().split(' ')[1];
			var beforeRate = $('#selcurrency option:contains("'+beforeCode+'")').attr('rate');
			$(this).html((price*beforeRate/nowRate).toFixed(2)+" "+currencyCode);
		});
	});
	$('#selcurrency option:first').attr("selected",true);
	$('#selcurrency').attr("disabled",false);

	var currencyID = !!parseInt(getCookie("currencyID")) ? parseInt(getCookie("currencyID")):1;
	$('input[name=moneytype]').removeAttr('checked');
	$('input[name=moneytype]:eq('+(currencyID-1)+')').attr('checked',true);
	if($('input[name=moneytype]')[currencyID-1]){
		$('input[name=moneytype]')[currencyID-1].checked = true;
	}

	
	//$(':text,:password').focus(function(){$(this).css('backgroundColor','#FFEEFF');}).blur(function(){$(this).css('backgroundColor','white');});
	
	//$('.ibtn').hover(function(){$(this).css({'cursor':'pointer'})},function(){$(this).css({'cursor':'default'})});
	

})

/*/ a-z 
$(function(){ 
	if($('.slist li').length>200){ 
		var list = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' ');
		var title = '';
		for (var i=0;i<list.length;i++) { 
			title += ' <a href="#index'+list[i]+'">'+list[i]+'</a> '
			$('.slist li a[title^="'+list[i]+'"]').first().parent().before('<div class="line"><a name="index'+list[i]+'">'+list[i]+'</a><span class="top" onclick="window.scrollTo(0,0);">^top</span></div>');
		}
		$('.slist').before('<div class="aztitle">'+title+'</div>');
	}
})*/

