﻿var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadstatustext="<img src='/AjaxSend/ajaxtabs/loading.gif' /> Requesting content..."

////NO NEED TO EDIT BELOW////////////////////////
var loadedobjects=""
var defaultcontentarray=new Object()
var bustcacheparameter=""
function getAjaxContent(url,callbackFunc,containerId)
{
ajaxpage(url,containerId,callbackFunc);
}
function ajaxpage(url, containerid, callbackFunc){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false

//document.getElementById(containerid).innerHTML=loadstatustext
   if(containerid != null && document.getElementById(containerid)) 
   { 
        page_request.onreadystatechange=function(){
        loadpage(page_request, containerid)
        }
    }
    else if(callbackFunc)
   {
        page_request.onreadystatechange = function()
       {
            if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
            {
                try
               {  
                    var _strResult = page_request.responseText;
                    callbackFunc(_strResult);
                   // eval(callbackFunc + "(\"" + _strResult +  "\");"); 
               }catch(e){} 
            } 
       } 
   }

if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()

page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
{

document.getElementById(containerid).innerHTML=page_request.responseText;

}
startajaxtabs();
}


function expandtab(tabcontentid, tabnumber){ 
var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel")){
ajaxpage(thetab.getAttribute("href"), thetab.getAttribute("rel"), thetab)
}
}

function startajaxtabs(){
;var ulist=document.getElementsByTagName("a") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x]

if (ulistlink.getAttribute("rel")){

//var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
//ulistlink.setAttribute("href", modifiedurl) //replace URL's root domain with dynamic root domain, for ajax security sake
ulistlink.onclick=function(){
ajaxpage(this.getAttribute("href"), this.getAttribute("rel"), this)
return false
}
if (ulist[x].className=="selected"){
ajaxpage(ulistlink.getAttribute("href"), ulistlink.getAttribute("rel"), ulistlink) 
}
}
}
}

function loginWindowShow()
{
    getAjaxContent("/ajaxResponse/LoginWindow.aspx","","LoginWindowDiv");
}
function ClearWindowShow()
{
    if(document.getElementById('LoginWindowDiv')!=null)
    {
    document.getElementById('LoginWindowDiv').innerHTML="";
    }
}

function SelectCityList()
{
    getAjaxContent("/ajaxResponse/selectCityList.aspx","","sel_city_lay");
    if(document.getElementById('sel_city_lay')!=null)
    {
     document.getElementById('sel_city_lay').style.display="block";
     }
}
function ClearSelectCityList()
{
    if(document.getElementById('sel_city_lay')!=null)
    {
    document.getElementById('sel_city_lay').innerHTML="";
    document.getElementById('sel_city_lay').style.display="none";
    }
}
function SelectCategory(id)
{
  getAjaxContent("/ajaxResponse/selectCategory.aspx?i="+id,"","SelectCategoryDiv");
}
function ClearCategoryShow()
{
    if(document.getElementById('SelectCategoryDiv')!=null)
    {
    document.getElementById('SelectCategoryDiv').innerHTML="";
    }
}
function SetCurrentAreaValue()
{
    var shiValue=getValue("ddlCity");
    var shengValue=getValue("ddlSheng");
    	getAjaxContent("/ajaxResponse/setAreaValue.aspx?s="+shengValue+"&c=" + shiValue,onSetAreaFinish,null);
}
function onSetAreaFinish(ajaxResult)
{
	if(ajaxResult == "Err")
		alert("设置失败!")
	else if(ajaxResult == "OK")
		  window.location.href=window.location.href;

}
function SetCurrentCategoryValue()
{
    var divValue2=getValue("ddlCategoryBShow");
    var divValue1=getValue("ddlCategoryAShow");
    if(divValue2=="")
        divValue2=divValue1;
   var webUrl=window.location.href;
    if( webUrl.indexOf("&")>0)
      webUrl=webUrl.substr(0,webUrl.indexOf("&"));
    else
      {
       if( webUrl.indexOf("y")>0)
         webUrl=webUrl.substr(0,webUrl.indexOf("y")-1);
      }
    if(divValue2!="")
    {
       if(webUrl.indexOf("?")>0) 
        window.location.href=webUrl+"&y="+divValue2;
       else
       window.location.href=webUrl+"?y="+divValue2;
    }
    else
       window.location.href=webUrl;
}

//new
function ShowAccountManage(id)
{
formNum=0;
  getAjaxContent("/account/ShowAccountManage.aspx?i="+id,"","accountAddDiv");
}
function ClearSystemManage(id)
{
    if(document.getElementById(id)!=null)
    {
    document.getElementById(id).innerHTML="";
    }
    if(formNum>0)
    window.location.href=window.location.href
}
var formNum=0;
function SystemFormSubmit(TheFormID)
{
    formNum=1;
     var FormNoID = document.getElementById(TheFormID);	     
 		    if (FormNoID != null)
                 FormNoID.submit();
}
function StatViewNum(id){
  getAjaxContent("/GuangGao/StatViewNumManage.aspx?i="+id,"","");
}