$(document).ready(function(){
	gen_pagging();
	get_beauty_gallery();
}
);
function get_beauty_gallery(){
	var page=$(document).getUrlParam("page");
	if(!page)page=1;
	var rpc = new PHPRPC_Client('http://bawbaw.deep.tw/beauty_gallery/rpc.beauty_gallery.php', ['get_beauty_gallery']);
	rpc.get_beauty_gallery(page,function(result){
		var html_str='';
		var photo_url='';
		if(!result[0]){
			alert('最後一頁啦~將回第一頁!');
			document.location.href=document.location.href.replace(/\?page=\d+/g, "")+'?page=1';
			return false;
		}
		var nums=result.length;
		for(var i=0;i<nums;i++){
			photo_url=result[i]['photo_url'];
			//html_str+='<li><div class="img"><a href="'+get_photo_proxy()+photo_url+'" class="thickbox" rel="gallery-plants">'+get_swfoto(get_thumb_photo_proxy()+photo_url)+'</a></div></li>';
			html_str+='<img src="'+get_thumb_reflect_photo_proxy()+photo_url+'" longdesc="'+get_photo_proxy()+photo_url+'" alt="美女相片" />';
		}
		$('#images').html(html_str);
		if($.browser.msie){
			setTimeout("init_image_flow();", 2000);
		}
	});
}
function init_image_flow(){
	$('#images img').ready(function(){
	if(document.getElementById(conf_imageflow))
	{
		hide(conf_loading);
		refresh(true);
		show(conf_images);
		show(conf_scrollbar);
		initMouseWheel();
		initMouseDrag();
	}
	});
}
function get_photo_proxy()
{
	var proxy_list=[
	'http://bawbaw.icittys.com/random_beauty.php/'
	];
	var proxy_count=proxy_list.length;
	return proxy_list[Math.floor(Math.random()*proxy_count)];
}
function get_thumb_reflect_photo_proxy()
{
	var proxy_list=[
	'http://bawbaw.icittys.com/random_beauty_thumb_reflect.php/'
	];
	var proxy_count=proxy_list.length;
	return proxy_list[Math.floor(Math.random()*proxy_count)];
}
function gen_pagging(){
	var page=parseInt($(document).getUrlParam("page"));
	if(!page)page=1;
	if(page==1){
		var prev=1;
		var next=2;
	}else{
		var prev=page-1;
		var next=page+1;
	}
	var str='<a href="./?page='+prev+'">上一本</a> | <a href="./?page='+next+'">下一本</a>';
	$('.pagging').html(str);
}