﻿// JScript 文件

function addfavorite()
{
 
   if (document.all)
   { 
      window.external.addFavorite('http://www.gzczwx.com','蒋武个人维修服务中心');
     
   }
   else if (window.sidebar)
   {
      window.sidebar.addPanel('蒋武个人维修服务中心', 'http://www.gzczwx.com', "");
   }
} 
  
         
       
function homepage(a)
{
     var url='http://www.gzczwx.com';
      
     a.style.behavior='url(#default#homepage)';a.setHomePage(url);return(false);
}

var flag=false; 
function DrawImage(ImgD,h,w){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
flag=true; 
if(image.width/image.height>= w/h){ 
if(image.width>w){ 
ImgD.width=w; 
ImgD.height=(image.height*w)/image.width; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
 
} 
else{ 
if(image.height>h){ 
ImgD.height=h; 
ImgD.width=(image.width*h)/image.height; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
 
} 
} 
} 

 
 function getarg()
            {
            var url = unescape(window.location.href);
            var allargs = url.split("?")[1];
            var args = allargs.split("&");
            for(var i=0; i<args.length; i++)
            {
            var arg = args[i].split("=");
            eval('this.'+arg[0]+'="'+arg[1]+'";');
            }
            } 
            
var lang = new Array();
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function $(id) {
	return document.getElementById(id);
}

  
function getCookie(name){
      var strCookie=document.cookie;
      var arrCookie=strCookie.split("; ");
      for(var i=0;i<arrCookie.length;i++){
            var arr=arrCookie[i].split("=");
            if(arr[0]==name)return arr[1];
      }
      return "";
}

function setCookie(name,value,expireHours){
      var cookieString=name+"="+escape(value);
      //判断是否设置过期时间
      if(expireHours>0){
             var date=new Date();
             date.setTime(date.getTime+expireHours*3600*1000);
             cookieString=cookieString+"; expire="+date.toGMTString();
      }
      document.cookie=cookieString;
}
 
 


function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}


function mb_strlen(str) {
	var len = 0;
	for(var i = 0; i < str.length; i++) {
		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1;
	}
	return len;
}
var xmlHttp;

 function createXMLHttpRequest() {
		var request = false;
		if(window.XMLHttpRequest) {
			request = new XMLHttpRequest();
			if(request.overrideMimeType) {
				request.overrideMimeType('text/xml');
			}
		} else if(window.ActiveXObject) {
			var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
			for(var i=0; i<versions.length; i++) {
				try {
					request = new ActiveXObject(versions[i]);
					if(request) {
						return request;
					}
				} catch(e) {}
			}
		}
		return request;
	}




var url="";

function MsghandleStateChange(){
var img = "<div align='left' style='padding-top:80px;padding-left:50px'><img src='images/loading.gif' ><br/>正在获取数据...</div>";
  
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成

    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
    
     $("msgInfo").innerHTML = result;
    }
}
else 
{
document.getElementById("msgInfo").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}

function getMsg(page)
{  
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = MsghandleStateChange; 
     
    xmlHttp.open("GET","AjaxRequest/getMsg.aspx?p="+page+"&ran="+Math.random()+"");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 






function handleStateChange(){
var img = "<div align='left' style='padding-top:80px;padding-left:50px'><img src='images/loading.gif' ><br/>正在获取数据...</div>";
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
    
     $("newslist").innerHTML = result;
    }
}
else 
{
document.getElementById("newslist").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}

function getNews(page)
{  
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange; 
    var nt_id=getCookie("nt_id");
    xmlHttp.open("GET","AjaxRequest/getNews.aspx?p="+page+"&t="+nt_id+"&ran="+Math.random()+"");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 



function handleStateChange1(){
var img = "<div align='left' style='padding-top:80px;padding-left:50px'><img src='../../images/loading.gif' ><br/>正在获取数据...</div>";
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
    
     $("newslist").innerHTML = result;
    }
}
else 
{
document.getElementById("newslist").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}

function getNews1(page)
{  
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange1; 
    
    var nt_id=getCookie("nt_id");
     
    xmlHttp.open("GET","../../AjaxRequest/getNews.aspx?p="+page+"&t="+nt_id+"&tag=1&ran="+Math.random()+"");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 
 


function handleStateChangeNewsType(){
var img = "<div align='left' >正在获取数据...</div>";
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
     $("typelist").innerHTML = result;
    }
}
else 
{
document.getElementById("typelist").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}

function getNewsType()
{  
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChangeNewsType; 
    xmlHttp.open("GET","../../AjaxRequest/getNewsType.aspx");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 





function getInitAbout()
{
try{
var urlarg=new getarg();
  
 if(urlarg.tag!=""&&typeof(urlarg)!="undefined")
     {
       getAboutInfo(urlarg.tag);
     }
}
catch(e){

}
}

//关于我们
function abouthandleStateChange(){
var img = "<div align='left' style='padding-top:80px;padding-left:50px'><img src='../../images/loading.gif' ><br/>正在获取数据...</div>";
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
    
     $("content").innerHTML = result;
    }
}
else 
{
document.getElementById("content").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}

function getAboutInfo(id)
{  
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = abouthandleStateChange; 
    xmlHttp.open("GET","AjaxRequest/getAbout.aspx?id="+id+"&ran="+Math.random()+"");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 
 




//招聘信息
function jobhandleStateChange(){
var img = "<div align='left' style='padding-top:80px;padding-left:50px'><img src='../../images/loading.gif' ><br/>正在获取数据...</div>";
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
    
     $("content").innerHTML = result;
     
    }
}
else 
{
document.getElementById("content").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}

function getJobInfo(id)
{ 
    xmlHttp=createXMLHttpRequest();
    
    xmlHttp.onreadystatechange = jobhandleStateChange; 
    xmlHttp.open("GET","AjaxRequest/getJob.aspx?id="+id+"&ran="+Math.random()+"");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 
 





function handleStateChangeProType(){
var img = "<div align='left' >正在获取数据...</div>";
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
     $("typelist").innerHTML = result;
    }
}
else 
{
document.getElementById("typelist").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}

function getProType()
{  
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChangeProType; 
    xmlHttp.open("GET","../../AjaxRequest/getProType.aspx");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 


function handleStateChangePro(){
var img = "<div align='left' style='padding-top:80px;padding-left:50px'><img src='images/loading.gif' ><br/>正在获取数据...</div>";
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
    
     $("prolist").innerHTML = result;
    }
}
else 
{
document.getElementById("prolist").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}
function getInitPro()
{
try{
var urlarg=new getarg();
 
 if(urlarg.t!=""&&typeof(urlarg)!="undefined")
     {
        setCookie('pt_id',urlarg.t,0);
        getPro(0);
     }
}
catch(e){

}
}
function getPro(page)
{  
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChangePro; 
    
    var pt_id=getCookie("pt_id");
     
    xmlHttp.open("GET","AjaxRequest/getPro.aspx?p="+page+"&t="+pt_id+"&ran="+Math.random()+"");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 



function handleStateChangePro1(){
var img = "<div align='left' style='padding-top:80px;padding-left:50px'><img src='../../images/loading.gif' ><br/>正在获取数据...</div>";
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
    
     $("prolist").innerHTML = result;
    }
}
else 
{
document.getElementById("prolist").innerHTML = img;
}
//若响应未完成的话，则显示loading..
}

function getPro1(page)
{  
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChangePro1; 
    
    var pt_id=getCookie("pt_id");
     
    xmlHttp.open("GET","../../AjaxRequest/getPro.aspx?p="+page+"&t="+pt_id+"&tag=1&ran="+Math.random()+"");    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(null); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
} 



function sendMsghandleStateChange(){
 
   
if(xmlHttp.readyState == 4)
{ //表示请求状态 4为完成
  
    if(xmlHttp.status == 200){ //http状态指示码，200表示ok
    //将服务器返回信息作为文本插入到DIV容器中。
     var result= xmlHttp.responseText; 
    
     if(result=="true")
     {
     $("txt_title").value="";
     $("txt_user").value="";
     $("txt_tel").value="";
     $("txt_qq").value="";
     $("txt_content").value="";
     $("sendBtn").disabled="";
     $("sending_div").style.display="none";
     $("msg_div").style.display="";
    // getMsg(0);
       alert("留言成功.");
     }
     else{
       $("sendBtn").disabled="";
       $("sending_div").style.display="none";
       $("msg_div").style.display="";
       alert("发送失败,请检查网络..");
      }
      
    }
}
else 
{
 
}
//若响应未完成的话，则显示loading..
}
  String.prototype.Trim = function() {  
var m = this.match(/^\s*(\S+(\s+\S+)*)\s*/);  
return (m == null) ? "" : m[1];  
} 
function sendMsg()
{
var domDoc = CreateDomDoc(); //创建对象 将用send发送到服务器端
 var c="";
     if(domDoc!=null)
     {
            var xml = CreateXml(domDoc); //写入xml 返回xml文档
     }

     else
     {
            alert("未安装MSXML控件,您输入的留言内容将截取300个字符.推荐使用IE浏览器");
            c=$("txt_content").value.substring(0,300);
            
     }

   
    var t=$("txt_title").value.Trim();
    var u=$("txt_user").value.Trim();
    var tel=$("txt_tel").value.Trim();
    var q=$("txt_qq").value.Trim();
    if(t=="")
    {
    alert("请输入地址");
    $("txt_title").focus();
    return false;
    }
     else if($("txt_user").value.Trim()=="")
    {
    alert("请输入姓名");
     $("txt_user").focus();
    return false;
    }
    else if($("txt_content").value.Trim()=="")
    {
    alert("请输入内容");
     $("txt_content").focus();
    return false;
    }
    else{
    //var c="";//$("txt_content").value;
     $("sending_div").style.display="";
    $("msg_div").style.display="none";
    $("sendBtn").disabled="disabled";
    t=encodeURI(t);
    u=encodeURI(u);
    tel=encodeURI(tel);
    q=encodeURI(q);
    c=encodeURI(c);
    xmlHttp=createXMLHttpRequest();
    xmlHttp.onreadystatechange = sendMsghandleStateChange; 
    xmlHttp.open("GET","AjaxRequest/sendMsg.aspx?t="+t+"&u="+u+"&tel="+tel+"&q="+q+"&c="+c);    
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); //关键,否则出错
    xmlHttp.send(domDoc); //发送一定是domDoc文档对象,如果只发送xml将出错”statue=500” 
    }
} 

   function CreateDomDoc()   //创建XML文档对象
{

var signatures = ["Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","Msxml2.DOMDocument.3.0","Msxml2.DOMDocument","Microsoft.XmlDom"];

  for(var i=0;i<signatures.length;i++)
    {
           try
           {
                  var domDoc = new ActiveXObject(signatures[i]);

                  return domDoc;
           }

           catch(e)
           {
           }
    }
    return null;
}

function CreateXml(doc)
{
var root= doc.createElement("root");
       var content= doc.createElement("content");
      // var Code= doc.createElement("Code");
      
       content.text=$("txt_content").value;
      
       //Code.text= document.getElementById('_ctl0'+msgcontrol+'_TextBox1').value;
     //  root.appendChild(Code);
       root.appendChild(content);
       doc.appendChild(root);
       return doc.xml;

}
 