/*--浏览用JS集合 create by ufomail 2009-1-13 --*/

//$(document).ready(function(){
	$(".tabs").tabs({
			deselectable: true
	});
	$(".accordion").accordion({
		header: "h3",alwaysOpen:false,autoHeight:false,fillSpace: true,animated:false
	});
	//--解决input默认值的问题--------------------------------------------------------------------
	$(":text").focus(function(){
		$(this).select();
		$(this).parent('div').prev("label.tip").css('display','none');
	});
	$(":text").blur(function(){
		if ($(this).val()=='')
		{
			$(this).parent('div').prev("label.tip").css('display','');
		}
	});
	$(":password").focus(function(){
		$(this).select();
		$(this).parent('div').prev("label.tip").css('display','none');
	});
	$(":password").focus(function(){
		if ($(this).val()=='')
		{
			$(this).parent('div').prev("label.tip").css('display','');
		}
	});
	$('label.tip').click(function(){
		$(this).next("div").find('input').focus();
	});
	//调出车型图片
	$('a.modelitem').mouseover(function(){
		var id=$(this).attr('value');
		$(this).css('position','relative');
		$(this).append("<div style='position:absolute;top:20px;left:0px;background:#FFFFFF;'><img src='/USITE/images/loading.gif' id='smodelpic'/></div>"); 
		$.get("/USITE/Function/getmodelpic.php",{mid:id,user:user,l:ver,random:Math.random()},function(data){
			$('#smodelpic').attr('src',data);
		});
		//alert($(this).css('position'));

	});
	$('a.modelitem').mouseout(function(){
		$('a.modelitem').css('position','static');
		$(this).find('div').remove();
	});
	//----------------------------------------------------------------------------
	$("input.checkthis").click(function(){
		id=$(this).attr("value");
		//alert($(this).attr("checked"));
		if ($(this).attr("checked"))
		{
			writeCookie('pro_'+id,'1',24);	
			$(this).parent('label').attr('class','chk');
		}
		else
		{
			writeCookie('pro_'+id,'0',0);
			$(this).parent('label').attr('class','');
		}
	});
	//树型目录的样式
	var vv=$('.lightTreeview').attr('key');
	if (vv=='')
		vv='default';
	$('.lightTreeview').lightTreeview({
		collapse: true,
		line: true,
		nodeEvent: true,
		unique: true,
		style: vv,
		animate: 100
	});
	//加载make
	loadmake();
	//加载part列表
	loadpart();
	//加载group列表
	loadgroup();
	
	//make变换操作
	$('select.make').change(function(){
		mno=$(this).find("option:selected").attr("value");
		mod=$(this).parents(".control").attr('id');
		makechange(mno,mod);
	});
	//group变换操作
	$('select.group').change(function(){
		//加载part列表
		var groupno=$(this).children("option:selected").attr("value");
		//记录cookies
		var module=$(this).parents(".control").attr('id');
		writeCookie(module+'_group',groupno,24);
		if (groupno!='')
		{		
			$.get("/USITE/Function/getpart.php",{user:user,l:ver,g:groupno,random:Math.random()},function(data){
				
				$('#'+module+' select.part').each(function(){
					$(this).html(data);
					key=$(this).attr('key');
					key=readCookie($(this).attr('id'));
					if (key!='')
					{
						$(this).val(key);
					}
				});
				$('#'+module+' select.part').change(function(){
					var partno=$(this).children("option:selected").attr("value");
					writeCookie(module+'_part',partno,24);
				});
			});
		}
	});
	$('select.part').change(function(){
		var partno=$(this).children("option:selected").attr("value");
		var module=$(this).parents(".control").attr('id');
		writeCookie(module+'_part',partno,24);
	});
	//车型树的点击动作
	$('.TreeTable tr.subtitle').click(function(){
		temp=$(this).attr('id');
		$('.TreeTable tr.'+temp).toggle();
	});
	//隔行变色
	$('tr:even').addClass('gray');
	
	//载入美化的select控件
	if (Bselect)
	{	
		$("select").each(function(){
			$(this).before('<div id="select_'+ $(this).attr("id")+'" class="select_box" onclick="showselect(\''+  $(this).attr("id")+'\')"><div class="tag_select"><div class="content">'+$(this).children("option:selected").attr("text")+'</div></div></div>');
		});
		//隐藏select
		$('select').css({position:'absolute',top:'0',left:'0',visibility:'hidden'});
	}
	//鼠标移过变色
	$(".TreeTable tr").hover(
		function(){
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass("hover");
		  }
	);
	makehtml();
	//生成静态页
	function makehtml()
	{
	$('.makehtml').each(function(){
		var uu=$(this).attr('href');
		if (uu.indexOf('index.php')>0)
		{
			uu=uu.replace('index.php','makehtml.php');
		}
		else
		{
			uu='makehtml.php'+uu;
		}
		$.get(uu,{random:Math.random()},function(data){
		});
	});
	}
	//生成文章上下页的内容
	$('#newsviewnav').each(function(){
		var id=$(this).attr('value');
		var vurl=window.location.href;
		var make=0;
		var tt=vurl.indexOf('.html',0);
		if (tt>0)
		{
			make=1;
		}
		$.get("/USITE/Function/newsviewnav.php",{nid:id,html:make,user:user,l:ver,random:Math.random()},function(data){
			$('#newsviewnav').html(data);
			makehtml();
		});
	});
	$('.close').click(function(){
		$('.nodisplay').css('display','none');
		$('#MUSK').remove();
	});
//处理ajax ie select 的问题
//$('select').ajaxSend(function(){
//   $(this).css('visibility', 'hidden');
//});
//$('select').ajaxComplete(function(event,request, settings){
//   $('select').css('visibility', 'visible');
// }); 
//$('select').ajaxStop(function(){
 //  $('select').css('visibility', 'visible');
// }); 
// $("select").ajaxError(function(event,request, settings){
//   $('select').css('visibility', 'visible');
//}); 
//});
function showform(str)
{
	$('<div id="MUSK"></div>').appendTo("body"); 
	$("div#MUSK").css("top",0);
	$("div#MUSK").css("left",0);
	$("div#MUSK").css({width:$(document).width(),height:$(document).height(),backgroundColor:'#fff'});
	$('.nodisplay').css('display','none');
	$('#'+str).css('display','');
	if(!document.all){
		mouseleft=e.pageX; 
		mousetop=e.pageY; 
	}else{ 
		mouseleft=document.body.scrollLeft+event.clientX; 
		mousetop=document.body.scrollTop+event.clientY; 
	} 

	alert(mouseleft+'||'+mousetop);
	$('#MUSK').one("click", function(){
	  $('.nodisplay').css('display','none');
	  $('#MUSK').remove();
	}); 
}
function loadmake()
{
	//加载make下拉菜单的内容
	$.get("/USITE/Function/getmake.php",{user:user,l:ver,random:Math.random()},function(data){
		$('select.make').each(function(){
			$(this).html(data);
			mod=$(this).parents(".control").attr('id');
			var key=$(this).attr('key');	
			if (key=='')
			{
				key=readCookie($(this).attr('id'));
			}
			if (key!='')
			{
				var obj=this;
				//为了兼容ie6的写法;TNND  BT ............................
				setTimeout(function(){
				$(obj).val(key);
				selectclick($(obj).attr("id"),key);
				mno=$(obj).val();
				makechange(mno,mod);
				},1);
			}
		});
	});
}
function loadpart()
{
	$.get("/USITE/Function/getpart.php",{user:user,l:ver,random:Math.random()},function(data){
		$('select.part').each(function(){
			$(this).html(data);
			key=$(this).attr('key');
			key=readCookie($(this).attr('id'));
			if (key!='')
			{
				$(this).val(key);
				selectclick($(this).attr("id"),key);
			}			
		});
	});	
}
function loadgroup()
{
	//加载group列表
	$.get("/USITE/Function/getgroup.php",{user:user,l:ver,random:Math.random()},function(data){
		$('select.group').each(function(){
			$(this).html(data);
			var module=$(this).parents(".control").attr('id');
			key=$(this).attr('key');
			key=readCookie($(this).attr('id'));
			if (key!='')
			{
				$(this).val(key);				
				selectclick($(this).attr("id"),key);
				$.get("/USITE/Function/getpart.php",{user:user,l:ver,g:key,random:Math.random()},function(data){
					$('#'+module+' select.part').each(function(){
						$(this).html(data);
						key=$(this).attr('key');
						key=readCookie($(this).attr('id'));
						if (key!='')
						{
							$(this).val(key);
						}
					});
					$('#'+module+' select.part').change(function(){
						var partno=$(this).children("option:selected").attr("value");
						writeCookie(module+'_part',partno,24);
					});
				});
			}
		});
	});
}
function makechange(makeno,module){
		//过滤model engine chassis
		//var makeno=$("select.make").find("option:selected").attr("value");
		//alert(makeno);
		//记录cookies
		writeCookie(module+'_make',makeno,24);
		//清空车型,发动机,底盘
		//writeCookie(module+'_model','',0);
		//writeCookie(module+'_engine','',0);
		//writeCookie(module+'_chassis','',0);
		$.get("/USITE/Function/getmodel.php",{user:user,l:ver,m:makeno,random:Math.random()},function(data){
			$("#"+module+" select.model").each(function(){
				$(this).html(data);
				key=$(this).attr('key');
				if (key=='')
				{
					key=readCookie($(this).attr('id'));
				}
				$('#select_'+$(this).attr("id")+' .content').text($(this).find("option:first").attr('text'));
				if (key!='')
				{
					$(this).val(key);
					selectclick($(this).attr("id"),key);
				}
			});
			//选择车型后其它两个选项不能动
			$("#"+module+" select.model").change(function(){
				cur=$(this).find("option:selected").attr('value'); 
				//记录cookie
				writeCookie(module+'_model',cur,24);
				//清空其它cookie
				writeCookie(module+'_engine','',0);
				writeCookie(module+'_chassis','',0);
				if (cur!='')
				{
					$('#'+module+' select.engine').val('');
					$('#'+module+' select.engine').attr('disabled','true');
					$('#'+module+' select.chassis').val('');
					$('#'+module+' select.chassis').attr('disabled','true');
				}
				else
				{	
					$('#'+module+' select.engine').attr('disabled','');
					$('#'+module+' select.chassis').attr('disabled','');
				}
			});
		});
		$.get("/USITE/Function/getengine.php",{user:user,l:ver,m:makeno,random:Math.random()},function(data){
			$('#'+module+' select.engine').each(function(){
				$(this).html(data);
				key=$(this).attr('key');
				if (key=='')
				{
					key=readCookie($(this).attr('id'));
				}
				$('#select_'+$(this).attr("id")+' .content').text($(this).find("option:first").attr('text'));
				if (key!='')
				{
					$(this).val(key);
					selectclick($(this).attr("id"),key);
				}
			});
			//选择车型后其它两个选项不能动
			$("#"+module+" select.engine").change(function(){
				cur=$(this).find("option:selected").attr('value'); 
				//记录cookie
				writeCookie(module+'_engine',cur,24);
				//清空其它cookie
				writeCookie(module+'_model','',0);
				writeCookie(module+'_chassis','',0);
				if (cur!='')
				{
					$('#'+module+' select.model').val('');
					$('#'+module+' select.model').attr('disabled','true');
					$('#'+module+' select.chassis').val('');
					$('#'+module+' select.chassis').attr('disabled','true');
				}
				else
				{	
					$('#'+module+' select.model').attr('disabled','');
					$('#'+module+' select.chassis').attr('disabled','');
				}
			});
		});
		$.get("/USITE/Function/getchassis.php",{user:user,l:ver,m:makeno,random:Math.random()},function(data){
			$('#'+module+' select.chassis').each(function(){
				$(this).html(data);
				key=$(this).attr('key');
				if (key=='')
				{
					key=readCookie($(this).attr('id'));
				}
				$('#select_'+$(this).attr("id")+' .content').text($(this).find("option:first").attr('text'));
				if (key!='')
				{
					$(this).val(key);
					selectclick($(this).attr("id"),key);
				}
			});
			//选择车型后其它两个选项不能动
			$("#"+module+" select.chassis").change(function(){
				cur=$(this).find("option:selected").attr('value'); 
				//记录cookie
				writeCookie(module+'_chassis',cur,24);
				//清空其它cookie
				writeCookie(module+'_model','',0);
				writeCookie(module+'_engine','',0);
				if (cur!='')
				{
					$('#'+module+' select.model').val('');
					$('#'+module+' select.model').attr('disabled','true');
					$('#'+module+' select.engine').val('');
					$('#'+module+' select.engine').attr('disabled','true');
				}
				else
				{	
					$('#'+module+' select.model').attr('disabled','');
					$('#'+module+' select.engine').attr('disabled','');
				}
			});
		});
		
}
function showselect(sel){
	if ($('#'+sel).attr("disabled")==true)
	{
		return;
	}
	$('<div id="POPselect"></div>').appendTo("body"); 
	$('<div id="MUSK"></div>').appendTo("body"); 
	$("div#MUSK").css("top",0);
	$("div#MUSK").css("left",0);
	$("div#MUSK").css({width:$(document).width(),height:$(document).height()});
	var temp='<ul>';
	var selecttitle;
	$('#'+sel+' option').each(function(){
		temp+='<li onclick="selectclick(\''+sel+'\',\''+$(this).attr('value')+'\')">'+$(this).attr('text')+'</li>';
		if ($(this).attr('value')=='')
		{
			selecttitle=$(this).attr('text');
		}
	});
	temp+='</ul>';
	$("div#POPselect").html('<div class="title">'+selecttitle+':<div class="tools"><span class="close" onclick="divclose(\'POPselect\')"></span></div></div><div class="content">'+temp+'</div><div id="close" onclick="divclose(\'POPselect\')" title="close window"></div>');
	//排序
	
	
	$("div#POPselect").css("top",$(document).scrollTop()+$(window).height()/2-450/2);
	$("div#POPselect").css("left",$(window).width()/2-800/2);
	$("div#POPselect").css({width:800,height:450});
	$("div#POPselect").fadeIn("slow");
	//点击MUSK关闭层
		$('#MUSK').click(function(){
			divclose('POPselect');
		});
}
function selectclick(sel,key)
{
	if (key=='')
	{
		$('#'+sel).val('');
		$('#select_'+sel+' .content').text($('#'+sel).find("option:first").attr('text'));
	}
	else
	{
		$('#'+sel).val('');
		$('#'+sel).val(key);
		$('#select_'+sel+' .content').text($('#'+sel).find("option[value='"+key+"']").attr('text'));
	}
	temp=sel.split('_');
	mod=$('#'+sel).parents(".control").attr('id');
	writeCookie(mod+'_'+temp[1],key,24);
	if (temp[1]=='make')
	{
		makechange(key,mod);
	}
	if (temp[1]=="group")
	{//加载part列表
		var groupno=$("select.group").find("option:selected").attr("value");
		$.get("/USITE/Function/getpart.php",{user:user,l:ver,g:groupno,random:Math.random()},function(data){
			$('select.part').each(function(){
				$(this).html(data);
				key=$(this).attr('key');
				key=readCookie($(this).attr('id'));
				$('#select_'+$(this).attr("id")+' .content').text($(this).find("option:first").attr('text'));
				if (key!='')
				{
					$(this).val(key);
					$('#select_'+$(this).attr("id")+' .content').text($(this).find("option[value='"+key+"']").attr('text'));
				}
			});
		});
	}
	if (temp[1]=="chassis")
	{
		//清空其它cookie
		writeCookie(mod+'_engine','',0);
		writeCookie(mod+'_model','',0);
		if (key!='')
		{
			$('#'+mod+' select.engine').val('');
			//$('#'+mod+' select.engine').attr('disabled','true');
			$('#'+mod+' #select_'+temp[0]+'_engine').addClass('disabled');
			$('#'+mod+' select.model').val('');
			//$('#'+mod+' select.model').attr('disabled','true');
			$('#'+mod+' #select_'+temp[0]+'_model').addClass('disabled');
		}
		else
		{	
			$('#'+mod+' select.engine').attr('disabled','');
			$('#'+mod+' #select_'+temp[0]+'_engine').removeClass('disabled');
			$('#'+mod+' select.model').attr('disabled','');
			$('#'+mod+' #select_'+temp[0]+'_model').removeClass('disabled');
		}
	}
	if (temp[1]=="model")
	{
		//清空其它cookie
		writeCookie(mod+'_engine','',0);
		writeCookie(mod+'_chassis','',0);
		if (key!='')
		{
			$('#'+mod+' select.engine').val('');
			//$('#'+mod+' select.engine').attr('disabled','true');
			$('#'+mod+' #select_'+temp[0]+'_engine').addClass('disabled');
			$('#'+mod+' select.chassis').val('');
			//$('#'+mod+' select.chassis').attr('disabled','true');
			$('#'+mod+' #select_'+temp[0]+'_chassis').addClass('disabled');
		}
		else
		{	
			$('#'+mod+' select.engine').attr('disabled','');
			$('#'+mod+' #select_'+temp[0]+'_engine').removeClass('disabled');
			$('#'+mod+' select.chassis').attr('disabled','');
			$('#'+mod+' #select_'+temp[0]+'_chassis').removeClass('disabled');
		}
	}
	if (temp[1]=="engine")
	{
		//清空其它cookie
		writeCookie(mod+'_model','',0);
		writeCookie(mod+'_chassis','',0);
		if (key!='')
		{
			$('#'+mod+' select.model').val('');
			//$('#'+mod+' select.model').attr('disabled','true');
			$('#'+mod+' #select_'+temp[0]+'_model').addClass('disabled');
			$('#'+mod+' select.chassis').val('');
			//$('#'+mod+' select.chassis').attr('disabled','true');
			$('#'+mod+' #select_'+temp[0]+'_chassis').addClass('disabled');
		}
		else
		{	
			$('#'+mod+' select.model').attr('disabled','');
			$('#'+mod+' #select_'+temp[0]+'_model').removeClass('disabled');
			$('#'+mod+' select.chassis').attr('disabled','');
			$('#'+mod+' #select_'+temp[0]+'_chassis').removeClass('disabled');
		}
	}
	divclose('POPselect');
}
function searchmodel(){
	var makeno=$('#keywordsearch input#keyword').attr('value');
	if(makeno!='')
	{
	$.get("/USITE/Function/searchmodel.php",{user:user,l:ver,m:makeno,random:Math.random()},function(data){
		$('select').addClass("hidden");
		$('<div id="POPmodellist"></div>').appendTo("body"); 
		$('<div id="MUSK"></div>').appendTo("body"); 
		$("div#MUSK").css("top",0);
		$("div#MUSK").css("left",0);
		$("div#MUSK").css({width:$(document).width(),height:$(document).height()});
		$("div#POPmodellist").html(data);
		$("div#POPmodellist").css("top",$(document).scrollTop()+$(window).height()/2-450/2);
		$("div#POPmodellist").css("left",$(window).width()/2-800/2);
		$("div#POPmodellist").css({width:800,height:450});
		$("div#POPmodellist").fadeIn("slow");
		//点击MUSK关闭层
		$('#MUSK').click(function(){
			divclose('POPmodellist');
		});
	});
	}
	else
	{
		$.get("/USITE/Function/getlanguage.php",{user:user,l:ver,m:'keywrodnolen',random:Math.random()},function(data){
			alert(data);
		});
	}
}
function showproduct(pid){
	var panel=arguments[1]?arguments[1]:0;
	$.get("/USITE/Function/showproduct.php",{user:user,l:ver,m:pid,random:Math.random()},function(data){
		$('select').addClass("hidden");
		$('<div id="POPproview"></div>').appendTo("body"); 
		$('<div id="MUSK"></div>').appendTo("body"); 
		$("div#MUSK").css("top",0);
		$("div#MUSK").css("left",0);
		$("div#MUSK").css({width:$(document).width(),height:$(document).height()});
		$("div#POPproview").html(data);
		$("div#POPproview").css("top",$(document).scrollTop()+$(window).height()/2-600/2);
		$("div#POPproview").css("left",$(window).width()/2-800/2);
		$("div#POPproview").css({width:800,height:600});
		$("div#POPproview").fadeIn("slow");
		$("div#POPproview").draggable({ handle: '.title' });
		$('.tabs').tabs('option', 'selected',panel);
		//车型树的点击动作
		$('.TreeTable tr.subtitle').click(function(){
			temp=$(this).attr('id');
			oheight=$('.TreeTable').height();
			$('.TreeTable tr.'+temp).toggle();
		});
		//点击MUSK关闭层
		$('#MUSK').click(function(){
			divclose('POPproview');
		});
		//鼠标移过变色
		$(".TreeTable tr").hover(
		function(){
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass("hover");
		  }
		);
	});
}
function showotherproduct(pid){
	$.get("/USITE/Function/showotherproduct.php",{user:user,l:ver,m:pid,random:Math.random()},function(data){
		$('select').addClass("hidden");
		$('<div id="POPproview"></div>').appendTo("body"); 
		$('<div id="MUSK"></div>').appendTo("body"); 
		$("div#MUSK").css("top",0);
		$("div#MUSK").css("left",0);
		$("div#MUSK").css({width:$(document).width(),height:$(document).height()});
		$("div#POPproview").html(data);
		$("div#POPproview").css("top",$(document).scrollTop()+$(window).height()/2-600/2);
		$("div#POPproview").css("left",$(window).width()/2-800/2);
		$("div#POPproview").css({width:800,height:600});
		$("div#POPproview").fadeIn("slow");
		//车型树的点击动作
		$('.TreeTable tr.subtitle').click(function(){
			temp=$(this).attr('id');
			oheight=$('.TreeTable').height();
			$('.TreeTable tr.'+temp).toggle();
		});
		//点击MUSK关闭层
		$('#MUSK').click(function(){
			divclose('POPproview');
		});
		//鼠标移过变色
		$(".TreeTable tr").hover(
		function(){
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass("hover");
		  }
		);
	});
}
function checklogin(){
	if ($("#loginform input[name='username']").attr('value')==undefined)
	{
		uname='';
		upass='';
	}
	else
	{
		uname=$("#loginform input[name='username']").attr('value');
		upass=$("#loginform input[name='password']").attr('value');
	}
	$.get("/USITE/Function/checklogin.php",{user:user,username:uname,pass:upass,l:ver,random:Math.random()},function(data){
		$('#loginform .content').html(data);
		$(":text").focus(function(){
			$(this).select();
		});
		$(":password").focus(function(){
			$(this).select();
		});
	});
}
function show(str){

	$("#"+str+" .hide").toggle();
	$("#"+str+" .more").toggle();
	cur=$("#"+str+" .hide").css('display');
	if (cur=='none')
		writeCookie('list_'+str,'',0);
	else
		writeCookie('list_'+str,'show',24);
	
}
function divclose(str)
{
	$('select').removeClass("hidden");
	$('#MUSK').remove();
	//$('#'+str).css('display',"none");
	$('#'+str).html('<b></b>');
	$('#'+str).empty();
	$('#'+str).remove();
}
function loadmode(style,obj)
{
	if ($('#'+obj+' img').attr('src')!=undefined)
	{		
		if ($('#'+obj+' img').attr('src').indexOf('loading.gif'))
		{
			$.get(style,{user:user,l:ver,random:Math.random()},function(data){
				$('#'+obj).html(data);
			});
		}
	}
	//alert($('#'+obj+' img').attr('src').indexOf('loading.gif'));
	/*  //2009-12-18屏去下面代码
	$(".TreeTable tr.subtitle").click(function(){
		temp=$(this).attr("id");
		$(".TreeTable tr."+temp).toggle();
	});
	//鼠标移过变色
	$(".TreeTable tr").hover(
	function(){
		$(this).addClass("hover");
	},
	function () {
		$(this).removeClass("hover");
	  }
	);
	*/
}
function gotopage()
{
	var str=window.location+'';
	var num=$('#pagecount').val();
	if (str.indexOf('page=')==-1)
	{
		window.location=str+'&page='+num;
	}
	else
	{
		window.location=str.replace(/page=([^&])+/g,'page='+num);
	}
}
//以下是用于购物车的JS========================
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 writeCookie(name, value, hours)   
{   
  var expire = "";   
  if(hours != null)   
  {   
	 expire = new Date((new Date()).getTime() + hours * 3600000);   
	 expire = "; expires=" + expire.toGMTString();   
  }   
  
  document.cookie = name + "=" + escape(value) + expire;   
}
function checkthis(id) {
	writeCookie('pro_'+id,'1',24);
	window.location='?m=pdcar';
}

function clearthis(id) {
	writeCookie('pro_'+id,'0',0);
	window.location.reload();
}
function clearall() {
	i=0;
	while(1){
		x = document.getElementById('id_'+i);
		if(!x) window.location.href='?m=pdcar';
		writeCookie('pro_'+x.value,'0',0);
		i++;
	}
}
function changeQTY() {
	var i=0;
	while(1){
		var x = $('#id_'+i)[0];
		if(!x) window.location.href='?m=pdcar';
		t = $('#qty_'+x.value)[0];
		writeCookie('pro_'+x.value,t.value,24);
		i++;
	}
}

$("a").bind("focus",function(){
	if(this.blur){ //如果支持 this.blur
	this.blur();
	}
});
