﻿// JScript 文件
function loadPage()
{
	var xhr = false;
	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
		if (xhr.overrideMimeType)
		{
			xhr.overrideMimeType('text/html');
		}
	}
	else if (window.ActiveXObject)
	{
		try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {}
			}
	}
	return xhr;
}

function showMobile(returnOBJ,DMValue,whereStatus)
{
    //debugger
    var xhr = loadPage();
    
	var qs = "";
	if (whereStatus=="1" || whereStatus=="2")
	{
	    qs="jsStation/BrandNameStation.aspx?DM="+DMValue+"&type=04&state="+whereStatus;
	    document.getElementById("hid_0").value="0";
	}
	else
	{
	    qs="jsStation/BrandNameStation1.aspx?DM="+DMValue+"&type=04&state="+whereStatus;
	    document.getElementById("hid_1").value="1";
	}
	
	
	
	var returnValue="";
	var reOBJ = document.getElementById(returnOBJ);
	reOBJ.innerHTML = "<img src=\"../image/r20066212549.gif\"><font style=\"font-size:12px;color:red\">正在引导数据,请稍候...</font>";
	if (xhr)
	{	
		xhr.open("GET", qs, true);
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr.onreadystatechange = function()
		{
			if (xhr.readyState == 4 && xhr.status == 200)
			{
				if(xhr.responseText.substring(0,3)=="-1-")//报错
				{
					alert(xhr.responseText.substring(4,xhr.responseText.length));
					if (whereStatus=="1" || whereStatus=="2")
					{
					    document.getElementById("nowPage").innerText="";
					    document.getElementById("allPage").innerText="";
					}
					else
					{
					    document.getElementById("nowPage1").innerText="";
					    document.getElementById("allPage1").innerText="";
					}
					reOBJ.innerHTML="";       
				}
				else if(xhr.responseText=="Null")
				{
					reOBJ.innerHTML = "";
					return;
				}
				else
				{
					var strReturn= xhr.responseText.split('_splitString_');
					if (whereStatus=="1" || whereStatus=="2")
					{
					    document.getElementById("nowPage").innerText="第 1 页";
					    document.getElementById("allPage").innerText="共 "+ strReturn[0] +" 页";
					}
					else
					{
					    document.getElementById("nowPage1").innerText="第 1 页";
					    document.getElementById("allPage1").innerText="共 "+ strReturn[0] +" 页";
					}
					
					reOBJ.innerHTML=strReturn[1];
				}
			}
		}
		xhr.send(null);
	}
}

function searchMobileGuide(returnOBJ,whereStatus)
{
	
	if (document.getElementById('ddlCXFS').value=="08" || document.getElementById('ddlCXFS').value=="09")
	{
	    document.getElementById("divzm").style.display="inline";
	}
	else
	{
	    document.getElementById("divzm").style.display="none";
	}
	
	var strCheck;
    if( whereStatus == "0" )
    {
        strCheck="|";
    }
    else if( whereStatus == "1" )
    {
        document.getElementById('ddlZMCX').value="";
        strCheck = document.getElementById('ddlCXFS').value+"|";
    }
    else if (whereStatus=="2")
    {
        strCheck = document.getElementById('ddlCXFS').value+";"+document.getElementById('ddlZMCX').value+"|";
    }
    else if (whereStatus=="3")
    {
        document.getElementById('ddlZMCX1').value="";
        strCheck = document.getElementById('ddlCXFS1').value+"|";
    }
     else if (whereStatus=="4")
    {
        strCheck = document.getElementById('ddlCXFS1').value+";"+document.getElementById('ddlZMCX1').value+"|";
    }
    else
    {   
		strCheck = document.getElementById('ddlCXFS').value+"|";
	}
	showMobile(returnOBJ,strCheck,whereStatus);
}

function movePrev(returnOBJ,page,hid)
{	
	var strPage=document.getElementById(page).innerText;
	if(strPage=="")
	{
		alert("对不起，请您选择查询方式！")
		return;
	}
	if(strPage.substring(2,strPage.length-2)=="1")
	{
		alert("对不起，当前已经是第一页！")
		return;
	}
    var xhr = loadPage();
    var qs="";
    var status=document.getElementById(hid).value;
    if (status=="0")
    {
        if (document.getElementById("ddlZMCX").value=="")
        {
            qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById('ddlCXFS').value
	+"|"+(parseInt(strPage.substring(2,strPage.length-2),10)-1) +"&type=02&state=1";
        }
        else
        {
            qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById('ddlCXFS').value+";"+document.getElementById('ddlZMCX').value
	+"|"+(parseInt(strPage.substring(2,strPage.length-2),10)-1) +"&type=02&state=1";
        }
        
    }
    else if (status=="1")
    {
        if (document.getElementById("ddlZMCX1").value=="")
        {
            qs="jsStation/BrandNameStation1.aspx?DM="+document.getElementById('ddlCXFS1').value
	+"|"+(parseInt(strPage.substring(2,strPage.length-2),10)-1) +"&type=02&state=3";
        }
        else
        {
            qs="jsStation/BrandNameStation1.aspx?DM="+document.getElementById('ddlCXFS1').value+";"+document.getElementById('ddlZMCX1').value
	+"|"+(parseInt(strPage.substring(2,strPage.length-2),10)-1) +"&type=02&state=3";
        }
        
    }
    else if (status=="3")
    {
        qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById('ddlSSFS').value+";"+document.getElementById('txtKW').value+"|"
        +(parseInt(strPage.substring(2,strPage.length-2),10)-1)+"&type=05&state=5";
    }
    else if (status=="4")
    {
        qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById('ddlSSFS1').value+";"+document.getElementById('txtKW1').value+"|"
        +(parseInt(strPage.substring(2,strPage.length-2),10)-1)+"&type=05&state=3";
    }
    
	
	var returnValue="";
	var reOBJ = document.getElementById(returnOBJ);
	reOBJ.innerHTML = "<img src=\"../image/r20066212549.gif\"><font style=\"font-size:12px;color:red\">正在引导数据,请稍候...</font>";
	if (xhr)
	{	
	    xhr.open("GET", qs, true);
	    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    xhr.onreadystatechange = function()
	    {
			if (xhr.readyState == 4 && xhr.status == 200)
			{
				document.getElementById(page).innerHTML="第 "+ (parseInt(strPage.substring(2,strPage.length-2))-1) +" 页";
				reOBJ.innerHTML=xhr.responseText;     
			}
		}
		xhr.send(null);
	}
}

function moveNext(returnOBJ,page,hid)
{	
	//debugger
	var strPage=document.getElementById(page).innerText;
	if(strPage=="")
	{
		alert("对不起，请您选择查询方式！")
		return;
	}
	
	var strAllPage="";
	var status=document.getElementById(hid).value;
	if (status=="0")
	{
	    strAllPage=document.getElementById("allPage").innerText;
	}
	else if (status=="3")
	{
	    strAllPage=document.getElementById("allPage2").innerText;
	}
	else
	{
	    strAllPage=document.getElementById("allPage1").innerText;
	}
	
	
	if(strPage.substring(2,strPage.length-2)==strAllPage.substring(2,strAllPage.length-2))
	{
		alert("对不起，当前已经是最后一页！")
		return;
	}
    var xhr = loadPage();
    var qs="";
    
    if (status=="0")
    {
        if (document.getElementById("ddlZMCX").value=="")
        {
            qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById('ddlCXFS').value+"|" 
	+(parseInt(strPage.substring(2,strPage.length-2),10)+1)+"&type=03&state=1";
        }
        else
        {
            qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById('ddlCXFS').value+";"+document.getElementById('ddlZMCX').value+"|" 
	+(parseInt(strPage.substring(2,strPage.length-2),10)+1)+"&type=03&state=1";
        }
        
    }
    else if (status=="1")
    {
        if (document.getElementById("ddlZMCX1").value=="")
        {
            qs="jsStation/BrandNameStation1.aspx?DM="+document.getElementById('ddlCXFS1').value+"|" 
	+(parseInt(strPage.substring(2,strPage.length-2),10)+1)+"&type=03&state=3";
        }
        else
        {
            qs="jsStation/BrandNameStation1.aspx?DM="+document.getElementById('ddlCXFS1').value+";"+document.getElementById('ddlZMCX1').value+"|" 
	+(parseInt(strPage.substring(2,strPage.length-2),10)+1)+"&type=03&state=3";
        }
        
    }
    else if (status=="3")
    {
        qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById('ddlSSFS').value+";"+document.getElementById('txtKW').value+"|"
        +(parseInt(strPage.substring(2,strPage.length-2),10)+1)+"&type=05&state=5";
    }
    else if (status=="4")
    {
        qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById('ddlSSFS1').value+";"+document.getElementById('txtKW1').value+"|"
        +(parseInt(strPage.substring(2,strPage.length-2),10)+1)+"&type=05&state=3";
    }
	
	var returnValue="";
	var reOBJ = document.getElementById(returnOBJ);
	reOBJ.innerHTML = "<img src=\"../image/r20066212549.gif\"><font style=\"font-size:12px;color:red\">正在引导数据,请稍候...</font>";
	if (xhr)
	{	
		xhr.open("GET", qs, true);
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr.onreadystatechange = function()
		{
			if (xhr.readyState == 4 && xhr.status == 200)
			{
				document.getElementById(page).innerHTML="第 "+ (parseInt(strPage.substring(2,strPage.length-2))+1) +" 页";
				reOBJ.innerHTML=xhr.responseText;   
				returnValue = xhr.responseText;     
			}
		}
		xhr.send(null);
    }  

}

function Searchmobile(returnOBJ,ddl,txt,whereStatus)
{
    
    if (document.getElementById(txt).value=="")
    {
        alert("对不起，请输入查询关键词！")
	    return;
    }
    var xhr = loadPage();
    if (whereStatus=="5")
    {
        document.getElementById("hid_2").value="3";
    }
   
    var qs="jsStation/BrandNameStation.aspx?DM="+document.getElementById(ddl).value+";"+document.getElementById(txt).value+"|"+"&type=05&state="+whereStatus;
    
    var returnValue="";
	var reOBJ = document.getElementById(returnOBJ);
	reOBJ.innerHTML = "<img src=\"../image/r20066212549.gif\"><font style=\"font-size:12px;color:red\">正在引导数据,请稍候...</font>";
	if (xhr)
	{	
		xhr.open("GET", qs, true);
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr.onreadystatechange = function()
		{
			if (xhr.readyState == 4 && xhr.status == 200)
			{
				if(xhr.responseText.substring(0,3)=="-1-")//报错
				{
					alert(xhr.responseText.substring(4,xhr.responseText.length));
					if (whereStatus=="1" || whereStatus=="2" || whereStatus=="5")
					{
					    document.getElementById("nowPage2").innerText="";
					    document.getElementById("allPage2").innerText="";
					    document.getElementById("PageButton").style.display="none";
					}
					else
					{
					    document.getElementById("nowPage1").innerText="";
					    document.getElementById("allPage1").innerText="";
					}
					reOBJ.innerHTML="";       
				}
				else if(xhr.responseText=="Null")
				{
					reOBJ.innerHTML = "";
					return;
				}
				else
				{
					var strReturn= xhr.responseText.split('_splitString_');
					if (whereStatus=="1" || whereStatus=="2" || whereStatus=="5")
					{
					    document.getElementById("nowPage2").innerText="第 1 页";
					    document.getElementById("allPage2").innerText="共 "+ strReturn[0] +" 页";
					    document.getElementById("PageButton").style.display="inline";
					}
					else
					{
					    document.getElementById("nowPage1").innerText="第 1 页";
					    document.getElementById("allPage1").innerText="共 "+ strReturn[0] +" 页";
					}
					
					reOBJ.innerHTML=strReturn[1];
				}
			}
		}
		xhr.send(null);
	}

}

function showLayer(DMValue)
{
    //debugger
    var tablestr="";
    tablestr="<table border=0 cellspacing=5 cellpadding=0>";
    tablestr+="<tr align=center>";
    for (var i=0;i<DMValue.split(';').length;i++)
    {
        tablestr+="<td><img width='80' height='54' src='../Mobile/img/"+DMValue.split(';')[i]+"' onerror='javascript:this.src=\"../Mobile/img/暂无图片.gif\"' /></td>";
    }
    tablestr+="</tr></table>";
    var vDiv=document.getElementById("divlayer");
    vDiv.style.backgroundColor="#e4f6ff";
    vDiv.style.borderColor="#5669e9";
    vDiv.style.borderWidth="1px";
    vDiv.style.borderStyle="solid";
    vDiv.style.display="";   
    vDiv.style.position="absolute";   
    vDiv.style.left=event.clientX+20;//'这里是位置,修改鼠标之间的距离   
    vDiv.style.top=event.clientY+document.body.scrollTop;//'修改鼠标之间的距离 
    
    vDiv.innerHTML=tablestr;  

    
    
}
function hideLayer()
{
    var vDiv=document.getElementById("divlayer");
    vDiv.style.display="none";
}
// 当选中手机品牌时，显示手机品牌的下拉列表框
function ddlChange(selectindex)
{
    if(selectindex==0)
    {
        document.getElementById("dSJPP").style.display="inline-block";
        document.getElementById("dSJPP").style.display="inline";
        document.getElementById("dKW").style.display="none";
        
    }
    else
    {
        document.getElementById("dSJPP").style.display="none";
        document.getElementById("dKW").style.display="inline-block";
        document.getElementById("dKW").style.display="inline";
    }
}

// 当手机品牌的下拉列表框选项变更时，将其值赋到txtKW里
function ddlPPChange(selectindex)
{
    var ddl=document.getElementById("ddlSJPP");
    var txt=document.getElementById("txtKW");
    txt.value=ddl.options[selectindex].innerText ;
}

//////////////////////////////////////////////MobileTitle.ascx


function selectDDL(ddlKey, ddlResult, type) {
    var xhr = loadPage();
    var result = document.getElementById(ddlResult);
    result.length = 0;
    result.add(new Option("正在检索......", 456), 0); //+"正在检索..."+"</option>";
    var qs = "../JavaScript/WebStation.aspx?DM=" + ddlKey + "&type=" + type + "&return=" + ddlResult;
    if (xhr) {
        xhr.open("GET", qs, true);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                result.outerHTML = xhr.responseText;
            }
        }
        xhr.send(null);
    }
}

function SearchNews(strDM) {
    var xhr = loadPage();
    var qs = "../JavaScript/WebStation.aspx?DM=" + document.getElementById('MobileTitle1_ddlFileType').value + "&type=15&swhere=" + document.getElementById('MobileTitle1_txtFile').value + "&pos=" + strDM;
    if (xhr) {
        xhr.open("GET", qs, true);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                window.open(xhr.responseText);

            }
        }
        xhr.send(null);
    }
}

function mobileSearch() {
    if (document.getElementById('MobileTitle1_ddlSCQY').value == "") {
        alert('请您选择企业名称！');
    }
    else if (document.getElementById('MobileTitle1_ddlSJXH').value == "") {
        alert('请您选择手机型号！');
    }
    else {
        var xhr = loadPage();
        var qs = "../JavaScript/WebStation.aspx?DM=" + document.getElementById('MobileTitle1_ddlSJXH').value
		+ "&type=31&SCQY=" + document.getElementById('MobileTitle1_ddlSCQY').value;
        qs = qs.replace(/\+/g, "%2B");

        if (xhr) {
            xhr.open("GET", qs, true);
            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    window.open("." + xhr.responseText);
                }
            }
            xhr.send(null);
        }
    }
}
//////////////////////////////////////////////////MobileTitle.ascx
