var imgtest=new Image();
imgtest.src="http://product.pcpop.com/images200709/xxx.gif";
function replaceRefUrl(refUrl)
{
	if (refUrl.indexOf('RefUrl') > -1)
	{
		var regexstr = /\?RefUrl=([\s\S]*?)$/i;
		refUrl = refUrl.replace(regexstr,'');
		refUrl = encodeURIComponent(refUrl);
	}
	return refUrl;
}
function l(DummyID,IngressID,BrandSN)
{
	if( self.name == 'right' )
	{
		parent.frames["left"].location.href = '/CategoryLeft200805.aspx?DummyID=' + DummyID.toString() + '&BrandSN=' + BrandSN.toString() + '&IngressID=' + IngressID.toString();
	}
}

function ActiveHead_New(SubCategoryIngressID)//激活head
{
	var HeadSubCategory = parent.document.getElementById('Head_' + SubCategoryIngressID);
	if (HeadSubCategory)
	{
		HeadSubCategory.style.color = '#ff0000';
	}
}




function readCookie(name)
{
	var cookieValue = "";
	var pattern = new RegExp(name + "=([^ ;]*)", "i");
	if (document.cookie.length > 0 && name.length > 0 && pattern.test(document.cookie))
	{
		pattern.exec(document.cookie);
		cookieValue = RegExp.$1;
	}
	return cookieValue;
}

function writeCookie_list(name, value, hours)
{
	var expire = "";
	if(hours != null)
	{
		expire = new Date((new Date()).getTime() + hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
	}
	domain = "; domain=pcpop.com";
	path = "; path=/";
	document.cookie = name + "=" + escape(value) + path + domain + expire;
}

function copyToclipboard(ss)
{
    window.clipboardData.setData("text",ss);
}
function myAddPanel(title,url,desc)   
{   
if (window.sidebar)//Gecko   
{   
window.sidebar.addPanel(title,url,desc);   
}   
else//IE   
{   
window.external.AddFavorite(url,title);   
}   
}

function zimuInit(flag,ingressid)
{
	$("#fp_pyIndex dt").mouseover(function(){ziover(this.id,0,flag,ingressid)}).mouseout(function(){ziout(this.id,0)});
    $("#fp_pyIndex dd").mouseover(function(){ziover(this.id,1,1,ingressid)}).mouseout(function(){ziout(this.id,1)}); 
}

///字母JS
var temparr=new Array();
function ziover(id,flag,c,ingressid)
{
    if(flag==0)
    {
        var sid='c'+id;
        $('#'+sid+'').attr('className','currDD');
        
        $('#'+id+'').attr('className','curr'); 
        var url="/";
        if(HaveData(id))
        {
			$('#'+sid+'').html("<center><img src='/images/loading_32x32.gif' border=0 /></center>");
           $.getJSON('/AjaxDataOperate/Ajax_200805.aspx?f='+id+'&c='+c+'&ingressid='+ingressid+'&d=1&jsoncallback=?',
                       function(json)
                       {
                           if(json.RECORDS.length>0)
                           {
                               $('#'+sid+'').empty();
                               var ul=$("<ul></ul>");
                               $.each(json.RECORDS,
                                    function(i,n)
                                    {
                                        if(c==1)
                                        {
                                            ul.append("<li><a href='"+url+n.F_IngressID+"/00000_1.html' onclick=\"l('"+n.ID+"','"+n.F_IngressID+"','')\">"+ClearBrandName(n.f_subcategoryname)+"</a></li>");
                                        }
                                        else
                                        {
                                            ul.append("<li><a href='"+url+ingressid+"/"+n.F_BrandSN+"_1.html'>"+ClearBrandName(n.F_BrandName)+"</a></li>");
                                        }
                                       
                                    });                      
                                $('#'+sid+'').prepend(ul);
                           }                           
                       });
            temparr[temparr.length]=id;
        }       
    }
    else
    {
        var sid=id.substring(1);
        $('#'+sid+'').attr('className','curr');
        $('#'+id+'').attr('className','currDD');        
    }
}
function ClearBrandName(name)
{
    if(name!=null)
    {
        return name.replace(/\(([\s\S]*?)\)/g,'').replace(/（([\s\S]*?)）/g,'');
    }
    else
    {
        return "";
    }
}
function HaveData(name)
{
    var a=true;
    for(var i=0;i< temparr.length;i++)
    {
        if(temparr[i]==name)
            a= false;
    }
    return a;
}
function ziout(id,flag)
{
    if(flag==0)
    {
        var sid='c'+id;
        $('#'+sid+'').attr('className','');
        $('#'+id+'').attr('className','');
    }
    else
    {
        var sid=id.substring(1);
        $('#'+sid+'').attr('className','');
        $('#'+id+'').attr('className','');
    }
}

function GetAreaIDByName(AreaName)
{
	switch (AreaName)
	{
		case '北京':
			return 1;
		case '广东':
			return 2;
		case '上海':
			return 3;
		case '山东':
			return 4;
		case '河南':
			return 5;
		case '河北':
			return 6;
		case '江苏':
			return 7;
		case '辽宁':
			return 8;
		case '湖北':
			return 9;
		case '四川':
			return 10;
		case '浙江':
			return 12;
		case '重庆':
			return 13;
		case '湖南':
			return 14;
		case '天津':
			return 15;
		case '陕西':
			return 16;
		case '山西':
			return 17;
		case '黑龙江':
			return 18;
		case '福建':
			return 19;
		case '吉林':
			return 20;
		case '安徽':
			return 21;
		case '江西':
			return 22;
		case '云南':
			return 23;
		case '贵州':
			return 24;
		case '内蒙古':
			return 25;
		case '广西':
			return 26;
		case '新疆':
			return 27;
		case '甘肃':
			return 28;
		case '海南':
			return 29;
		case '宁夏':
			return 30;
		case '青海':
			return 31;
		case '九龙':
			return 32;
		case '西藏':
			return 33;
		case '澳门':
			return 34;
		case '香港岛':
			return 35;
		case '全国':
			return 0;
		default:
			return 1;
	}
}
//列表页获取更多产品
function addtr(tableid,addcount,subsn,parid,parvalueid,priceid,orderby,isdesc,isstop,areaid,citysn)
{
	var count = $("#"+tableid+">tbody>tr").length;
	var html = $.ajax({type: "POST",url: "../AjaxDataOperate/Ajax_RightProductList200807.aspx",data: "brand="+tableid+"&count="+count+"&addcount="+addcount+"&subsn="+subsn+"&parid="+parid+"&parvalueid="+parvalueid+"&priceid="+priceid+"&orderby="+orderby+"&isdesc="+isdesc+"&isstop="+isstop+"&areaid="+areaid+"&citysn="+citysn,async: false}).responseText;
	var strarr = html.split("∑");
	if( strarr[strarr.length-1] == 1 )
	{
		$("#"+tableid+"more").css("display","none");
	}
	for(var i=0; i<strarr.length-1; i=i+5)
	{
		$("<tr><td class='ld731'><a href='"+strarr[i+3]+"'>"+strarr[i]+"</a></td><td class='ld731_1'><a href='"+strarr[i+4]+"'>"+strarr[i+1]+"</a></td><td class='ld732'>"+strarr[i+2]+"</td></tr>").appendTo("#"+tableid);
	}
}
//定位锚点
var currentpos,timer,topX; 
function getTopx()
{			
	currentpos = 0;
	topX = 0;
	document.getElementById("thistag").style.position="relative";
	topX = document.getElementById("thistag").offsetTop;
	initialize();
}
function initialize() 
{ 
	timer=setInterval("scrollwindow()",2);
} 
function sc(){
	clearInterval(timer); 
}
function scrollwindow() 
{
	currentpos=GetScrollTop();
	if(currentpos==topX)
	{
		sc();
	}
	else
	{
		if( (currentpos+30) > (topX) )
		{
			window.scrollTo(0,topX);
		}
		else
		{
			window.scrollTo(0,currentpos+30);
		}				
	}
}
function GetScrollTop()
{
	return document.documentElement.scrollTop;
}

//列表页载入经销商
function LoadAreaFranchiser(subcategorysn, brandsn, ingressid, subcategoryname, brandname, areaid)
{
	$.ajax({type: "POST",url: "../AjaxDataOperate/Ajax_RightProductList200807.aspx",data: "subcategoryname="+escape(subcategoryname)+"&brandname="+escape(brandname)+"&ingressid="+ingressid+"&brand="+brandsn+"&subsn="+subcategorysn+"&areaid="+areaid+"&LoadAreaFranchiser=1",dataType: "html",success: handleResponse});
	function handleResponse(CallBack)
	{
		document.getElementById("asyncDiv").innerHTML = CallBack;
	}
}

function NextPage()
{
	document.getElementById("PrvJT").src = "/images200805/left2.gif";
	for(var i=1; i<=3; i++)
	{
		if( document.getElementById("JTChange"+i) != null )
		{
			if( document.getElementById("JTChange"+i).style.display == "block" )
			{
				if( document.getElementById("JTChange"+(parseInt(i)+1)) != null )
				{
					HiddenJTPage();
					if( document.getElementById("JTChange"+(parseInt(i)+2)) == null )
					{
						document.getElementById("NextJT").src = "/images200805/right1.gif";
					}
					document.getElementById("JTChange"+(parseInt(i)+1)).style.display = "block";
					break;
				}
			}
		}
	}
}

function PrvPage()
{
	document.getElementById("NextJT").src = "/images200805/right2.gif";
	for(var i=3; i>=1; i--)
	{
		if( document.getElementById("JTChange"+i) != null )
		{
			if( document.getElementById("JTChange"+i).style.display == "block" )
			{
				if( document.getElementById("JTChange"+(parseInt(i)-1)) != null )
				{
					HiddenJTPage();
					if( document.getElementById("JTChange"+(parseInt(i)-2)) == null )
					{
						document.getElementById("PrvJT").src = "/images200805/left1.gif";
					}
					document.getElementById("JTChange"+(parseInt(i)-1)).style.display = "block";
					break;
				}
			}
		}
	}
}

function HiddenJTPage()
{
	for(var i=1; i<=3; i++)
	{
		if( document.getElementById("JTChange"+i) != null )
		{
			document.getElementById("JTChange"+i).style.display = "none";
		}
	}
}


function AreaInfoChange(thisid, areaname, count, subcategorysn, brandsn, ingressid)
{
	for( var i=1; i<=36; i++ )
	{
		if( i>2 )
			document.getElementById("ad_word"+i).style.display = "none";
		else
			document.getElementById("ad_word_"+i).style.display = "none";
	}
	var numid = parseInt(GetAreaIDByName(areaname)+1);
	if( numid > 2 )
		document.getElementById("ad_word"+numid).style.display = "block";
	else
		document.getElementById("ad_word_"+numid).style.display = "block";
	for(var i=1; i<=count; i++)
	{
		try
		{
			document.getElementById("AreaName"+i).className = "AreaFranchiser2";
		}
		catch(err){}
	}
	document.getElementById(thisid).className = "AreaFranchiser1";
	var num = thisid.replace("AreaName","");
	
	if( document.getElementById("AreaContentHtml"+num).innerHTML != "" )
	{
		document.getElementById("AreaFranchiserInfo").innerHTML = document.getElementById("AreaContentHtml"+num).innerHTML;
	}
	else
	{
		var html = $.ajax({type: "POST",url: "../AjaxDataOperate/Ajax_RightProductList200807.aspx",data: "brand="+brandsn+"&subsn="+subcategorysn+"&areaname="+escape(areaname)+"&ingressid="+ingressid, async: false}).responseText;
		document.getElementById("AreaContentHtml"+num).innerHTML = html;
		document.getElementById("AreaFranchiserInfo").innerHTML = html;
	}
}

//列表页载入产品参数筛选
function LoadProductParameter(nameen, namech, subsn, brandsn, parid, parvalueid, priceid,TotalRecord)
{
	$.ajax({type: "POST",url: "../AjaxDataOperate/Ajax_RightProductList200807.aspx",data: "nameen="+nameen+"&namech="+escape(namech)+"&subsn="+subsn+"&brandsn="+brandsn+"&parid="+parid+"&parvalueid="+parvalueid+"&priceid="+priceid+"&loadproductparameter=1",dataType: "html",success: handleResponse});
	function handleResponse(CallBack)
	{
		var info="";
		document.getElementById("ProductParameterDiv").innerHTML = CallBack;
		if( document.getElementById("price"+priceid) ){
			document.getElementById("price"+priceid).className="filnl6";
			
			if(priceid!=-1)
			{
				var saixuantiaojian=$("#saixuantiaojian").html();
				info=document.getElementById("price"+priceid).innerText;				
			}
		}
		if(parid != -1)
		{
			document.getElementById("par"+parid+"_"+parvalueid).className="filnl6";
			document.getElementById("parall"+parid).className="filnl5";
			//已选条件
			info=document.getElementById("par"+parid+"_"+parvalueid).innerText;			
		}
		if(info!="" && info!="全部" && info.toLowerCase()!="undefined")
		{
			var saixuantiaojian=$("#saixuantiaojian").html();
			var ProductCountStr="";
			if(TotalRecord>0){ProductCountStr=",共<font color='#C70002'>"+TotalRecord+"</font>款产品";}
			if(saixuantiaojian!="")
			{
				var temp=saixuantiaojian.split(',')[0]+info+ProductCountStr+")";
				$("#saixuantiaojian").html(temp);
			}
			else
			{
				$("#saixuantiaojian").html("(已选条件："+info+namech+ProductCountStr+")");
			}
			$("#listnullinfo_para").html(info);
		}
		$(".filnl5").mouseover(function(){this.className="filnl6";});
		$(".filnl5").mouseout(function(){this.className="filnl5";});
		//getTopx();
	}
}

var curra=0;
function ChangeRootShortNavi(a)
{
	if(curra==a)return;
	var ID=ChooseID(a);
	var LastID=ChooseID(curra);	
	if(document.getElementById(ID))
	{
		if(document.getElementById("ShortNavi_"+a)){document.getElementById("ShortNavi_"+a).className="maysunb43";}
		if(document.getElementById("ShortNavi_"+curra)){document.getElementById("ShortNavi_"+curra).className="maysunb42";}
		document.getElementById(ID).style.display='block';
		if(document.getElementById(LastID)){document.getElementById(LastID).style.display='none';}
	}
	curra=a;
} 

function ChooseID(a)
{
	var ID="";
	switch(a)
	{
		case 0:ID="MainParameter20090602";break;
		case 1:ID="ProductInfo20090602";break;
		case 2:ID="BBSHTML20090602";break;
		case 3:ID="ProductRelated20090602";break;
	}
	return ID;
}

//覆盖层
function CreateLightBox(category,product)
{
	var htmls="<div class=shoucangDivBox><div class=shoucangDivBoxTitle><a onclick=\"Closemsg()\" style=\"cursor:pointer\"'><img  src=\"http://product.pcpop.com/images200709/xxx.gif\" border=0  /></a></div><div style=\"height:25px;clear:both\"></div><div style=\"width:335px;clear:both;text-align:center;margin:auto\"><iframe id=\"shoucangIframe\"   width=335px height=235px  frameborder=0  scrolling=no  ></iframe></div></div>"; 
	var p=document.createElement("DIV");
	p.id="LadyUserlogin_p";
	p.style.position="absolute";
	p.style.width="100%";
	p.style.height=((document.body.offsetHeight>document.body.scrollHeight)?'100%':document.body.scrollHeight + "px");
	p.style.zIndex='998';
	p.style.top='0px';
	p.style.left='0px';
	p.style.backgroundColor="gray";
	//FireFox
	p.style.opacity='0.5';
	//IE
	p.style.filter="alpha(opacity=80)";
	document.body.appendChild(p);
	//高亮对话框
	var LadyUserlogin_p1=document.createElement("DIV");
	LadyUserlogin_p1.style.position="absolute";
	LadyUserlogin_p1.id="LadyUserlogin_p1";	
	LadyUserlogin_p1.style.width= "335px";	
	LadyUserlogin_p1.style.height="295px";
	LadyUserlogin_p1.style.zIndex='99999';	
	var top;
	var left=Math.ceil(((document.documentElement.offsetWidth)-parseInt(LadyUserlogin_p1.style.width.replace('px','')))/2);//+document.documentElement.scrollLeft;
	document.ns = navigator.appName == "Netscape";
	if(document.ns)
	{
		top= pageYOffset+(window.innerHeight-153)/2;
	}
	else
	{
		top=Math.ceil(((document.documentElement.offsetHeight)-parseInt(LadyUserlogin_p1.style.height.replace('px','')))/2)+document.documentElement.scrollTop;
	}
	LadyUserlogin_p1.style.top=( top < 0 ? 0 : top ) + 'px';
	LadyUserlogin_p1.style.left=( left < 0 ? 0: left ) + 'px';
	document.body.appendChild(LadyUserlogin_p1);
	//对话框中的html	                       
	LadyUserlogin_p1.innerHTML=htmls;
	document.getElementById("shoucangIframe").src="http://my.pcpop.com/Favorite/AddCollection.aspx?category="+category+"&product="+product+"&type=2";
	var arr=document.getElementsByTagName("select");//http://my.pcpop.com/Static/AddCollection.htm
	var i=0;
	while(i<arr.length){
		arr[i].style.visibility='hidden';
		i++;
	}
	LadyUserlogin_p1.focus();	
}

 function Closemsg()
 { 
	var comment_temp = decodeURI(readCookie('pop_userid'));
	if( document.cookie.indexOf('pop_userid=') != -1)
	{
		document.getElementById("product_userlogin").innerHTML='&nbsp;<a style="color:#FDF499" href="http://sso.pcpop.com/jumpsns.aspx?username='+ comment_temp.substring(0,18) + '&flag=1">'+ comment_temp.substring(0,18) +'</a>&nbsp; <a href="http://product.pcpop.com/Users/Login.aspx?exitSystem=1&backurl='+document.URL+'"  target=_self>退出</a>';
	}
    document.body.removeChild(document.getElementById('LadyUserlogin_p'));
	document.body.removeChild(document.getElementById('LadyUserlogin_p1'));
	var arr=document.getElementsByTagName("select");
	var i=0;
	while(i<arr.length){
	arr[i].style.visibility='visible';
	i++;
	}	 
}
 
function ViewBigLogo(obj)
{
	obj.style.position = "relative";
	var biglogo = document.getElementById("nvlogobig");
	biglogo.style.left = (obj.offsetLeft+50)+"px";
	biglogo.style.top = obj.offsetTop+"px";
	biglogo.style.display = "block";
}
var isonload=false;
 window.onload = function() {isonload=true;}
 
