//+---------------------------------------------------
//|	301重定向
//+---------------------------------------------------
if (document.domain =='saapaa.com'){ 
    this.location = "http://www.saapaa.com" + this.location.pathname + this.location.search;
}

//+---------------------------------------------------
//|	快速方法获得当前的对象
//+---------------------------------------------------
function $byid(objectId){
	return reobj=(typeof(objectId)=="object") ? objectId : document.getElementById(objectId);
}



//+---------------------------------------------------
//|	显示或隐藏一个对象
//+---------------------------------------------------
function display(objectId){

	if($byid(objectId).style.display=='none'){
		$byid(objectId).style.display='block';
	}else{
		$byid(objectId).style.display='none';
	}
}

//+---------------------------------------------------
//|	JS对list数据的排序
//|	AjaxSortBy (模型,操作,字段,排序,对象,分页)
//AjaxPageBy (model,action,field,sort,obj,page
//+---------------------------------------------------
function AjaxPageBy (url,obj,page){
	ThinkAjax.get(APP+"/"+model+"/"+action+"/","p="+page+"&_order="+field+"&_sort="+sort,obj);
}


//+---------------------------------------------------
//|	最简单的ajax方式
//|	AjaxSortBy (模型/操作,对象)
//+---------------------------------------------------
function simajax (url,obj){
	//$("#"+obj).html(loading);
	$.ajax({
		//url: APP+"/"+url,
		url: url,
		type:"POST",
		success: function(msg){
			$("#"+obj).html(msg);
		}
	});
}

//+---------------------------------------------------
//|	最简单的ajax方式
//|	AjaxSortBy (模型/操作,对象),会员中心专用
//| ZD 13:55 2010-9-16 修改
//+---------------------------------------------------
function mbsimajax(passurl,obj){
	window.inibidjs='';//主要处理了会员中心里ajax后不能移除用户正在进行拍卖的进程
	$(document.body).prepend('<div id="highlightTips" style="position:absolute; top:50%; left:50%; margin-left:-100px; width:200px;Z-index:11005;">'+loading+'</div>');
	$.ajax({
		type: "POST",
		url:passurl,
		"data": '',
		success: function(msg){
			setTimeout(function(){$("#highlightTips").remove();},100);//清除掉提示语 ( loading )
			$("#"+obj).html(msg);
			$("#highlightTips").remove();
			initStyle();
		}
	});

}
//+---------------------------------------------------
//|	最简单的ajax方式[2010-10-09小宗添加,重载函数-主要用于后台]
//|	AjaxSortBy (模型/操作,对象),会员中心专用
//| ZD 13:55 2010-9-16 修改
//+---------------------------------------------------
function mbsimajax(passurl,obj,divId,zIndex)
{
	//if(typeof(divId)=="undefined" || divId.length<1)
	if(divId==null || divId.length<1) divId="highlightTips";
	if(zIndex==null) zIndex = 10005;		
	
	window.inibidjs='';//[保留]
	$(document.body).prepend('<div id="'+ divId +'" style="position:absolute; top:50%; left:50%; margin-left:-100px; width:200px;Z-index:'+ zIndex +';">'+loading+'</div>');
	$.ajax({
		type: "POST",
		url:passurl,
		"data": '',
		success: function(msg)
		{
			setTimeout(function(){$("#"+ divId +"").remove();},100);//清除掉提示语 ( loading )
		//$("#Admin_SetOperateState_Info .dialogboxContent").html(msg);
			$("#"+obj).html(msg);
			$("#"+ divId +"").remove()
			initStyle();
		}
	});

}

//+---------------------------------------------------
//|	最简单的ajax方式[2010-10-09小宗添加,重载函数-主要用于后台]
//|	AjaxSortBy (模型/操作,对象),会员中心专用
//| ZD 17:19 2010-10-16 修改
//+---------------------------------------------------
function SimpleAjax(ToUrl,obj,divId,zIndex,data)
{
	if(obj==null || obj=="") obj = "AjaxShowArea";
	//if(typeof(divId)=="undefined" || divId.length<1)
	if(divId==null || divId.length<1) divId="Simple_highlightTips";
	if(zIndex==null) zIndex = 10005;		
	
	$(document.body).prepend('<div id="'+ divId +'" style="position:absolute; top:50%; left:50%; margin-left:-100px; width:200px;Z-index:'+ zIndex +';">'+loading+'</div>');
	$.ajax({
		"type": "POST",
		"url":ToUrl,
		"data": (data==null)?'':data,
		success: function(msg)
		{
			setTimeout(function(){$("#"+ divId +"").remove();},100);//清除掉提示语 ( loading )
		//$("#Admin_SetOperateState_Info .dialogboxContent").html(msg);
			$("#"+obj).html(msg);
			$("#"+ divId +"").remove()
			//initStyle();
		},
		error:function(msg)
		{
			$("#"+ divId +"").remove();
		}
	});

}


//+---------------------------------------------------
//|	打开模式窗口
//+---------------------------------------------------
function openwindow(theURL)
{
	//window.open(theURL,null,null);
	window.open (theURL, "newwindow", "height=420, width=600, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}

//+---------------------------------------------------
//|	js时间整除
//+---------------------------------------------------
function Div(exp1, exp2) {
	var n1 = Math.round(exp1); //四舍五入
	var n2 = Math.round(exp2); //四舍五入
	var rslt = n1 / n2; //除
	if (rslt >= 0) {
		rslt = Math.floor(rslt); //返回小于等于原rslt的最大整数。
	}else{
		rslt = Math.ceil(rslt); //返回大于等于原rslt的最小整数。
	}
	return rslt;
}

//+---------------------------------------------------
//|	js时间求余
//+---------------------------------------------------
function Mod(exp1, exp2) {
	var n1 = Math.round(exp1); //四舍五入
	var n2 = Math.round(exp2); //四舍五入
	var rslt = n1 % n2; //除
	if (rslt >= 0) {
		rslt = Math.floor(rslt); //返回小于等于原rslt的最大整数。
	}else{
		rslt = Math.ceil(rslt); //返回大于等于原rslt的最小整数。
	}
	return rslt;
}

//+---------------------------------------------------
//|	js时间求余
//+---------------------------------------------------
function Ft(d) {
	if(d<10){
		d="0"+d
	}
	return d;
}
//+---------------------------------------------------
//|	小数点取两位
//+---------------------------------------------------
function Ftmath(d) {
	numObj = new Number(d);
	d=numObj.toFixed(2);
	return d;
}




//+---------------------------------------------------
//清除URL里面的元素，主要是因为如果有很多个#的锚点没办法定位
//url为输入和地址,ps符号
//+---------------------------------------------------
function clearurl(url,ps){
	var   s=url;
	var   sarray=new   Array();
	sarray=s.split(ps);
	var   sa=sarray[0];
	// alert(sa);
	return sa;

}

function fleshVerify(id){
	//重载验证码
	var timenow = new Date().getTime();
	$byid(id).src= APP+'/User/verify/'+timenow;
//	alert($byid(id).src);
	//$byid('verifyImg').src= URL+'/verify/'+timenow;
}

function gotourl(url){
	location.href=APP+url;
}

/*连续字符自动换行*/
function toBreakWord(strContent,intLen){

	var strTemp="";
	while(strContent.length>intLen){
		strTemp+=strContent.substr(0,intLen)+" ";
		strContent=strContent.substr(intLen,strContent.length);
	}
	strTemp+=" "+strContent;
	return strTemp;
}



//+---------------------------------------------------
//|	操作cookie的方法
//@Author: johnson
//+---------------------------------------------------
function setCookie(name,value) {
	var Days = 30; //此 cookie 将被保存 30 天
	var exp  = new Date();    //new Date("December 31, 9998");
	exp.setTime(exp.getTime() + Days*24*60*60*1000);

	//document.cookie = name + "="+value+ ";path=/;expires=" + exp.toGMTString();
	document.cookie = name + "="+ escape (value) + ";path=/;expires=" + exp.toGMTString();

}

function getCookie(name) {
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null){
		if (unescape(arr[2]) == null){
			return ;
		}else{
			return unescape(arr[2]);
		}
		
	}else{
		return ;
	}
}

function delCookie(name){
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null) document.cookie= name + "="+cval+";path=/;expires="+exp.toGMTString();
}

/*以json的形式写入数组cookie*/
function setjsonCookie(name,value){
	//alert(name);
	//alert(value);
	var co = json_encode(value);
	setCookie(name,co);
}

/*以json的形式读取数组cookie*/
function getjsonCookie(name){
	var co = getCookie(name);
	//alert(json_decode(co));
	if(co!=null){
		co = co.replace(/,_/g, ',');
		co = co.replace(/{_/g, '{');
		co = co.replace(/_}/g, '}');
		return json_decode(co);
	}else{
		return false;
	}

}

/*以删除所有cookie*/
function clearCookie()
{
	var strCookie=document.cookie;
	var arrCookie=strCookie.split("; "); // 将多cookie切割为多个名/值对
	for(var i=0;i <arrCookie.length;i++)
	{ // 遍历cookie数组，处理每个cookie对
		var arr=arrCookie[i].split("=");
		if(arr.length>0)
		delCookie(arr[0]);
	}
}




/*
* @JavaScript Library: jquery.1.3.2.js by John Resig
* @Author: A.D.JC
*
* What are you looking for?
*
*/

/* ----------------------------------------------------------------------------------------------------
* 公共方法
* ----------------------------------------------------------------------------------------------------
*/
/* 公共用来显示ajax的方法 ajaxnote(内容,目标对象id,类型)*/
function showtips(str,target,type)
{
	$('#'+target).html(loading);
	if(type==0)
	{
		//正常
		$('#'+target).html(str);
	}
	else if(type==1)
	{
		//高亮提示
		$('#'+target).html('<div id="highlightTips"><p><img src="'+IMG_PATH+'/sprites/sprite.gif" class="sprite sprite_highlightTips"/>'+str+'</p></div>');
	}
	else if(type==2)
	{
		//警告提示
		$('#'+target).html('<div id="errorTips"><p><img src="'+IMG_PATH+'/sprites/sprite.gif" class="sprite sprite_highlightTips"/>'+str+'</p></div>');
	}
	else if(type==3)
	{
		//成功提示
		$('#'+target).html('<div id="errorTips"><p><img src="'+IMG_PATH+'/sprites/sprite.gif" class="sprite sprite_highlightTips"/>'+str+'</p></div>');
	}
	setTimeout("closetips('"+target+"')", 5000);//清空提示信息
}

/*清空信息的的方法,以后再做一些特效吧*/
function closetips(target)
{
	$('#'+target).html('');
}

function closetips2(target)
{
	$('#'+target).fadeOut("fast");
}


/* ----------------------------------------------------------------------------------------------------
* 公共函数
* ----------------------------------------------------------------------------------------------------
*/

/* check browser version (document.compatMode == "CSS1Compat") */
var sys = {};
var navua = navigator.userAgent.toLowerCase();
var browser;
(browser = navua.match(/msie ([\d.]+)/)) ? sys.ie = browser[1] :
(browser = navua.match(/firefox\/([\d.]+)/)) ? sys.firefox = browser[1] :
(browser = navua.match(/chrome\/([\d.]+)/)) ? sys.chrome = browser[1] :
(browser = navua.match(/opera.([\d.]+)/)) ? sys.opera = browser[1] :
(browser = navua.match(/version\/([\d.]+).*safari/)) ? sys.safari = browser[1] : 0;


/* 限定区域 */
function checkLimits(box,prison)
{
	//获取box对象的偏移
	var box_top    = parseInt(box.css("top"));
	var box_right  = box_left + parseInt(box.css("width"));
	var box_bottom = box_top + parseInt(box.css("height"));
	var box_left   = parseInt(box.css("left"));

	//获取对象的限定区域
	var prison_left   = document.getElementById(prison).offsetLeft;
	var prison_right  = prison_left + document.getElementById(prison).offsetWidth;
	var prison_top    = document.getElementById(prison).offsetTop;
	var prison_bottom = prison_top + document.getElementById(prison).offsetHeight;

	if(box_left < prison_left){box.css("left", prison_left);}
	if(box_top < prison_top){box.css("top", prison_top);}
	if(box_right > prison_right){box.css("left", prison_right - parseInt(box.css("width")));}
	if(box_bottom > prison_bottom){box.css("top", prison_bottom - parseInt(box.css("height")));}
}

/* iframe高度自适应 */
function iframeAutoHeight(obj)
{
	var frm = $byid(obj);
	var subWeb = document.frames ? document.frames[obj].document : frm.contentDocument;
	if (frm != null && subWeb != null){frm.height = subWeb.body.scrollHeight;}
}

/* 最小高度 */
function minHeight(id,obj)
{
	if($(id).height() <  $(obj).height())
	{
		autoHeight(id,obj);
	}
}

/* 高度自适应 */
function autoHeight(id,obj)
{
	$(id).height($(obj).height());
}

/* 宽度自适应 */
function autoWidth(id,obj)
{
	$(id).width($(obj).width());
}

/* 高宽自适应 */
function autoResize(id,obj)
{
	$(id).width($(obj).width());
	$(id).height($(obj).height());
}

/* 浮动层垂直居中的宽度计算，左偏移取自身宽一半的负值 */
function marginLeftOffset(obj)
{
	var leftOffset = -($(obj).width()/2);
	$(obj).css({"margin-left":leftOffset});
}



/* 屏幕遮罩 quitScreenMask()设置了单击或按esc退出遮罩 */
function addScreenMask(id)
{
	if(id==null) id="";//2010-09-27 Add
	
	var screenMaskA = '<div id="screenMask'+ id +'" style=" position:absolute; z-index:10000; top:0; left:0; display:none; width:100%; background:#000; opacity:0.5;"></div>';
	var screenMaskB = '<iframe frameborder="0" scrolling="no" id="screenMask'+ id +'" style=" position:absolute; z-index:10000; top:0; left:0; display:none; width:100%; background:#000; filter:alpha(opacity=30);"></iframe>';
	var screenMask = (!sys.ie) ? screenMaskA : screenMaskB;

	$(document.body).prepend(screenMask);
	$("#screenMask"+ id +"").height($(document).height()).fadeIn("fast");
}

//+---------------------------------------------------
//|	addScreenMask 
//@Author: WisdomStar
//@Date  : 2010-10-09 
//@gneng : 重载,在当前对话框内生成新对话框   
//+---------------------------------------------------
function addScreenMask(id,zIndex)
{
	if(id==null) id="";//2010-09-27 Add
	if(zIndex==null) zIndex = 10000;
	
	var screenMaskA = '<div id="screenMask'+ id +'" style=" position:absolute; z-index:'+ zIndex +'; top:0; left:0; display:none; width:100%; background:#000; opacity:0.5;"></div>';
	var screenMaskB = '<iframe frameborder="0" scrolling="no" id="screenMask'+ id +'" style=" position:absolute; z-index:'+ zIndex +'; top:0; left:0; display:none; width:100%; background:#000; filter:alpha(opacity=30);"></iframe>';
	var screenMask = (!sys.ie) ? screenMaskA : screenMaskB;

	$(document.body).prepend(screenMask);
	$("#screenMask"+ id +"").height($(document).height()).fadeIn("fast");
}


function removeScreenMask(id)
{
	if(id==null) id="";//2010-09-27 Add
	$("#screenMask"+ id ).fadeOut("fast",function(){
		$(this).remove();
	});
}

function quitScreenMask(fadeOutObj,id)
{
	if(id==null) id="";//2010-09-27 Add
	$("#screenMask" + id).bind("click", function(){
		removeScreenMask(id);
		$(fadeOutObj).fadeOut("fast");
		removeDialogbox(id);//临时加入
	});
	$(document.body).keydown(function(e){
		if (e.keyCode == 27)
		{
			removeScreenMask(id);
			$(fadeOutObj).fadeOut("fast");
			removeDialogbox(id);//临时加入
		}
	});
}


/* 对话框 内容嵌入到 .dialogboxContent */
function addDialogbox(objId,title,zIndex,objWidth,ScreenMaskId,zIndex_Sub)
{
	if(ScreenMaskId==null) ScreenMaskId="";//2010-09-27 Add

		zIndex_Sub = parseInt(zIndex)-1;
	addScreenMask(ScreenMaskId,zIndex_Sub);

	var objIdInHTML = objId.replace(/#/,"");
	var sTop = (document.compatMode == "CSS1Compat") ? document.documentElement.scrollTop : document.body.scrollTop;

	//why document.body.scrollTop == 0 on chrome?
	if (sys.chrome){sTop = document.body.scrollTop;}

	var docBodyScrollTop = sTop + $(window).height()/7;
	var left = $(window).width()/2 - objWidth/2;

	//处理子框生成
	if(zIndex_Sub!=null)
	{
		docBodyScrollTop = docBodyScrollTop + 100;
	}

	$(document.body).prepend(
	'<div id='+objIdInHTML+' class="dialogbox" style="top:'+docBodyScrollTop+'px; left:'+left+'px; z-index:'+zIndex+'; width:'+objWidth+'px;">'+

	'<div class="dialogboxTitle clearfix">'+
	'<h2>'+title+'</h2>'+
	'<p><a class="closeDialogbox" href="javascript:void(0);" title="关闭对话框"><img class="sprite sprite_close" src="'+IMG_PATH+'/sprites/sprite.gif" alt="关闭对话框00" /></a></p>'+
	'</div>'+

	'<div class="dialogboxContent" ></div>'+
	'</div>'
	);

	$(objId).fadeIn("fast");

	$(objId+" .closeDialogbox").bind("click",function(){
		removeDialogbox(objId,ScreenMaskId);
	});
}

function removeDialogbox(objId,ScreenMaskId)
{
	if(ScreenMaskId==null) ScreenMaskId="";//2010-09-27 Add

	$(objId).fadeOut("fast",function(){
		removeScreenMask(ScreenMaskId);
		$(this).remove();//从DOM中删除本对象
		//$("html").removeClass("hidden");
	});
}



/* ----------------------------------------------------------------------------------------------------
* 全局函数
* ----------------------------------------------------------------------------------------------------
*/

/* 垂直向上 循环滚动显示 */
function autoScroll(obj,marginTopValue)
{
	$(obj).find("ul:first").animate({
		marginTop:marginTopValue
	},500,function(){
		$(this).css({marginTop:"0"}).find("li:first").appendTo(this);
	});	
}
function startAutoScroll(obj,time)
{
	autoScrollIntervalId = setInterval(obj,time);
}
function clearAutoScroll()
{
	clearInterval(autoScrollIntervalId);
}
//显示大图
$(document).ready(function(){
    $("#picSlide img").not(":first").hide();
    $("#picNumBtn a").click(function(){
        if ($("#" + this.rel).is(":hidden"))
        {
            $("#picSlide img").slideUp();
            $("#" + this.rel).slideDown();
        }
		$(this).parent().addClass("currentNum").siblings().removeClass("currentNum");
    }).focus(function(){
        $(this).blur();
    });
});



/* Tabview and Button */
function initStyle()
{
	//tabview
	var $tabs = $(".tab a");

	$tabs.bind("click", function(){
		var tabId = $(this).attr("href");
		var tabIdStr = tabId.split("#");
		var currentTabId = '#'+tabIdStr[1];
		$(currentTabId).show().siblings(".content").hide();
		$(this).parent("li").addClass("on").siblings().removeClass("on");
		$(this).parent("h2").parent("li").addClass("on").siblings().removeClass("on");
		return false;
	})
	.focus(function(){
		$(this).blur();
	});
	
	//input[type='text'] input[type='password'] textarea button
	$(".input").hover(
	function(){
		$(this).addClass("input-hover");
	},
	function(){
		$(this).removeClass("input-hover");
	});
	
	$(".input").bind("focus",function(){
		$(this).addClass("input-focus");
	}).blur(function(){
		$(this).removeClass("input-focus");
	});
	
	$(".button button").bind("click",function(){
		$(this).blur();
	});
	
	$(".input:disabled").addClass("input-disabled");
	
	$(".button").hover(
	function(){
		$(this).addClass("button-hover");
	},
	function(){
		$(this).removeClass("button-hover");
	});
	
	$(".button-hilite").hover(
	function(){
		$(this).addClass("button-hilite-hover");
	},
	function(){
		$(this).removeClass("button-hilite-hover");
	});
}



/* 登录 注册 忘记账户或密码 */
function register()
{
	$("#userEmail").click(function(){
		$("#verifycodeInput").removeClass("displayNone");
	});
}


/* 主导航 */
function headerHandler()
{
	//主导航菜单
	$("#Auction").one("mouseover",function(){
		$("#auctionList").html(loading);
		$.ajax({
			type: "POST",
			url:APP+"/Auction/menuListAuction/",
			dataType: "html",
			success: function(msg){
				$("#auctionList").html(msg);
			}
		});
	});

	$(".mainNav").hover(
		function() {
			$(this).addClass("mainNavOn");
		},
		function() {
			$(this).removeClass("mainNavOn");
		}
	);

	//最新成交
	startAutoScroll("autoScroll('#latestDeals','-23px')",4000);
}


/* jt mouseover & mouseout */
function showTip(id){
	$("#"+id).mouseover(function(){
		var self = $(this).attr("id");
		jt(self);
		var _jtc = $(this).attr("jtContent");
		$("#jtContent").html(_jtc);
	}).mouseout(function(){
		$("#jt").remove();
	});
}


/*
 * Javascript Tips(jt)
 *
 * 作用：仅处理获取父级私有属性值后并赋予自身。
 *
 * 提示：
 * 1. 需要以一个事件来触发jt()
 * 2. 以id作为唯一标示传给jt()
 * 3. 必需加的属性 jtTitle="" jtWidth=""，当需要ajax某个页面的时候，可选属性 jtURL=""(该属性有待修改)
 * 4. #jt 是插入层的id，别冲突了

 * BidTip Example:

	$(document).ready(function(){
		$(".jtMO").mouseover(function(){
			var self = $(this).attr("id");
			jt(self);
		}).mouseout(function(){
			$("#jt").remove();
		});
	});

	<a id="ajaxTip2" href="/" jtURL='__APP__/User/getcount/' jtTitle="客服中心" jtWidth="250" class="jtMO">JT提示</a>

	<span jtTitle="提示" jtWidth="350" id="ajaxTip3" class="button jtBid">
		<span class="first-child">
			<button type="button" class="strong">出 价</button>
		</span>
	</span>

*/
function jt(objId)
{
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var hasArea = w - getAbsoluteLeft(objId);
	var clickElementy = getAbsoluteTop(objId) - 3;

	var $self = $("#" + objId);
	var _u = $self.attr("jtURL");
	var _t = $self.attr("jtTitle");
	var _w = $self.attr("jtWidth");
	var _c = $self.attr("jtContent");
	var jtArray = {"url":_u,"title":_t,"width":_w,"content":_c};
	
	//
	var _url = jtArray.url;
	if(_url === undefined)
	{
		_url = "";
	}
	else
	{
		$.ajax({
			type: "POST",
			url:_url,
			dataType: "html",
			success: function(msg){
				$("#jtContent").html(msg);
			}
		});
	}
	
	//
	var _content = jtArray.content;
	if(_content === undefined){_c = "";}

	if(hasArea>((jtArray.width*1)+75))
	{
		$("body").append("<div id='jt' style='display:none; width:"+jtArray.width*1+"px'><div id='jtArrowL'></div><div id='jtTitleL'>"+jtArray.title+"</div><div id='jtContent'><div id='jtLoader'><div></div></div>");
		var arrowOffset = getElementWidth(objId) + 11;
		var clickElementx = getAbsoluteLeft(objId) + arrowOffset;
	}
	else
	{
		$("body").append("<div id='jt' style='display:none; width:"+jtArray.width*1+"px'><div id='jtArrowR' style='left:"+((jtArray.width*1)+1)+"px'></div><div id='jtTitleR'>"+jtArray.title+"</div><div id='jtContent'><div id='jtLoader'><div></div></div>");
		var clickElementx = getAbsoluteLeft(objId) - ((jtArray.width*1) + 15);
	}

	$('#jt').css({left:clickElementx+"px", top:clickElementy+"px"}).fadeIn("fast");

	//Get width
	function getElementWidth(objId)
	{
		var x = $byid(objId);
		return x.offsetWidth;
	}

	//Get left position from the parent object
	function getAbsoluteLeft(objId)
	{
		var o = $byid(objId);
		var oLeft = o.offsetLeft;
		while(o.offsetParent!=null)
		{
			oParent = o.offsetParent;
			oLeft += oParent.offsetLeft;
			o = oParent;
		}
		return oLeft;
	}

	//Get top position from the parent object
	function getAbsoluteTop(objId)
	{
		var o = $byid(objId);
		var oTop = o.offsetTop;
		while(o.offsetParent!=null)
		{
			oParent = o.offsetParent;
			oTop += oParent.offsetTop;
			o = oParent;
		}
		return oTop;
	}
}


/* scaling in proportion */
function drawImage(obj,w,h)
{
	var image = new Image();
	image.src = obj.src;
	
	if(image.width>0 && image.height>0)
	{
		flag = true;
		if(image.width/image.height >= w/h)
		{
			if(image.width > w)
			{
				obj.width = w;
				obj.height = (image.height*w)/image.width;
			}
			else
			{
				obj.width = image.width;
				obj.height = image.height;
			}
		}
		else
		{
			if(image.height > h)
			{
				obj.height = h;
				obj.width = (image.width*h)/image.height;
			}
			else
			{
				obj.width = image.width;
				obj.height = image.height;
			}
		}
	}
}

/* ---------------------------------------------------------------------------------------------------
* 功能:显示异常信息
* 开发:智慧星
* 日期:下午 14:41 2010-10-19
* 条件:...
* ----------------------------------------------------------------------------------------------------
*/
function ShowErrorMsg(str)
{
	var id = "DivAjaxErrorMessage";
	var width = 560;
	var height = 200;
	var zIndex = 20001;
	var DialogCaption = "异常信息"
	addDialogbox("#"+id,DialogCaption,zIndex,width);
	var msg = '<textarea id="DivAjaxErrorMessage_textarea" style="width:'+(width-30)+'px;height:'+height+'px">' + str + '</textarea> ';
	$("#DivAjaxErrorMessage .dialogboxContent").html(msg);
}

/* ---------------------------------------------------------------------------------------------------
* 功能:加载编辑器
* 开发:智慧星
* 日期:上午 07:49 2010-10-12
* 条件:加载编辑器所需的相关文件和JS库
* ----------------------------------------------------------------------------------------------------
*/
function LoadEditor(TextAreaId)
{
	//alert(KE);
	if(TextAreaId==null || TextAreaId=="") TextAreaId = "Content";
	if(document.getElementById(TextAreaId)!=null)
	{  
		KE.init({
			id : TextAreaId,
		    width : "530px", //编辑器的宽度为70%
		    height : "300px", //编辑器的高度为100px
		    filterMode : true, //不会过滤HTML代码
		    resizeMode : 0, //编辑器只能调整高度
		    urlType : 'relative',//相对URL
			allowFileManager : true,
			autoOnsubmitMode :false,
		    imageUploadJson : '/kindeditor/asp.net/upload_json.ashx',
		    fileManagerJson : '/kindeditor/asp.net/file_manager_json.ashx'	
		    //afterCreate : function(id) {KE.util.focus(id);}
		});     

		KE.create(TextAreaId);
	}
	else
	{
		//alert("没找到DOM对象"+TextAreaId+",编辑器加载失败.");
	}
}

/*++++++++++++++++++++++++++++++++++++++++++
+ 替换 window.open()
++++++++++++++++++++++++++++++++++++++++++*/

function WindowOpen(url)
{

	var obj = document.getElementById("A_Window_Open");
	if(!obj)
	{
		// '<a id="A_Window_Open" href="'+ url +'" target="_blank"></a>';
		obj = document.createElement ( "a" ) ;
		obj.id="A_Window_Open";
		obj.target ="_blank";
		obj.href = url; 
		document.body.appendChild(obj); 
	}
	else
	{
		obj.href = url; 
		
		//myA.click();
	}
	/*
	try
	{
				var evt = document.createEvent("MouseEvents"); 
		evt.initEvent("click", true, true); 
		obj.dispatchEvent(evt);  		
		//  initMouseEvent("click", true, true, window,0, 0, 0, 0, 0,true, false, false, false, 0, null);
	}
	catch(e)
	{

		obj.click();
	}	
	*/
	name = "A_Window_Open";
          if(document.all)   
          {   
              document.getElementById(name).click();   
          }   
          else   
          {   
          	  /*
              var evt = document.createEvent("MouseEvents");   
              evt.initEvent("click", true, true);   
              document.getElementById(name).dispatchEvent(evt);   
              */
              window.open(url);
          }   	
			/*
	if(	$("#A_Window_Open").length<1)
	{
		$(document.body).prepend("<a id='A_Window_Open' href='"+ url +"' target='_self'>新弹框</a>");
		ShowErrorMsg($(document.body).html());
	}	
	else
	{
		$("#A_Window_Open").attr("href",url);//.attr("target","_blank");
		
		//ShowErrorMsg($("#A_Window_Open").attr("href"));
		
	}
	$("#A_Window_Open").click();
	
	*/	
		

}


/* 设置当前行的选中状态 */
function SetActive(id)
{
	$("[id^='tr_']").css({"background-color":"#ffffff"});
	$("#tr_"+id).css({"background-color":"#dddefa"});
}