var mainone_special = 0;

if (typeof (mainone_mainword) == 'undefined') {
    mainone_mainword = "";
}

if (typeof (mainone_wordtype) == 'undefined') {
    mainone_wordtype = 0;
}

if (typeof (mainone_special_1) != 'undefined')
{ mainone_special = mainone_special_1; }

if (typeof (mainonestyle) == 'undefined')
{ mainonestyle = 1; }


if (mainone_mainword != "" && mainone_wordtype == 1) {
    mainone_mainword = GetQueryString(mainone_mainword);
}
else {
    if (mainone_special == 1)
    { mainone_mainword = decodeURIComponent(mainone_mainword); }
    else if (mainone_special == 10)
    { mainone_mainword = mainone_mainword; }
    else
    { mainone_mainword = escape(mainone_mainword); }
}

//2010-01-21 xlg add begin
//function:replace special character to empty
if (typeof (mainone_replacecharacter) == 'undefined') {
    mainone_replacecharacter = "";
}
if(mainone_replacecharacter != "")
{mainone_mainword = mainone_mainword.toLowerCase().replace(mainone_replacecharacter,"");}
//2010-01-21 xlg add end
var mainoneheight;
if (mainonestyle == 2) { 
	mainoneheight = 308;
	if (mainone_if_width == null) { mainone_if_width = 240; }
	if (mainone_if_width <= 180) { mainone_if_width = 180; }
} 
else
{
	mainoneheight=120;
	if (mainone_if_width == null) { mainone_if_width = 760; }
	if (mainone_if_width <= 650) { mainone_if_width = 650; }
}
if (mainone_if_width == null) { mainone_if_width = 760; }   
if (mainone_if_width <= 0) { mainone_if_width = 650; }      
if (mainone_color_bg != '') { mainone_mainword += '&BGcolor=' + mainone_color_bg; } 
if (mainone_color_bd != '') { mainone_mainword += '&BDcolor=' + mainone_color_bd; } 

document.write('<ifr' + 'ame id="mainoneiframe"  src="'+URL()+'/keyword.aspx?mainonestyle='+ mainonestyle +'&mainkey=' +mainone_mainword +'&maionewidth='+mainone_if_width  + '" width="' + mainone_if_width + '" height="'+mainoneheight+'" scrolling="no" frameborder="0"> </ifr' + 'ame>');
var b2bUnionUrl = "<script src=\"" + URL() + "/B2bUnionEntry.ashx?key=" + mainone_mainword + "\"><" + "/script>";
document.write(b2bUnionUrl);


function GetQueryString(name) 
{ 
    if(window.location.href=="" || window.location.href == null) 
    {
       alert("CurrentURL Is Empty!");
       return "";
    }    
    var mainone_reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");    
    var mainone_r ;
    
    if(mainone_special == 3)
    { mainone_r = window.parent.location.search.substr(1).match(mainone_reg);}
    else
    { mainone_r = window.location.search.substr(1).match(mainone_reg);}
    if (mainone_r != null) {
	if(window.location.href.indexOf("mainone_type=2011") >=0)
	{
	    alert(mainone_r[2]);
	}
        if (mainone_special == 1 || window.location.href.indexOf("www.china-papernet.com") >= 0 || window.location.href.indexOf("www.zhongguosyzs.com") >= 0) 
        {
            try { return decodeURIComponent(mainone_r[2]); }
            catch (err) { return mainone_r[2]; }
        }
        if(window.location.href.indexOf("jkwjw.com") >=0 || mainone_special ==2)
        {return escape(decodeURIComponent(mainone_r[2]));}
        return mainone_r[2];      
    }
    return "";
}
function MainOne_GetKeyword(key)
{    
    var mainone_getkeyword=GetQueryString(key);
    if(mainone_getkeyword== "")
    {
        mainone_getkeyword=document.getElementById(key).value;    
        return mainone_getkeyword;
    }
    return "";
}
	
function URL()
{	
    var url="http://acode.b2b.cn/union";
    if (getPageCharset()=="utf-8" || getPageCharset()=="gb18030")
    {	        
        url="http://acode.b2b.cn/union_utf";
    }
    if (getPageCharset()=="gbk")
    {	        
        url="http://acode.b2b.cn/union_gbk";
    }    
    return url;
}

function getPageCharset() {
    var charSet = "";
    var oType = getBrowser();
    switch (oType) {
        case "IE":
            charSet = document.charset;
            break;
        case "FIREFOX":
            charSet = document.characterSet;
            break;
        default:
            break;
    }
    return charSet.toLowerCase();
}

function getBrowser(){
    var oType = "";
    if(navigator.userAgent.indexOf("MSIE")!=-1){
        oType="IE";
    }else if(navigator.userAgent.indexOf("Firefox")!=-1){
        oType="FIREFOX";
    }
    return oType;
} 

function isChinese(temp) {
    var re = /[^\u4e00-\u9fa5]/;
    if (temp != "") {
        for (j = 0; j < temp.length; j++) {
            if (!re.test(temp.charAt(j)))
            { return true; }
        }
    }
    return false;
}
