//----------------------------------------
var xmlHttp;
var myElementId;
var myUrl;
var myTargetPage="";

if(!navigator.cookieEnabled)alert("為提供您更佳的服務品質，瀏覽本網站時請開啟您的瀏覽器 Cookie 存取權限");

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function handleStateChangeTc() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
          //alert(myTargetPage);
          window.open(myTargetPage);
        } else {
           //alert("網路連線有誤，請稍後再試");
		}
    }
}

function handleStateChangeInfSco() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			if(xmlHttp.responseText.indexOf("ERR:")==0){
			   alert(xmlHttp.responseText.substring(4));
			} else {
			   alert("推薦成功！謝謝您的意見");
			   document.getElementById("lblSco").innerHTML=xmlHttp.responseText;
			   document.getElementById("lblScoHead").innerHTML=xmlHttp.responseText;
			}
        } else {
           alert("抱歉！網路連線有誤，請稍後再試");
		}
    }
}
function handleStateChangeInfCost() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			if(xmlHttp.responseText.indexOf("ERR:")==0){
			   alert(xmlHttp.responseText.substring(4));
			} else {
			   alert("付費成功！謝謝您對本文章的支持");
			   document.getElementById("lblDesp").innerHTML=xmlHttp.responseText;
			   document.getElementById("lblScoShow").style.display="block";
			   document.getElementById("lblCostShow").style.display="none";
			}
        } else {
           alert("抱歉！網路連線有誤，請稍後再試");
		}
    }
}

function handleStateChangeInfTagC() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			if(xmlHttp.responseText.indexOf("ERR:")==0){
			   alert(xmlHttp.responseText.substring(4));
			} else {
			   alert("設定成功！謝謝您貢獻的標籤");
			   document.getElementById("lblMyTags").innerHTML=xmlHttp.responseText;
			   document.getElementById("lblMyTagsHead").innerHTML=xmlHttp.responseText;
			   document.getElementById("spanTgrTagMsg").innerHTML= "以上是您曾經為本文下過的標籤，如需更改，請直接更動內容再送出一次即可";
			   SetColTagCloudC(querySt("idb"));
			}
        } else {
           alert("抱歉！網路連線有誤，請稍後再試");
		}
    }
}
function handleStateChangeInfOpt() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			if(xmlHttp.responseText.indexOf("ERR:")==0){
			   alert(xmlHttp.responseText.substring(4));
			} else {
			   alert("設定成功！謝謝您貢獻的讀後短評語");
			   document.getElementById("lblMyOpts").innerHTML=xmlHttp.responseText;
			   document.getElementById("lblMyOptsHead").innerHTML=xmlHttp.responseText;
			   document.getElementById("spanTgrOptMsg").innerHTML= "以上是您曾經為本文下過的讀後短評語，如需更改，請直接更動內容再送出一次即可";
			   SetColOptCloud(querySt("idb"));
			}
        } else {
           alert("抱歉！網路連線有誤，請稍後再試");
		}
    }
}
function handleStateChangeColTagCloudC() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			if(xmlHttp.responseText!="")
			  document.getElementById("lblArticleTagCloudC").innerHTML=xmlHttp.responseText;
        } else {
           alert("抱歉！網路連線有誤，請稍後再試");
		}
    }
}
function handleStateChangeColOptCloud() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			if(xmlHttp.responseText!="")
			  document.getElementById("lblArticleOptloud").innerHTML=xmlHttp.responseText;
        } else {
           alert("抱歉！網路連線有誤，請稍後再試");
		}
    }
}
function handleStateChangeColFumList() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			  document.getElementById("lblFumList").innerHTML=xmlHttp.responseText;
        } else {
           alert("抱歉！網路連線有誤，請稍後再試");
		}
    }
}



function SetObjTrace(TargetPage) {
    createXMLHttpRequest();
	myTargetPage=TargetPage;
	xmlHttp.open("POST", "/service/Set_ClkLog_Tc.aspx?tg=" + encodeURIComponent(TargetPage) + "&url=" + encodeURIComponent(window.location) , true);
	xmlHttp.onreadystatechange = handleStateChangeTc;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	xmlHttp.send("");
}
function SetInfSco(InfObjDBID) {
    createXMLHttpRequest();
	xmlHttp.open("POST", "/service/Set_InfSco.aspx?idb=" + InfObjDBID , true);
	xmlHttp.onreadystatechange = handleStateChangeInfSco;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	xmlHttp.send("");
}
function SetInfCost(InfObjDBID) {
    createXMLHttpRequest();
	xmlHttp.open("POST", "/service/Set_InfCost.aspx?idb=" + InfObjDBID , true);
	xmlHttp.onreadystatechange = handleStateChangeInfCost;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	xmlHttp.send("");
}

function SetMyTags(InfObjDBID,myTags) {
    createXMLHttpRequest();
	xmlHttp.open("POST", "/service/Set_InfTagC.aspx?idb=" + InfObjDBID + "&myTags=" + encodeURIComponent(myTags) , true);
	xmlHttp.onreadystatechange = handleStateChangeInfTagC;  
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	xmlHttp.send("");
}
function SetMyOpts(InfObjDBID,myOpts) {
    createXMLHttpRequest();
	xmlHttp.open("POST", "/service/Set_InfOpt.aspx?idb=" + InfObjDBID + "&myOpts=" + encodeURIComponent(myOpts) , true);
	xmlHttp.onreadystatechange = handleStateChangeInfOpt;  
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	xmlHttp.send("");
}
function SetColTagCloudC(InfObjDBID) {
    createXMLHttpRequest();
	xmlHttp.open("POST", "/service/RETURN_TagCloudC.aspx?idb=" + InfObjDBID , true);
	xmlHttp.onreadystatechange = handleStateChangeColTagCloudC;  
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	xmlHttp.send("");
}
function SetColOptCloud(InfObjDBID) {
    createXMLHttpRequest();
	xmlHttp.open("POST", "/service/RETURN_OptCloud.aspx?idb=" + InfObjDBID , true);
	xmlHttp.onreadystatechange = handleStateChangeColOptCloud;  
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	xmlHttp.send("");
}
function SetColFumList(InfObjDBID) {
    createXMLHttpRequest();
	xmlHttp.open("POST", "/service/RETURN_FumList.aspx?idb=" + InfObjDBID , true);
	xmlHttp.onreadystatechange = handleStateChangeColFumList;  
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
	xmlHttp.send("");
}
//----------
function querySt(ji) {
	hu = window.location.search.substring(1);
		gy = hu.split("&");
		for (i=0;i<gy.length;i++) {
			ft = gy[i].split("=");
			if (ft[0] == ji && ft[1]!='') {
				return ft[1];
			}
		}
	hu = window.location.pathname.substring(1);
		gy = hu.split("/");
		ft = "";
		for (i=0;i<gy.length;i++) {
			if (gy[i]!='') {ft=gy[i];}
		}
		return ft;
}
