
var photobox_dicts=new Array();
var photobox_index=0;

var photobox_urls=new Array();
var photobox_names=new Array();

var photobox_sorted_dicts=new Array();
var photobox_flag_all=false;
var photobox_max=0;

function loadFriends(){
    var i=0;
    photobox_urls[i]="http://homepage.mac.com/djkaz/pb2/";photobox_names[i]="DJ-Kazさん";++i;
    photobox_urls[i]="http://homepage.mac.com/kyoshihiko/pb/";photobox_names[i]="S-NETさん";++i;
    photobox_urls[i]="http://www.m-sis.com/~bancho/";photobox_names[i]="bancho";++i;
    photobox_urls[i]="http://badge-works.ciao.jp/photolog/";photobox_names[i]="bopeeさん";++i;
    photobox_urls[i]="http://chesu.to/~ham/pb/";photobox_names[i]="hamさん";++i;
    photobox_urls[i]="http://homepage.mac.com/ikkoh1/pb/";photobox_names[i]="ikkohさん";++i;
    photobox_urls[i]="http://www.m-sis.com/~j4u/pb/";photobox_names[i]="j4u氏";++i;
    photobox_urls[i]="http://www.m-sis.com/~hobby/";photobox_names[i]="jinさん";++i;
    photobox_urls[i]="http://homepage.mac.com/kko_kuri/pb/";photobox_names[i]="k-koちゃん";++i;
    photobox_urls[i]="http://homepage.mac.com/kenjiro99/pb/";photobox_names[i]="ken'sさん";++i;
    photobox_urls[i]="http://homepage.mac.com/kow_1_k/pb/";photobox_names[i]="kittaさん";++i;
    photobox_urls[i]="http://masato-j.com/pb/";photobox_names[i]="masato_jさん";++i;
    photobox_urls[i]="http://homepage.mac.com/murozo/pb/";photobox_names[i]="murozoさん";++i;
    photobox_urls[i]="http://www.m-sis.com/~nail/pb/";photobox_names[i]="nailさん";++i;
    photobox_urls[i]="http://color.digichrome.org/";photobox_names[i]="noshigeさん";++i;
    photobox_urls[i]="http://homepage.mac.com/osawa1103/pb2/";photobox_names[i]="osawaさん";++i;
    photobox_urls[i]="http://homepage.mac.com/kazue147/pb/";photobox_names[i]="shamalさん";++i;
    photobox_urls[i]="http://homepage.mac.com/tkoike/pb/";photobox_names[i]="tkoikeさん";++i;
    photobox_urls[i]="http://homepage.mac.com/yamamoto2000/pb/";photobox_names[i]="yamamoto2000さん";++i;
    photobox_urls[i]="http://homepage.mac.com/nexthome/pb/";photobox_names[i]="おなりさん";++i;
    photobox_urls[i]="http://homepage.mac.com/cubiccomet/pb/";photobox_names[i]="くま某さん";++i;
    photobox_urls[i]="http://www.m-sis.com/~naoki/pb/";photobox_names[i]="くりぞ氏";++i;
    photobox_urls[i]="http://homepage.mac.com/yoshiko314/pb/";photobox_names[i]="けろちゃん";++i;
    photobox_urls[i]="http://taicho.orz.ne.jp/";photobox_names[i]="たいちょさん";++i;
    photobox_urls[i]="http://www.geocities.jp/makinosomurie/pb/";photobox_names[i]="ソムリエさん";++i;
    photobox_urls[i]="http://homepage.mac.com/ashind/pb/";photobox_names[i]="秋人さん";++i;
    photobox_urls[i]="http://homepage.mac.com/sly_t/pb/";photobox_names[i]="slyさん";++i;
    photobox_urls[i]="http://www.melimelo.jp/sasurau2/";photobox_names[i]="めりめろさん";++i;
    photobox_urls[i]="http://homepage.mac.com/mimizuk/pb/";photobox_names[i]="MIMIZUKさん";++i;
    photobox_urls[i]="http://www.itoolsjp.com/sakurakame/";photobox_names[i]="さくらさん";++i;

    for(i=0;i<photobox_urls.length;++i)	loadInfo(photobox_urls[i]);
}
function loadInfo(top){
    document.write('<'+'script type="text/javascript" src="'+top+'info.js"></script'+'>');
    document.write('<'+'script type="text/javascript" src="http://www.m-sis.com/~edge/friends-append.js"></script'+'>');  
}


function htmlStringFromDict(dict)
{
	if(photobox_flag_all){
		return "				<div class=\"allfriends_item\">\n					<h2>"+dict["name"]+"</h2>\n					<p class=\"photo\">\n						<a href=\""+dict["top"]+"\">\n							<img src=\""+dict["image"]+"\" alt=\""+dict["name"]+" "+date(dict["date"])+"\" title=\""+dict["name"]+" "+date(dict["date"])+"\" width=\"120\" height=\"90\" />\n						</a>\n					</p>\n					<p class=\"information\">\n						"+date(dict["date"])+"\n					</p>\n				</div>\n";
	}else{
		return "		<div class=\"friends_item\">\n			<p class=\"photo\">\n				<a href=\""+dict["top"]+"\">\n					<img src=\""+dict["image"]+"\" alt=\""+dict["name"]+" "+date(dict["date"])+"\" title=\""+dict["name"]+" "+date(dict["date"])+"\" width=\"120\" height=\"90\" />\n				</a>\n			</p>\n			<p class=\"information\">\n				"+dict["name"]+"<br />"+date(dict["date"])+"\n			</p>\n		</div>";
	}
}
function buildFriendsArea(max)
{
	if(max==0){
		photobox_flag_all=false;
		photobox_max=5;
	}else{
		photobox_flag_all=true;
		photobox_max=max;
	}
    
    var emptyDict=new Array();
    emptyDict["top"]="javascript:void(0);";
    emptyDict["image"]="http://www.m-sis.com/~edge/pbimg/loading.png";
    emptyDict["name"]="Loading...";
    emptyDict["date"]="000000000000";
    
    for(i=0;i<photobox_max;++i){
        document.write("<div id='friends_item_"+(i)+"'>");
        document.write(htmlStringFromDict(emptyDict));
        document.write("</div>");
    }
}
function friendsLoaded(idx)
{
	var insertIndex=-1;
	for(i=0;i<photobox_sorted_dicts.length;++i){
		if(compare(photobox_dicts[idx],photobox_sorted_dicts[i])>0){
			insertIndex=i;
			break;
		}
	}
	if(insertIndex==-1) insertIndex=photobox_sorted_dicts.length;
	for(i=photobox_sorted_dicts.length;i>insertIndex;--i){
		photobox_sorted_dicts[i]=photobox_sorted_dicts[i-1];
	}
	photobox_sorted_dicts[insertIndex]=photobox_dicts[idx];
	
	
	
    for(i=insertIndex;i<Math.min(photobox_sorted_dicts.length,photobox_max);++i){
		document.getElementById("friends_item_"+(i)).innerHTML=htmlStringFromDict(photobox_sorted_dicts[i]);
    }
}


/////////////////////////////////////////////////////////////////////

function year(date){	return (""+date).substr(0,4);}
function month(date){	return (""+date).substr(4,2);}
function day(date){		return (""+date).substr(6,2);}
function hour(date){	return (""+date).substr(8,2);}
function minute(date){	return (""+date).substr(10,2);}

function compare(a,b){	return (a["date"]-b["date"]);}
function date(date){//do not remove
    return ""+year(date)+"/"+month(date)+"/"+day(date)+" "+hour(date)+":"+minute(date);
}

/////////////////////////////////////////////////////////////////////

function intelligentOpen(file,openType){
    if( openType == 'Photo' ){
        window.open(file, openType, "toolbar=no,status=no,menubar=no");
    }
    else if( openType == 'Movie' ){
        window.open(file, openType, "toolbar=no,status=no,menubar=no,width=400,height=300");
    }
    else if( openType == 'Audio' ){
        window.open(file, openType, "toolbar=no,status=no,menubar=no,width=400,height=64");
    }
}
