﻿// JScript File

	///查询
	function topsearch(typeobjname,searchobjname,webname)
	{
		var name=document.getElementById(searchobjname).value;
		var typeselect=document.getElementById(typeobjname)
		var url=''
		switch( typeselect.innerText)
		{
			case "0":
				if(name=='')
				{
				    url=webname+"/web/ProductType.html"
				}else 
				{
				    url=webname+"/ProductIndexII.aspx?Name="+name+""
				}
				//==========
				if(url!='')
				{
				    WinLocation(url)	
				}	
			break;
			case "1":
				if(name=='')
				{
				    url=webname+"/web/shoptype.html"
				 }
				 else
				 {
                    url=webname+"/CompanyIndex.aspx?Name="+name+""				 
				 }
				//==========
				if(url!='')
				{
				    WinLocation(url)	
				}
			break;
	        case "2":
	            url=webname+"/NewsIndex.aspx?Name="+name+""
	            if(name!='')
	            {
	                 WinLocation(url)
	            }
	        break;
	        case "3":
	            url=webname+"/DeviceIndex.aspx?Name="+name+""
	            if(name!='')
	            {
	                 WinLocation(url)
	            }
	        break;
	        case "4":
	            url=webname+"/MovieIndex.aspx?Name="+name+""
	            if(name!='')
	            {
	                 WinLocation(url)
	            }
	        break;
	        case "5":
	            url=webname+"/BBSIndex.aspx?Name="+name+""
	            if(name!='')
	            {
	                 WinLocation(url)
	            }
	        break;
			default:
				alert('测试中')
			break;
		}
	}
		
	
	function topsearchProduct(typeobjname,searchobjname,webname)
	{
	   var typeselect=document.getElementById(typeobjname)
	   var name=document.getElementById(searchobjname).value;
	   var url="";
		switch( typeselect.options[typeselect.selectedIndex].value)
		{
			case "1":
	           
	            url=webname+"/ProductIndexII.aspx?Name="+name+""
	            if(name!='')
	            {
	                 WinLocation(url)
	            }
	            break;
	        case "2":
	            url=webname+"/CompanyIndex.aspx?Name="+name+""
	            if(name!='')
	            {
	                 WinLocation(url)
	            }
	        break;
			default:
				alert('测试中')
	    }
	}
	
	
	
	//窗口转向
	function WinLocation(url)
	{
		window.location.href=url
	}
	
	//检查登陆状态
	function CheckCookies(webname)
	{
		//user = decodeURIComponent (user); //处理编码问题
		var userID=ReadCookies("UserID")
		if(userID!=null)
		{
		    var user=ReadCookies("User")
		    document.getElementById("RegDiv").style.display="none";
		    document.getElementById("UserDiv").style.display="";
		    
			var htmlstr="<a style='color:#424242;'>"+user+"</a>";
			htmlstr+="&nbsp;&nbsp;<a href='"+webname+"/Main.aspx'  style='color:red;' >[&nbsp;后台管理&nbsp;]</a>";
			
			document.getElementById("UserIDDiv").innerHTML=htmlstr;	
		}	
		else
		{
		    document.getElementById("RegDiv").style.display="";
		    document.getElementById("UserDiv").style.display="none";	
		}
	    setTimeout('CheckCookies("'+webname+'");',10000); 
	}
	
	
	//分享
    function ShareCopyText(type)
    {
        var thistext=window.location.href.toString();
        //var thistitle = document.title;

        if(type==1)
        {
            
            var _t = encodeURI(document.title);
            var _url = encodeURI(document.location);
            var _appkey = encodeURI("appkey");//你从腾讯获得的appkey
            
            var _sharepic ="";
            if(document.getElementById("sharePhotoDiv")!=null)
            {
                 _sharepic = document.getElementById("sharePhotoDiv").innerText;
            }
            var _pic = encodeURI(_sharepic);//（列如：var _pic='图片url1|图片url2|图片url3....）
            var _site = 'http://ctwen.com';//你的网站地址
            var _u = 'http://v.t.qq.com/share/share.php?title='+_t+'&url='+_url+'&appkey='+_appkey+'&site='+_site+'&pic='+_pic;
            window.open(_u)
            
        }
        if(type==2)
        {
            window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+thistext+'')
        }
        if(type==3)
        {
             window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(document.title.substring(0,76))+'&amp;rurl='+encodeURIComponent(location.href)+'&amp;rcontent=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes')
        }
        if(type==4)
        {
            window.open('http://share.renren.com/share/buttonshare.do?link='+thistext+'')
        }
        if(type==5)
        {
             var _sharepic ="";
            if(document.getElementById("sharePhotoDiv")!=null)
            {
                 _sharepic = document.getElementById("sharePhotoDiv").innerText.replace('\\','/');
            }
            var _pic = encodeURI(_sharepic);
            window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)+'&pic='+_pic+'','_blank','width=450,height=400');
        }
    }
    
    
  
    //===========================================================================================
    //===========================================================================================
    //===========================================================================================
    
    function createHTTP()
    {
        //根据不同的游览器创建XMLHttpRequest 
        if(window.ActiveXObject)
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") ;
        }
        else if(window.XMLHttpRequest)
        {
            xmlhttp = new XMLHttpRequest() ;
        }
    }

    //开始调用
    function Http_ShopTopStart()
    {
        createHTTP() ; 
        xmlhttp.onreadystatechange = Http_ShopTopFinish ;
        var RadomDate=new  Date()
        xmlhttp.open("GET","/xml/ShopTopAD.xml",false)
        xmlhttp.setRequestHeader("If-Modified-Since","0");
        xmlhttp.send() ;
    }
    
    
    function Http_ShopTopFinish()
    {
        if(xmlhttp.readystate == 4)
        {
            //判断是否执行成功
            if(xmlhttp.status == 200)
            {
                //更新数据;
                var xml = xmlhttp.responseXML;
                var items = xml.getElementsByTagName("CTWEN");
                var cContent = items[0].childNodes[1].text;
                
                if(cContent!="")
                {
                    document.getElementById("CTWENTopADDiv").style.display="";
                    document.getElementById("CTWENTopADDiv").innerHTML=cContent;	
                }
                else
                {
 
                    document.getElementById("CTWENTopADDiv").style.display="none";
                }

            }
        }
    }
    

    //===========================================================================================
    //===========================================================================================
    //===========================================================================================
    //开始调用
    function Http_ADRightStart()
    {
    
        createHTTP() ; 
        xmlhttp.onreadystatechange = Http_ADRightFinish ;
        var RadomDate=new  Date()
        xmlhttp.open("GET","/xml/ShopRightAD.xml",false)
        xmlhttp.setRequestHeader("If-Modified-Since","0");
        xmlhttp.send() ;
       
    }
    
    
    function Http_ADRightFinish()
    {
        if(xmlhttp.readystate == 4)
        {
          
            //判断是否执行成功
            if(xmlhttp.status == 200)
            {
                //更新数据;
                var xml = xmlhttp.responseXML;
                var items = xml.getElementsByTagName("CTWEN");
                var cContent = items[0].childNodes[1].text;
                
                if(cContent!="")
                {
                    document.getElementById("CTWENRightADDiv").style.display="";
                    document.getElementById("CTWENRightADDiv").innerHTML=cContent;	
                }
                else
                {
 
                    document.getElementById("CTWENRightADDiv").style.display="none";
                }

            }
        }
    }
    

