<!--
//使用短函数替代 document.getElementById
function geid(id){ return document.getElementById(id); }
function getn(id){ return document.getElementsByTagName(id); }
function gen(id){ return document.getElementsByName(id); }
function getform(formid,id){
	if(!formid || formid == "undefined"){ formid = "form"; }
	return document.forms[formid].elements[id];
}
//按需加载JS文件以加快浏览速度
function js_load(url){
	var this_script = getn("script");
	for(i=0;i<this_script.length;i++) {
		if(this_script[i].src && this_script[i].src.indexOf(url)!=-1) { return true; }
	}
	var load_script = document.createElement("script");
	load_script.type = "text/javascript";
	load_script.src = url;
	var head = getn("head")[0];
	head.appendChild(load_script);
}

//按需加载CSS文件
function css_load(url){
	var this_style = getn("link");
	for(i=0;i<this_style.length;i++) {
		if(this_style[i].href && this_style[i].href.indexOf(url)!=-1) { return true; }
	}
	var load_style = document.createElement("link");
	load_style.type = "text/css";
	load_style.href = url;
	load_style.media = "all";
	load_style.rel = "stylesheet"
	var head=getn("head")[0];
	head.appendChild(load_style);
}

//验证是否为数字
function IsNumeric(input){
    var RE = /^-{0,1}\d*\.{0,1}\d+$/;
    return (RE.test(input));
}

//图片处理 Begin ===========================================
var flag=false; 
function DrawImage(ImgD,w,h){ 
var image=new Image();
image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		flag = true; 
		if(image.width/image.height>= w/h){ 
			if(image.width>w){ 
				ImgD.width=w; 
				ImgD.height=(image.height*w)/image.width; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
		}else{ 
			if(image.height>h){ 
				ImgD.height=h; 
				ImgD.width=(image.width*h)/image.height; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
		} 
	} 
} 
//改变图片大小
function resizepic(thispic){if(thispic.width>500) thispic.width=500;}
//图片处理 End ===========================================

function textLimitCheck(thisArea, maxLength){
	if (thisArea.value.length > maxLength){
		alert('限 '+maxLength + ' 个字符. \r超出的部分将自动去除.');
		thisArea.value = thisArea.value.substring(0, maxLength);
		thisArea.focus();
	}
}

//更改字体大小 Begin =============================================
var curfontsize=20;
var curlineheight=25;
function fontZoomA(){
  if(curfontsize>8){
    geid('fontzoom').style.fontSize=(--curfontsize)+'pt';
	geid('fontzoom').style.lineHeight=(--curlineheight)+'pt';
  }
}
function fontZoomB(){
  if(curfontsize<64){
    geid('fontzoom').style.fontSize=(++curfontsize)+'pt';
	geid('fontzoom').style.lineHeight=(++curlineheight)+'pt';
  }
}
//更改字体大小 End =============================================


function full_N_img(d){
	if(d != ""){
		var vd = new Date(d.replace("-","/"));
		var o = vd.setDate( vd.getDate()+3 );
		var n = new Date();
		if ( o < n.getTime() ){
			return "<img src='/images/overnew.gif' />";
		}else{
			return false;
		}
	}
}
//检查内容是否过期 | 加NEW图片 =============================================

/*
	$.cookie('the_cookie'); // 读取 cookie
	$.cookie('the_cookie', 'the_value'); // 存储 cookie
	$.cookie('the_cookie', 'the_value', { expires: 7 }); // 存储一个带7天期限的 cookie
	$.cookie('the_cookie', '', { expires: -1 }); // 删除 cookie
	参数：
	expires：可以是数字或者Data类型的对象。如果传入数字表示几天后过期。
	path：路径，默认为域名根目录（“/”）。
	secure：是否启用加密，默认为否。
*/
jQuery.cookie = function(name, value, options){
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = ''; options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


//窗口大小不可变
function OpenWin(win,url,w,h){
    parameter = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+w+",height="+h+"";
    window.open(url,win,parameter);
}

//http://www.xij.cn/blog/wp-content/uploads/2008/08/dialog/
//1 title 弹出层的标题 必填，纯文本
//2 content 弹出层的内容 :url get或post某一页面里的html，该页面要求只包含body的子标签url:post?
//:text 直接写入内容
//:id 显示页面里某id的子标签
//:iframe 层内内容以框架显示
//3 width 弹出层的宽 必填，css值，比如 200
//4 height 弹出层的高 如上，但是可用“auto”
//5 cssName 弹出层的css 给id floatBox加入的样式名，层内样式可以通过这个样式名来定制
var dialogFirst=true;
function dialog(title, content, w, h, cssName, scroll){
	if( dialogFirst == true ){
		var temp_float=new String;
		temp_float="<div id=\"floatBoxBg\" style=\"height:"+$(document).height()+"px;\"></div>";
		temp_float+="<div id=\"floatBox\">";
		temp_float+="<div class=\"dl_top\"><h4 id=\"dl_title\"></h4><span id=\"dl_close\">×</span></div>";
        var s = '';
        if( h == 'auto' ){
            s = '';
        }else {
            s = ' style="height:'+(parseInt(h)-30)+'px;"';
        }
		temp_float+="<div class=\"content\""+s+"></div>";
		temp_float+="</div>";
		$("body").append(temp_float);
		dialogFirst = false;
	}

	$("#dl_close").click(function(){ closeifram(); });

	$("#dl_title").html(title);
	contentType = content.substring(0,content.indexOf(":"));
	content = content.substring(content.indexOf(":")+1,content.length);
	switch(contentType){
		case "url":
			var content_array=content.split("?");
			$("#floatBox .content").ajaxStart(function(){
                $(this).html("loading...");
			});
			$.ajax({
    			type:content_array[0],
    			url:content_array[1],
    			data:content_array[2],
    			error:function(){
                    $("#floatBox .content").html("error...");
                },
                success:function(html){
                    $("#floatBox .content").html(html);
                }
			});
			break;
		case "text":
			$("#floatBox .content").html(content);
            break;
        case "id":
			$("#floatBox .content").html($("#"+content+"").html());
			break;
		case "iframe":
			$("#floatBox .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt($("#floatBox").height())-30)+"\" scrolling="+scroll+" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" allowTransparency=\"true\"></iframe>");
	}

	$("#floatBoxBg").fadeIn("slow");
	$("#floatBoxBg").animate({opacity:"0.5"},"normal");
	$("#floatBox").fadeIn("slow");
	var _version = $.browser.version;

    $("#floatBox").css({display:"block", left:""+($(window).width()-w)/2+"", top:""+($(window).height()-$("#floatBox").height())/2+"", zIndex: "10000", width:w+"px", height: h+"px"});

}
function closeifram(){
	$("#floatBoxBg").fadeOut("slow");
	$("#floatBox").fadeOut("slow");
}
//ajax提示框功能 End ========================================

/*间隔滚动  Begin ========================================
<div class="scrollGallery">
	<ul>
		<li></li>
	</ul>
</div>
<script type="text/javascript">
<!--
	$(".scrollGallery").jScroll({speed: 1000, scroll: 3});
//-->
</script> 
*/
(function($){
	$.fn.extend({
		"jScroll":function(o){
			o = $.extend({
				auto: 3000, //延迟时间（毫秒）
				speed: 800, //单次滚动时长（毫秒）
				vertical: false, //是否向上滚动(默认向左)
				scroll: 1 //每次滚动的元素数量
			},o);
			var running = false, sizeCss = o.vertical ? "height" : "width", ulSize = 0;
			var scrollTimer, scrollLen, itemSize, animCss, i;
			var div = $(this), ul = div.find("ul"), li = ul.children("li");
			
			div.css({overflow: "hidden"});
			ul.css({margin: "0", padding: "0", display: "inline-block"});
			li.css({"list-style-type": "none", float: o.vertical ? "none" : "left"});
			
			//获取LI元素总宽(高)
			for(i=0; i<=li.size()-1; i++){
				itemSize = o.vertical ? li.eq(i).outerHeight() : li.eq(i).outerWidth();
				ulSize+=itemSize;
			}
			var divSize = o.vertical ? div.height() : div.width(); //容器宽(高)
			ul.css(sizeCss, (ulSize*2)+"px");
			if(ulSize > divSize) running = true; //UL的宽(高)大于容的器宽(高)时才滚动
		
			div.hover(function(){
				clearInterval(scrollTimer);
			},function(){
				if(running){
					scrollTimer = setInterval(function(){
						scrollLen = 0;
						itemSize = 0;
						li = ul.children("li");
						for(i=0; i<=o.scroll-1; i++){
							itemSize = o.vertical ? li.eq(i).outerHeight() : li.eq(i).outerWidth();
							scrollLen+=itemSize;
						}
						animCss = o.vertical ? {marginTop:-scrollLen +"px"} : {marginLeft:-scrollLen +"px"};
						ul.animate(animCss, o.speed, function(){
							ul.css(o.vertical ? "margin-top" : "margin-left", "0");
							li.slice(0,o.scroll).appendTo(ul); //将前面的元素移至末尾
						})
					}, parseInt(o.auto+o.speed));
				}
			}).trigger("mouseleave"); //DOM加载完毕后自动执行hover(fn1, fn2)的fn2
		}
	});
})(jQuery);
//间隔滚动  End ========================================
// -->

