// JavaScript Document
var SiteUrl="http://www.baxsun.cn/";
//全站设置文字大小
function fontZoom(size)
{
   document.getElementById('con').style.fontSize=size+'px';
}

//设置图片按比例展
function setImg(theURL,slink,target,px,autosize,altt,css){ 

	imgObj = new Image();
	imgObj.src = theURL;
	if(!imgObj.width){
		document.write("<a href='"+ slink +"' target='"+ target +"' class='"+css+"'><img src='"+ theURL +"'  "+ autosize +"='"+ px +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
	}else{
	if(imgObj.width>=imgObj.height){
		if(imgObj.width>=px){
document.write("<a href='"+ slink +"' target='"+ target +"' class='"+css+"'><img src='"+ theURL +"' width='"+ px +"' border=0  title='"+altt+"'  onload='DrawImage(this,"+px+","+px+")'></a>");
		}else{
document.write("<a href='"+ slink +"' target='"+ target +"' class='"+css+"'><img src='"+ theURL +"'  border=0  title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}
	}else{
		if(imgObj.height>=px){
document.write("<a href='"+ slink +"' target='"+ target +"' class='"+css+"'><img src='"+ theURL +"' height='"+ px +"'  border=0  title='"+altt+"' onload='javascript:DrawImage(this,"+px+","+px+")'></a>");
		}else{
document.write("<a href='"+ slink +"' target='"+ target +"' class='"+css+"'><img src='"+ theURL +"'  border=0  title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}
	}
	}
	
}

//产品详情叶图片展示设置图片按比例展
function setImgX2(theURL,px,autosize,altt){ 

	imgObj = new Image();
	imgObj.src = theURL;
	if(!imgObj.width){
		document.write("<a href='"+ theURL +"' ><img id='simage' src='"+ theURL +"'  "+ autosize +"='"+ px +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
	}else{
	if(imgObj.width>=imgObj.height){
		if(imgObj.width>=px){
document.write("<a href='"+ theURL +"' target='_blank'><img id='simage' src='"+ theURL +"' width='"+ px +"' border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}else{
document.write("<a href='"+ theURL +"' target='_blank'><img id='simage' src='"+ theURL +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}
	}else{
		if(imgObj.height>=px){
document.write("<a href='"+ theURL +"' target='_blank'><img id='simage' src='"+ theURL +"' height='"+ px +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}else{
document.write("<a href='"+ theURL +"' target='_blank'><img id='simage' src='"+ theURL +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}
	}
	}
	
}
//产品详情叶图片展示设置图片按比例展
function setImgX3(theURL,px,autosize,altt){ 

	imgObj = new Image();
	imgObj.src = theURL;
	if(!imgObj.width){
		document.write("<a href='"+ theURL +"' class='jqzoom' rel='gal1' title='BaxSunZoom'><img src='"+ theURL +"'  "+ autosize +"='"+ px +"'  title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
	}else{
	if(imgObj.width>=imgObj.height){
		if(imgObj.width>=px){
document.write("<a href='"+ theURL +"' class='jqzoom' rel='gal1' title='BaxSunZoom'><img src='"+ theURL +"' width='"+ px +"' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}else{
document.write("<a href='"+ theURL +"' class='jqzoom' rel='gal1' title='BaxSunZoom'><img src='"+ theURL +"'  title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}
	}else{
		if(imgObj.height>=px){
document.write("<a href='"+ theURL +"' class='jqzoom' rel='gal1' title='BaxSunZoom'><img src='"+ theURL +"' height='"+ px +"'  title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}else{
document.write("<a href='"+ theURL +"' class='jqzoom' rel='gal1' title='BaxSunZoom'><img src='"+ theURL +"'  title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}
	}
	}
	
}

function setImgX(theURL,px,autosize,altt){ 

	imgObj = new Image();
	imgObj.src = theURL;
	if(!imgObj.width){
		document.write("<a href='"+ theURL +"' ><img src='"+ theURL +"'  "+ autosize +"='"+ px +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
	}else{
	if(imgObj.width>=imgObj.height){
		if(imgObj.width>=px){
document.write("<a href='"+ theURL +"' target='_blank'><img src='"+ theURL +"' width='"+ px +"' border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}else{
document.write("<a href='"+ theURL +"' target='_blank'><img src='"+ theURL +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}
	}else{
		if(imgObj.height>=px){
document.write("<a href='"+ theURL +"' target='_blank'><img src='"+ theURL +"' height='"+ px +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}else{
document.write("<a href='"+ theURL +"' target='_blank'><img src='"+ theURL +"'  border='0' title='"+altt+"' onload='DrawImage(this,"+px+","+px+")'></a>");
		}
	}
	}
	
}
function PreloadImg(){   
  var Arrimg=new Array();   
  if(typeof(arguments[0])=="string")Arrimg[0]=arguments[0];   
  if(typeof(arguments[0])=="object"){   
      for(var i=0;i<arguments[0].length;i++){   
          Arrimg[i]=arguments[0][i]   
        }   
    }   
  var img=new Array()   
  for(var i=0;i<Arrimg.length;i++){   
    img[i]=new Image();   
    img[i].src=Arrimg[i];   
  }   
}  

$(document).ready(function(){
	$("#pageok table").css("text-align","right");
	$("#pageok table").css("padding-right","10px");
	//$("p").css({text-align: "center", background: "blue" }); 
});

var flag=true;
function DrawImage(ImgD,iwidth,iheight){
//参数(图片,允许的宽度,允许的高度)
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){
				ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.alt=image.width+"×"+image.height;
		}
		else{
			if(image.height>iheight){
				ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.alt=image.width+"×"+image.height;
		}
	}
}

function myBrowser(){
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isOpera = userAgent.indexOf("Opera") > -1;

if (isOpera){return "Opera"}; //判断是否Opera浏览器 
if (userAgent.indexOf("Firefox") > -1){return "FF";} //判断是否Firefox浏览器 
if (userAgent.indexOf("Safari") > -1){return "Safari";} //判断是否Safari浏览器 
if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera){return "IE";} ; //判断是否IE浏览器
} //myBrowser() end

function MM_preloadImages() {
  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];}}   
}

$(function(){
	$(".sub_nav li").mouseover(function (){
		$(this).children("span").addClass("hover");
		$(this).children("ul").css({display:"block"});
	});
	$(".sub_nav li").mouseout(function (){
		$(this).children("span").removeClass("hover");
		$(this).children("ul").css({display:"none"});
	});
	$(".main_sort li").mouseover(function (){
		$(this).children("h4").addClass("hover");
		$(this).children(".floatSort").css({display:"block"});
	});
	$(".main_sort li").mouseout(function (){
		$(this).children("h4").removeClass("hover");
		$(this).children(".floatSort").css({display:"none"});
	});
			
	$("#order").Slide({
		effect : "fade",
		speed : "normal",
		autoPlay:false,
		timer : 5000
	});
	$("#friend_link").Slide({
		effect : "scroolLoop",
		autoPlay:true,
		speed : "normal",
		timer : 3000,
		steps:9
	});
	$("#ad_focus").Slide({
		effect : "scroolY",
		speed : "normal",
		timer : 3000
	});
		
	$("#ad_activity").Slide({
		effect : "scroolLoop",
		autoPlay:true,
		speed : "normal",
		timer : 3000,
		steps:3
	});
	$("#pro_push").Slide({
		effect : "fade",
		speed : "normal",
		autoPlay:false,
		timer : 3000
	});

	$(".con_Style1 li").mouseover(function(){
		$(this).addClass("hover").siblings("li").removeClass("hover");
	});
	$(".con_Style1 li").mouseout(function(){
		$(this).removeClass("hover");
	});

	$(".filter_button").toggle(
		function (){
			$(this).css({backgroundPosition:"0 -37px"});
			$(".product_filter_con").css({display:"none"});
		},
		function (){
			$(this).css({backgroundPosition:"0 0"});
			$(".product_filter_con").css({display:"block"});
		}
	);
	$(".product_tab b").toggle(
		function (){
			$(this).css({backgroundPosition:"-10px 0"});
			sc="asc";
		},
		function (){
			$(this).css({backgroundPosition:"0 0"});
			sc="desc";
		}
	
	);
	//topmenu('toubiao',0,0);

	$("#ord1").click(function (){
		window.location.href="./?Catid="+catid+"&ord=price1&sc="+sc;
	});
	$("#ord2").click(function (){
		window.location.href="./?Catid="+catid+"&ord=dtime&sc="+sc;
	});
	$("#ord3").click(function (){
		window.location.href="./?Catid="+catid+"&ord=cl&sc="+sc;
	});
});

function brandclick(id){	
	var tdid=id;
    $.cookie('brand', null, { path: '/' });
	var date = new Date();   
    date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));   
   	$.cookie('brand', tdid, { path: '/', expires: date });
	//alert(tdid);
	window.location.reload();

}
function jiageclick(id){
	var tdid=id;
    $.cookie('jiage', null, { path: '/' });
	var date = new Date();   
    date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));   
   	$.cookie('jiage', tdid, { path: '/', expires: date });
	//alert(tdid);
	window.location.reload();
}

function sx1click(id){		  
	var tdid=id;
    $.cookie('sx1', null, { path: '/' });
	var date = new Date();   
    date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));   
   	$.cookie('sx1', tdid, { path: '/', expires: date });
	//alert(tdid);
	window.location.reload();
}
function sx2click(id){	  
	var tdid=id;
    $.cookie('sx2', null, { path: '/' });
	var date = new Date();   
    date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));   
   	$.cookie('sx2', tdid, { path: '/', expires: date });
	//alert(tdid);
	window.location.reload();
} 
function sx3click(id){		  
	var tdid=id;
    $.cookie('sx3', null, { path: '/' });
	var date = new Date();   
    date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));   
   	$.cookie('sx3', tdid, { path: '/', expires: date });
	//alert(tdid);
	window.location.reload();
}
function sx4click(id){	  
	var tdid=id;
    $.cookie('sx4', null, { path: '/' });
	var date = new Date();   
    date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));   
   	$.cookie('sx4', tdid, { path: '/', expires: date });
	//alert(tdid);
	window.location.reload();
} 
function sx5click(id){		  
	var tdid=id;
    $.cookie('sx5', null, { path: '/' });
	var date = new Date();   
    date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));   
   	$.cookie('sx5', tdid, { path: '/', expires: date });
	//alert(tdid);
	window.location.reload();
}
function hfall() {
   	$.cookie('brand', null, { path: '/' });
	$.cookie('jiage', null, { path: '/' });
	$.cookie('sx1', null, { path: '/' });
	$.cookie('sx2', null, { path: '/' });
	$.cookie('sx3', null, { path: '/' });
	$.cookie('sx4', null, { path: '/' });
	$.cookie('sx5', null, { path: '/' });
	window.location.reload();
	}
function shophis(){
	var goodsid=GetCookie("cookids");
	var Url="";
	if(myBrowser()=="IE"){Url="http://www.baxsun.cn/ajax.php";}
	if(myBrowser()=="FF"){Url="../../../ajax.php";}
	if(myBrowser()=="Opera"){Url="../../../ajax.php";}
	if(myBrowser()=="Safari"){Url="../../../ajax.php";}
	
	$.post(Url,{"goodsid":goodsid},
		function(data){
$("#shophis").html(data);
		},'html');
}

function getCookieVal(offset) { 
var endstr = document.cookie.indexOf (";", offset); 
if (endstr == -1){endstr = document.cookie.length;} 
return unescape(document.cookie.substring(offset, endstr)); 
}

function GetCookie(name) {  
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;
}
function toueme(){//关闭顶部菜单
    document.getElementById("toubiao").style.display="none";
}
topmenu=function (id,_top,_left){
	var me=id.charAt?document.getElementById(id):id, d1=document.body, d2=document.documentElement;
	d1.style.height=d2.style.height='100%';
	me.style.top=_top?_top+'px':0;
	me.style.left=_left+"px";//[(_left>0?'left':'left')]=_left?Math.abs(_left)+'px':0;
	me.style.position='absolute';
	setInterval(function (){me.style.top=parseInt(me.style.top)+(Math.max(d1.scrollTop,d2.scrollTop)+_top-parseInt(me.style.top))*0.1+'px';},10+parseInt(Math.random()*20));
	return arguments.callee;
};
//固元膏代金券点击效果开始
$(document).ready(function(){
	$("#daijinquan").click(function(){
	$("#xinxi").show(400);
	});
$(".guanbi").click(function(){
	$("#xinxi").hide(400);
	});
	});
$("#daijinquan").mouseover(function(){
	$(this).css("cursor","pointer");
	});
//固元膏代金券点击效果券结束
