﻿function goSearch()
{
    var v = $.trim($("#q").val());
	if(v.length > 50){
		alert("您输入的关键字过长！");
		$('#q').focus();
		return false;
	}
	if(v == ""  || v.substring(0,3) =="请输入") {
		alert('请输入要搜索的关键字!');
		$('#q').focus();
        return false;
	}
	$('#q').val(v);
    return true;
}
    
function ajaxLoad()
    {
  $('.u').load('/XHttpService/Ajax_UserInfo.aspx #info');
    }

function showQuickAlert(msg) 
{
    $('<div class="quick-alert">'+msg+'</div>')
    .insertAfter( $("#BTN_Submit") )
    .fadeIn('slow')
    .animate({opacity: 1.0}, 3000)
    .fadeOut('slow', function() {
      $(this).remove();
    });
}


//CheckBox 全选
function selectAllCheckBox() 
{
  var b=false;
  if($("#selall").attr("checked"))
       b=true;
  $("input:checkbox").each(function(){$(this).attr("checked",b); });
}

//CheckBox 检测是否至少选择了一个
function checkSelectCheckBox() 
{
	var b=false;
	$("input:checkbox").each(function(){if($("this").attr("checked"))b=true;});
 
  if(!b)
  {
    alert("至少要选择一条信息后才能进行操作！");
  }
  return b;
}

function changeManageState()
{   
if($("#ManageState").val()=="ToCategory")
  {
       $("#ToCategory").show();
   }
}

jQuery.fn.cycle = function(c1, c2, cm){
    if(!(c1 && c2)) 
    {return;} //判断有没得参数传入
    var css='';
    var oj='';
    this.each(function(){ //选中了多少个表格
        oj = jQuery("tr",jQuery(this));
        oj.each(
        function(i){ // 选中表格中的 TR 加 CSS
        if(i % 2 == 0)
        {css =c1;}
        else
        {css =c2;};
        jQuery(this).addClass(css);
        });
        
        if(cm){ //如果有第三个参数
            oj.hover(function(){
                jQuery(this).addClass(cm);
            },
            function(){
                jQuery(this).removeClass(cm);
            });
        };
    });
}

function checkImageSize(id,w,h)
{ 
        var s_width=$(id).width();
        var s_height=$(id).height();
        if($(id).width()>w)
        {
            $(id).width(w);
            $(id).height(w/s_width*s_height);
        }
        if($(id).height()>h)
        {
            $(id).height(h);
            $(id).width(h/s_height*s_width);
        }
};

function getLeftChars(varField,num)
{
var i = 0;
var counter = 0;
var cap = num;
var leftchars = cap - varField.value.length;
return (leftchars);
}

function onCharsChange(varField,num)
{
var leftChars = getLeftChars(varField,num);
	if ( leftChars >= 0)
	{
	charsmonitor.innerText = leftChars;	
	return true;
	} 
	else
	{
	charsmonitor.innerText="0";
	window.alert("超过了系统限定字数，你只能输入"+num+"个字符！");
	var len = varField.value.length + leftChars;
	varField.value = varField.value.substring(0, len);
	leftChars = getLeftChars(varField,num);
	if ( leftChars >= 0)
	{charsmonitor.innerText=leftChars;}
	return false;
	}
}

function getOtherOffer(type,id)
{
    $("#OtherSellInfo").html("<img src=http://img.dooreb.com/icon_loading.gif /> 载入中...");
   var url = "/XHttpService/XHttp.ashx?f=get_other_offer&type="+type+"&id="+id+"&d="+new Date();
    $.get(url,function(data)
     {     	
	if(data != "")
　　{$("#OtherSellInfo").html(data);$(".goodslist img").LoadImage(true,110,110,"");}
　　else
　　{$("#OtherSellInfo").html("暂无此类信息！");}     
    });
}

function show_pic_468x60()
{
document.writeln("<div class=gad-pic><script type=\"text\/javascript\"><!--");
document.writeln("google_ad_client = \"pub-8233113895447008\";");
document.writeln("\/* 468x60, 创建于 09-11-20 *\/");
document.writeln("google_ad_slot = \"6760985087\";");
document.writeln("google_ad_width = 468;");
document.writeln("google_ad_height = 60;");
document.writeln("\/\/-->");
document.writeln("<\/script>");
document.writeln("<script type=\"text\/javascript\" src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">");
document.writeln("<\/script></div>");
}