﻿var myXmlDoc;
var IE;
var xmlhttp;
var UserXmlDoc;
var RootSite="/";
var ComID=0;
function ooj(idname){
	return document.getElementById( idname );
}
function oos(idname){
	return document.getElementsByName( idname );
}
try{
   myXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
   UserXmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
   IE=true;
   }catch(e){
   myXmlDoc =  document.implementation.createDocument("", "", null);
   UserXmlDoc =  document.implementation.createDocument("", "", null);
   IE=false;
  }
 
myXmlDoc.async=false;//禁止同步等到全部载入的时候在执行
UserXmlDoc.async=false;
try{
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }catch(e){
   xmlhttp = new XMLHttpRequest();
}
String.prototype.Trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
//验证整数
function ShowMenu(id){
	var menu=document.getElementById(id);
	if (menu.style.display=="none"){
		menu.style.display="";
	}else{
		menu.style.display="none";
	}
}
function IsInt(code)
  {
  var i,j,strTemp;
  var GoInt=true;
 strTemp="0123456789";
 if ( code.length == 0 ){
 GoInt = false;
 }
 for (i=0;i<code.length;i++)
 {
  j=strTemp.indexOf(code.charAt(i)); 
  if (j==-1)
  {
  //说明有字符不是数字
   GoInt = false;
   break;
  }
 }
 return GoInt;
}
 
  //验证邮件地址
  function Em(str){return(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(str))}
  function Http(str){return(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/.test(str))}
  function QQ(str){return(/^[1-9]\d{4,11}$/.test(str))}
  
var AllCount=0;
var EnString="abcdefghijklmnopqrstuvwxyz1234567890_";
var GBCount=0;
var ENCount=0;
var AnyCount=0;
var kaka="Yes";
function GoCount(ckstring){
var kaka="Yes";
AllCount=0;
GBCount=0;
ENCount=0;
AnyCount=0;
ckstring=ckstring.toLowerCase();
var r;
for(i=0;i<ckstring.length;i++)   
          {   
                  r   =   ckstring.charCodeAt(i,1); 
                  if(r<=255){
				  AllCount++;
				  ENCount++;
				  var thisstring=ckstring.substring(i,i+1);
                     if (EnString.indexOf(thisstring)<0)
                     {
                     AnyCount++;
                     }
                     if(i==0&&thisstring=="_"){
                     AnyCount++;
                     }
                  }else{
				  AllCount=AllCount+2;
				  GBCount++;
				  } 
          }
          kaka=kaka;
}
function OpenUrl(){
var args=OpenUrl.arguments;
var GoLong=0;
//var type=new Array("Url","Name","height","width","top","left","toolbar","menubar","scrollbars","resizable","location","status");
var file=new Array("/Close.Html","CreatB.Com","300","450","yes","200","300","no","no","no","no","no");
if (args.length<1){
alert("Error!");
return false;
}
if (args.length>12){
GoLong=12;
}else{
GoLong=args.length;
}
for (var i=0;i<args.length;i++){
if (args[i].Trim()!="")file[i]=args[i];
}
window.open (file[0], file[1], 'height='+file[2]+', width='+file[3]+', scrollbars='+file[4]+', top='+file[5]+', left='+file[6]+', toolbar='+file[7]+', menubar='+file[8]+', resizable='+file[9]+',location='+file[10]+', status='+file[11]+'') //这句要写成一行
}
function OpenMiddle( url, winName, width, height) 
{
xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - width) / 2;
yposition = (screen.height - height) / 2;
}
theproperty= "width=" + width + "," 
+ "height=" + height + "," 
+ "location=0," 
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=1,"
+ "status=0," 
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //仅适用于Netscape
+ "screeny=" + yposition + "," //仅适用于Netscape
+ "left=" + xposition + "," //IE
+ "top=" + yposition; //IE 
window.open( url,winName,theproperty );
}
var flag=false;
function DrawImage(ImgD,Hw,Hh){
 var image=new Image();
 var iwidth = Hw;  //定义允许图片宽度
 var iheight = Hh;  //定义允许图片高度
 image.src=ImgD.src;
 if(image.width>0 && image.height>0){
 flag=false;
 if(image.width/image.height>= iwidth/iheight){
  if(image.width>iwidth){  
  ImgD.width=iwidth;
  ImgD.height=(image.height*iwidth)/image.width;
  }else{
  ImgD.width=image.width;  
  ImgD.height=image.height;
  }
  }
 else{
  if(image.height>iheight){  
  ImgD.height=iheight;
  ImgD.width=(image.width*iheight)/image.height;  
  }else{
  ImgD.width=image.width;  
  ImgD.height=image.height;
  }
  }
 }
} 
function   HtmlDecode(text)   
{   
   try{
	   return encodeURIComponent(text);
   }catch(e){
       return   text.replace(/&/g,   '&amp').replace(/\"/g,   '&quot;').replace(/</g,   '&lt;').replace(/>/g,   '&gt;');
	   }
}
function QueryString(sName)   
  {   
  var   sSource   =   String(window.document.location);   
  var   sReturn   =   "";   
  var   sQUS   =   "?";   
  var   sAMP   =   "&";   
  var   sEQ   =   "=";   
  var   iPos;     
  iPos   =   sSource.indexOf(sQUS);   
  var   strQuery   =   sSource.substr(iPos,   sSource.length   -   iPos);   
  var   strLCQuery   =   strQuery.toLowerCase();   
  var   strLCName   =   sName.toLowerCase();    
  iPos   =   strLCQuery.indexOf(sQUS   +   strLCName   +   sEQ);   
  if   (iPos   ==   -1)   
  {   
  iPos   =   strLCQuery.indexOf(sAMP   +   strLCName   +   sEQ);   
  if   (iPos   ==   -1)   
  return   "";   
  }   
  sReturn   =   strQuery.substr(iPos   +   sName.length   +   2,strQuery.length-(iPos   +   sName.length   +   2));   
  var   iPosAMP   =   sReturn.indexOf(sAMP);    
  if   (iPosAMP   ==   -1)   
  return   sReturn;   
  else   
  {   
  sReturn   =   sReturn.substr(0,   iPosAMP);   
  }   
  return   sReturn;   
  }
function Flash(file, w, h)
{
	document.write("\r\n\
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + w + "' height='" + h + "'>\r\n\
	<param name='movie' value='" + file + "' />\r\n\
	<param name='wmode' value='Opaque' />\r\n\
	<param name='menu' value='true' />\r\n\
	<param name='quality' value='high' />\r\n\
	<param name='SCALE' value='noborder' /><param name=\"loop\" value=\"false\" />\r\n\
	<embed type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' loop='false' menu='true' quality='high' wmode='Opaque' src='" + file + "' width='" + w + "' height='" + h + "'  scale='noborder' loop=\"false\"></embed>\r\n\
</object>");
}
function FlashAp(file, w, h)
{
	document.write("\r\n\
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + w + "' height='" + h + "'>\r\n\
	<param name='movie' value='" + file + "' />\r\n\
	<param name='wmode' value='transparent' />\r\n\
	<param name='menu' value='true' />\r\n\
	<param name='quality' value='high' />\r\n\
	<param name='SCALE' value='noborder' /><param name=\"loop\" value=\"false\" />\r\n\
	<embed type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' loop='false' menu='true' quality='high' wmode='transparent' src='" + file + "' width='" + w + "' height='" + h + "'  scale='noborder' loop=\"false\"></embed>\r\n\
</object>");
}
function UBBImage(ImageID){
  if(ImageID.width>550){
  ImageID.width=550;
  ImageID.height=(ImageID.height*550)/ImageID.width;
  }
}
function SelectAll(obj){
var CkeckType=document.getElementsByName("SelectID");
for (i=0;i<CkeckType.length;i++){
CkeckType[i].checked=obj.checked;
}
}
//检查操作
function CheckSelect()
{
    var aspnetForm=document.getElementsByName("SelectID");
    var checked=false;
    if (aspnetForm != null)
    {
            for (i=0;i<aspnetForm.length;i++)
            {
                if(aspnetForm[i].checked == true)
                {
                    checked=true;
                }
            }
    }
    if (checked == false)
    {
        alert("请至少选择一项！");
        return false;
    }
    else
    {
        if (!confirm("你确认执行此操作？"))
        {
            return false;
        }
    }
    return true;
}
function BuySelect(){
    var aspnetForm=document.getElementsByName("SelectID");
    var checkID="0";
    if (aspnetForm != null)
    {
            for (i=0;i<aspnetForm.length;i++)
            {
                if(aspnetForm[i].checked == true)
                {
                    checkID+="|"+aspnetForm[i].value;
                }
            }
    }
	if(checkID=="0"){
		alert("请至少选择一项！");
	}else{
		OpenMiddle(""+RootSite+"Buy.aspx?GoodsArray="+checkID+"", "BuyThisProducts", '600', '500');
	}
}
function ckcode(){
   document.getElementById("ImageCode").src=""+RootSite+"Images/009.gif";
   document.getElementById("ImageCode").src=""+RootSite+"ShowCode.aspx?Rnd="+Math.random()+"";
}
function popCoverDiv(){
    var cover_div=ooj("cover_div");
    var bodySize=getBodySize();
    cover_div.style.left=(bodySize[0]/2-180)+'px';
    cover_div.style.display = "";
    if (IE) {
        cover_div.style.filter="Alpha(Opacity=70)";
    }else{
        cover_div.style.opacity=0.7;
    }
    cover_div.innerHTML="<img src=\""+RootSite+"images/indicator_medium.gif\" style=\"float:left;\">&nbsp;&nbsp;&nbsp;&nbsp;Update This Page Now...Please Loading...";
}
function getBodySize(){
   var bodySize = [];
   with(document.documentElement) {
    bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;
    bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;
   }
   return bodySize;
}
function OutView(){
    var cover_div=ooj("cover_div");
    cover_div.style.display = "none";
    cover_div.innerHTML="";
}
function Search(way,key){
    if(way=="SiteService"){
        window.open(""+RootSite+"Services.aspx?Key="+escape(key)+"");
    }else if(way=="Help"){
        window.open(""+RootSite+"Help.aspx?Key="+escape(key)+"");
    }else if(ComID==0){
        window.open(""+RootSite+"SiteNews.aspx?Key="+escape(key)+"");    
    }else{
	    window.open(""+RootSite+"SiteSearch.aspx?Trade=0&Country=0&Way="+way+"&Key="+escape(key)+"");
	}
}
