function DictLangSwitch(dictLang) {
	if (0 == dictLangList.length) {
		return;
	}
	var dictLangConfig = '';
	var dictLangFound = false;
	if (!dictLang) {
		//dictLangConfig = decodeURIComponent(readCookie("dictLang"));
		dictLangConfig = dictLangList[0];
		for(var ldli=0; ldli<dictLangList.length; ldli++) {
			if (dictLangConfig == dictLangList[ldli]) {
				dictLangFound = true;
				break;
			}
		}
		if (!dictLangFound) dictLangConfig = dictLangList[0];
	} else {
		dictLangFound = true;
		dictLangConfig = dictLang;
		if (!dictLangConfig) {
			dictLangConfig = dictLangList[0];
			dictLangFound = false;
		}
	}

	$(dictLangConfig).className = 'display_front';

	$('dictlangc_'+dictLangConfig).style.display = 'block';
	for(var ldi=0; ldi<dictLangList.length; ldi++) {
		if (dictLangConfig != dictLangList[ldi]) {
			$(dictLangList[ldi]).className = 'display_bg';
			$('dictlangc_'+dictLangList[ldi]).style.display = 'none';
		}
	}
	$('dictlangc_'+dictLangConfig).style.display = 'block';
	//if (dictLangFound) writeCookie('dictLang', dictLangConfig, 8760, document.location.host, '/');
};

function GetWinSize(obj) {
	var windowWidth, windowHeight;
	if(obj) {
        target = obj.document;
    } else {
        target = document;
    }
	if (self.innerHeight) {
		if(obj) {
            target = obj.self;
        } else	 {
            target = self;
        }
		windowWidth = target.innerWidth;
		windowHeight = target.innerHeight;
	} else if (target.documentElement && target.documentElement.clientHeight) {
		windowWidth = target.documentElement.clientWidth;
		windowHeight = target.documentElement.clientHeight;
	} else if (target.body) {
		windowWidth = target.body.clientWidth;
		windowHeight = target.body.clientHeight;
	}
	return {width:parseInt(windowWidth),height:parseInt(windowHeight)};
};

function ShowMiddle(obj){
    var win = GetWinSize();
    with (obj) {
        style.position = "absolute";
        style.left = (win.width - offsetWidth)/2+'px';
        style.top = (win.height - offsetHeight)/2 + document.documentElement.scrollTop+'px';
    }
};


function rwWord(str) {
    document.write('<a href="/'+encodeURI(str)+'/">'+str+'</a>');
}

function readCookie(name) {
	var cookieValue = ""; 
	var search = name + "=";
	if (document.cookie.length > 0) { 
		offset = document.cookie.indexOf(search); 
		if (offset != -1) { 
			offset += search.length; 
			end = document.cookie.indexOf(";", offset); 
			if (end == -1) {
				end = document.cookie.length;
			}
			cookieValue = document.cookie.substring(offset, end);
		}
	}
	return cookieValue; 
};

function writeCookie(name, value, hours, domain, path) {
	var expire = ""; 
	if(hours != null) { 
		expire = new Date((new Date()).getTime() + hours * 3600000); 
		expire = "; expires=" + expire.toGMTString(); 
		if (domain) domain = "; domain=" + domain;
		if (path) path = "; path=" + path;
	}
	document.cookie = name + "=" + encodeURIComponent(value) + expire + domain + path; 
};

function echoFlash(url) {
    document.write('<span style="vertical-align:middle ;" onclick="UaaClickCount(13)"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="20" height="20">');
    document.write('<param name="wmode" value="transparent">');
    document.write('<param name="movie" value="'+url+'" />');
    document.write('<param name="quality" value="high" />');
    document.write('<embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="20" height="20"></embed>');
    document.write('</object></span>');
}

function video(theURL) {
    window.open(theURL,"video","width=260,height=350,top=200,left=300,resizable=yes,z-look=yes");
}

function ff(){
    document.getElementById('word').focus();
}

function str2img(str) {
    var src = 'http://res.iciba.com/resource/yinbiao/';
    var lenStr = str.length;
    var rsString    = "";
    for (var i=0;i<lenStr;i++) {
        var theChar   = str.substr(i,1);
        if (theChar == " ") {
            rsString += " ";
        } else if (theChar == "-") {
            rsString += "<img src=\""+src+"zhonggangxian.png\" border=\"0\" align=\"absmiddle\" />";
        } else if (theChar == "_") {
            rsString += "<img src=\""+src+"/xiahuaxian.png\" border=\"0\" align=\"absmiddle\" />";
        } else if (theChar == ".") {
            rsString += "<img src=\""+src+"dian.png\" border=\"0\" align=\"absmiddle\" />";
        } else if (theChar == "\\") {
            rsString += "<img src=\""+src+"xiexian.png\" border=\"0\" align=\"absmiddle\" />";
        } else if (theChar == "/") {
            rsString += "<img src=\""+src+"fanxiexian.png\" border=\"0\" align=\"absmiddle\" />";
        } else if (theChar == "?") {
            rsString += "<img src=\""+src+"wenhao.png\" border=\"0\" align=\"absmiddle\" />";
        } else{
            rsString += "<img src=\""+src+theChar+".png\" border=\"0\" align=\"absmiddle\" />";
        }
    }
    document.write('<img src="http://res.iciba.com/dict/img/fangkh-z.gif" alt="" align=\"absmiddle\" />');
    document.write(rsString);
    document.write('<img src="http://res.iciba.com/dict/img/fangkh-y.gif" alt="" align=\"absmiddle\" />');
}

function str2img2(str) {
    var src = 'http://res.iciba.com/resource/yinbiao/';
    var lenStr = str.length;
    var rsString    = "";
    for (var i=0;i<lenStr;i++) {
        var theChar   = str.substr(i,1);
        if (theChar == " ") {
            rsString += " ";
        } else if (theChar == "-") {
            rsString += "<img src=\""+src+"zhonggangxian.png\" border=\"0\" />";
        } else if (theChar == "_") {
            rsString += "<img src=\""+src+"/xiahuaxian.png\" border=\"0\" />";
        } else if (theChar == ".") {
            rsString += "<img src=\""+src+"dian.png\" border=\"0\" />";
        } else if (theChar == "\\") {
            rsString += "<img src=\""+src+"xiexian.png\" border=\"0\" />";
        } else if (theChar == "/") {
            rsString += "<img src=\""+src+"fanxiexian.png\" border=\"0\" />";
        } else if (theChar == "?") {
            rsString += "<img src=\""+src+"wenhao.png\" border=\"0\" />";
        } else{
            rsString += "<img src=\""+src+theChar+".png\" border=\"0\" />";
        }
    }

	rsString = '<img src="http://res.iciba.com/dict/img/fangkh-z.gif" alt="" />' + rsString + '<img src="http://res.iciba.com/dict/img/fangkh-y.gif" alt="" />';
	return rsString;
}

function getElementsByClass(rootNodeId,classToSearch,tagName) { 
	var elementsToReturn = new Array(); 
	var rootNode = document.getElementById(rootNodeId);
	var elementList = rootNode.getElementsByTagName(tagName);  
	var nLen = elementList.length; 

	var pattern = new RegExp("\\b"+classToSearch+"\\b"); 

	for(var i = 0; i < nLen; i++)
	{ 
		if( pattern.test(elementList[i].className) )
		{ 
		elementsToReturn[elementsToReturn.length] = elementList[i]; 
		} 
	} 
	return elementsToReturn; 
}

function expand_dict(type)
{

	var type = type;
	var expand_dict_div = getElementsByClass('left','expand_dict_class','div');
	var expand_dict_button = getElementsByClass('left','expand_dict_button','div');
	var close_dict_button    = getElementsByClass('left','close_dict_button','div');

	var expand_dict_div_length = expand_dict_div.length;
	var expand_dict_button_length = expand_dict_button.length;

	if(type==1)
	{
			for (var i=0;i<expand_dict_button_length;i++)
			{
				expand_dict_button[i].style.display = 'none';
				close_dict_button[i].style.display = '';
			}
		  writeCookie('is_all', 1, 8760, document.location.host, '/');
		  UClickCount(61);
	}
	else
	{
			for (var i=0;i<expand_dict_button_length;i++)
			{
				expand_dict_button[i].style.display = '';
				close_dict_button[i].style.display = 'none';
			}
		    writeCookie('is_all', 0, 8760, document.location.host, '/');
			UClickCount(62);
	}

	for (var i=0;i<expand_dict_div_length;i++)
	{
	    if(expand_dict_div[i].style.display == "block")
	    {
			expand_dict_div[i].style.display = "none";
	    }
		else
		{
		    expand_dict_div[i].style.display = "block";
		}
	}
}

function findPos(o)
{
    this.top  = o.offsetTop;
    this.left = o.offsetLeft;
    while(o = o.offsetParent)
    {
        this.top  += o.offsetTop;
        this.left += o.offsetLeft;
    }
}

function echoAudio(a){  
	document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="44" height="19" class="explain_symbol_spellimg">' +'<param name="allowScriptAccess" value="sameDomain" />' +'<param name="movie" value="http://www.iciba.com/scripts/player_44_19_20080829.swf" />' +'<param name="loop" value="false" />' +'<param name="menu" value="true" />' +'<param name="quality" value="high" />' +'<param name="FlashVars" value="f=' + a + '">'+'<param name="wmode" value="transparent" />' +'<embed src="http://www.iciba.com/scripts/player_44_19_20080829.swf" loop="false" menu="true" quality="high"  width="44" height="19" align="absmiddle" allowScriptAccess="sameDomain" FlashVars="f=' + a + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"  class="explain_symbol_spellimg" />' +'</object>');}