function ajaxLoginOut() {
	$.get('ajax.php',{action:'loginout'},function(data) {
		if(data !='') {
			window.location.reload();	
		}
	});	
}
//变换验证码图片
function changeCheckSrc(){
	var o = new Date();
	var oldSrc = $("#checkCodeImg").attr('src');
	var nweSrc = oldSrc + '?pram=' + o.getMilliseconds();
	$("#checkCodeImg").attr('src',nweSrc);
}

function AutoSize(ImgD,MaxWidth,MaxHeight)
{
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0)
   {
    flag=true;
    if(image.width/image.height>= MaxWidth/MaxHeight)
    {
     if(image.width>MaxWidth)
     { 
     ImgD.width=MaxWidth;
     ImgD.height=(image.height*MaxWidth)/image.width;
     }
     else
     {
     ImgD.width=image.width; 
     ImgD.height=image.height;
     }
     //ImgD.alt="原始尺寸:宽" + image.width+",高"+image.height;
     }
    else
    {
     if(image.height>MaxHeight)
     { 
     ImgD.height=MaxHeight;
     ImgD.width=(image.width*MaxHeight)/image.height;     
     }
     else
     {
     ImgD.width=image.width; 
     ImgD.height=image.height;
     }
     }
    }
   } 
   //下拉列表默认选择
 function defaultOption(id,valueStr){
	 	var obj=document.getElementById(id);
		for(var i=0;i<obj.options.length;i++){
			if(obj.options[i].value == valueStr){
				obj.options[i].selected=true;
				break;
			}
		}
	 }
//更新品牌人气
function ajaxAddBrandFavor(id) {
	$.get('ajax.php',{action:'addBrandFavor',goods_id:id});
}

function checkAll() {
	//全选和反选
	$(".checkBoxAll").click(function(){
		if($(this).attr('checked') == true)
		{
			$("input[@name='cBox[]']").each(function(){
				$(this).attr('checked',true);
				$(this).parent().parent().attr({isclick:true});
				//$(this).parent().parent().children().css('background','#FFC000');
			});
		}
		else
		{
			$("input[@name='cBox[]']").each(function(){
				$(this).attr('checked',false);
			});
			tbodyOBJ = $(this).parent().parent().parent().next().find('tr');
			tbodyOBJ.each(function(i){
/*				if(i%2 == 0)
					$(this).children().css({background:"#FFF"});
				else
					$(this).children().css({background:"#F5F5F5"});*/
				$(this).attr({isclick:false});
				$(this).children().css('font-weight','normal');
			})
		}
	});

	//单击单个checkbox事件
	$("input[@name='cBox[]']").click(function(){
		if(!$(this).attr('checked'))
		{
			$(".checkBoxAll").attr('checked',false);
			$(this).parent().parent().attr({isclick:true});
			//$(this).parent().parent().children().css('background','');
		}
		else {
			$(this).parent().parent().attr({isclick:false});
			//$(this).parent().parent().children().css('background','#FFC000');
		}
	});	   
}

//添加图片广告的点击次数
function addAdViewTimes(i) {
	$.get('ajax.php',{action:'addAdViewTimes',id:i});
}

function getTl(id){
	var obj=document.getElementById(id);
	var t=obj.offsetTop;
	var l=obj.offsetLeft;
	while(!(obj.tagName.toLowerCase()=='body')){
		obj=obj.parentNode;
		t+=obj.offsetTop;
		l+=obj.offsetLeft;
	}
	return Array(t,l);
}

//删除收藏
function deleteCollect(i) {
	if(confirm("确定要删除吗？")) {
		$.get("ajax.php",{action:'deleteColect',id:i},function(data){
			if(data=='ok'){
				window.location.reload();
			}
		});
	}
}
//添加收藏i是资源id,t是收藏类型1设计师2手记
function addCollect(i,t) {
	$.get("ajax.php",{action:'addColect',id:i,collect_type:t},function(data){
		if(data=='ok'){
			alert('收藏成功');
		} else {
			alert(data);
		}
	});
}
