function moveandshowdiv(strImgID,id)
{
	for(i = 1; i < 4; i++)
	$("#" + strImgID +  i).css("display","none") ;		
	$("#" + strImgID + id).fadeIn(1000);	
}

function quickbuy()
{
	if($("#selectGame").val() != 0 && $("#selectBlock").val() != 0)
	{
		window.location.href = "/fillorder/fillgoldorder/"+$("#selectServer").val()+"/"+$("#selectBlock").val()+"/"+$("#selectGame").val();
	}

}

function ajaxAddOptions(url, target, id, text){  
     target.empty();  
     $.getJSON(url, function(json){  
         $(json).each(function(i){  
             var x = json[i];  
             target.append("<option value='" + eval("x." + id) + "'>" + eval("x." + text) + "</option>" );  
         })  
     });  
}

$("#selectGame").bind('change',function()
{
	ajaxAddOptions("/quickbuy/getGameServer/" + $("#selectGame").val() , $("#selectServer"), "id", "text");
	ajaxAddOptions("/quickbuy/getGameFirstBlock/" + $("#selectGame").val()  , $("#selectBlock"), "id", "text");
});

$("#selectServer").bind('change',function()
{
	ajaxAddOptions("/quickbuy/getGameBlock/" + $("#selectGame").val() + "/" + $("#selectServer").val()  , $("#selectBlock"), "id", "text");
});


$("#img_ad1").bind('click', function()
	{
		
		moveandshowdiv('div_ad',1);
		clearInterval(m_tAutoImgShow);
	});
	
	 $("#img_ad2").bind('click', function()
	{
			moveandshowdiv('div_ad',2);
			clearInterval(m_tAutoImgShow);
	});
	
		$("#img_ad3").bind('click', function()
	{
			moveandshowdiv('div_ad',3);
			clearInterval(m_tAutoImgShow);
	});
		

$(document).ready(function(){	
		var nShowImgID = 1;
	var m_tAutoImgShow;
	$(document).ready(function(){
	$.extend({
	   show:function(){
			nShowImgID++;
			if ( nShowImgID > 3)
				nShowImgID = 1;
			moveandshowdiv('div_ad',nShowImgID)
	   }
	});
	m_tAutoImgShow = setInterval("$.show()",8000);
});
	
});
