function countdown(endtime,showpath)
{
today = new Date();
var endyear=endtime.substr(0,4);
var endmon=endtime.substr(4,2)-1;
var endday=endtime.substr(6,2);
var endhh=endtime.substr(9,2);
var endmm=endtime.substr(12,2);
var endss=endtime.substr(15,2);
var target_time=new Date(endyear,endmon,endday,endhh,endmm,endss);
var timeold=(target_time.getTime()-today.getTime());
var sectimeold=timeold/1000;
var secondsold=Math.floor(sectimeold);
var msPerDay=24*60*60*1000;
var e_daysold=timeold/msPerDay;
var daysold=Math.floor(e_daysold);
var e_hrsold=(e_daysold-daysold)*24;
var hrsold=Math.floor(e_hrsold);
var e_minsold=(e_hrsold-hrsold)*60;
var minsold=Math.floor(e_minsold);
var e_seconds=(e_minsold-minsold)*60;
var seconds=Math.floor(e_seconds);
var e_millisecond=(e_seconds-seconds)*1000;
var millisecond=Math.floor(e_millisecond);
var millisecond10=Math.floor(millisecond/10);
var the_element=document.getElementById(showpath);

the_element.innerHTML=""+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒";
window.setTimeout("countdown('" + endtime + "', '"+showpath+"')", 100);
}

function addBookmark() {
	var title="八分酷 - 全国首家买家定价式消费电子类产品购物网";
	var url = "http://www.8fenku.com/";
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
	return true;
	}
}
function GetCookie(name)
//获得Cookie的原始值
	{
		var arg = name + "=";
		var alen = arg.length;
		var clen = document.cookie.length;
		var i = 0;
		while (i < clen)
		{
			var j = i + alen;
			if (document.cookie.substring(i, j) == arg)
				return GetCookieVal (j);
			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}
		return null;
	}
window.onload=function(){
gethead();
}
function GetCookieVal(offset)
//获得Cookie解码后的值
　　{
	　　var endstr = document.cookie.indexOf (";", offset);
	　　if (endstr == -1)
	　　	endstr = document.cookie.length;
	　　return unescape(document.cookie.substring(offset, endstr));
　　}
function shoucang(url){
		if(GetCookie("userName")!=null){
			shoucangvalidator(url);
		}else{
			checklogin();
		}
	}
function checklogin(){
		var url = window.location.href;
		location.href  = 'http://www.8fenku.com/public/login.htm';
		return false;
	}
var bXmlHttpSupport = (typeof XMLHttpRequest != "undefined" || window.ActiveXObject);
	if (typeof XMLHttpRequest == "undefined" && window.ActiveXObject) {
	        function XMLHttpRequest() {
	            var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
	                                 "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
	                                 "Microsoft.XMLHTTP"];
	                             
	            for (var i=0; i < arrSignatures.length; i++) {
	                try {        
	                    var oRequest = new ActiveXObject(arrSignatures[i]);            
	                    return oRequest;        
	                } catch (oError) { /*ignore*/ }
	            }          
	    
	            throw new Error("MSXML is not installed on your system.");               
	        }
	}    
function shoucangvalidator(url) {  
	    	var sUrl="shoucangvalidator.htm?url="+url+"&index=1";    
	        if(bXmlHttpSupport) {
	            var oRequest = new XMLHttpRequest();
	            oRequest.onreadystatechange = function() {
	                if(oRequest.readyState == 4) {                    
	                    var oBook = eval("(" + oRequest.responseText + ")");
	                    if(oBook.data=="1"){
							alert("收藏成功。");
							parent.location.href="index.htm";
	                    }else{
	                    	alert("您已经收藏过此宝贝！");
	                    	parent.location.href="index.htm";
	                    }
	                }
	            };
	            oRequest.open('POST', sUrl,false);
	            oRequest.send(null);
	        }
	    }
function showpic(name,cursel,n)
{
	for(i=1;i<=n;i++)
	   {
	      var menu=document.getElementById(name+i);
	      var con=document.getElementById("imgpic"+"_"+i);
	      menu.className=i==cursel?"hover":"";
	      con.style.display=i==cursel?"block":"none";
	    }
	}
function gethead(){
	updateIndexPage();
}

function updateIndexPage() {  
	    	$.ajax({
				url: 'http://www.8fenku.com/public/updateindexpage.htm',
				type: 'POST',
				dataType: 'json',
				timeout: 2000,
				success: function(data){
					if(data.msg=='yes'){
						//$('#Top_line').html("");
						//$('#Top_line').html(data.head);

						//$('#logininfo').html(data.logininfo);
						document.getElementById("Top_line").innerHTML="";
						document.getElementById("Top_line").innerHTML=data.head;
					}

				}
			});
	    }
