$(document).ready(function() {
    $.add_links = function(node, te, ln) {
        var pos, skip, spannode, middlebit, endbit, middleclone;
        skip = 0;
        if (node.nodeType == 3) {
            pos = node.data.toUpperCase().indexOf(te);
            if (pos >= 0 && node.parentNode.className != 'keyword') {
                var pre = node.nodeValue.substr(pos-1, 1);
                var post = node.nodeValue.substr(pos+te.length, 1)
                spannode = document.createElement('a');
                spannode.href = ln;
                spannode.className = 'keyword';
                spannode.target = '_blank';
                middlebit = node.splitText(pos);
                endbit = middlebit.splitText(te.length);
                middleclone = middlebit.cloneNode(true);
                spannode.appendChild(middleclone);
                middlebit.parentNode.replaceChild(spannode, middlebit);
                skip = 1;
            }
        }
        else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
            for (var i = 0; i < node.childNodes.length; ++i) {
                i += $.add_links(node.childNodes[i], te, ln);
            }
        }
        return skip;
    }

    function set_link(keyword, url) {
        this.keyword = keyword;
        this.url = url;
    }

    var links = new Array();
    links[0] = new set_link('AFEIS', 'http://www.ares.com.tw/products/afeis.php');
    links[1] = new set_link('AGILEPOINT', 'http://www.ares.com.tw/products/bpm.php');
    links[2] = new set_link('AGILE', 'http://www.ares.com.tw/products/bpm.php');
    links[3] = new set_link('ARGOERP', 'http://www.ares.com.tw/ArgoERP');
    links[4] = new set_link('BPM', 'http://www.ares.com.tw/products/bpm.php');
    links[5] = new set_link('CIMES', 'http://www.cimes.com.tw');
    links[6] = new set_link('EARESBANK', 'http://www.ares.com.tw/products/eAresBank.php');
    links[7] = new set_link('ERP', 'http://www.ares.com.tw/ArgoERP');
    links[8] = new set_link('FSTP', 'http://www.ares.com.tw/products/fstp.php');
    links[9] = new set_link('GD-CRM', 'http://www.ares.com.tw/products/crm.php');
    links[10] = new set_link('GV', 'http://www.ares.com.tw/products/lt.php');
    links[11] = new set_link('GIB', 'http://www.ares.com.tw/products/lt.php');
    links[12] = new set_link('HCP', 'http://hcp.ares.com.tw');
    links[13] = new set_link('NM', 'http://www.ares.com.tw/products/lt.php');
    links[14] = new set_link('UIAM', 'http://pki.ares.com.tw');
    links[15] = new set_link('UPKI', 'http://pki.ares.com.tw');
    links[16] = new set_link('PLM', 'http://www.ares.com.tw/products/plm.php');
    links[17] = new set_link('SUMMIT', 'http://www.ares.com.tw/products/summit.php');
    links[18] = new set_link('SWIFT', 'http://www.ares.com.tw/products/swift.php');
    links[19] = new set_link('IAM', 'http://pki.ares.com.tw');
    links[20] = new set_link('PKI', 'http://pki.ares.com.tw');
    links[21] = new set_link('SSO', 'http://pki.ares.com.tw');
    links[22] = new set_link('ARES', 'http://www.ares.com.tw');
    links[23] = new set_link('資通電腦', 'http://www.ares.com.tw');
    links[24] = new set_link('資通', 'http://www.ares.com.tw');
    links[25] = new set_link('單一簽入', 'http://pki.ares.com.tw');
    links[26] = new set_link('SINGLE SIGN ON', 'http://pki.ares.com.tw');
	links[27] = new set_link('人力資產規劃系統', 'http://hcp.ares.com.tw');
	links[28] = new set_link('HRM', 'http://hcp.ares.com.tw');
	links[29] = new set_link('HR', 'http://hcp.ares.com.tw');
	links[30] = new set_link('人力資源', 'http://hcp.ares.com.tw');
	links[31] = new set_link('製造執行系統', 'http://www.cimes.com.tw');
	links[32] = new set_link('MES', 'http://www.cimes.com.tw');
	links[33] = new set_link('e管家', 'http://www.ares.com.tw/services/emsg.php');
    links[34] = new set_link('生產履歷', 'http://www.cimes.com.tw');
	links[35] = new set_link('AgilePoint', 'http://www.ares.com.tw/products/bpm.php');

	$("#content").each(function() {
		for (var i=0; i<links.length; i++) {
			$.add_links(this, links[i].keyword, links[i].url);
		}
	});
	
	var originalFontSize = $("#cc").css('font-size');
	
	$(".resetFont").click(function() {
		$("#cc").css('font-size', originalFontSize);
	});
	
	$(".increaseFont").click(function() {
		var currentFontSize = $("#cc").css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum+2+'px';
		$("#cc").css('font-size', newFontSize);
		return false;
	});

	$(".decreaseFont").click(function() {
		var currentFontSize = $("#cc").css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum-2+'px';
		$("#cc").css('font-size', newFontSize);
		return false;
	});

});


