﻿// JavaScript Document
var Absoulteurl = '';
if(typeof(MAGAZINE_LINK)!='undefined'){
	Absoulteurl = MAGAZINE_LINK;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) {
    if (obj.style) {obj=obj.style;}
	v=args[i+2];
	if(v){v=(v=='show')?'visible':(v=='hide')?'hidden':v;}
	else {v=obj.visibility; v=(v=='hidden')?'visible':(v=='visible')?'hidden':v;}
    obj.visibility=v; }
}

function doselectAll(theBox){
  	xState=theBox.checked;
  	elm=theBox.form.elements;
  	for(i=0;i<elm.length;i++) {
   		if(elm[i].type=="checkbox") {
			elm[i].checked=xState;
		}
	}    
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' 必须是一个EMAIL地址.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' 必须包含一个数字.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' 必须在数字 '+min+' 和 '+max+'之间.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' 是必填的.\n'; }
  } if (errors) alert('有以下错误发生:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + value + expire;
}

// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function switchTab(tabid,flag)
{
 	if(flag!=true) clearTimeout(jingpin);
    var obj;
    var obj2;
	for(i=1; i <=5; i++)
	{
		obj=document.getElementById("navtab_"+i);
		obj2=document.getElementById("tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhover";
		     if (obj2!=null){
				// if(document.getElementById("tabcontent"+i).innerHTML=='' || document.getElementById("tabcontent"+i).innerHTML=='<div style=\"padding:20px; text-align:center\">数据加载中...</div>'){
			 		 //document.getElementById("tabcontent"+switch_jingpin_now).style.filter = "alpha(opacity=50)";
					 document.getElementById("tabcontent"+i).innerHTML='<div style=\"padding:20px; text-align:center\">数据加载中...</div>';
					 ajax_get('index_area.asp?lx=jp&typeid='+i,'tabcontent'+i);	
					 //ajax_get('index_area_link.php?id='+i,'index_area_link');
				 //}
				//document.getElementById("tabcontent"+switch_jingpin_now).style.filter = "";
				obj2.style.display='block';
			 }
		   }
		   else
		   {
   		     obj.className="normal";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
	switch_jingpin_now = tabid;
}

/*function daodu_switchTab(tabid,flag)
{
	if(flag!=true) clearTimeout(daodu);
    var obj;
    var obj2;
	for(i=1; i <=10; i++)
	{
		obj=document.getElementById("nav_daodu_tab_"+i);
		obj2=document.getElementById("daodu_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhover";
		     if (obj2!=null){
		       	//if(document.getElementById("daodu_tabcontent"+i).innerHTML=='' ||document.getElementById("daodu_tabcontent"+i).innerHTML=='<div style=\"padding:20px; text-align:center\">数据加载中...</div>'){
					document.getElementById("daodu_tabcontent"+i).innerHTML='<div style=\"padding:20px; text-align:center\">数据加载中...</div>';
					ajax_get('index_area.php?mod=dd&typeid='+i,'daodu_tabcontent'+i);	 
				//}
			    obj2.style.display='block';
			 }
		   }
		   else
		   {
   		     obj.className="normal";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}

function zuixin_switchTab(tabid,flag)
{
	if(flag!=true) clearTimeout(zuixin);
    var obj;
    var obj2;
	for(i=1; i <=5; i++)
	{
		obj=document.getElementById("nav_zuixin_tab_"+i);
		obj2=document.getElementById("zuixin_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhoverright";
		     if (obj2!=null){
				if(document.getElementById("zuixin_tabcontent"+i).innerHTML=='' || document.getElementById("zuixin_tabcontent"+i).innerHTML=='<div style=\"padding:20px; text-align:center\">数据加载中...</div>'){
					document.getElementById("zuixin_tabcontent"+i).innerHTML='<div style=\"padding:20px; text-align:center\">数据加载中...</div>';
					ajax_get('index_area.php?mod=zx&typeid='+i,'zuixin_tabcontent'+i);	 
				} 
		        obj2.style.display='block';
			 }
		   }
		   else
		   {
   		     obj.className="normalright";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}



function tuijian_switchTab(tabid)
{
    var obj;
    var obj2;
	for(i=1; i <=4; i++)
	{
		obj=document.getElementById("nav_tuijian_tab_"+i);
		obj2=document.getElementById("tuijian_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="tuijian_nav_on";
		     if (obj2!=null)
		        obj2.style.display='block';
		   }
		   else
		   {
   		     obj.className="tuijian_nav";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}*/
function down_switchTab(tabid)
{
    var obj;
    var obj2;
	for(i=1; i <=2; i++)
	{
		obj=document.getElementById("nav_down_tab_"+i);
		obj2=document.getElementById("down_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhoverright";
		     if (obj2!=null)
				obj2.style.display='block';
		   }
		   else
		   {
   		     obj.className="normalright";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}
function hot_switchTab(tabid,flag)
{
	if(flag!=true) clearTimeout(rexiao);
    var obj;
    var obj2;
	for(i=1; i <=5; i++)
	{
		obj=document.getElementById("nav_hot_tab_"+i);
		obj2=document.getElementById("hot_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhoverright";
		     if (obj2!=null){
		        
					document.getElementById("hot_tabcontent"+i).innerHTML='<div style=\"padding:20px; text-align:center\">数据加载中...</div>';
					
					ajax_get('index_area.asp?lx=hot&typeid='+i,'hot_tabcontent'+i);	 
				
				obj2.style.display='block';
			 }
		   }
		   else
		   {
   		     obj.className="normalright";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}

function confirm_redirect(url,text)
{
	if (confirm(text)) {
			window.location = url;
	}
}
function   myAddPanel(title,url,desc)   {   
  if   ((typeof   window.sidebar   ==   'object')   &&   (typeof   window.sidebar.addPanel   ==   'function'))//Gecko   
  {   
  window.sidebar.addPanel(title,url,desc);   
  }   
  else//IE   
  {   
  window.external.AddFavorite(url,title);   
  }   
}   

function show_layer(){
	var eSrc=(document.all)?window.event.srcElement:arguments[1];
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = ((document.documentElement.clientHeight>document.documentElement.scrollHeight)?document.documentElement.clientHeight:document.documentElement.scrollHeight)+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;

	document.body.appendChild(shield);
	document.getElementById("download_layer").style.display='block';
	this.setOpacity = function(obj,opacity){
		if(opacity>=1)opacity=opacity/100;
		try{ obj.style.opacity=opacity; }catch(e){}
		try{ 
			if(obj.filters.length>0&&obj.filters("alpha")){
				obj.filters("alpha").opacity=opacity*100;
			}else{
				obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
			}
		}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
		if (++c > 20){clearInterval(ad);return 0;}
		setOpacity(shield,c);
	}
	var ad = setInterval("doAlpha()",1);
	this.doOk = function(){
		//alertFram.style.display = "none";
		//shield.style.display = "none";
		//document.body.removeChild(alertFram);
		document.getElementById("download_layer").style.display='none';
		document.body.removeChild(shield);
		//eSrc.focus();
		document.body.onselectstart = function(){return true;}
		document.body.oncontextmenu = function(){return true;}
	}
	//document.getElementById("do_OK").focus();
	//eSrc.blur();
	document.body.onselectstart = function(){return false;}
	document.body.oncontextmenu = function(){return false;}
}

function  openWindows(url)   {  
  //window.location.href=url;
  window.open(url);
  //bschitchat=window.open(url,'bschitchat','fullscreen=yes,toolbar=no,Status=no,scrollbars=yes,resizable=yes');
  return;
} 

function pep_download(pid,uid)
{
	/*
	window.scrollTo(0,0);
	show_float_layer("new_down_layer","");
	document.getElementById('new_down_msg').innerHtml = '';
	ajax_get('new_dl_select.php?pid='+pid,'new_down_msg');
	*/
	window.location.href='down_select.php?pid='+pid;
	/*
	var DooX;
	//alert("downloading...");
	try
	{
		DooX = document.createElement("OBJECT");
		DooX.classid = "CLSID:C6D3941B-8B86-4B91-8067-42813A9B90EC";
		//show_float_layer("float_down_layer","close");
	}
	catch(e)
	{
		document.getElementById('down_msg').innerHtml = '您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。<BR>请在软件下载页面下载安装客户端。';
		//show_float_layer("float_down_layer","close");
		alert("您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。\n请在软件下载页面下载安装客户端。");
		document.getElementById('down_soft').style.display='block';
		return;
	}

	try
	{
		DooX.Init();
		DooX.StartDownLoad('<i c="down" p="'+pid+'" t="mag" u="'+uid+'" />');
	}
	catch(e)
	{
		 document.getElementById('down_msg').innerHtml = '您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。<BR>请在软件下载页面下载安装客户端。';
		//show_float_layer("float_down_layer","close");
		 alert("您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。\n请在软件下载页面下载安装客户端。");
		document.getElementById('down_soft').style.display='block';
		 return;
	}
	*/
}

var menuDisplayed = false;
var canCloseMenu = true;
var menuDisplayed1 = false;
var canCloseMenu1 = true;
var nowLetter;
var lastLetter;
var firstTime = true;

function enableCloseMenu() {
	canCloseMenu = true;
}

function enableCloseMenu1() {
	canCloseMenu1 = true;
}

function head_brand(l){
	if(nowLetter==l){
		document.getElementById('head_brand').style.display='none';
		nowLetter = '';
		menuDisplayed = false;
	}else{
		canCloseMenu = false;
		menuDisplayed = true;
		
		if(!firstTime){
			
			document.getElementById('h_'+lastLetter).className ='';
			
		}
		document.getElementById('h_'+l).className ='active_name';
		document.getElementById('head_brand').style.display='block';
		ajax_get('head_brand.php?l='+l+'&t='+Math.random(),'head_brand');
		setTimeout("enableCloseMenu()", 200);
		nowLetter = l;
		lastLetter = l;
		firstTime = false;
	}
}


function head_sort_brand(l){

		canCloseMenu1 = false;
		menuDisplayed1 = true;
		clickHandler();
		document.getElementById('head_sort_brand').style.display='block';
		ajax_get(Absoulteurl+'head_sort_brand.php?id='+l+'&t='+Math.random(),'head_sort_brand');
		setTimeout("enableCloseMenu1()", 200);

}

function head_sort_brand_v3(l){

		canCloseMenu1 = false;
		menuDisplayed1 = true;
		clickHandler();
		document.getElementById('head_sort_brand').style.display='block';
		ajax_get(Absoulteurl+'head_sort_brand_v3.php?id='+l+'&t='+Math.random(),'head_sort_brand');
		setTimeout("enableCloseMenu1()", 200);

}

function clickHandler() {
	if(canCloseMenu && menuDisplayed){
		document.getElementById('head_brand').style.display='none';
		if(nowLetter) document.getElementById('h_'+nowLetter).className ='';
		nowLetter = '';
	}
	
	if(canCloseMenu1 && menuDisplayed1){
		document.getElementById('head_sort_brand').style.display='none';
	}
}

function bookmark(){
var title=document.title
var url=document.location.href
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera && window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}

function SetHome(obj,vrl){
        try{
                 obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
         }
        catch(e){
                if(window.netscape) {
                        try {
                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                         } 
                        catch (e) {
                                 alert("此操作被浏览器拒绝！请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                         }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService

(Components.interfaces.nsIPrefBranch);
                         prefs.setCharPref('browser.startup.homepage',vrl);
                  }
         }
}

