﻿var g_Config = {
    SEFormat: {
        nRow: 3,
        nColumn: 3,
        strSELayerId: 'SELayer',
        strDefaultState: 'hidden',
        strBGColor: '#FFFFFF',
		nMaxOption: 12
    },
    SEItemTip: {
        nFontSize: 1,
        strUncheckedColor: '#D8D8D8',
        nXoffset: 15,
        nXoffset_Child: 180,
        nYoffset_Child: 70,
        strBGColor: '#FFFFD9',
        strLayerId: 'SEItemTip'
    },
    SETab: {
        strHideImage: '/title_bg_hide.gif',
        strShowImage: '/title_bg_show.gif',
        strSETabPrefix: 'menuTitle',
        strFontStyle: 'mm',
        nWidth: 142,
        nHeight: 23
    },
    SEItemLayer: {
        strHide: 'none',
        strShow: 'block',
        strFontStyle: 'nn',
        strStyle: 'sec',
        strSEItemLayerPrefix: 'menu',
        nWidth: 140,
        nPixelCntDown: 5,
        nSEItemLayerTimeInterval: 1 //-- 1 second
    },
    PagePostfix: {
        strMain: '_Main',
        strChild: '_Child'
    },
    bMainPage: true,
    strLogoImage: '/d2d16899-WptMojoLingo.jpg',
	strLogoSmallImage: '/d2d16899-WptMojoLingo_small.jpg',
	strLogoLink: 'http://www.winperturn.com.tw',
	strMojoLingo: 'MojoLingo',
    PortalIdx: {
        nSearch: 1,
        nUrl: 2,
        nText: 3,
        nRss: 4
    },
    nPortalState: 1,
    strFontStyle: 'Verdana',
    nChildTextTabIdx: 0,
	nChildRssTabIdx: 0,
	nMaxTab: 16,
	nIsLoadState: 1,
    CommonString: {
        strHTTP: 'http://',
        strHTTPS: 'https://',
        strCommonPrefix: '/m2m-',
        strSamplePrefix: '/m2m-0000/'
    }
};

var g_LangConfig = {
    SearchEngineName: {
        Google: 'Google',
        Yahoo: 'Yahoo',
        MSN: 'MSN',
        eBay: 'eBay',
        Alibaba: '阿里巴巴',
        Sina: '新浪',
        Baidu: '百度',
        Sogou: '搜狗',
        Hinet: 'HiNet'
    },
    CheckBoxName: {
        TC: '繁體網頁',
        SC: '簡體網頁',
        EN: '英文網頁',
        JP: '日文網頁',
        SC_Taobao: '簡體淘寶網'
    },
    GotoMainPage: {
        LinkName: '回到MojoLingo',
        LinkUrl: 'd2d16899-search.tw.htm'
    },
    BusinessSolution: {
        LinkName: '企業多語言解決方案',
        LinkUrl: 'http://www.winperturn.com.tw/page_product_list.htm'
    },
    ManualPage: {
        LinkName: '使用說明',
        LinkUrl: 'd2d16899-srchhelp.tw.htm'
    },
    SearchPage: {
        LinkName: '關鍵字查詢',
        LinkUrl: 'http://www.mojolingo.xuite.net'
    },
    UrlPage: {
        LinkName: '網站翻譯',
        LinkUrl: 'http://url.mojolingo.xuite.net'
    },
    TextPage: {
        LinkName: '文字翻譯',
        LinkUrl: 'http://text.mojolingo.xuite.net'
    },
    RssPage: {
        LinkName: 'RSS Bridge',
        LinkUrl: 'http://rss.mojolingo.xuite.net'
    },
    ClientTmPage: {
        LinkName: '常用語設定',
        LinkUrl: 'd2d16899-clientTM.tw.htm'
    },
	ADpage: {
		strInputTran: '輸入翻譯',
		stroutputTran: '網頁翻譯'	
	},
    LangSelection: [
		{name: '原文', name2: '原文', name3: '原文', value: 0},
		{name: '繁體中文', name2: '繁中', name3: '繁', value: 1},
		{name: '簡體中文', name2: '簡中', name3: '簡', value: 2},
        {name: '全部英文', name2: '英文', name3: '英', value: 3},
        {name: '全部日文', name2: '日文', name3: '日', value: 4}
    ],
    CopyRight: {
        CompanyName: '溫普敦資訊股份有限公司',
        CompanyUrl: 'http://www.winperturn.com.tw'
    },
    Message: {
        strBriefDescription: '請勾選欲搜尋的網頁',
        strClientTM: '使用端者TM設定',
        strInputKeyword: '輸入關鍵字',
        strInputUrl: '輸入欲瀏覽網址',
        strTextTrans: '線上即時文字翻譯',
        strSourceText: '原始文字(兩百字以內)',
        strDstText: '翻譯後文字',
        strFromDescription_Main: '剛輸入的關鍵字是',
        strFromText: '將剛輸入的文字從',
        strFromUrl: '將剛輸入的網址內容從',
		strFromInput: '將內容從',
        strToDescription_Main: '，將搜尋結果翻譯成',
        strToUrl: '翻譯成',
        strFromDescription: '關鍵字包含',
        strToDescription: '網頁翻譯成',
        strNotSupportJpEn: '不支援日英、英日翻譯！',
        strTcEnRefer: '中文翻英文的精準服務請參考以下網站: http://www.winperturn.com.tw/',
        strPopupBlocker: '看不到搜尋結果？',
        strNotSupportHttps: '不支援HTTPS！',
		strNotInputKeyword: '尚未輸入關鍵字',
		strNotInputUrl: '尚未輸入網址',
		strNotInputText: '尚未輸入文字',
		strNotInputRssLocation: '尚未輸入原始RSS連結',
        strInputTooLong: '請輸入200字以內！',
		strOverMaxNumber: '最多只能選12個選項哦！',
		strOverMaxTabNumber: '最大視窗數為16個！'
    },
    ActionButtonName: '搜尋',
    strUrlButtonName: '翻譯',
    strTextButtonName: '翻譯',
    ShowLayerName: '選擇語言',
    ShowUrlSELayerName: '選擇其他語言',
    ShowSELayerName: '選擇多國語言搜尋網站',
    strProcessing: '翻 譯 中 ...',
    ClientTM: {
        strFromLang: '原始文字為',
        strToLang: '轉譯成',
        strBigCookieErr: '已沒有空間儲存此次設定！',
        strCookieSaved: '設定完成！',
        strMainDescription: '常用語設定',
        strAddRows: '增加列數+',
        strOrgText: '原始文字',
        strButtonName: '儲存',
        strDelete: '刪除'
    },
    nUserLang :1
};

//---- 跨瀏覽器設置
var bIsDOM = (getObjectById ? true : false); 
//var bIsIE4 = ((document.all && !bIsDOM) ? true : false);
var bIsIE4 = (document.all)? true : false;
var bIsNS4 = (document.layers ? true : false);
var bIsDyn = (bIsDOM || bIsIE4|| bIsNS4);
function getObjectById(p_nId)
{
    if (bIsDOM) return document.getElementById(p_nId);
	if (bIsIE4) return document.all[p_nId];
	if (bIsNS4) return document.layers[p_nId];
}
function getStyleById(p_nId)
{
    return (bIsNS4 ? getObjectById(p_nId) : getObjectById(p_nId).style);
}
function getHeight(p_strHeightPixel)
{
    var nHead = 0;
    while ('0' == p_strHeightPixel.charAt(nHead))
        nHead++;
    var nTail = p_strHeightPixel.indexOf('px');
    if (nTail == nHead)
        return 0;
    if (-1 != nTail)
        return p_strHeightPixel.substring(nHead, nTail);
    return p_strHeightPixel.substring(nHead);
}
function getHeightPixel(p_strHeight)
{
    var strHeightPixel = p_strHeight + 'px';
    return strHeightPixel;
}
function d2d_getCookie(p_strName)
{
	var c_start = 0;
	var c_end = 0;
	if ((document.cookie.length > 0) && (p_strName.length > 0)) {
		c_start = document.cookie.indexOf(p_strName + "=");
		if (c_start != -1) { 
			c_start = c_start + p_strName.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return document.cookie.substring(c_start, c_end);
		} 
	}
	return null;
}
function d2d_setCookie(p_strName, p_strValue, p_nExpiredays)
{
	domain = "xuite.net"; //-- 必須為伺服器的網域
	path = "/";
	
	//alert('p_strName:'+p_strName+' p_strValue:'+p_strValue+' p_nExpiredays:'+p_nExpiredays);
	var exdate = new Date();
	exdate.setTime(exdate.getTime() + (p_nExpiredays*24*3600*1000));
	document.cookie = p_strName + "=" + p_strValue + ((p_nExpiredays==null) ? "" : "; expires=" + exdate.toGMTString()) + ((domain) ? "; domain=" + domain : "")+ ((path) ? "; path=" + path : "");
	//alert (p_strName + "=" + p_strValue + ((p_nExpiredays==null) ? "" : "; expires=" + exdate.toGMTString()) + ((domain) ? "; domain=" + domain : "")+ ((path) ? "; path=" + path : ""));
}
function d2d_main()
{
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.Google, 100);
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.Yahoo, 100);
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.MSN, 100);
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.eBay, 75);
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.Alibaba, 75);
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.Sina, 75);
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.Baidu, 25);
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.Sogou, 25);
    g_SEPlatform.addSE(g_LangConfig.SearchEngineName.Hinet, 25);
	
    g_SEPlatform.addLGW('tc2tc.mojolingo.xuite.net', 0, 0);
    g_SEPlatform.addLGW('tc2sc.mojolingo.xuite.net', 0, 1);
    g_SEPlatform.addLGW('tc2en.mojolingo.xuite.net', 0, 2);
    g_SEPlatform.addLGW('tc2jp.mojolingo.xuite.net', 0, 3);
	g_SEPlatform.addLGW('sc2tc.mojolingo.xuite.net', 1, 0);
    g_SEPlatform.addLGW('sc2sc.mojolingo.xuite.net', 1, 1);
    g_SEPlatform.addLGW('sc2en.mojolingo.xuite.net', 1, 2);
    g_SEPlatform.addLGW('sc2jp.mojolingo.xuite.net', 1, 3);
	g_SEPlatform.addLGW('en2tc.mojolingo.xuite.net', 2, 0);
    g_SEPlatform.addLGW('en2sc.mojolingo.xuite.net', 2, 1);
    g_SEPlatform.addLGW('en2en.mojolingo.xuite.net', 2, 2);
    g_SEPlatform.addLGW('en_jp.c2c.idc.hinet.net', 2, 3);
	g_SEPlatform.addLGW('jp2tc.mojolingo.xuite.net', 3, 0);
    g_SEPlatform.addLGW('jp2sc.mojolingo.xuite.net', 3, 1);
    g_SEPlatform.addLGW('jp_en.c2c.idc.hinet.net', 3, 2);
    g_SEPlatform.addLGW('jp2jp.mojolingo.xuite.net', 3, 3);

    g_SEPlatform.addSEItem('www.google.com.tw/search', 'hl=zh-TW&q', '1', '1', g_LangConfig.SearchEngineName.Google, g_LangConfig.CheckBoxName.TC);   // Google台灣
    g_SEPlatform.addSEItem('www.google.com.cn/search', 'hl=zh-CN&q', '1', '2', g_LangConfig.SearchEngineName.Google, g_LangConfig.CheckBoxName.SC);   // Google簡體網頁
    g_SEPlatform.addSEItem('www.google.com/search', 'hl=en&q', '1', '3', g_LangConfig.SearchEngineName.Google, g_LangConfig.CheckBoxName.EN);         // Google英文網頁
    g_SEPlatform.addSEItem('www.google.co.jp/search', 'hl=ja&q', '1', '4', g_LangConfig.SearchEngineName.Google, g_LangConfig.CheckBoxName.JP);     // Google日本
    g_SEPlatform.addSEItem('tw.search.yahoo.com/search', 'ei=UTF-8&p', '1', '1', g_LangConfig.SearchEngineName.Yahoo, g_LangConfig.CheckBoxName.TC);     // Yahoo台灣
    g_SEPlatform.addSEItem('www.yahoo.com.cn/search', 'ei=UTF-8&p', '1', '2', g_LangConfig.SearchEngineName.Yahoo, g_LangConfig.CheckBoxName.SC);     // Yahoo簡體網頁
    g_SEPlatform.addSEItem('search.yahoo.com/search', 'ei=UTF-8&p', '1', '3', g_LangConfig.SearchEngineName.Yahoo, g_LangConfig.CheckBoxName.EN);     // Yahoo英文網頁
    g_SEPlatform.addSEItem('search.yahoo.co.jp/search', 'p', '1', '4', g_LangConfig.SearchEngineName.Yahoo, g_LangConfig.CheckBoxName.JP);     // Yahoo日文網頁
    g_SEPlatform.addSEItem('search.msn.com.tw/results.aspx', 'cp=950&q', '0', '1', g_LangConfig.SearchEngineName.MSN, g_LangConfig.CheckBoxName.TC);  // MSN台灣
    g_SEPlatform.addSEItem('beta.search.msn.com.cn/results.aspx', 'cp=936&q', '0', '2', g_LangConfig.SearchEngineName.MSN, g_LangConfig.CheckBoxName.SC); // MSN簡體網頁
    g_SEPlatform.addSEItem('search.msn.com/results.aspx', 'q', '1', '3', g_LangConfig.SearchEngineName.MSN, g_LangConfig.CheckBoxName.EN);        // MSN英文網頁
    g_SEPlatform.addSEItem('search.msn.co.jp/results.aspx', 'q', '1', '4', g_LangConfig.SearchEngineName.MSN, g_LangConfig.CheckBoxName.JP);     // MSN日文網頁
//    g_SEPlatform.addSEItem('search.tw.ebay.com/search/search.dll', 'query', '1', '1', g_LangConfig.SearchEngineName.eBay, g_LangConfig.CheckBoxName.TC);     // ebay台灣
    g_SEPlatform.addSEItem('search.ebay.com.cn/search/search.dll', 'query', '1', '2', g_LangConfig.SearchEngineName.eBay, g_LangConfig.CheckBoxName.SC);     // ebay簡體網頁
    g_SEPlatform.addSEItem('search.ebay.com/search/search.dll', 'satitle', '0', '3', g_LangConfig.SearchEngineName.eBay, g_LangConfig.CheckBoxName.EN);     // ebay英文網頁
    g_SEPlatform.addSEItem('search1.taobao.com/browse/search_product.htm', 'search_type=auction&title',	'0', '2', g_LangConfig.SearchEngineName.Alibaba, g_LangConfig.CheckBoxName.SC_Taobao);   // 淘寶網
    g_SEPlatform.addSEItem('search.china.alibaba.com/turbine/template/search,OfferSearch', 'keywords', '0', '2', g_LangConfig.SearchEngineName.Alibaba, g_LangConfig.CheckBoxName.SC);     // 阿里巴巴
    g_SEPlatform.addSEItem('www.alibaba.com/trade/search', 'SearchText', '0', '3', g_LangConfig.SearchEngineName.Alibaba, g_LangConfig.CheckBoxName.EN);     // 阿里巴巴英文網頁
    g_SEPlatform.addSEItem('google.sina.com.tw/cgi-bin/webpage_full.cgi', 'word', '0', '1', g_LangConfig.SearchEngineName.Sina, g_LangConfig.CheckBoxName.TC);     // 新浪台灣
    g_SEPlatform.addSEItem('iask.com/w', 'k', '0', '2', g_LangConfig.SearchEngineName.Sina, g_LangConfig.CheckBoxName.SC);     // 新浪簡體網頁
    g_SEPlatform.addSEItem('www.accoona.cn/en/search.jsp', 'qt', '0', '3', g_LangConfig.SearchEngineName.Sina, g_LangConfig.CheckBoxName.EN);     // 新浪北美
	g_SEPlatform.addSEItem('www.baidu.com/s', 'wd', '0', '2', g_LangConfig.SearchEngineName.Baidu, g_LangConfig.CheckBoxName.SC);    // 百度
    g_SEPlatform.addSEItem('www.sogou.com/web', 'query', '0', '2', g_LangConfig.SearchEngineName.Sogou, g_LangConfig.CheckBoxName.SC);       // 搜狗
    g_SEPlatform.addSEItem('webpage.hisearch.hinet.net/bin/search', 'k', '0', '1', g_LangConfig.SearchEngineName.Hinet, g_LangConfig.CheckBoxName.TC);      // Hinet台灣

	for (i=0; i<5; i++)
        g_SEPlatform.addLangName(g_LangConfig.LangSelection[i].name2, i);

	g_SEPlatform.formatSE();
}
//------------------------------------------------------------- g_SEPlatform
var g_SEPlatform = new Platform();
function Platform()
{
    this.SE = [];
    this.SEItem = [];
    this.LGW = [];
    this.LangName = [];
    this.nTotalShownSEItem = 0;
    this.nWhichOpen = 0;
    this.nWhichContinue = -1;
    this.nSEShownCnt = 0;
}
Platform.prototype.addSE = function(p_strSEName, p_nHeight)
{
	for (var i=0; i<this.SE.length; i++)
		if (this.SE[i].strName == p_strSEName)
			return this;
	this.SE.push({strName: p_strSEName, nHeight: p_nHeight});
	return this;
}
Platform.prototype.addSEItem = function(p_strSEUrl, p_strArg, p_nUtf8, p_nWebCharset, p_strSEName, p_strSEItemName)
{
	for (var i=0; i<this.SEItem.length; i++)
		if ((this.SEItem[i].strSEName == p_strSEName) && (this.SEItem[i].strSEItemName == p_strSEItemName))
			return this;
	this.SEItem.push({strSEUrl: p_strSEUrl, strArg: p_strArg, nUtf8: p_nUtf8, nWebCharset: p_nWebCharset, strSEName: p_strSEName, strSEItemName: p_strSEItemName});
	return this;
}
Platform.prototype.addLGW = function(p_strLGW, p_nFromChar, p_nToChar)
{
	for (var i=0; i<this.LGW.length; i++)
		if (this.LGW[i].strLGW == p_strLGW)
			return this;
	this.LGW.push({strLGW: p_strLGW, nFromChar: p_nFromChar, nToChar: p_nToChar});
	return this;
}
Platform.prototype.getLGW = function(p_nFromChar, p_nToChar)
{
	for (var i=0; i<this.LGW.length; i++)
		if ((this.LGW[i].nFromChar == p_nFromChar) && (this.LGW[i].nToChar == p_nToChar))
			return this.LGW[i].strLGW;
	return '';
}
Platform.prototype.addLangName = function(p_strLangName, p_nCharset)
{
	for (var i=0; i<this.LangName.length; i++)
		if (this.LangName[i].nCharset == p_nCharset)
			return this;
	this.LangName.push({strLangName: p_strLangName, nCharset: p_nCharset});
	return this;
}
Platform.prototype.getLangName = function(p_nCharset)
{
	for (var i=0; i<this.LangName.length; i++)
		if (this.LangName[i].nCharset == p_nCharset)
			return this.LangName[i].strLangName;
	return '';
}
Platform.prototype.formatSE = function()
{
    var strPagePostfix = '';
    strPagePostfix = g_Config.PagePostfix.strChild;
    
    var nMaxH = 0;
    var nNewMaxH = 0;
    for (nCnt=0; (nCnt<g_Config.SEFormat.nColumn) && (nCnt < this.SE.length); nCnt++)
    {
        nNewMaxH = this.SE[nCnt].nHeight;
        if (0 < (nNewMaxH-nMaxH))
            nMaxH = nNewMaxH;
    }
    
    var strText = '';
	strText += '<table class="mm">';
	strText += '<tr><td nowrap align=left colspan=2>'+g_LangConfig.Message.strBriefDescription+'</td><td><a href="#" onclick="g_SEPlatform.switchSELayer()">關閉</a></td></tr>';
	strText += '<tr><td nowrap align=left colspan=3>';
	strText += '&nbsp;' + g_LangConfig.Message.strFromDescription + '&nbsp;';
	strText += '<select id="wptInType'+strPagePostfix+'" name="wptInType'+strPagePostfix+'">';
	for (nCnt=1; nCnt<5; nCnt++)
		strText += '<option value='+g_LangConfig.LangSelection[nCnt].value+' >'+g_LangConfig.LangSelection[nCnt].name+'</option>';
	strText += '</select>';
	strText += '&nbsp;' + g_LangConfig.Message.strToDescription + '&nbsp;';
	strText += '<select id="wptConvType'+strPagePostfix+'" name="wptConvType'+strPagePostfix+'">';
	for (nCnt=0; nCnt<5; nCnt++)
		strText += '<option value='+g_LangConfig.LangSelection[nCnt].value+'>'+g_LangConfig.LangSelection[nCnt].name+'</option>';
	strText += '</select>';
	strText += '</td></tr>';
	strText += '</table>';

	strText += '<div id="'+g_Config.SEItemTip.strLayerId+strPagePostfix+'" style="position:absolute; visibility:visible; left:25px; top:-50px"></div>';
	strText += '<table>';
	var nSEShownCnt = 0;
	for (nRowCnt=0; (nRowCnt<g_Config.SEFormat.nRow) && (nSEShownCnt < this.SE.length); nRowCnt++)
	{
		strText += '<tr>';
		for (nColCnt=0; (nColCnt<g_Config.SEFormat.nColumn) && (nSEShownCnt < this.SE.length); nColCnt++)
		{
			strText += '<td valign=top>';
			if (nSEShownCnt < g_Config.SEFormat.nColumn)
				strText += this.formatSEItems(nSEShownCnt, nMaxH);
			else
				strText += this.formatSEItems(nSEShownCnt, 0);
			strText += '</td>';
			nSEShownCnt++;
		}
		strText += '</tr>';
	}
	this.nSEShownCnt = nSEShownCnt;
	strText += '<table>';

	getObjectById(g_Config.SEFormat.strSELayerId).innerHTML = strText;
		
	var cookieVal = d2d_getCookie("MojoLingoSelect");
	if (cookieVal != null) {
		//getObjectById('wptInType'+strPagePostfix).value = cookieVal.charAt(0);

		if ( !(cookieVal.charAt(1)==0) )
			getObjectById('wptConvType'+strPagePostfix).value = cookieVal.charAt(1);
	}
}
Platform.prototype.formatSEItems = function(p_nSEIdx, p_nHeight)
{
    var strPagePostfix = '';
    strPagePostfix = g_Config.PagePostfix.strChild;
    
    var strSEItemContent = '';
    var strDisplay = g_Config.SEItemLayer.strHide;
    var strBGImage = g_Config.SETab.strHideImage;
    if (0 != p_nHeight)
    {
        strDisplay = g_Config.SEItemLayer.strShow;
        strBGImage = g_Config.SETab.strShowImage;
    }
    strSEItemContent = '<table cellpadding="0" cellspacing="0" class="'+g_Config.SETab.strFontStyle+'" width="'+g_Config.SETab.nWidth+'">';
    strSEItemContent += '<tr style="cursor:pointer">';
    strSEItemContent += '<td id="'+g_Config.SETab.strSETabPrefix+strPagePostfix+p_nSEIdx+'" height="'+g_Config.SETab.nHeight+'" background="'+strBGImage+'" onclick="g_SEPlatform.clickSE('+p_nSEIdx+');">';
    strSEItemContent += this.SE[p_nSEIdx].strName;
    strSEItemContent += '</td></tr><tr><td>';
    strSEItemContent += '<div id="'+g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+p_nSEIdx+'" class="'+g_Config.SEItemLayer.strStyle+'" style="width:'+g_Config.SEItemLayer.nWidth+'px;height:'+p_nHeight+'px;display:'+strDisplay+';">';
    strSEItemContent += '<table class="'+g_Config.SEItemLayer.strFontStyle+'">';
    var nIdx = 0;
    for (nCnt=0; nIdx < this.SEItem.length; nCnt++)
    {
        for (; nIdx<this.SEItem.length; nIdx++)
        {
            if (this.SEItem[nIdx].strSEName == this.SE[p_nSEIdx].strName)
                break;
        }
        if (nIdx < this.SEItem.length)
        {
            var strText = this.SEItem[nIdx].strSEItemName;
            var strColorText = strText;
            var strChecked = '';
            if ((0 == nIdx) && (0 == p_nSEIdx))
            {
                strColorText = '<font color="red"><b>' + strColorText;
                strColorText = strColorText + '</b></font>';
                strChecked = 'checked';
            }
			if (d2d_getCookie("MojoLingoOption")!=null) {
				if ( d2d_getCookie("MojoLingoOption").charAt(nIdx)=="1" ) strChecked = 'checked';
				//alert(d2d_getCookie("MojoLingoOption").charAt(nIdx));
			}
            strSEItemContent += '<tr><td>';
            strSEItemContent += '<input type="checkbox" id="'+g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+p_nSEIdx+'_'+nCnt+'" value="'+strText+'" '+strChecked+'>';
            strSEItemContent += strColorText;
            strSEItemContent += '</td></tr>';
            nIdx++;
            this.nTotalShownSEItem++;
        }
    }
    strSEItemContent += '</table>';
    strSEItemContent += '</div>';
    strSEItemContent += '</td>';
    strSEItemContent += '</tr>';
    strSEItemContent += '</table>';
    return strSEItemContent;
}
Platform.prototype.switchSELayer = function()
{
    if (getStyleById(g_Config.SEFormat.strSELayerId).visibility == 'hidden')
        getStyleById(g_Config.SEFormat.strSELayerId).visibility = 'visible';
    else
        getStyleById(g_Config.SEFormat.strSELayerId).visibility = 'hidden';
}
Platform.prototype.disSELayer = function()
{
        getStyleById(g_Config.SEFormat.strSELayerId).visibility = 'hidden';
}
Platform.prototype.showSE = function(p_nClickIdx, p_nMaxH, p_nRowIdx)
{
    var strPagePostfix = '';
    strPagePostfix = g_Config.PagePostfix.strChild;
    
    var nSEItemLayerPixelVar = p_nMaxH / g_Config.SEItemLayer.nPixelCntDown;
    if (p_nMaxH > getHeight(getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+p_nRowIdx).height))
	{
	    for (nCnt=0; (nCnt<g_Config.SEFormat.nColumn) && ((p_nRowIdx+nCnt) < this.nSEShownCnt); nCnt++)
	    {
	        var nMenuIdx = p_nRowIdx + nCnt;
	        getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nMenuIdx).height = getHeightPixel(getHeight(getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nMenuIdx).height)-0+nSEItemLayerPixelVar);
	        getObjectById(g_Config.SETab.strSETabPrefix+strPagePostfix+nMenuIdx).background = g_Config.SETab.strShowImage;
	        if (nSEItemLayerPixelVar == getHeight(getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nMenuIdx).height))
	            getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nMenuIdx).display = g_Config.SEItemLayer.strShow;
	    }
		myClickIdx = p_nClickIdx;
		myMaxH = p_nMaxH;
		myRowIdx = p_nRowIdx;
		setTimeout('g_SEPlatform.showSE(myClickIdx, myMaxH, myRowIdx)', g_Config.SEItemLayer.nSEItemLayerTimeInterval);
	}
}
Platform.prototype.hideSE = function(p_nClickIdx, p_nMaxH, p_nRowIdx)
{
    var strPagePostfix = '';
    strPagePostfix = g_Config.PagePostfix.strChild;
    
    var nSEItemLayerPixelVar = p_nMaxH / g_Config.SEItemLayer.nPixelCntDown;
	if (0 < getHeight(getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+p_nRowIdx).height))
	{
	    for (nCnt=0; (nCnt<g_Config.SEFormat.nColumn) && ((p_nRowIdx+nCnt) < this.nSEShownCnt); nCnt++)
	    {
	        var nMenuIdx = p_nRowIdx + nCnt;
	        if (nSEItemLayerPixelVar == getHeight(getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nMenuIdx).height))
	            getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nMenuIdx).display = g_Config.SEItemLayer.strHide;
	        getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nMenuIdx).height = getHeightPixel(getHeight(getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nMenuIdx).height)-nSEItemLayerPixelVar);
	        getObjectById(g_Config.SETab.strSETabPrefix+strPagePostfix+nMenuIdx).background = g_Config.SETab.strHideImage;
	    }
		myClickIdx = p_nClickIdx;
		myMaxH = p_nMaxH;
		myRowIdx = p_nRowIdx;
		setTimeout('g_SEPlatform.hideSE(myClickIdx, myMaxH, myRowIdx)', g_Config.SEItemLayer.nSEItemLayerTimeInterval);
	}
    else
    {
        this.nWhichOpen = -1;
        if (0 <= this.nWhichContinue)
            this.clickSE(this.nWhichContinue);
    }
}
Platform.prototype.clickSE = function(p_nSEIdx)
{
    var strPagePostfix = '';
    strPagePostfix = g_Config.PagePostfix.strChild;
    
    var r = p_nSEIdx % g_Config.SEFormat.nColumn;
    var nRowIdx = p_nSEIdx - r;
    var nMaxH = 0;
    var nNewMaxH = 0;
    for (nCnt=nRowIdx; (nCnt<(nRowIdx+g_Config.SEFormat.nColumn)) && (nCnt < this.nSEShownCnt); nCnt++)
    {
        nNewMaxH = this.SE[nCnt].nHeight;
        if (0 < (nNewMaxH-nMaxH))
            nMaxH = nNewMaxH;
    }
	if (0 < getHeight(getStyleById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+p_nSEIdx).height))
    {
		this.hideSE(p_nSEIdx, nMaxH, nRowIdx);
    }
	else
    {
		if (0 <= this.nWhichOpen)
		{
            this.nWhichContinue = p_nSEIdx;
            this.clickSE(this.nWhichOpen);
		}
		else
		{
            this.showSE(p_nSEIdx, nMaxH, nRowIdx);
            this.nWhichOpen = p_nSEIdx;
            this.nWhichContinue = -1;
		}
    }
}
Platform.prototype.sendQuery = function()
{
    var strPagePostfix = '';
	strPagePostfix = g_Config.PagePostfix.strChild;
    var strQuery = escape(document.ff.query.value);
    if (0 >= strQuery.length) {
		alert(g_LangConfig.Message.strNotInputKeyword);
        return;
	}

   // g_ClientTm.fillClientTmTalble();
    
    var nItemIdxInSE = 0;
    var nSEItemIdx = 0;
    var nShownSEIdx = 0;
	var nPageNumber = 0;
	var strSearchEngine = "";
	var strCookieUrl, strCookieName, strCookieTitle;
	
	for (nShownSEIdx=0; nShownSEIdx<this.nSEShownCnt; nShownSEIdx++,nItemIdxInSE=0,nSEItemIdx=0)
    {
        while (nSEItemIdx < this.SEItem.length)
        {
            for (; nSEItemIdx < this.SEItem.length; nSEItemIdx++)
            {
                if (this.SEItem[nSEItemIdx].strSEName == this.SE[nShownSEIdx].strName)
                    break;
            }
            if (nSEItemIdx < this.SEItem.length)
            {
                if (getObjectById(g_Config.SEItemLayer.strSEItemLayerPrefix+strPagePostfix+nShownSEIdx+'_'+nItemIdxInSE).checked)
                {
                    if (((this.SEItem[nSEItemIdx].nWebCharset == 4) && (getObjectById('wptInType'+strPagePostfix).value == 3)) ||
                        ((this.SEItem[nSEItemIdx].nWebCharset == 4) && (getObjectById('wptConvType'+strPagePostfix).value == 3)) ||
                        ((this.SEItem[nSEItemIdx].nWebCharset == 3) && (getObjectById('wptInType'+strPagePostfix).value == 4)) ||
                        ((this.SEItem[nSEItemIdx].nWebCharset == 3) && (getObjectById('wptConvType'+strPagePostfix).value == 4)))
                    {
                        alert(g_LangConfig.Message.strNotSupportJpEn);
    	    	        nItemIdxInSE++;
	    	            nSEItemIdx++;
						continue;
                    }
					nPageNumber++;
					strSearchEngine += "1";
                }
                else
                {
					strSearchEngine += "0";
                }
                nItemIdxInSE++;
                nSEItemIdx++;
            }
        }
    }
	//this.disSELayer();

	if (nPageNumber > 0) {
		
		d2d_setCookie("MojoLingoQuery", strQuery, 365);
		d2d_setCookie("MojoLingoIn", getObjectById('wptInType'+strPagePostfix).value, 365);
		d2d_setCookie("MojoLingoConv", getObjectById('wptConvType'+strPagePostfix).value, 365);
		d2d_setCookie("MojoLingoOption", strSearchEngine, 365);
		
		var strURL = 'http://www.mojolingo.com.tw/?'
		strURL += 'q='+strQuery;
		strURL += '&il='+getObjectById('wptInType'+strPagePostfix).value;
		strURL += '&ol='+getObjectById('wptConvType'+strPagePostfix).value;
		strURL += '&op='+strSearchEngine;

		location.href = strURL;
		

	}
}
function d2d_keyDown(eEvent)
{
    var nKeyCode = 0;
    if (bIsIE4)
        nKeyCode = event.keyCode;
    else
        nKeyCode = eEvent.which;
    
    if (13 == nKeyCode)
    {
      	g_SEPlatform.sendQuery();
    }
}
document.onkeydown = d2d_keyDown;



