String.prototype.ReplaceAll = strReplaceAll;
String.prototype.trim = strtrim;

function strReplaceAll(AFindText,ARepText){ 
	raRegExp = new RegExp(AFindText,"g"); return this.replace(raRegExp,ARepText) 
}

function strtrim(){ return this.replace(/^\s*|\s*$/g,""); }

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 MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
function _login_ipart(objFrm){
	if(trim(objFrm.username.value)=='' || trim(objFrm.password.value)==''){
		alert("請填入登入資訊");
  	(objFrm.username.value=="") ? objFrm.username.focus() : objFrm.password.focus();
    return false;
  }  
  objFrm.f.value = encodeURI(this.location.href);
  objFrm.btnLogin.disabled = true;
  return true;
}
function trim(str){
  return str.replace(/^\s*|\s*$/g,"");
}
function fnGoToMyFriendPage(u){
	if(u != "")	window.open("http://photo.i-part.com.tw/" + u,"","");
}

function _gF(){
	$.ajax({
		url: '/ajax/ajax_api.php',
    data: 'func=doFavAction&uid='+_uid+'&aid='+_aid+'&fid='+_fid+'&ftype=0&fmt=html',    
    type: 'POST',
    dataType: 'html',
    timeout: 1000,
    error: function(){
        alert('Error loading HTML document');
    },
    success: function(html){
    	if(_fid==-1){
    		if(html.trim()=="fail"){ alert("收藏相簿失敗"); return false;}
    		alert("收藏相本成功");
    		_fid = html.trim(); $("#btn_fav").attr("value","取消收藏");
    	}else{
    		if(html.trim()=="ok"){ alert("取消收藏相簿成功");	}else{ alert("取消收藏相簿失敗"); }
    		$("#btn_fav").attr("value","收藏相簿"); _fid= '-1';
    	}
    }
	});
}
	

function failimg(imgobj){
	imgobj.onerror = function(){};
	imgobj.src = "http://c-photo.i-part.com.tw/images/album_default.gif";
}