// get thumbnail size
var ThumbSizeChgDirNames = new Array();
ThumbSizeChgDirNames = ["small","thumb","medium"];

var currentThumbsSize = 0;

var currentThumbsSizeCookie = jQuery.cookie("currentThumbsSize");
if(currentThumbsSizeCookie==null){
	var currentThumbsSize = 0;
}else{
	var currentThumbsSize = Number(currentThumbsSizeCookie);
}

//===========================================
//	onload events
//===========================================

jQuery(document).ready(function(){
	setTimeout(function(){
		jQTooltipInit();
		TBOverflowSet();
		PicSelectorInit();
		UserSelectorInit();
		FrameSelectorInit();
		CategoryTreeSelectorInit();
		FileChooseWaySelectorInit();
		TransIconInit();
		DirChgNameEditInit();
		TextSearchInit();
		SearchTxtInit();
		IE6MinWidth();
		ChooseThumbsSizeInit();
		ChgThubmsSizeIfCookied();
		RevealPollBtnInit();
		SubCategoryChainSelectInit();
		GoUpInit();
		CameraMakerSelectInit();
		ItemLi02CheckHighlight();
		ItemLi02CheckAllInit();
		ImgSortFix();
		SetWinNameFotonomabase();
		TBLowShowInit();
		SafariFooterFix();
		SafariFooterFixInterval();
		changeBtmFrameDueToURLOfMainFrame();	//メインフレームのURLに応じて下フレームを切り替える
		windowTitleInit();
	},100);
});


//===========================================
//	set windowname as fotonomabase
//===========================================
function SafariFooterFix(){

			if(jQuery("body").height()<jQuery("div#BodyIWrap1").height()){
				jQuery("#BodyIWrap1").css("min-height","0");
				jQuery("#FotonomaFooter").css("position","static");
			}else{
				jQuery("#BodyIWrap1").css("min-height","100%");
				jQuery("#FotonomaFooter").css("position","absolute");
			}
}
function SafariFooterFixInterval(){
	// fix safari
	if(safari){
		setInterval(function(){
			if(jQuery("body").height()<jQuery("div#BodyIWrap1").height()){
				jQuery("#BodyIWrap1").css("min-height","0");
				jQuery("#FotonomaFooter").css("position","static");
			}else{
				jQuery("#BodyIWrap1").css("min-height","100%");
				jQuery("#FotonomaFooter").css("position","absolute");
			}
		},5000);
	}
}


//===========================================
//	set windowname as fotonomabase
//===========================================
function SetWinNameFotonomabase(){
	if(!document.getElementById("BodyIWrap1")) return;
	if(jQuery(top.document).find("frameset").length==0){
		window.name="fotonomabase";
		jQuery(focus());
	}else{
		top.window.name="fotonomabase";
		jQuery(jQuery(top.document).focus());
	}
}

//===========================================
//	image sort fix
//===========================================
function ImgSortFix(){
	if(document.getElementById("ImgSortIframe") && (ie6||ie7)){
		jQuery("#ImgSortIframe").attr("name","ImgSortIframe");
		frames['ImgSortIframe'].location.reload();
	}
}


//===========================================
//	ItemLi02 Check All Btns
//===========================================
var ItemLi02ItemAmount;
var ItemLi02IsItemCheckStats = new Array();

function ItemLi02CheckAllInit(){
	
	if(!document.getElementById("ThumbsSizeChgArea")) return;
	
	jQuery("input.ItemLi02CheckAll").click(function(){
		if(this.checked){
			ItemLi02CheckAll();
			jQuery("#ItemLi02CheckAllUpper").siblings("label").html("すべて解除する");
			jQuery("#ItemLi02CheckAllLower").siblings("label").html("すべて解除する");
		}else{
			ItemLi02ResetAll();
			jQuery("#ItemLi02CheckAllUpper").siblings("label").html("すべて選択する");
			jQuery("#ItemLi02CheckAllLower").siblings("label").html("すべて選択する");
		}
	});
}

//===========================================
//	ItemLi02 Check Highlight
//===========================================

function ItemLi02CheckHighlight(){
	
	if(!document.getElementById("ThumbsSizeChgArea")) return;
	
	/* init */
	
	ItemLi02ItemAmount = jQuery("#ThumbsSizeChgArea input").length;
	if(ItemLi02ItemAmount==0) return;
	
	/* set checked stats to array */
	
	for(i=0;i<ItemLi02ItemAmount;i++){
		var inputDOM = jQuery("#ThumbsSizeChgArea input").eq(i).get(0);
		
		/* get current stats */
		
		if(inputDOM.checked){
			ItemLi02IsItemCheckStats[i] = 1;
			jQuery("#ThumbsSizeChgArea .Item").eq(i).attr("class","Item Checked");
		}else{
			ItemLi02IsItemCheckStats[i] = 0;
			jQuery("#ThumbsSizeChgArea .Item").eq(i).attr("class","Item");
		}
	}
	
	/* if all checked or not - set all reset/check btn */
	
	if(IsItemLi02InputsCheckedAll()){
		jQuery("#ItemLi02CheckAllUpper").get(0).checked = true;
		jQuery("#ItemLi02CheckAllLower").get(0).checked = true;
		jQuery("#ItemLi02CheckAllUpper").siblings("label").html("すべて解除する");
		jQuery("#ItemLi02CheckAllLower").siblings("label").html("すべて解除する");
	}else{
		jQuery("#ItemLi02CheckAllUpper").get(0).checked = false;
		jQuery("#ItemLi02CheckAllLower").get(0).checked = false;
		jQuery("#ItemLi02CheckAllUpper").siblings("label").html("すべて選択する");
		jQuery("#ItemLi02CheckAllLower").siblings("label").html("すべて選択する");
	}
	
	/* set click action */
	
	jQuery("#ThumbsSizeChgArea input").click(function(){
		if(this.checked){
			ItemLi02IsItemCheckStats[ItemLi02SearchWhereIAm(this)] = 1;
			toggleItem02Status(this);
			if(IsItemLi02InputsCheckedAll()){
				ItemLi02CheckAll();
				jQuery("#ItemLi02CheckAllUpper").siblings("label").html("すべて解除する");
				jQuery("#ItemLi02CheckAllLower").siblings("label").html("すべて解除する");
			}
		}else{
			ItemLi02IsItemCheckStats[ItemLi02SearchWhereIAm(this)] = 0;
			toggleItem02Status(this);
			jQuery("#ItemLi02CheckAllUpper").get(0).checked = false;
			jQuery("#ItemLi02CheckAllLower").get(0).checked = false;
			if(!IsItemLi02InputsCheckedAll()){
				jQuery("#ItemLi02CheckAllUpper").siblings("label").html("すべて選択する");
				jQuery("#ItemLi02CheckAllLower").siblings("label").html("すべて選択する");
			}
		}
	})
}

/* get where I am */

function ItemLi02SearchWhereIAm(ele){
	var myNumber;
	for(i=0;i<ItemLi02ItemAmount;i++){
		if(ele==jQuery("#ThumbsSizeChgArea input").eq(i).get(0)){
			myNumber = i;
			break;
		}
	}
	return myNumber;
}

/* toggle .Item class name */

function toggleItem02Status(inputItem){
	var itemWrapDOM = jQuery(inputItem).parents("td.Item").eq(0);
	if(inputItem.checked){
		itemWrapDOM.attr("class","Item Checked");
	}else{
		itemWrapDOM.attr("class","Item");
	}
}

/* reset all */

function ItemLi02ResetAll(){
	for(i=0;i<ItemLi02ItemAmount;i++){
		jQuery("#ThumbsSizeChgArea input").eq(i).get(0).checked=false;
		ItemLi02IsItemCheckStats[i] = 0;
	}
	jQuery("#ThumbsSizeChgArea .Item").attr("class","Item");
	jQuery("#ItemLi02CheckAllUpper").get(0).checked = false;
	jQuery("#ItemLi02CheckAllLower").get(0).checked = false;
}

/* check all */

function ItemLi02CheckAll(){
	for(i=0;i<ItemLi02ItemAmount;i++){
		jQuery("#ThumbsSizeChgArea input").eq(i).get(0).checked=true;
		ItemLi02IsItemCheckStats[i] = 1;
	}
	jQuery("#ThumbsSizeChgArea .Item").each(function(){
		if(jQuery(this).children("div").length>0){
			jQuery(this).attr("class","Item Checked");
		}
	});
	jQuery("#ItemLi02CheckAllUpper").get(0).checked = true;
	jQuery("#ItemLi02CheckAllLower").get(0).checked = true;
}

/* check input items stats */

function IsItemLi02InputsCheckedAll(){
	var isCheckedAll = true;
	for(i=0;i<ItemLi02ItemAmount;i++){
		if(ItemLi02IsItemCheckStats[i]==0){
			isCheckedAll = false;
			break;
		}
	}
	return isCheckedAll;
}

//===========================================
//	Chain Category Select
//===========================================
function CameraMakerSelectInit(){
	jQuery("select.CameraMakerSelect").change(function(){
		if(jQuery(this).parents("tr").eq(0).find("input.CameraNameInput").eq(0).val()==""){
			jQuery(this).parents("tr").eq(0).find("input.CameraNameInput").eq(0).val("カメラ機種名");
		}
		jQuery(this).parents("tr").eq(0).find("input.CameraNameInput").eq(0).css("display","block");
		jQuery(this).parents("tr").eq(0).find("input.CameraNameInput").eq(0).get(0).focus();
		jQuery(this).parents("tr").eq(0).find("input.CameraNameInput").eq(0).get(0).select();
	});
}

//===========================================
//	Chain Category Select
//===========================================
var categoryList = new Array();
		
function SubCategoryChainSelectInit(){
	if(!document.getElementById("fSearchCategoryChain1")) return;
	if(!document.getElementById("fSearchCategoryChain2")) return;
	
		//	Category Search Setting
		//-----------------------------------------
		
		categoryList[0]="風景";
		categoryList[1]="動物・植物";
		categoryList[2]="食べ物";
		categoryList[3]="スポーツ";
		categoryList[4]="乗り物";
		categoryList[5]="国・地域";
		categoryList[6]="アート・デザイン";
		categoryList[7]="イベント";
		categoryList[8]="団体";
		categoryList[9]="人物";
		categoryList[10]="色";
		
		Create2ndCategoryArray();
		
		// Set 2nd Categories
		
		categoryList[0][0]="建築";
		categoryList[0][1]="山";
		categoryList[0][2]="高原";
		categoryList[0][3]="森林";
		categoryList[0][4]="花畑";
		categoryList[0][5]="田園";
		categoryList[0][6]="渓谷";
		categoryList[0][7]="海";
		categoryList[0][8]="湖";
		categoryList[0][9]="川";
		categoryList[0][10]="空";
		categoryList[0][11]="街・住宅";
		categoryList[0][12]="ビル・オフィス";
		categoryList[0][13]="神社・寺";
		categoryList[0][14]="日の出";
		categoryList[0][15]="太陽";
		categoryList[0][16]="月";
		categoryList[0][17]="星";
		
		categoryList[1][0]="犬";
		categoryList[1][1]="猫";
		categoryList[1][2]="鳥";
		categoryList[1][3]="昆虫";
		categoryList[1][4]="は虫類";
		categoryList[1][5]="魚";
		categoryList[1][6]="小動物";
		categoryList[1][7]="花";
		categoryList[1][8]="草";
		categoryList[1][9]="木";

		categoryList[2][0]="和食";
		categoryList[2][1]="中華";
		categoryList[2][2]="洋食";
		categoryList[2][3]="イタリアン";
		categoryList[2][4]="沖縄料理";
		categoryList[2][5]="パン";
		categoryList[2][6]="ビール";
		categoryList[2][7]="カクテル";
		categoryList[2][8]="焼酎";
		categoryList[2][9]="日本酒";
		categoryList[2][10]="コーヒー・紅茶";
		categoryList[2][11]="ジュース";
		categoryList[2][12]="バー";
		categoryList[2][13]="居酒屋";
		categoryList[2][14]="ワイン";
		categoryList[2][15]="韓国料理";
		categoryList[2][16]="アジア料理";

		categoryList[3][0]="野球";
		categoryList[3][1]="サッカー・フットサル";
		categoryList[3][2]="ゴルフ";
		categoryList[3][3]="サーフィン";
		categoryList[3][4]="テニス";
		categoryList[3][5]="バスケットボール";
		categoryList[3][6]="バレーボール";
		categoryList[3][7]="スキー・スノーボード";
		categoryList[3][8]="ダイビング";
		categoryList[3][9]="モータースポーツ";
		categoryList[3][10]="アウトドア";
		categoryList[3][11]="つり";
		categoryList[3][12]="登山";
		categoryList[3][13]="ウォータースポーツ";
		categoryList[3][14]="陸上";
		categoryList[3][15]="格闘技";
		categoryList[3][16]="バトミントン";
		categoryList[3][17]="卓球";
		categoryList[3][18]="乗馬";
		categoryList[3][19]="フィギュアスケート";
		categoryList[3][20]="オリンピック";
		categoryList[3][21]="ワールドカップ";

		categoryList[4][0]="車";
		categoryList[4][1]="バイク";
		categoryList[4][2]="鉄道";
		categoryList[4][3]="飛行機";
		categoryList[4][4]="船";
		categoryList[4][5]="自転車";

		categoryList[5][0]="日本";
		categoryList[5][1]="アジア";
		categoryList[5][2]="オセアニア";
		categoryList[5][3]="中近東";
		categoryList[5][4]="アフリカ";
		categoryList[5][5]="北米";
		categoryList[5][6]="中南米";
		categoryList[5][7]="ヨーロッパ";
		categoryList[5][8]="北極・南極";
		categoryList[5][9]="北海道";
		categoryList[5][10]="東北";
		categoryList[5][11]="関東";
		categoryList[5][12]="甲信越";
		categoryList[5][13]="中部";
		categoryList[5][14]="北陸";
		categoryList[5][15]="関西";
		categoryList[5][16]="中国";
		categoryList[5][17]="四国";
		categoryList[5][18]="九州";
		categoryList[5][19]="沖縄";
		categoryList[5][20]="太平洋";

		categoryList[6][0]="アート";
		categoryList[6][1]="デザイン";
		categoryList[6][2]="イラスト";
		categoryList[6][3]="CG";
		categoryList[6][4]="生け花";
		categoryList[6][5]="陶芸";
		categoryList[6][6]="模型";
		categoryList[6][7]="インテリア";
		categoryList[6][8]="ファッション";
		categoryList[6][9]="絵画";
		categoryList[6][10]="ガーデニング";
		categoryList[6][11]="フラワーアレンジメント";
		categoryList[6][12]="漫画・アニメ";

		categoryList[7][0]="祭り";
		categoryList[7][1]="正月";
		categoryList[7][2]="節分";
		categoryList[7][3]="海水浴";
		categoryList[7][4]="キャンプ";
		categoryList[7][5]="花火";
		categoryList[7][6]="クリスマス";
		categoryList[7][7]="結婚式";
		categoryList[7][8]="誕生日";
		categoryList[7][9]="発表会";
		categoryList[7][10]="ライブ";
		categoryList[7][11]="撮影会";
		categoryList[7][12]="ひな祭り";
		categoryList[7][13]="七夕";
		categoryList[7][14]="旅行";
		categoryList[7][15]="卒業";
		categoryList[7][16]="入園・入学・入社";
		categoryList[7][17]="バレンタイン";
		categoryList[7][18]="お花見";
		categoryList[7][19]="母の日";
		categoryList[7][20]="父の日";
		categoryList[7][21]="パーティ";
		categoryList[7][22]="歓送迎会";
		categoryList[7][23]="運動会";
		categoryList[7][24]="文化祭";
		categoryList[7][25]="遠足";
		categoryList[7][26]="修学旅行";
		categoryList[7][27]="音楽祭";
		categoryList[7][28]="バーベキュー";

		categoryList[8][0]="幼稚園";
		categoryList[8][1]="小学校";
		categoryList[8][2]="中学校";
		categoryList[8][3]="高校";
		categoryList[8][4]="専門学校";
		categoryList[8][5]="大学";
		categoryList[8][6]="クラブ";
		categoryList[8][7]="サークル";
		categoryList[8][8]="同窓会";
		categoryList[8][9]="学校行事";
		categoryList[8][10]="会社";

		categoryList[9][0]="赤ちゃん";
		categoryList[9][1]="子供";
		categoryList[9][2]="息子";
		categoryList[9][3]="娘";
		categoryList[9][4]="夫妻";
		categoryList[9][5]="孫";
		categoryList[9][6]="友人";
		categoryList[9][7]="恋人";
		categoryList[9][8]="兄弟・姉妹";
		categoryList[9][9]="祖父・祖母";
		categoryList[9][10]="親";
		categoryList[9][11]="自分";

		categoryList[10][0]="赤";
		categoryList[10][1]="オレンジ";
		categoryList[10][2]="黄";
		categoryList[10][3]="緑";
		categoryList[10][4]="青";
		categoryList[10][5]="紺";
		categoryList[10][6]="紫";
		categoryList[10][7]="茶";
		categoryList[10][8]="ピンク";
		categoryList[10][9]="白";
		categoryList[10][10]="黒";
		categoryList[10][11]="グレー";
		categoryList[10][12]="金（ゴールド）";
		categoryList[10][13]="銀（シルバー）";
	
	if(jQuery("#fSearchCategoryChain1").get(0).selectedIndex>0){
		Chg2ndCategory();
	}
	jQuery("#fSearchCategoryChain1").change(function(){
		if(jQuery("#fSearchCategoryChain1").get(0).selectedIndex>0){
			Chg2ndCategory();
		}else{
			Reset2ndCatOpts();
			Create2ndCat1stOpt2();
			jQuery("#fSearchCategoryChain2").get(0).disabled = true;
		}
	});
	jQuery("#fSearchCategoryChain2").change(function(){
		jQuery("#fTxtSearch").get(0).focus();
	});
}

function Chg2ndCategory(){
	
	Reset2ndCatOpts();
	Create2ndCat1stOpt1();
	
	var index = jQuery("#fSearchCategoryChain1").get(0).selectedIndex;
	if(index==0){
		jQuery("#fSearchCategoryChain2").get(0).disabled = true;
		Reset2ndCatOpts();
		Create2ndCat1stOpt2();
	}else{
		index--;
		jQuery("#fSearchCategoryChain2").get(0).disabled = false;
		var i;
		for(i=0;i<categoryList[index].length;i++){
			jQuery("#fSearchCategoryChain2").append("<option value='" + categoryList[index][i]+ "'>" + categoryList[index][i] + "<\/option>");
		}
		jQuery("#fSearchCategoryChain2").get(0).selectedIndex=0;
	}
	
	// Init 2nd category options
	jQuery("#fSearchCategoryChain2").focus();
	jQuery("#fSearchCategoryChain2").select();
}

// reset 2nd Category

	function Reset2ndCatOpts(){
		jQuery("#fSearchCategoryChain2 option").remove();
	}

// put 1st option

	function Create2ndCat1stOpt1(){
		jQuery("#fSearchCategoryChain2").append("<option value=''>サブカテゴリを選択</option>");
	}
	function Create2ndCat1stOpt2(){
		jQuery("#fSearchCategoryChain2").append("<option value=''>大カテゴリを選択してください</option>");
	}

// create 2nd category array

	function Create2ndCategoryArray(){
		for(i=0;i<categoryList.length;i++){
			categoryList[i] = new Array();
		}
	}


//===========================================
//	Reveal Poll Btns
//===========================================
function RevealPollBtnInit(){
	if(!document.getElementById("RevealPollBtns")) return;
	jQuery("#RevealPollBtns").click(function(event){
		if(jQuery("#PollBtns").css("display")=="none"){
			jQuery("#PollBtns").slideDown(350);
			setTimeout(function(){
				jQuery("#RevealPollBtns").slideUp(350);
			},200);
		}
		event.preventDefault();
		event.returnValue = false;
	});
}

//===========================================
//	change thumbs size if cookied
//===========================================

// change thumbs size if cookie was setted to M or L

function ChgThubmsSizeIfCookied(){
	if(document.getElementById("Gallery")){
		
		// if gallery
		
		if(currentThumbsSize==1){
			ChgThumbsSizeAndSort(4,1,"ThumbsSizeM");
		}else if(currentThumbsSize==2){
			ChgThumbsSizeAndSort(2,2,"ThumbsSizeL");
		}
		
	}else{
		
		// if not gallery
		
		if(currentThumbsSize==1){
			ChgThumbsSizeAndSort(3,1,"ThumbsSizeM");
		}else if(currentThumbsSize==2){
			ChgThumbsSizeAndSort(2,2,"ThumbsSizeL");
		}
	}
	jQuery("#ThumbsSizeChgArea").css("display","block");
}

//===========================================
//	Thumbs Size change
//===========================================

function ChooseThumbsSizeInit(){
		
	if(document.getElementById("Gallery")){
	
	// If gallery
	
		jQuery("#ThumbsSizeChgS").click(function(event){
			if(currentThumbsSize!=0){
				ChgThumbsSizeAndSort(6,0,"ThumbsSizeS");
				jQuery.cookie("currentThumbsSize", "0", {path:"/"});
				currentThumbsSize = 0;
			}
		});
		jQuery("#ThumbsSizeChgM").click(function(event){
			if(currentThumbsSize!=1){
				ChgThumbsSizeAndSort(4,1,"ThumbsSizeM");
				jQuery.cookie("currentThumbsSize", "1", {path:"/"});
				currentThumbsSize = 1;
			}
		});
		jQuery("#ThumbsSizeChgL").click(function(event){
			if(currentThumbsSize!=2){
				ChgThumbsSizeAndSort(2,2,"ThumbsSizeL");
				jQuery.cookie("currentThumbsSize", "2", {path:"/"});
				currentThumbsSize = 2;
			}
		});
		
	}else{
		
	// If not gallery
	
		jQuery("#ThumbsSizeChgS").click(function(event){
			if(currentThumbsSize!=0){
				ChgThumbsSizeAndSort(5,0,"ThumbsSizeS");
				jQuery.cookie("currentThumbsSize", "0", {path:"/"});
				currentThumbsSize = 0;
			}
		});
		jQuery("#ThumbsSizeChgM").click(function(event){
			if(currentThumbsSize!=1){
				ChgThumbsSizeAndSort(3,1,"ThumbsSizeM");
				jQuery.cookie("currentThumbsSize", "1", {path:"/"});
				currentThumbsSize = 1;
			}
		});
		jQuery("#ThumbsSizeChgL").click(function(event){
			if(currentThumbsSize!=2){
				ChgThumbsSizeAndSort(2,2,"ThumbsSizeL");
				jQuery.cookie("currentThumbsSize", "2", {path:"/"});
				currentThumbsSize = 2;
			}
		});
	}
	
}
function ChgThumbsSizeAndSort(size,newDirNum,newSize){
	
	var newRowNum = size;
	
	// get td infos
	
	var allTdElms = new Array();
	var howmanyItems = jQuery("#ThumbsSizeChgArea td.Item").length;
	for(i=0;i<howmanyItems;i++){
		allTdElms.push(jQuery("#ThumbsSizeChgArea td.Item").eq(i));
	}
	jQuery("#ThumbsSizeChgArea td.Item").remove();
	jQuery("#ThumbsSizeChgArea tr").remove();
	
	// reset new tds
	
	var i;
	var CurrentTrNo = 1;
	jQuery("#ThumbsSizeChgArea > tbody").append("<tr id='ThumbsChgTr1'><\/tr>");
	for(i=0;i<howmanyItems;i++){
		if((i+1)%newRowNum==1){
			CurrentTrNo++;
			jQuery("#ThumbsSizeChgArea > tbody").append("<tr id='ThumbsChgTr" + CurrentTrNo + "'><\/tr>");
		}
		jQuery("#ThumbsChgTr" + CurrentTrNo).append(allTdElms[i]);
	}
	
		// set rest td as empty
		
		var restOfTdsAmount = newRowNum - (howmanyItems%newRowNum);
		if(restOfTdsAmount!=newRowNum){
			for(i=0;i<restOfTdsAmount;i++){
				jQuery("#ThumbsChgTr" + CurrentTrNo).append("<td class='Item'>&nbsp;</td>");
			}
		}
		
		// remove tds which has only empty
		var sortedTrAmount = jQuery("#ThumbsSizeChgArea > tbody > tr").length;
		var currentTr;
		var currentTrImgs;
		for(i=0;i<sortedTrAmount;i++){
			currentTr = jQuery("#ThumbsSizeChgArea > tbody > tr").eq(i);
			currentTrImgs = currentTr.find("div.Img img").length;
			if(currentTrImgs==0){
				currentTr.remove();
			}
		}
		
	// chg Thumbs detection class
	
	jQuery("#ThumbsSizeChgArea").removeClass("ThumbsSizeS");
	jQuery("#ThumbsSizeChgArea").removeClass("ThumbsSizeM");
	jQuery("#ThumbsSizeChgArea").removeClass("ThumbsSizeL");
	jQuery("#ThumbsSizeChgArea").addClass(newSize);
	
	// chg img path
	
	var newImgAmount = jQuery("#ThumbsSizeChgArea div.Img").length;
	var i,j;
	var src;
	var currentImgDom;
	var tempDirName;
	for(i=0;i<newImgAmount;i++){
		currentImgDom = jQuery("#ThumbsSizeChgArea div.Img img").eq(i);
		src = currentImgDom.attr("src");
		for(j=0;j<ThumbSizeChgDirNames.length;j++){
			tempDirName = ThumbSizeChgDirNames[j];
			src = src.replace(tempDirName,"TEMPDIRNAME");
		}
		src = src.replace(/TEMPDIRNAME/,ThumbSizeChgDirNames[newDirNum]);
		currentImgDom.attr("src",src);

	}
		
	// chg btn img
	if(newSize=="ThumbsSizeS"){
		jQuery("#ThumbsSizeChgS img").attr("src","/image/fotonoma/btns/active/thumbsize_s.gif");
		jQuery("#ThumbsSizeChgM img").attr("src","/image/fotonoma/btns/thumbsize_m.gif");
		jQuery("#ThumbsSizeChgL img").attr("src","/image/fotonoma/btns/thumbsize_l.gif");
	}
	if(newSize=="ThumbsSizeM"){
		jQuery("#ThumbsSizeChgS img").attr("src","/image/fotonoma/btns/thumbsize_s.gif");
		jQuery("#ThumbsSizeChgM img").attr("src","/image/fotonoma/btns/active/thumbsize_m.gif");
		jQuery("#ThumbsSizeChgL img").attr("src","/image/fotonoma/btns/thumbsize_l.gif");
	}
	if(newSize=="ThumbsSizeL"){
		jQuery("#ThumbsSizeChgS img").attr("src","/image/fotonoma/btns/thumbsize_s.gif");
		jQuery("#ThumbsSizeChgM img").attr("src","/image/fotonoma/btns/thumbsize_m.gif");
		jQuery("#ThumbsSizeChgL img").attr("src","/image/fotonoma/btns/active/thumbsize_l.gif");
	}

// body size will be changed and safari cant move footer correctly
SafariFooterFix();
	

}


//===========================================
//	IE6 Min Width
//===========================================
function IE6MinWidth(){
	if(!ie6&&!ie55) return;
	if(!document.getElementById("BodyIWrap1")) return;
	jQuery("div#BodyIWrap1").wrap("<table style='width:100%;height:100%'><tr><td id='IEMinWidthFix' style='width:100%;height:100%'><\/td><\/tr><\/table>");
	jQuery("td#IEMinWidthFix").prepend("<div style='height:1px;width:886px;overflow:hidden;margin:0 0 -1px'>&nbsp;<\/div>");
}

//===========================================
//	TextSearch Init
//===========================================
function TextSearchInit(){
	jQuery("input.TextSeachInput").click(function(){
		var Str = jQuery(this).attr("value");
		if(Str=="テキスト検索"){
			jQuery(this).attr("value","");
		}
	});
	jQuery("input.TextSeachInput").focus(function(){
		var Str = jQuery(this).attr("value");
		if(Str=="テキスト検索"){
			jQuery(this).attr("value","");
		}
	});
	jQuery("input.TextSeachInput").blur(function(){
		var Str = jQuery(this).attr("value");
		if(Str=="" || Str==undefined){
			jQuery(this).attr("value","テキスト検索");
		}
	});
}

function SearchTxtInit(){
    jQuery("input.SearchTxt").click(function(){
        var Str = jQuery(this).attr("value");
        if(Str=="ニックネーム検索"){
            jQuery(this).attr("value","");
        }
    });
    jQuery("input.SearchTxt").focus(function(){
        var Str = jQuery(this).attr("value");
        if(Str=="ニックネーム検索"){
            jQuery(this).attr("value","");
        }
    });
    jQuery("input.SearchTxt").blur(function(){
        var Str = jQuery(this).attr("value");
        if(Str=="" || Str==undefined){
            jQuery(this).attr("value","ニックネーム検索");
        }
    });
}

//===========================================
//	Dir Change Name
//===========================================
function DirChgNameEditInit(){
	if(!document.getElementById("DirNameChangeModule")) return;
	jQuery("div#DirNameChangeModule .Item .Action1 input").click(function(){
		if(jQuery(this).parents(".Item").eq(0).find(".Name input").css("display")=="none"){
			var currentName = jQuery(this).parents(".Item").eq(0).find(".Name p").html();
			jQuery(this).parents(".Item").eq(0).find(".Name p").css("display","none");
			jQuery(this).parents(".Item").eq(0).find(".Name input").css("display","inline");
			jQuery(this).parents(".Item").eq(0).find(".Name input").attr("value",currentName);
			jQuery(this).parents(".Item").eq(0).find(".Name input").get(0).focus();
			jQuery(this).parents(".Item").eq(0).find(".Name input").get(0).select();
			jQuery(this).attr("value","決定");
			return false;
		}
	});
}

//===========================================
//	GoUp
//===========================================
function GoUpInit(){
	if (!ie5 && !ie4 && !nn4){
		jQuery("a.smooth").click(function(){
			if(document.getElementById("TBInIfBody") && (ff1||ff2)){
			}else{
				anchorPoint = this.getAttribute('href',2);
				jQuery(anchorPoint).ScrollTo(400, 'easeout');
				return false;
			}
		});
	}
}

//===========================================
//	set overflow and close btn if TBPop
//===========================================

function TBOverflowSet(){
if(safari){

	var TBOverflowDOM;
	if(
		TBOverflowDOM = document.getElementById("TB-OverflowArea") 
			|| document.getElementById("ImgSortIframe")
			|| document.getElementById("IfInTB")
	){
		var CurrentWinHeight = jQuery(parent.document).find("#TB_iframeContent").height();
		jQuery(TBOverflowDOM).height(CurrentWinHeight-59);
	}
	var ParentHeight = jQuery("#TB-OverflowArea").height();
	var ContentsHeight = jQuery("#TB-OverflowAreaContents").height();

}else{

	if(document.getElementById("TBPop01")){
		var SetHeightTimer = setTimeout(function(){
			var TBOverflowDOM;
			if(
				TBOverflowDOM = document.getElementById("TB-OverflowArea") 
					|| document.getElementById("ImgSortIframe")
					|| document.getElementById("IfInTB")
			){
				var CurrentWinHeight = jQuery(parent.document).find("#TB_iframeContent").height();
				jQuery(TBOverflowDOM).height(CurrentWinHeight-59);
			}
			var ParentHeight = jQuery("#TB-OverflowArea").height();
			var ContentsHeight = jQuery("#TB-OverflowAreaContents").height();
			
		},10);
	}


}

}

//===========================================
//	tooltip setting
//===========================================

function jQTooltipInit() {
	if(nn7) return;
	if(ie6){
		jQuery(".TipA").Tooltip({
			delay: 0,
			event: "mouseover",
			showURL: false,
			extraClass: "tooltipA"
		});
		jQuery(".TipB").Tooltip({
			delay: 0,
			event: "mouseover",
			showURL: false,
			extraClass: "tooltipB"
			
		});
	}else{
		jQuery(".TipA").Tooltip({
			track: true,
			delay: 0,
			event: "mouseover",
			showURL: false,
			extraClass: "tooltipA"
			
		});
		jQuery(".TipB").Tooltip({
			track: true,
			delay: 0,
			event: "mouseover",
			showURL: false,
			extraClass: "tooltipA"
			
		});
	}
}


//===========================================
//	FileChooseWaySelector
//===========================================
function FileChooseWaySelectorInit(){
	
	if(!document.getElementById("FileChooseWaySelector") && !document.getElementById("FileChooseWaySelector2")) return;
	
	/* set choose way info */
	
	jQuery("a#SrcMyTrank").click(function(){
		jQuery(".NowSheet").css("visibility", "visible");
		jQuery("#WhichSrcYouChose").attr("value","MyTrank");
	});
	jQuery("a#SrcLocalAtOnce").click(function(){	
		jQuery(".NowSheet").css("visibility", "hidden");
		
		// if no at once upload
		if(document.getElementById("NoAtOnceUpload")){
			
			jQuery("#OneByOne").css("display","block");
			jQuery("#WhichSrcYouChose").attr("value","LocalInputFile");
			
		// if at once upload available
		}else{
			
			jQuery("#WhichSrcYouChose").attr("value","LocalAtOnce");
			var linkStr = jQuery("#AtOnceOrOneByOneChoose li a").eq(0).html();
			if(linkStr == "一括アップロード"){
				jQuery("#AtOnceOrOneByOneChoose li a").eq(0).html("一括アップロードがご利用いただけない方");
				jQuery("#AtOnce").css("display","block");
				jQuery("#OneByOne").css("display","none");
				jQuery("#WhichSrcYouChose").attr("value","LocalAtOnce");
			}
			
		}
		
	});
	
	/* change contents visibility */
	
	jQuery(".TabAreaSet").each(function(){
		var TabAreaAmount = jQuery(this).find(".TabAreaChgMenu").children("li").length;
		var ActiveTabNo;
		
		/* get active tab number */
		
		for(i=0;i<TabAreaAmount;i++){
			if(jQuery(this).find(".TabAreaChgMenu li").eq(i).attr("class") == "On"){
				ActiveTabNo = i;
			}
		}
		
		/* hide non-active tab contents */
		
		for(i=0;i<TabAreaAmount;i++){
			if(i!=ActiveTabNo){
				jQuery(this).find(".TabAreaContents").eq(i).hide();
			}
		}
		
		/* bind click action */
		
		jQuery(this).find(".TabAreaChgMenu li a").click(function(){
			jQuery(this).parents("li").eq(0).addClass("Clicked");
			var ClickedTabNo;
			for(i=0;i<TabAreaAmount;i++){
				if(
					jQuery(this).parents(".TabAreaSet").eq(0).find(".TabAreaChgMenu li").eq(i).attr("class")!=null
					&& jQuery(this).parents(".TabAreaSet").eq(0).find(".TabAreaChgMenu li").eq(i).attr("class").indexOf("Clicked")!=-1
				){
					ClickedTabNo = i;
					jQuery(this).parents("li").eq(0).removeClass("Clicked");
					jQuery(this).parents("li").eq(0).addClass("On");
				}else if(jQuery(this).parents(".TabAreaSet").eq(0).find(".TabAreaChgMenu li").eq(i).attr("class")!=null){
					jQuery(this).parents(".TabAreaSet").eq(0).find(".TabAreaChgMenu li").eq(i).removeClass("On");
				}
			}
			for(i=0;i<TabAreaAmount;i++){
				if(i!=ClickedTabNo){
					jQuery(this).parents(".TabAreaSet").eq(0).find(".TabAreaChgContents").eq(0).find(".TabAreaContents").eq(i).hide();
				}
			}
			jQuery(this).parents(".TabAreaSet").eq(0).find(".TabAreaChgContents").eq(0).find(".TabAreaContents").eq(ClickedTabNo).show();
			
			/* change img src */
			
			for(i=0;i<TabAreaAmount;i++){
				var navImgEle = jQuery(this).parents(".TabAreaChgMenu").eq(0).find("li").eq(i).find("img").eq(0);
				var imgSrc = navImgEle.attr("src");
				if(imgSrc == null || imgSrc == "") continue;
				if(i!=ClickedTabNo){
					if(imgSrc.indexOf("active")!=-1){
						imgSrc = imgSrc.replace(/parts_selectsrc01\/active/,"parts_selectsrc01");
						navImgEle.attr("src",imgSrc);
					}
				}else{
					if(imgSrc.indexOf("active")==-1){
						imgSrc = imgSrc.replace(/parts_selectsrc01/,"parts_selectsrc01\/active");
						navImgEle.attr("src",imgSrc);
					}
				}
			}
		});
	});
	
	/* about upload module */
	
	jQuery("#AtOnceOrOneByOneChoose li").click(function(){
		var linkStr = jQuery(this).find("a").eq(0).html();
		if(linkStr == "一括アップロードがご利用いただけない方"){
			jQuery(this).find("a").eq(0).html("一括アップロード");
			jQuery("#AtOnce").css("display","none");
			jQuery("#OneByOne").css("display","block");
			jQuery("#WhichSrcYouChose").attr("value","LocalInputFile");
		}else{
			jQuery(this).find("a").eq(0).html("一括アップロードがご利用いただけない方");
			jQuery("#AtOnce").css("display","block");
			jQuery("#OneByOne").css("display","none");
			jQuery("#WhichSrcYouChose").attr("value","LocalAtOnce");
		}
	});
}


//===========================================
//	picture selector
//===========================================
function PicSelectorInit(){
	if(document.getElementById("PicSelector")){
		jQuery("#PicSelector .Item span").bind("click",function(){
			var inputDOM = jQuery(this).parent(".Item").find("input").eq(0).get(0);
			var inputDOMType = jQuery(inputDOM).attr("type");
			if(inputDOMType=="checkbox"){
				if(inputDOM.checked){
					inputDOM.checked = false;
					PicSelectorHilightOff(jQuery(this).parent(".Item"));
					calcSelectedPhotoCount(-1);
				}else{
					inputDOM.checked = true;
					PicSelectorHilightOn(jQuery(this).parent(".Item"));
					calcSelectedPhotoCount(1);
				}
			}else if(inputDOMType=="radio"){
				if(inputDOM.checked){
					inputDOM.checked = false;
				}else{
					inputDOM.checked = true;
				}
				PicSelectorStatusSet();
			}
		});
	}
}

function PicSelectorStatusSet(){
	jQuery("#PicSelector .Item input").each(function(){
		var jQuerythisImgEle = jQuery(this).parent(".Item").eq(0);
		if(jQuery(this).get(0).checked){
			PicSelectorHilightOn(jQuerythisImgEle);
		}else{
			PicSelectorHilightOff(jQuerythisImgEle);
		}
	});
}

function PicSelectorHilightOff(jQueryele){
	jQueryele.attr("class","Item");
}
function PicSelectorHilightOn(jQueryele){
	jQueryele.attr("class","Item Selected");
}

function calcSelectedPhotoCount(incr){
	var cnt = parseInt(jQuery("#SelectedPhotoCount").html());
	cnt = cnt + parseInt(incr);
	if(cnt <= 0) cnt = "0";
	jQuery("#SelectedPhotoCount").html(cnt);
}

//===========================================
//	user selector
//===========================================

function UserSelectorInit(){
	if(document.getElementById("UserSelector")){
		
		/* first check */
		
		jQuery("#UserSelector .Item input[@type=checkbox]").each(function(){
			var itemEle = jQuery(this).parents(".Item").eq(0);
			if(jQuery(this).get(0).checked){
				UserSelectorHilightOn(itemEle);
			}else{
				UserSelectorHilightOff(itemEle);
			}
		});
		
		/* bind click action */
		
		jQuery("#UserSelector .Item input[@type=checkbox]").bind("click",function(){
			if(this.checked){
				this.checked = false;
			}else{
				this.checked = true;
			}
		});
		
		jQuery("#UserSelector .Item").bind("click",function(){
			var inputDOM = jQuery(this).find("input[@type=checkbox]").eq(0).get(0);
			if(inputDOM.checked){
				inputDOM.checked = false;
				UserSelectorHilightOff(jQuery(this));
			}else{
				inputDOM.checked = true;
				UserSelectorHilightOn(jQuery(this));
			}
		});
	}
}

function UserSelectorStatusSet(){
	jQuery("#UserSelector .Item input").each(function(){
		var jQuerythisImgEle = jQuery(this).parent(".Item").eq(0);
		if(jQuery(this).get(0).checked){
			UserSelectorHilightOn(jQuerythisImgEle);
		}else{
			UserSelectorHilightOff(jQuerythisImgEle);
		}
	});
}

function UserSelectorHilightOff(jQueryele){
	jQueryele.attr("class","Item");
}
function UserSelectorHilightOn(jQueryele){
	jQueryele.attr("class","Item Selected");
}


//===========================================
//	frame selector
//===========================================

function FrameSelectorInit(){
	if(!document.getElementById("FrameSelector")) return;
		
	/* first check */
	
	jQuery("#FrameSelector .Item input[@type=radio]").each(function(){
		var itemEle = jQuery(this).parents(".Item").eq(0);
		if(jQuery(this).get(0).checked){
			FrameSelectorHilightOn(itemEle);
		}else{
			FrameSelectorHilightOff(itemEle);
		}
	});
	
	/* bind click action */
	
	jQuery("#FrameSelector .Item img").bind("click",function(){
		var inputDOM = jQuery(this).siblings("input[@type=radio]").eq(0).get(0);
		if(inputDOM.checked){
			inputDOM.checked = false;
			FrameSelectorHilightOff(jQuery(this));
		}else{
			inputDOM.checked = true;
			FrameSelectorHilightOn(jQuery(this));
		}
		FrameSelectorStatusSet();
	});
}

function FrameSelectorStatusSet(){
	jQuery("#FrameSelector .Item input").each(function(){
		var jQuerythisImgEle = jQuery(this).siblings("img").eq(0);
		if(jQuery(this).get(0).checked){
			FrameSelectorHilightOn(jQuerythisImgEle);
		}else{
			FrameSelectorHilightOff(jQuerythisImgEle);
		}
	});
}

function FrameSelectorHilightOff(jQueryele){
	jQueryele.parents("div.Item").eq(0).attr("class","Item");
}
function FrameSelectorHilightOn(jQueryele){
	jQueryele.parents("div.Item").eq(0).attr("class","Item Selected");
}


//===========================================
//	category tree selector
//===========================================

function CategoryTreeSelectorInit(){
	if(!document.getElementById("CategoryTreeSelector")) return;
		
	/* first check */
	
	// show if any checked
	jQuery("#CategoryTreeSelector input[@type=checkbox]").each(function(){
		if(jQuery(this).get(0).checked){
			jQuery(this).parents("li").eq(1).attr("class","Opened");
			jQuery(this).parents("li").eq(1).show();
		}
	});
	
	/* bind click action */
	
	jQuery("#CategoryTreeSelector a").bind("click",function(){
		if(jQuery(this).parent().attr("class") == "Closed"){
			jQuery(this).parent().attr("class","Opened");
			jQuery(this).siblings("ul").slideDown(200);
		}else{
			jQuery(this).parent().attr("class","Closed");
			jQuery(this).siblings("ul").slideUp(200);
		}
		return false;
	});
	
	return false;
}

function CategoryTreeSelectorStatusSet(){
	jQuery("#CategoryTreeSelector .Item input").each(function(){
		var jQuerythisImgEle = jQuery(this).parent(".Item").eq(0);
		if(jQuery(this).get(0).checked){
			CategoryTreeSelectorHilightOn(jQuerythisImgEle);
		}else{
			CategoryTreeSelectorHilightOff(jQuerythisImgEle);
		}
	});
}

function CategoryTreeSelectorHilightOff(jQueryele){
	jQueryele.attr("class","Item");
}
function CategoryTreeSelectorHilightOn(jQueryele){
	jQueryele.attr("class","Item Selected");
}


//===========================================
//	TransIcon click fix IE6 Fix
//===========================================

function TransIconInit(){
	if(ie6||ie55){
		jQuery("span.TransIcon").each(function(){
			var src = jQuery(this).find("img").attr("src");
			jQuery(this).find("span").eq(0).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + src + ", sizingMethod='image')");
			jQuery(this).find("img").css("visibility","hidden");
			if(jQuery(this).find("a").length>0){
				jQuery(this).find("span").eq(0).css("cursor","pointer");
			}
		});
		jQuery(".NLImg01B table td.Prv span a").click(function(){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		});
		jQuery(".NLImg01B table td.Nxt span a").click(function(){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		});
		jQuery(".NLImg01B table td.Prv span").click(function(){
			var URL = jQuery(this).find("a").attr("href");
			location.href(URL);
		});
		jQuery(".NLImg01B table td.Nxt span").click(function(){
			var URL = jQuery(this).find("a").attr("href");
			location.href(URL);
		});
		jQuery(".UserInfoNav01A .Menu1 td a").click(function(){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		});
		jQuery(".UserInfoNav01A .Menu1 td span span").click(function(){
			var IsThick = jQuery(this).find("a").eq(0).attr("class");
			if(IsThick!=null && IsThick.indexOf("ThickBoxB")!=-1){
				var URL = jQuery(this).find("a").attr("href");
				if(!IsWhileMoving){
					if(CheckParentFrameExist()){
						HideFrame();
					}
					TB_show("","","",717,"","",80,URL,true);
				}else{
					event.preventDefault();
					return false;
				}
			}else{
				var URL = jQuery(this).find("a").attr("href");
				location.href(URL);
			}
		});
	}
}


//===========================================
//	TB Low toggle
//===========================================

function TBLowShowInit(){
	jQuery("#TBLawNoteShow").click(function(){
		jQuery("#TBLawNoteToggleTxt").slideUp(300);
		jQuery("#TBLawNoteMain").slideDown(400);
	});
}

//===========================================
//	change bottom frame due to URL of main frame
//===========================================

function changeBtmFrameDueToURLOfMainFrame(){
	if(top == self) return;
	
	if(top.FrameMain != self) return;
	
	var str = "";
	var ref = document.referrer.split("/");
	for(i = 0; i < (ref.length - 1); i++){
		if(i > 0) str = str + "/";
		str = str + ref[i];
	}
	
	var reg = new RegExp(str); 
	if(!document.location.href.match(reg)){
		if(window.name == "FrameMain" && window.top.FrameMain.document.location.toString().match(/MyTrunk/) != null){
			var order_print_url = "/sec/WorkOrderPrintList.blog";
			if(window.top.FrameBtm.document.location.toString().match(/WorkOrderPrintList/) == null) window.top.FrameBtm.document.location = order_print_url;
		}else{
			var trunk_copy_url = "/sec/WorkTrunkCopyList.blog";
			if(window.top.FrameBtm.document.location.toString().match(/WorkTrunkCopyList/) == null) window.top.FrameBtm.document.location = trunk_copy_url;
		}
	}

}

function windowTitleInit(){
	if(self == top.FrameMain){
		top.document.title = self.document.title;
	}
}
