function MM_preloadImages() 
{ 
	//v3.0
 	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() 
{ 
	//v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) 
{ 
	//v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ 
	//v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}





function ShowSearchFrame(idx1, idx2){
		CleanHover();
		document.getElementById("SearchFrame_ID").style.display = 'none';
		document.getElementById("SearchFrame_Friend").style.display = 'none';
		document.getElementById("SearchFrame_Photo").style.display = 'none';
		document.getElementById("SearchFrame_Diary").style.display = 'none';
		document.getElementById("SearchFrame_Club").style.display = 'none';
	
		document.getElementById(idx1).style.display = 'block';
		document.getElementById(idx2).style.display = 'none';
		
		document.getElementById(idx1 + "_A").style.backgroundImage = "url('http://www.i-part.com.tw/images2/index/search_page_on.gif')";
		document.getElementById(idx1 + "_A").style.fontWeight = "bold";
		document.getElementById(idx1 + "_A").style.color = "#FFF";
}

function CleanHover(){
		document.getElementById("SearchFrame_ID" + "_A").style.backgroundImage = "url('http://www.i-part.com.tw/images2/index/search_page.gif')";
		document.getElementById("SearchFrame_ID" + "_A").style.fontWeight = "normal";
		document.getElementById("SearchFrame_ID" + "_A").style.color = "#775022";

		document.getElementById("SearchFrame_Friend" + "_A").style.backgroundImage = "url('http://www.i-part.com.tw/images2/index/search_page.gif')";
		document.getElementById("SearchFrame_Friend" + "_A").style.fontWeight = "normal";
		document.getElementById("SearchFrame_Friend" + "_A").style.color = "#775022";

		document.getElementById("SearchFrame_Photo" + "_A").style.backgroundImage = "url('http://www.i-part.com.tw/images2/index/search_page.gif')";
		document.getElementById("SearchFrame_Photo" + "_A").style.fontWeight = "normal";
		document.getElementById("SearchFrame_Photo" + "_A").style.color = "#775022";

		document.getElementById("SearchFrame_Diary" + "_A").style.backgroundImage = "url('http://www.i-part.com.tw/images2/index/search_page.gif')";
		document.getElementById("SearchFrame_Diary" + "_A").style.fontWeight = "normal";
		document.getElementById("SearchFrame_Diary" + "_A").style.color = "#775022";

		document.getElementById("SearchFrame_Club" + "_A").style.backgroundImage = "url('http://www.i-part.com.tw/images2/index/search_page.gif')";
		document.getElementById("SearchFrame_Club" + "_A").style.fontWeight = "normal";
		document.getElementById("SearchFrame_Club" + "_A").style.color = "#775022";
}

function HideAllShowAd(){
		CleanHover();	
		document.getElementById("SearchFrame_ID_A").style.color = "#775022";	
		document.getElementById("SearchFrame_ID").style.display = 'none';
		document.getElementById("SearchFrame_Friend").style.display = 'none';
		document.getElementById("SearchFrame_Photo").style.display = 'none';
		document.getElementById("SearchFrame_Diary").style.display = 'none';
		document.getElementById("SearchFrame_Club").style.display = 'none';	
		document.getElementById("AdBanner_Gold").style.display = 'block';
}

function HideSearchFrameDiv(idx1, idx2){
		if(typeof(event) != "undefined"){
		    var obj = event.toElement;
		    while( obj!=null && obj.id!=idx1 ){
		        obj = obj.parentElement;
		    }
		    if( obj==null ){ 
		    		document.getElementById(idx1).style.display = 'none';
		    		document.getElementById(idx2).style.display = '';
		    }    
   } 
}

var VIPZone_index = 1;
var C_VIPZone_index = 1;

function fn_C_IMG_C_VIPZone_Border(v, a){
		for( i = 1; i <= 4; i++){
				if(i == a){
						C_VIPZone_index = a;
						x = document.getElementById("IMG_C_VIPZone"+v+"_" + i);
						document.getElementById("SPN_C_VIPZone"+v+"_" + i).style.display = "";
						x.style.borderTop = '3px solid #FBB2CF';
						x.style.borderBottom = '3px solid #FBB2CF';
						x.style.borderLeft = '3px solid #FBB2CF';
						x.style.borderRight = '3px solid #FBB2CF';
						
						x.style.filter = "alpha(opacity=100)";
						x.style.opacity = "1";
						
				}else{
						x = document.getElementById("IMG_C_VIPZone"+v+"_" + i);
						document.getElementById("SPN_C_VIPZone"+v+"_" + i).style.display = "none";
						x.style.borderTop = '0px solid #FBB2CF';
						x.style.borderBottom = '0px solid #FBB2CF';
						x.style.borderLeft = '0px solid #FBB2CF';
						x.style.borderRight = '0px solid #FBB2CF';

						x.style.filter = "alpha(opacity=70)";
						x.style.opacity = "0.7";
				}			
		}
}

function ShowVIPZone(v){
	for(j=1; j<= 3;j++){
		if(document.all){
				if(j == v){
						VIPZone_index = v;
						document.getElementById("TB_C_VIPZone_" + j).style.display = "";
						document.getElementById("A_C_VIPZone_" + j).style.filter = "alpha(opacity=100)";
						document.getElementById("A_C_VIPZone_" + j).style.opacity = "0.7";
						document.getElementById("A_C_VIPZone_" + j).style.color = "#000";
						fn_C_IMG_C_VIPZone_Border(j,1);
				}else{
						document.getElementById("TB_C_VIPZone_" + j).style.display = "none";
						document.getElementById("A_C_VIPZone_" + j).style.filter = "alpha(opacity=70)";
						document.getElementById("A_C_VIPZone_" + j).style.opacity = "1";
						document.getElementById("A_C_VIPZone_" + j).style.color = "#444";
				}
		}else{
				if(j == v){
						VIPZone_index = v;
						document.getElementById("TB_C_VIPZone_" + j).style.display = "";
						document.getElementById("A_C_VIPZone_" + j).style.filter = "alpha(opacity=100)";
						document.getElementById("A_C_VIPZone_" + j).style.opacity = "1";
						document.getElementById("A_C_VIPZone_" + j).style.color = "#000";
						fn_C_IMG_C_VIPZone_Border(j,1);
				}else{
						document.getElementById("TB_C_VIPZone_" + j).style.display = "none";
						document.getElementById("A_C_VIPZone_" + j).style.filter = "alpha(opacity=100)";
						document.getElementById("A_C_VIPZone_" + j).style.opacity = "0.7";
						document.getElementById("A_C_VIPZone_" + j).style.color = "#444";
				}
		}
	}
}

function fnNowVIPZone(x){
		if(x == "Out"){
				ShowVIPZone(VIPZone_index);
		}else{
				if(document.all){
						x.style.filter = "alpha(opacity=100)";
						x.style.opacity = "0.7";
				}else{
						x.style.filter = "alpha(opacity=70)";
						x.style.opacity = "1";
				}
				x.style.color = "#000";
		}
}

function fnC_NowVIPZone(x){
		if(x == "Out"){
				fn_C_IMG_C_VIPZone_Border(VIPZone_index, C_VIPZone_index);
		}else{
				x.style.borderTop = '3px solid #FBB2CF';
				x.style.borderBottom = '3px solid #FBB2CF';
				x.style.borderLeft = '3px solid #FBB2CF';
				x.style.borderRight = '3px solid #FBB2CF';				
				x.style.filter = "alpha(opacity=100)";
				x.style.opacity = "1";
		}
}


function fnAddFav(title, url){
 var url="http://www.i-part.com.tw";
 var title="愛情公寓";
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}

function fnSetIpartHome(){
	var name = navigator.appName;
	var useragent = navigator.userAgent;
	var version = parseInt(navigator.appVersion);
	if (useragent.indexOf("MSIE") != -1) {
			document.body.style.behavior = "url(#default#homepage)";
			document.body.setHomePage('http://www.i-part.com.tw/');
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0 Add by Sean
  window.open(theURL,winName,features);
}















var ThemeZone_index = 1;
var C_ThemeZone_index = 1;


function ShowThemeZone(v){
	for(j=1; j<= 3;j++){
		if(document.all){
				if(j == v){
						ThemeZone_index = v;
						document.getElementById("TB_C_ThemeZone_" + j).style.display = "";
						document.getElementById("A_C_ThemeZone_" + j).style.filter = "alpha(opacity=100)";
						document.getElementById("A_C_ThemeZone_" + j).style.opacity = "0.7";
						document.getElementById("A_C_ThemeZone_" + j).style.color = "#000";
				}else{
						document.getElementById("TB_C_ThemeZone_" + j).style.display = "none";
						document.getElementById("A_C_ThemeZone_" + j).style.filter = "alpha(opacity=70)";
						document.getElementById("A_C_ThemeZone_" + j).style.opacity = "1";
						document.getElementById("A_C_ThemeZone_" + j).style.color = "#444";
				}
		}else{
				if(j == v){
						ThemeZone_index = v;
						document.getElementById("TB_C_ThemeZone_" + j).style.display = "";
						document.getElementById("A_C_ThemeZone_" + j).style.filter = "alpha(opacity=100)";
						document.getElementById("A_C_ThemeZone_" + j).style.opacity = "1";
						document.getElementById("A_C_ThemeZone_" + j).style.color = "#000";
				}else{
						document.getElementById("TB_C_ThemeZone_" + j).style.display = "none";
						document.getElementById("A_C_ThemeZone_" + j).style.filter = "alpha(opacity=100)";
						document.getElementById("A_C_ThemeZone_" + j).style.opacity = "0.7";
						document.getElementById("A_C_ThemeZone_" + j).style.color = "#444";
				}
		}
	}
}



function fnNowThemeZone(x){
		if(x == "Out"){
				ShowThemeZone(ThemeZone_index);
		}else{
				if(document.all){
						x.style.filter = "alpha(opacity=100)";
						x.style.opacity = "0.7";
				}else{
						x.style.filter = "alpha(opacity=70)";
						x.style.opacity = "1";
				}
				x.style.color = "#000";
		}
}

function fnC_NowThemeZone(x){
		if(x == "Out"){
				//fn_C_IMG_C_ThemeZone_Border(ThemeZone_index, C_ThemeZone_index);
		}else{
				x.style.borderTop = '3px solid #FBB2CF';
				x.style.borderBottom = '3px solid #FBB2CF';
				x.style.borderLeft = '3px solid #FBB2CF';
				x.style.borderRight = '3px solid #FBB2CF';				
				x.style.filter = "alpha(opacity=100)";
				x.style.opacity = "1";
		}
}


function fnGOMore_C_VIPZone(){
		if(VIPZone_index==1)
				location.href="/room/room_seeklist.php?q=F";
		else if(VIPZone_index==2)
				location.href="/file/index_morebirthday.php";
		else if(VIPZone_index==3)
				location.href="/file/index_morehouseholder.php";
}

function fnGOMore_C_ThemeZone(){
		if(ThemeZone_index==1)
				location.href="http://photo.i-part.com.tw/subject_user_list.php";
		else if(ThemeZone_index==2)
				location.href="/diary/diary_weekmore.php";
		else if(ThemeZone_index==3)
				location.href="http://photo.i-part.com.tw/subject_user_list.php";
}


















function fnChkTop_Search1(t){
		v=document.getElementById("nkname").value;
		if(t==1){
				if(v!=""&&v>0&&!isNaN(v))
						location.href="http://www.i-part.com.tw/file/file_viewfile.php?u="+v;
				else
						alert("住戶編號填寫錯誤！");
		}else{
				if(v!="")
						document.fmTopS1.submit();
				else
						alert("暱稱搜尋不能為空白！");
		}
}



function fnChkTop_Search2(){
		if(	document.getElementsByName("s_age[]")[0].value != "" && 
				(isNaN(document.getElementsByName("s_age[]")[0].value) || document.getElementsByName("s_age[]")[0].value < 10 || document.getElementsByName("s_age[]")[0].value > 100 )){
						alert("請真寫正確的年齡範圍！");return false;
		}
		if(	document.getElementsByName("s_age[]")[1].value != "" && 
				(isNaN(document.getElementsByName("s_age[]")[1].value) || document.getElementsByName("s_age[]")[1].value < 10 || document.getElementsByName("s_age[]")[1].value > 100)){
						alert("請真寫正確的年齡範圍！");return false;
		}
 		document.getElementById('btn1').style.display='none';
 		document.getElementById('btn2').style.display='';
		return true;
}

function fnChkTop_Search3(t){
		v = document.getElementById("content").value;
		if(v == ""){
						alert("請填寫要搜尋的內容！");return;
		} else {
			if(t==2){
				document.getElementById("act").value = 'tag';
			} else {
				document.getElementById("act").value = 'title';
			}
			window.document.fmTopS3.submit();
		}
		//if(t==2)
				//top.location.href="http://photo0.i-part.com.tw/tag_save.php?act=tag&content=" + v +"&charset=utf8";
		//else
				//top.location.href="http://photo0.i-part.com.tw/tag_save.php?act=title&content=" + v +"&charset=utf8";
}

var flag_fnChkTop_Search4_1 = true;
function fnChkTop_Search4_1(){
		if(fnChkTop_Search4_1){
				v = document.getElementById("keyword").value;
				if(v == ""){
								alert("請填寫要搜尋的內容！");return false;
				}
				flag_fnChkTop_Search4_1 = false;
				return true;
		}else{
				return false;
		}
}

var flag_fnChkTop_Search5 = true;
function fnChkTop_Search5(){
		if(fnChkTop_Search5){
				v = document.getElementById("q2").value;
				if(v == ""){
								alert("請填寫要搜尋的內容！");return false;
				}
				flag_fnChkTop_Search5 = false;
				return true;
		}else{
				return false;
		}
}
