
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/yukiboh/pb/";photobox_names[i]="ゆき坊";++i;
    photobox_urls[i]="http://itools.jp/~sakura/pb/";photobox_names[i]="さくら";++i;
    photobox_urls[i]="http://www.m-sis.com/~j4u/pb/";photobox_names[i]="黒幕";++i;
    photobox_urls[i]="http://homepage.mac.com/haruyo0511/pb/";photobox_names[i]="はるよ";++i;
    photobox_urls[i]="http://homepage.mac.com/section_d/dsec/contents/pb/";photobox_names[i]="Dai.";++i;
    photobox_urls[i]="http://homepage.mac.com/djkaz/pb2/";photobox_names[i]="DJ-Kaz";++i;
    photobox_urls[i]="http://homepage.mac.com/yamamoto2000/pb/";photobox_names[i]="yamamoto2000";++i;
    photobox_urls[i]="http://buono-casa.com/blog/";photobox_names[i]="mama*azarashi";++i;
    photobox_urls[i]="http://homepage.mac.com/nexthome/pb/";photobox_names[i]="studio C-TAKE";++i;
    photobox_urls[i]="http://dj-kaz.com/pb/";photobox_names[i]="DJ-Kaz.com";++i;
    photobox_urls[i]="http://homepage.mac.com/haruyo0511/nichidou/";photobox_names[i]="なす";++i;
    photobox_urls[i]="http://homepage.mac.com/banjun/pb/";photobox_names[i]="ば";++i;
    photobox_urls[i]="http://homepage.mac.com/kko_kuri/pb/";photobox_names[i]="k-ko";++i;
    photobox_urls[i]="http://www.m-sis.com/~leche/pb/";photobox_names[i]="空";++i;
    photobox_urls[i]="http://homepage.mac.com/naoki_k_e/pb/";photobox_names[i]="くりぞ";++i;
    photobox_urls[i]="http://www.m-sis.com/~bancho/";photobox_names[i]="bancho";++i;
    photobox_urls[i]="http://www.m-sis.com/~nail/pb/";photobox_names[i]="nail";++i;
    photobox_urls[i]="http://homepage.mac.com/ichirui/pb/";photobox_names[i]="トロの冷え牛";++i;
    photobox_urls[i]="http://homepage.mac.com/kow_1_k/pb/";photobox_names[i]="kitta";++i;
    photobox_urls[i]="http://dj-kaz.com/pb2/";photobox_names[i]="DJ-Kaz";++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://mlog.kuma-danna.com/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\"><a href=\""+dict["top"]+"\"><img src=\""+dict["image"]+"\" alt=\""+dict["name"]+" "+date(dict["date"])+"\" title=\""+dict["name"]+" "+date(dict["date"])+"\" width=\"120\" height=\"90\" /></a></p>\n<p class=\"information\">"+date(dict["date"])+"</p>\n</div>\n";
	}else{
		return "<div class=\"friends_item\">\n<p class=\"photo\"><a href=\""+dict["top"]+"\"><img src=\""+dict["image"]+"\" alt=\""+dict["name"]+" "+date(dict["date"])+"\" title=\""+dict["name"]+" "+date(dict["date"])+"\" width=\"120\" height=\"90\" /></a></p>\n<p class=\"information\">"+dict["name"]+"<br />\n"+date(dict["date"])+"</p>\n</div>";
	}
}
function buildFriendsArea(max)
{
	if(max==0){
		photobox_flag_all=false;
		photobox_max=6;
	}else{
		photobox_flag_all=true;
		photobox_max=max;
	}
    
    var emptyDict=new Array();
    emptyDict["top"]="javascript:void(0);";
    emptyDict["image"]="http://mlog.kuma-danna.com/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");
    }
}
