/*
*Here defines all the javascript functions used in the jsp file
*/

// generate the code to the clip board
function copyit(theField) {
    var tempval = document.getElementById(theField);
    if (tempval != null) {
	    tempval.focus()
	    tempval.select()
	    therange = tempval.createTextRange()
	    therange.execCommand("Copy")
    } // if
    alert('已复制到剪贴板，您可以粘帖到博客HTML文件中了！');
}
	
// record the click times
function clickblog(url, pos) {
	new Image().src = 'log.jsp?type=click&pos=' + pos + '&url=' + url;
}

// record the click times
function blogdoc(url, pos) {
	new Image().src = 'log.jsp?type=blogdoc&pos=' + pos + '&url=' + url;
}

// record the feedback in the log
function feedbackblog(url, res, ans) {
	new Image().src = 'log.jsp?type=feedback&res=' + res + '&ans=' + ans + '&rss=' + url;
}
	
// record the timmes of using generated code
function copylog(rss) {
	new Image().src = 'log.jsp?type=copy&rss=' + rss;
}
	
// tab pen style, display the selected tab
function switchpanel(idx) {
	for (i = 1; i <= 4; i ++) {
		elmenu = document.getElementById("menu" + i);
		eldata = document.getElementById("data" + i);
		if (i == idx) {
			eldata.style.display = "block";
			elmenu.className = "menuon";
		} else {
			eldata.style.display = "none";
			elmenu.className = "menuoff";
		} // else
	} // for i
}

function showwaiting() {
	el = document.getElementById("result");
	if (el != null)
		el.style.display="none";
	el = document.getElementById("waiting");
	if (el != null)
		el.style.display="block";
}

// change cursor
function change() {
	document.body.style.cursor='url(./images/wait.ani)';
	setTimeout("showwaiting();", 1000);
}

