// JavaScript Document
//参考Ajax 与.Net 2.0 高级程序设计,小基 http://slzzp.cn[GO,GO,GO]
//Create Date:2008-04
//WebSite:www.chemp.net
//Author:H.Q.L
//请保留此申明，谢谢！
var xmlhttp = false;
///===============================================================
//创建一个xmlhttp对象,根据不同的浏览器而创建的
function GetHttpRequest(){
    try {
        //首先先尝试以前的遗留对象
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) {
        try {
            //尝试IE来实现生成xmlhttp
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (e) {
            xmlhttp = false;
        }
        if (!xmlhttp && typeof XmlHttpRequest != 'undefined') {
            //使用基于Mozilla的浏览器
            xmlhttp = new XmlHttpRequest();
        }
    }
}

//可以定义多个回调函数:
//定义一个回调函数,xmlHttpRequest处理进度,将返回的信息显示到div上
function callback(){
    var msg;
    switch (xmlhttp.readyState) {
        case 4:
            if (xmlhttp.status == 200) {
                msg = unescape(xmlhttp.responseText);
                //HQL添加进行对是否存在TagsId进行判断
                if (document.getElementById(TagsId)) {
                    document.getElementById(TagsId).innerHTML = msg;
                }
                
            }
            else {
                msg = "Error !" + xmlhttp.status;
            }
            break;
        default:
            //默认文字
            if (document.getElementById(TagsId)) {
                msg = document.getElementById(TagsId).innerHTML;
            }
            break;
    }
    if (document.getElementById(TagsId)) {
        document.getElementById(TagsId).innerHTML = msg;
    }
}

//2.第二个回调函数,返回msg
function callback_1(){
    var msg;
    switch (xmlhttp.readyState) {
        case 4:
            if (xmlhttp.status == 200) {
                msg = unescape(xmlhttp.responseText);
                //HQL添加进行对是否存在TagsId进行判断
                //if(document.getElementById(TagsId))
                //{
                document.getElementById(TagsId).innerHTML = msg;
            //}
            
            }
            else {
                msg = "Error !" + xmlhttp.status;
            }
            break;
        default:
            //默认文字
            //if (document.getElementById(TagsId))
            //{
            //msg="";
            msg = document.getElementById(TagsId).innerHTML;
            //}				
            break;
    }
    document.getElementById(TagsId).innerHTML = msg;
}

///===============================================================
//////////////////////////////////////////////////////////////////
//调用一个xmlHttpRequest事件
function getTextXmlData(url, key, mode, cb){
    //创建一个xmlhttp
    GetHttpRequest();
    xmlhttp.open(mode, url, true);
    xmlhttp.onreadystatechange = cb;
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(key);
}

function ajax(url, p, Tags, mode, cb){
    TagsId = Tags;
    getTextXmlData(url, p, mode, cb);
    
}

//////////////////////////////////////////////////////////////////
//显示隐藏层
function showHidDiv(divid){
    if (document.getElementById(divid).style.display == "none") {
        document.getElementById(divid).style.display = "block"
    }
    else {
        document.getElementById(divid).style.display = "none"
    }
}

//////////////////////////////////////////////////////////////////////////////////
//主程序.调用.主程序.调用.主程序.调用.主程序.调用.主程序.调用.
//////////////////////////////////////////////////////////////////////////////////
//0.关于跳转页面操作
function interval11(){
	var s = document.getElementById("timeout");
	if(s.innerHTML == 0){
		window.location.href=hostpath+"default.aspx";
		return false;
	}
	s.innerHTML = s.innerHTML * 1 - 1;
}
var duration=5000;
var timer=null;
var endTime = new Date().getTime() + duration + 100;
 function interval()
   {
          var n=(endTime-new Date().getTime())/1000;
          if(n<0) return;
          document.getElementById("timeout").innerHTML = n.toFixed(3);
          setTimeout(interval, 10);
   }
 function stopJump()
   {
          clearTimeout(timer);
          document.getElementById("jumphint").style.display = "none";
   }

//1.静态页面的权限访问 08.6.12
function htmLimit_old(url, p, Tags, mode, HidTags){
    //ajax(url, p, Tags, mode, callback);
    //alert(document.getElementById(TagsId).innerHTML);
    /*if(document.getElementById(Tags).innerHTML=="ok")
    {
      document.getElementById(HidTags).style.display = "block";
    }
    else
    {
    document.write(document.getElementById(Tags).innerHTML);
     //document.getElementById(HidTags).style.display = "none";
     // _confirm_msg_show("网页打开中...","","","","");
     document.write("<div style='background-image:url('images/dd.jpg');'><li>很抱歉,此信息只有钻石会员才能查看！</li><li>如果您是VIP会员, 请先<a href='/user/login.aspx'>登陆</a></li><li><span id='jumphint'>系统在 <span id='timeout'>5.000</span> 秒后 将自动</span>跳转到 <a href='default.aspx'>首页</a></li></div>");  
     timer=setTimeout("window.location.href='default.aspx'", duration);
     interval();
     }*/
    
}
function htmLimit(Name,HidTags)
{
   var msg;
   msg =getCookie(Name);
   if (msg == '1') {
          document.getElementById(HidTags).style.display = "block";
    }
    else {
     //document.write(document.getElementById(Tags).innerHTML);
     //document.getElementById(HidTags).style.display = "none";
     // _confirm_msg_show("网页打开中...","","","","");
     document.write("<div style='background-image:url('"+hostpath+"images/dd.jpg');'><li>很抱歉,此信息只有钻石会员才能查看！</li><li>如果您是VIP会员, 请先<a href='"+hostpath+"user/mem_login.aspx'>登陆</a></li><li><span id='jumphint'>系统在 <span id='timeout'>5.000</span> 秒后 将自动</span>跳转到 <a href='"+hostpath+"index.aspx'>首页</a></li></div>");  
     timer=setTimeout("window.location.href='"+hostpath+"default.aspx'", duration);
     interval();
    }
}

//2.对于供应具体页中的VIP会员不显示提交留言的用户名,联系方式,而非VIP会员则显示
function pageDetailShowDiv(Name,HidTags){
    var msg;
	//读取cookie
    if (Name=='user_id')
   {
     Name="chemp_user_id";
   }
    msg = getCookie(Name);
    //对Asny返回值进行判断
    if (msg != '0') {
        document.getElementById(HidTags).style.display = "none";
    }
    else {
		document.getElementById(HidTags).style.display = "block";
    }
}

//3.对于供应具体页中提交留言的操作,Asny提交
function tradeDetailSendMsg(url,p,Tags,mode){
	alert("dfdas");
}

//4.以下实现对cookies的操作
//function setCookie(name, value){
//    expires = new Date();
//    expires.setTime(expires.getTime() + (86400 * 365));
//    document.cookie = name + "=" + value + "; expires=" + expires.toGMTString() + "; path=/";
//}

//function getCookie(Name){
//    var search = Name + "="
//    if (document.cookie.length > 0) { // if there are any cookies
//        offset = document.cookie.indexOf(search)
//        if (offset != -1) { // if cookie exists 
//            offset += search.length
//            end = document.cookie.indexOf(";", offset)
//            if (end == -1) 
//                end = document.cookie.length
//            return unescape(document.cookie.substring(offset, end))
//        }
//    }
//    return 0;
//}

/////////////////////////////////////////////////////////////////////
// JScript 文件
function responajax(id,vl,url){
GetHttpRequest();
if(xmlhttp)
{
//alert(vl);
var sendurl;
sendurl=url + "?" + id + "=" + vl+"&refresh="+ Math.random();
xmlhttp.open("GET",sendurl,true);
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
  var fh;
  fh=xmlhttp.responseText;
  //alert(fh);
  checkvalue(id,fh);
 }
 else{
 alert("status="+xmlhttp.status);
 }
 }
 }
xmlhttp.send(null);
}  
}
		
function checkvalue(id,fh){
if(fh=="0"){
 document.getElementById(id + "_info").innerHTML="<img src='images/err.gif'/><span class='red1'>该会员名已经存在</span>";
 rtn[0]=0;
 }
 else if(fh=="1"){
 document.getElementById(id + "_info").innerHTML="<img src='images/right.gif'/>恭喜您，该会员名可以注册！";
 rtn[0]=1;
 }
 else if(fh=="NO"){
 document.getElementById(id + "_info").innerHTML="<img src='images/err.gif'/><span class='red1'>对不起，该公司名称已经注册，如有疑问，请拨打：021-51699521咨询</span>";
 rtn[1]=0;
 }
 else if(fh=="YES"){
 document.getElementById(id + "_info").innerHTML="<img src='images/right.gif'/>恭喜您，该公司名称可以注册！";
 rtn[1]=1;
 }
 ///////////////////////用于企业商铺的风格设计//////////////////////////////
  else if(fh=="fengge")
  {
  
alert("设计风格－－主题图片上的内容设置成功！");
 }
///////////////////////企业商铺的风格设计结束//////////////////////////////
 
 
 
}


