﻿/*************************
TKF Frame
*************************/
var tkf={
$:function(id){return document.getElementById(id)}
//start param
,fixed:true
,resizeTimer:null
,NeedLeaveAsk:false//默认关闭退出之前的询问
,screenwidth:screen.width
,screenheight:screen.height
,OldWidth:document.documentElement.clientWidth
//**start method 
,p$:function p$(string){document.write(string);}
//当div不存在的时候创建div
,checkDiv:function checkDiv(id){if($("#"+id)[0]){$("#"+id).remove();}$("<div id=\""+id+"\"></div>").appendTo("body");}
,rnd:function rnd(n){return Math.floor(Math.random()*n);}
,tagArr:function tagArr(o,name){return o.getElementsByTagName(name)}
,att:function att(o,name,fun){return document.all ? o.attachEvent(name,fun) : o.addEventListener(name.substr(2),fun,false);}
,style:function style(o){	return o.currentStyle || document.defaultView.getComputedStyle(o,null);}
,offsetLT:function offsetLT(o){var x = 0, y = 0;do { x += o.offsetLeft, y += o.offsetTop; } while (o = o.offsetParent);return { 'x' : x, 'y' : y };}
,dElement:function dElement(){ return document.documentElement || document.body;}
,rewriteAtt:function rewriteAtt(formerObj,newObj){for(var i in newObj){formerObj[i]=newObj[i];}return formerObj;}
,scpage:function scpage() {
   return {
        width: function() {return document.documentElement.clientWidth;},
        height: function() {return document.body.clientHeight;},
        theight: function() {var d = document, b = d.body, e = d.documentElement;var _h = 0;if ($.browser.msie) {_h = b.scrollHeight;}else { _h = e.scrollHeight; }return Math.max(_h, Math.max(b.clientHeight, e.clientHeight));},
        twidth: function() {var d = document, b = d.body, e = d.documentElement;var _h = 0;if ($.browser.msie) {_h = b.scrollWidth;}else { _h = e.scrollWidth; }return Math.max(_h, Math.max(b.clientWidth, e.clientWidth));}
    }}()
//计算相对位置
,getposOffset:function getposOffset(what, offsettype) {var totaloffset = (offsettype == "left") ? what.offsetLeft : what.offsetTop;var parentEl = what.offsetParent;while (parentEl != null) {totaloffset = (offsettype == "left") ? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop;parentEl = parentEl.offsetParent;}return totaloffset;}
//取消错误
,killErrors:function killErrors() {return true;}
//计算字符串的长度，汉字占两个字符
,StringLength:function StringLength(str){return str.replace(/[^\x00-\xff]/g,"**").length}
//用來存储目前已输入多少字，计算字數
,checkCount:function checkCount(obj,maxChr,displaySpan){
        var countobj='';var nowChr = 0;nowChr = StringLength(obj.value);
        var willChr=maxChr-nowChr;
        if(displaySpan!=''){countobj=document.getElementById(displaySpan);}
        if(willChr>0 && willChr!=maxChr){if(displaySpan!=''){countobj.innerHTML="可输入"+willChr+"字";}}
        else if(willChr==maxChr){if(displaySpan!=''){countobj.innerHTML="可输入"+maxChr+"字";}}
        else {if(displaySpan!=''){countobj.innerHTML="字数已到最大限制";}obj.value=obj.value.substr(0,maxChr)}
}
//显示一定的透明度
,displayOpacity:function displayOpacity(id, n) {
	if(!tkf.$(id)) {return;}
	if(n >= 0) {n -= 10;tkf.$(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + n + ')';tkf.$(id).style.opacity = n / 100;setTimeout('displayOpacity(\'' + id + '\',' + n + ')', 50);} 
	else {tkf.$(id).style.display = 'none';tkf.$(id).style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';tkf.$(id).style.opacity = 1;}
}
//输入的只能是数字和小数点
,clearNoNum:function clearNoNum(obj) { obj.value = obj.value.replace(/[^\d.]/g,"");obj.value = obj.value.replace(/^\./g,"");obj.value = obj.value.replace(/\.{2,}/g,".");obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");}
//用于在控件上执行正则表达式
,regInput:function regInput(obj, reg, inputStr){var docSel = document.selection.createRange();if (docSel.parentElement().tagName != "INPUT"){return false;}oSel = docSel.duplicate();oSel.text = "";var srcRange = obj.createTextRange();oSel.setEndPoint("StartToStart", srcRange);var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length);return reg.test(str);}
//判断是否是空或者空格
,checkspace:function checkspace(checkstr) {var str = '';for(i = 0; i < checkstr.length; i++) {str = str + ' ';}return (str == checkstr);}
//功能：判断是否在逗号分割的字符串内,参数：逗号分割的字符串，字符串
,checkStringInArrayStrings:function checkStringInArrayStrings(strings,str){if(strings=="")return false;var arrayStrings=strings.split(",");for (j = 0; j < arrayStrings.length; j++){if(str==arrayStrings[j]){return true;}}return false;}
//功能：去掉字符串右的逗号
,TrimRightDot:function TrimRightDot(str){if(str=="")return str;if(str.substring(str.length-1,str.length)==","){return str.substring(0,str.length-1);}else{return str;}}
//功能：将文本框中的字符串变成html
,TxtToHtml:function TxtToHtml(str){while (str.indexOf("\n") != -1){str = str.substring(0, str.indexOf("\n")) + "<br>" + str.substring(str.indexOf("\n") + 1);}return str;}
//检查邮箱是否正确
,IsMail:function IsMail(ChkStr) {var isEmail1= /^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;var isEmail2= /^.*@[^_]*$/;return ((isEmail1.test(ChkStr)) && (isEmail2.test(ChkStr)));}
//展开和折叠层
,deploy:function deploy(ID){obj=document.getElementById(ID);if(obj.style.display=="none"){obj.style.display="";}else{obj.style.display="none";}return false;}
//动态关闭div
,closediv:function closediv(o){var Intervalclosediv;o.style.height = o.clientHeight;var cy = parseInt(o.style.height);if(cy > 5){o.style.height = (cy - Math.ceil(cy/5)) +"px";Intervalclosediv = setInterval(function(){closediv(o)},100);}else{clearInterval(Intervalclosediv);o.style.display="none";}}
//判断是否定义
,isVarDefined:function isVarDefined(obj) {if(typeof(obj) == "undefined") {return false;} else {return true;}}
//确保div有个最小值
,minheight:function minheight(ID,height){obj=document.getElementById(ID);if(obj){if(obj.offsetHeight <height){obj.style.height=height+"px";}}}
//图片按比例缩放 调用：<img src="图片" onload="javascript:tkf.DrawImage(this)">
,DrawImage:function DrawImage(ImgD,iwidth,iheight){var image=new Image();image.src=ImgD.src;if(image.width>0 && image.height>0){if(image.width/image.height>= iwidth/iheight){if(image.width>iwidth){ImgD.width=iwidth;}}else{if(image.height>iheight){ImgD.height=iheight;}}}} 
//约束图片宽度
,fixImagesWidth:function fixImagesWidth(_id,_maxwidth){var elem=document.getElementById(_id);var images=elem.getElementsByTagName("img");for(var i=0;i<images.length;i++){if(images[i].offsetWidth > _maxwidth){images[i].style.width=_maxwidth+"px";}}}
//图片预览
,previewPhoto:function previewPhoto(pfile){var photoName=pfile.value;var i = photoName.lastIndexOf(".");var strExt = photoName.substring(i);if (strExt.toLowerCase() == ".gif" || strExt.toLowerCase() == ".jpg" || strExt.toLowerCase() == ".jpeg"){var htm = "<img border=0 width=200px src='" + photoName + "' onload='tkf.DrawImage(this);' />";document.getElementById("PicUpload1_divPhoto").innerHTML =htm;}else{document.getElementById("PicUpload1_divPhoto").innerHTML = "图片格式不正确，必须是gif、jpg或者jpeg";}}
//对象的绝对位置var x=getOJ(obj)[0];var y=getOJ(obj)[1];
,getOJ:function getOJ(e){var t = [e.offsetLeft,e.offsetTop];if(e=e.offsetParent){var r = getOJ(e);t[0] += r[0];t[1] += r[1];}return t;}  
//得到对象的位置
,getPosition:function getPosition() {var top = document.documentElement.scrollTop; var left = document.documentElement.scrollLeft; var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; return {top:top,left:left,height:height,width:width}} 
//Colour pallete top offset
,getOffsetTop:function getOffsetTop(elm) {var mOffsetTop = elm.offsetTop;var mOffsetParent = elm.offsetParent;while(mOffsetParent){mOffsetTop += mOffsetParent.offsetTop;mOffsetParent = mOffsetParent.offsetParent;}return mOffsetTop;}
//Colour pallete left offset
,getOffsetLeft:function getOffsetLeft(elm) {var mOffsetLeft = elm.offsetLeft;var mOffsetParent = elm.offsetParent;while(mOffsetParent) {mOffsetLeft += mOffsetParent.offsetLeft;mOffsetParent = mOffsetParent.offsetParent;}return mOffsetLeft;}

,addLoadEvent:function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {window.onload = func;} else {
        window.onload = function() {oldonload();func();}
    }
}
,addResizeEvent:function addResizeEvent(func) {
    var oldonload = window.onresize;
    if (typeof window.onresize != 'function') {window.onresize = func;} else {
        window.onresize = function() {oldonload();func();}
    }
}

/*************************
 * 功能：复选框全选
 * 调用示例：页面复选框，如：struts标签 <html:multibox property="checkFlag">0</html:multibox>或html标签 <input type="checkbox" name="checkFlag" value="0">   
 * 按钮或者连接中增加onclick事件，如：<input type="button" name="checkAll" value="全选" onclick="checkAll('checkFlag')">
*************************/
,checkAll:function checkAll(checkBoxName){var checkBox = document.getElementsByName(checkBoxName);for (var i = 0; i < checkBox.length; i++){var temp = checkBox[i];temp.checked = true;}}
//功能：复选框全不选
,checkNone:function checkNone(checkBoxName){var checkBox = document.getElementsByName(checkBoxName);for (var i = 0; i < checkBox.length; i++){var temp = checkBox[i];temp.checked = false;}}
//功能：复选框反选
,checkReverse:function checkReverse(checkBoxName){var checkBox = document.getElementsByName(checkBoxName);for (var i = 0; i < checkBox.length; i++){var temp = checkBox[i];temp.checked = !temp.checked;}}
//复制
,copyToClipBoard:function copyToClipBoard(){var clipBoardContent="";clipBoardContent+=this.location.href;window.clipboardData.setData("Text",clipBoardContent);alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友");} 
,copyToClipBoard:function copyToClipBoard(clipBoardContent){window.clipboardData.setData("Text",clipBoardContent);}


//获取页面的内容
,GetAjax:function GetAjax(url){var faileStr = "";var xmlHttp;try{xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}catch(e){return faileStr;}}try{xmlHttp.Open("GET",url,false);xmlHttp.Send();strRtn = xmlHttp.responseText;if(strRtn != null && strRtn != ""){return strRtn;}}catch(e){return faileStr;}return faileStr;}
/*更换标签显示样式*/ 
,change_menu:function change_menu(id,content_id,num,total_ztc_menu,menu_on,menu_off){for (var i=1;i<=total_ztc_menu;i++){tkf.$(id+i).className=menu_off;tkf.$(content_id+i).style.display='none';}tkf.$(id+num).className=menu_on;tkf.$(content_id+num).style.display='block';}

/*************************
 * Form Layer Class
*************************/
//打开窗口
,windowopen:function windowopen(sUrl,iWidth,iHeight,sResize){if(iWidth==0)iWidth=600;if(iHeight==0)iHeight=450;if(sResize=="yes"){l = (screenwidth - iWidth)/2-5;t = (screenheight - iHeight)/2-20;}else{l = (screen.width - iWidth)/2-5;t = (screen.height- iHeight)/2-20;sResize = "no";}var ff_submain = window.open("","","scroll=auto,resizable=" + sResize + ",status=1,width="+iWidth+",height="+iHeight+",left="+l+",top="+t);if (sUrl!=""){ff_submain.document.location.href = sUrl}}
//显示DIV
,Show:function Show(id, handid) {
    var o=$("#" + id);
    o.css('display', 'block');
    o.css('width', $("#" + id).width()+'px');
    tkf.pos(tkf.$(id));
    //tkf.mask();
    //tkf.resizeOn(id);
    tkf.Drag(id, handid);
    return false;
}

//确认提示1
,Alert:function Alert(content) {

    if ($('#M_Confirm')[0]) {
        $('#M_Confirm').remove();
    }

    var AlertHtml ="";//"<div class=\"alert\"  id=\"M_Confirm\">        <div class=\"alert_blc\">            <div class=\"alert_title\" id=\"M_ConfirmHand\"><h3>"+tit+"</h3></div>            <div class=\"alert_info\"> <div class=\"alert_confirm\"><b></b><p>" + content + "</p><i></i></div> </div>            <div class=\"btns\">                <a href=\"javascript:void(0)\" onclick=\"return false;\" class=\"submit\"><input type=\"botton\" value=\"确定\" onclick=\"$('#M_Confirm').remove();tkf.Close();\"  /></a>                         </div>            <span class=\"more\"><a class=\"alert_close\" href=\"javascript:void(0);\" onclick=\"$('#M_Confirm').remove();tkf.Close();\" title=\"关闭\">关闭</a></span>        </div>    </div>";

    
    AlertHtml+="<div class=\"pop_up01\" id=\"M_Confirm\">";
    AlertHtml+="<div class=\"pop_title01\" id=\"M_ConfirmHand\">";
    AlertHtml+="<span class=\"more\"><a class=\"title01_close\" href=\"javascript:void(0);\" onclick=\"$('#M_Confirm').remove();tkf.Close();\" title=\"关闭\">关闭</a></span>";
    AlertHtml+="系统提示";
    AlertHtml+="</div>";
    AlertHtml+="<div class=\"pop_content\">"+content+"</div>";
    AlertHtml+="<div class=\"pop_bn\"> <a href=\"javascript:void(0);\" onclick=\"$('#M_Confirm').remove();tkf.Close();\" class=\"submit01\"><input type=\"submit\" value=\"确定\" /></a></div>";
    AlertHtml+="<div class=\"pop_footer\"></div>";
    AlertHtml+="</div>";
    
    $("body").append(AlertHtml);
    $("#M_Confirm").css('width', '426px');
    tkf.pos(tkf.$("M_Confirm"));
    //tkf.MaskShow();

    tkf.resizeOn("M_Confirm");
    tkf.Drag("M_Confirm", "M_ConfirmHand");
    return false;
}

//弹出成功提示(基本功能)
,showAlert:function showSuccessDiv(width,height,divhtml,classname,isShowClose){
        var obj = tkf.$("successDiv"); 
        obj.style.display = "block"; obj.className ="tkfpopbox";
        obj.style.position = "absolute"; obj.style.zindex = "999"; 
        obj.style.width = width + "px"; obj.style.height = height + "px"; 
        var Position = getPosition(); 
        leftadd = (Position.width-width)/2; topadd = (Position.height-height)/2; 
        obj.style.top = (Position.top + topadd) + "px"; obj.style.left = (Position.left + leftadd) + "px"; 
        var str="";
        if(isShowClose){str+="<a href=\"javascript:void(0);\" onclick='$(\"#successDiv\").hide()' class=\"close\" title=\"关闭\">关闭</a>";}
        str+="<p class='"+classname+"'>"+divhtml+"</p>";
        str+="<div style='display:block;clear:both;'></div>";
        obj.innerHTML=str;
}

//弹出气泡(基本功能)
,showmsg:function showmsg(width,height,divhtml,divclassname){

        tkf.checkDiv("tkfmsg");
        var newDiv =tkf.$("tkfmsg");
        newDiv.className = divclassname; 
        newDiv.style.position = "absolute"; 
        newDiv.style.zindex = "99999999"; 
        newDiv.style.width = width + "px"; 
        newDiv.style.height = height + "px"; 
        var Position = tkf.getPosition(); 
        leftadd = (Position.width-width)/2; 
        topadd = (Position.height-height)/2; 
        
	    var pbegin = (Position.top + topadd) ; 
	    var pend = (Position.top + topadd/6); 
        
        newDiv.style.top = pbegin; 
        newDiv.style.left = (Position.left + leftadd) + "px"; 
        var str="";
        //str+="<a href=\"javascript:void(0);\" onclick='document.getElementById(\"successDiv\").style.display=\"none\"' class=\"close\" title=\"关闭\">关闭</a>";
        str+="<div class='innerdiv'>"+divhtml+"</div>";
        str+="<div style='display:block;clear:both;'></div>";
        newDiv.innerHTML=str;
        newDiv.style.display = "block"; 
        
        $("#tkfmsg").animate({top: pend }, 1000)
        .animate({opacity: 1.0}, 20).fadeOut("slow",function(){$(this).hide();});  
}
,oppop:function oppop(html){tkf.showmsg(225,75,"<div class='title_tips'>"+html+"<i></i></div>",'');}

//加载中
,Load:function Load(id, alertId) {
    if (id) {
        tkf.$(id).innerHTML = "<div class=\"float_tips\"><p><em class=\"loading\"><i></i>正在加载....</em></p><b></b></div>";
        return;
    }
    if ($('#TLoading')[0]) {
        $('#TLoading').remove();
    }
    if (alertId) {
        $("#" + alertId).after("<div class=\"float_tips\" id=\"TLoading\" style=\"position:absolute;top:160px;left:270px;zIndex:1000;\"><p><em class=\"loading\"><i></i>正在加载....</em></p><b></b></div>");
        return;
    }
    $("body").append($("<div class=\"float_tips\" id=\"TLoading\"><p><em class=\"loading\"><i></i>正在加载....</em></p><b></b></div>"));
    tkf.pos(tkf.$("TLoading"));
}

//错误提示框
,ErrMsg:function ErrMsg(id, tit) {
    if ($("#errorMsg_" + id)[0]) {$("#errorMsg_" + id).html("<p>" + tit + "</p><i></i><q></q>");}
    else{$("#" + id).after("<div class=\"check_tips\" id=\"errorMsg_" + id + "\"><p>" + tit + "</p><i></i><q></q></div>");}
    return;
}

//清除错误提示
,MsgRemove:function MsgRemove(id) {$("#" + id).remove();return;}

//标题提示框，有id定位，没id浮动
,TitMsg:function TitMsg(tit, id) {
    if (id) {
        $("#" + id).css('display', 'block');
        tkf.$(id).innerHTML = "<div class=\"title_tips\">" + tit + "<i></i></div>";
        return;
    }
    $("<div class=\"title_tips\" id=\"BitDoMsg\">" + tit + "<i></i></div>").appendTo("body");
    $("#BitDoMsg").addClass("fixed");
    var p = tkf.$("BitDoMsg");
    p.style.top = 20 + 'px';
    p.style.left = (document.documentElement.clientWidth / 2 - p.offsetWidth / 2) + 'px';
    p.style.zIndex = "1001";
    tkf.IsIe6Souce(p, "top");
    //变化
    addResizeEvent(tkf.TitOnsize);
    setTimeout("wokew.Common.MsgRemove('BitDoMsg');", 3000);
}
,TitOnsize:function TitOnsize() {
    if (tkf.$('BitDoMsg'))
        tkf.$('BitDoMsg').style.left = (document.documentElement.clientWidth / 2 - tkf.$('BitDoMsg').offsetWidth / 2) + 'px';
}

//随手帮助
,Help:function Help(obj, tit) {
    $("#showHelpMsg").remove();
    var OutHtml = "<div class=\"float_tips_up\"  id=\"showHelpMsg\"  style=\"POSITION: absolute;z-Index:999\"  onMouseOver=\"if (isMouseLeaveOrEnter(event, this)) clearTimeout(noneTime);\" onmouseout=\"if (isMouseLeaveOrEnter(event, this))wokew.Common.MsgRemove('showHelpMsg');\"><p>" + tit + "</p><b></b><q></q></div>";
    $("body").append(OutHtml);
    obj.onmouseout = function() { noneTime = setTimeout("wokew.Common.MsgRemove('showHelpMsg');", 500); };
    tkf.$("showHelpMsg").style.top = (tkf.getposOffset(obj, "top") + 20) + "px";
    tkf.$("showHelpMsg").style.left = (tkf.getposOffset(obj, "left")) + "px";
    return;
}

//确认提示1
,ConfirmOperate:function ConfirmOperate(tit,content,func) {
    if ($('#M_Confirm')[0]) {
        $('#M_Confirm').remove();
    }

    //var content = "\"" + tit + "\"";
    //var h = obj.href.replace(/'/g, '\\\''); ;

    var AlertHtml = "<div class=\"alert\" id=\"M_Confirm\">";  
    AlertHtml += "<div class=\"alert_blc\">  ";          
    AlertHtml += "<div class=\"alert_title\" id=\"M_ConfirmHand\"><h3>"+tit+"</h3></div> ";
    AlertHtml += "<div class=\"alert_info\"> <div class=\"alert_confirm\"><b></b><p>" + content + "</p><i></i></div> ";
    AlertHtml += "</div> ";
    AlertHtml += "<div class=\"btns\"><a href=\"javascript:void(0)\" onclick=\"return false;\" class=\"submit\">";
    AlertHtml += "<input type=\"submit\" value=\"确定\" onclick=\"$('#M_Confirm').remove();tkf.Close();"+func+"();\"  /></a>";
    AlertHtml += "<a href=\"javascript:void(0)\" onclick=\"return false;\" class=\"cancel\">";
    AlertHtml += "<input type=\"button\" value=\"取消\" onclick=\"$('#M_Confirm').css('display','none');tkf.Close();\" ></a>";
    AlertHtml += "</div> ";
    AlertHtml += "<span class=\"more\"><a class=\"alert_close\" href=\"javascript:void(0);\" onclick=\"$('#M_Confirm').remove();tkf.Close();\" title=\"关闭\">关闭</a></span>";
    AlertHtml += "</div>";
    AlertHtml += "</div>";
    $("body").append(AlertHtml);
    $("#M_Confirm").css('width', '416px');
    tkf.pos(tkf.$("M_Confirm"));
    tkf.MaskShow();

    tkf.resizeOn("M_Confirm");
    tkf.Drag("M_Confirm", "M_ConfirmHand");
    return false;
}

//确认提示1
,ConfirmEvent:function ConfirmEvent(tit, content,obj) {
//debugger;
    if ($('#M_Confirm')[0]) {
        $('#M_Confirm').remove();
    }

    var h = obj.href.replace(/'/g, '\\\''); ;

    var AlertHtml = "<div class=\"alert\" id=\"M_Confirm\">        <div class=\"alert_blc\">            <div class=\"alert_title\" id=\"M_ConfirmHand\"><h3>"+tit+"</h3></div>            <div class=\"alert_info\"> <div class=\"alert_confirm\"><b></b><p>" + content + "</p><i></i></div> </div>            <div class=\"btns\">                <a href=\"javascript:void(0)\" onclick=\"return false;\" class=\"submit\"><input type=\"submit\" value=\"确定\" onclick=\"$('#M_Confirm').remove();tkf.Close();window.location.href='" + h + "';\"  /></a>                <a href=\"javascript:void(0)\" onclick=\"return false;\" class=\"cancel\"><input type=\"button\" value=\"取消\" onclick=\"$('#M_Confirm').css('display','none');tkf.Close();\" ></a>            </div>            <span class=\"more\"><a class=\"alert_close\" href=\"javascript:void(0);\" onclick=\"$('#M_Confirm').remove();_M.Close();\" title=\"关闭\">关闭</a></span>        </div>    </div>";
    $("body").append(AlertHtml);
    $("#M_Confirm").css('width', '416px');
    tkf.pos(tkf.$("M_Confirm"));
    tkf.MaskShow();

    tkf.resizeOn("M_Confirm");
    tkf.Drag("M_Confirm", "M_ConfirmHand");
    return false;
}

,isMouseLeaveOrEnter:function isMouseLeaveOrEnter(e, handler) {
    if (e.type != 'mouseout' && e.type != 'mouseover') return false;
    var reltg = e.relatedTarget ? e.relatedTarget :
	e.type == 'mouseout' ? e.toElement : e.fromElement;
    while (reltg && reltg != handler) reltg = reltg.parentNode;
    return (reltg != handler);
}

//校验提示有id定位，没id浮动
,CheckResult:function CheckResult(tit, id) {
    if (id) {
        $("#" + id).css('display', 'block');
        tkf.$(id).innerHTML = "<div class=\"fault_tips\">" + tit + "</div>";
        return;
    }
    $("<div class=\"fault_tips fixed\" id=\"BitCheckMsg\">" + tit + "</div>").appendTo("body");
    var p = tkf.$("BitCheckMsg");
    p.style.top = 20 + 'px';
    p.style.left = (document.documentElement.clientWidth / 2 - p.offsetWidth / 2) + 'px';
    p.style.zIndex = "1002";
    tkf.IsIe6Souce(p, "top");
    //变化
    addResizeEvent(tkf.CheckOnsize);
    setTimeout("wokew.Common.MsgRemove('BitCheckMsg');", 3000);
}
,CheckOnsize:function CheckOnsize() {
    if (tkf.$('BitCheckMsg'))
        tkf.$('BitCheckMsg').style.left = (document.documentElement.clientWidth / 2 - tkf.$('BitCheckMsg').offsetWidth / 2) + 'px';
}

//显示TKF IFRAMW窗体,（基础方法）
,showtkfpop:function showtkfpop(width,height,html,classname){
            tkf.checkDiv("tkfpop");
            var obj = tkf.$("tkfpop"); 
            obj.style.filter = "Alpha(Opacity=1)";	
            obj.style.display = "block"; 
            obj.style.position = "absolute"; 
            obj.style.zindex = "999"; 
            obj.style.width = width + "px"; 
            obj.style.height = height + "px"; 
            //obj.innerHTML="<div id=\"tkfpopctrl\"><a href=\"javascript:tkf.hidetkfpop()\">关闭</a></div><div class='"+classname+"' id=\"tkfpopdata\">"+html+"</div>";
            obj.innerHTML="<div id=\"tkfpopctrl\">"+html+"</div>";
            var tkfpop_innerHTML=obj.innerHTML;
            //debugger;
            tkf.MaskShow();
            tkf.pos(obj);
            tkf.resizeOn("tkfpop");
            tkf.Drag("tkfpop", "tkfpopctrl");
            $("#tkfpop").animate({opacity: 1.0}, 100).fadeIn("slow",null);
}
        
//隐藏弹出窗体
,hidetkfpop:function hidetkfpop(){
    //$("#tkfpop").animate({opacity: 1.0}, 20).fadeOut("slow",function(){$(this).hide();});
    $("#tkfpop").hide();tkf.MaskClose();
} 
//关闭调用
,Close:function Close(){window.onresize = null;tkf.MaskClose();}

//显示对用户通知
,showusermsg:function showusermsg(){tkf.$("showusermsg").src="http://service.shuaiche.com/user/showusermsg.aspx";}
//上传图片pop窗体
//cutconfig  1|300|300|100|100 表示 是|画布宽|画布高|剪裁目标宽|剪裁目标高
,showuppicpop:function showuppicpop(objtxtid,board,aimimg,cutconfig){
            var popwidth=480;var popheight=400;
            var url="/control/index.aspx?";
            url+="aimImg="+aimimg;
            url+="&p="+board;
            url+="&isneedclosepop=1";
            url+="&txtPicPath="+objtxtid;
            url+="&zipWidth=100&zipHeight=100&k=500";
            if(cutconfig){url+="&cutConfig="+cutconfig;}

            var d="<iframe frameborder='0'  width='"+popwidth+"px' height='"+(popheight-20)+"px' src='"+url+"'></iframe>";
            tkf.showtkfpop(popwidth,popheight,d,"m0");
}

//选择地区pop窗体
,showselareapop:function showselareapop(board,maxnum,txtids,txttitles,divhtml){
        var popwidth=580;
        var popheight=360;
        var d="<iframe frameborder='0'  width='"+popwidth+"px' height='"+(popheight-20)+"px' src='/control/selarea/index.aspx?txtids="+txtids+"&txttitles="+txttitles+"&divhtml="+divhtml+"&p="+board+"&isneedclosepop=1'></iframe>";
        tkf.showtkfpop(popwidth,popheight,d,"m0");
}

//加为好友的pop窗体
,showjoinfriendpop:function showjoinfriendpop(userid){
            var popwidth=400;
            var popheight=270;
            var d="<iframe frameborder='0'  width='"+popwidth+"px' height='"+(popheight-20)+"px' src='/control/joinfriend/index.aspx?ruid="+userid+"'></iframe>";
            tkf.showtkfpop(popwidth,popheight,d,"m0");
}
//选择公司
,showselcomppop:function showselcomppop(allowcompids,txtcontrolcompid,txtcontrolcompname,board){
        var popwidth=580;
        var popheight=460;
        var d="<iframe frameborder='0'  width='"+popwidth+"px' height='"+(popheight-20)+"px' src='/control/selcomp/index.aspx?allowcompids="+allowcompids+"&p="+board+"&isneedclosepop=1&txtcontrolcompid="+txtcontrolcompid+"&txtcontrolcompname="+txtcontrolcompname+"'></iframe>";
        tkf.showtkfpop(popwidth,popheight,d,"m0");
        }
//设为首页
,setHomePage:function setHomePage(obj){obj.style.behavior='url(#default#homepage)';obj.setHomePage(window.location.href);}        

//定位弹窗
,pos:function pos(p) {
    var t = 10;
    if (!tkf.fixed) {
        p.className = p.className + " fixed";
        p.style.position = "fixed";
        tkf.IsIe6Souce(p);
    } else {
        t = document.documentElement.scrollTop;
        p.style.position = "absolute";
    }
    p.style.top = t + document.documentElement.clientHeight / 2 - p.offsetHeight / 2 + 'px';
    p.style.left = (document.documentElement.clientWidth / 2 - p.offsetWidth / 2) + 'px';
    p.style.zIndex = 999;
}
//IE6浮动代码
,IsIe6Souce:function IsIe6Souce(o, type) {
    if ($.browser.msie && $.browser.version == 6) {
        var h = 10 + parseInt(document.documentElement.clientHeight / 2 - o.offsetHeight / 2);
        if (type == "top"){h = 10;}
        $('body').append("<style type=\"text/css\">*{margin: 0px;padding: 0px;}body {_background-image: url(about:blank);_background-attachment: fixed;}</style>");
        var css = "_position: absolute;_top: expression(documentElement.scrollTop + " + h.toString() + " + \"px\"); ";
        o.style.cssText = o.style.cssText + css;
    }
}

//黑屏计算
,MaskShow:function() {
    if ($('#shuaicheMask')[0]) {
        $('#shuaicheMask').remove();
        $('#popIframe').remove();
    }
    var popCss = "background:#000;opacity:0.3;-ms-filter:\'progid:DXImageTransform.Microsoft.Alpha(opacity=30)\'; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); position:absolute;left:0;top:0;overflow:hidden;";
    $("<div id=\"shuaicheMask\" style=\"" + popCss + "\"></div>").appendTo("body");
    var sk=$('#shuaicheMask');
    sk.css("height", tkf.scpage.theight() + 'px');
    sk.css("width", tkf.scpage.twidth() + 'px');
    sk.css("position", "absolute");
    sk.css("zIndex", 998);
    sk[0].style.opacity = "0.3";
    sk[0].style.filter = 'alpha(opacity=30)';
    tkf.FullIframe();
}
,FullIframe:function() {
    var popCss = "opacity:0;-ms-filter:\'progid:DXImageTransform.Microsoft.Alpha(opacity=0)\'; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0); position:absolute;left:0;top:0;overflow:hidden;";
    var pop_Iframe = document.createElement("iframe"); pop_Iframe.id = "popIframe";
    document.getElementsByTagName("body")[0].appendChild(pop_Iframe);
    pop_Iframe.style.cssText = popCss;
    pop_Iframe.style.zIndex = "988";
    pop_Iframe.style.height = tkf.scpage.theight() + "px";
    pop_Iframe.style.width = (parseInt(tkf.scpage.twidth()) - 5) + "px";
}
//黑屏功能
,MaskClose:function() {$('#shuaicheMask').remove();$('#popIframe').remove();window.onresize = null;}

//拖动功能
,Drag:function(rootid, handid) {
    var div_root = document.getElementById(rootid);
    var div_handle = document.getElementById(handid);
    var w = 0, h = 0;
    if (tkf.$(rootid).style.width != "")
        w = parseInt(tkf.$(rootid).style.width);
    if (tkf.$(rootid).style.height != "")
        h = parseInt(tkf.$(rootid).style.height);
        
    var scpagewidth=tkf.scpage.twidth();
    var scpageheight=tkf.scpage.theight();
    Drag.init(div_handle, div_root, 0, scpagewidth-w, 0, scpageheight- h);
}

//通常放在拖动之前
,resizeOn:function(id) {
    var oldonload = window.onresize;
    if (typeof window.onresize != 'function') {
        window.onresize = function() {
        if (tkf.OldWidth != document.documentElement.clientWidth) {
            if (!tkf.resizeTimer) {
                tkf.resizeTimer = setTimeout("tkf.resize(tkf.$('" + id + "'))", 100); //控制调用方法的时间间隔
            }
            tkf.resizeTimer = null;
        }
        return false;
        };
    } else {
        window.onresize = function() {
            oldonload();
            if (tkf.OldWidth != document.documentElement.clientWidth) {
                if (!tkf.resizeTimer) {
                    tkf.resizeTimer = setTimeout("tkf.resize(tkf.$('" + id + "'))", 100); //控制调用方法的时间间隔
                }
                tkf.resizeTimer = null;
            }
            return false;
        }
    }
}
//
,resize:function(p) {tkf.MaskShow();if(p){tkf.pos(p);}tkf.OldWidth = document.documentElement.clientWidth;return false;}

//*********退出前询问************
,BindBeforClose:function BindBeforClose() {
    tkf.NeedLeaveAsk = true;
    window.onbeforeunload = tkf.IsExit;
}
,CancelBeforClose:function CancelBeforClose(){
    tkf.NeedLeaveAsk = false;
    window.onbeforeunload = null;
}

,IsExit:function IsExit() {
    if (tkf.NeedLeaveAsk) {
        if (window.document != null && window.document.activeElement != null && window.document.activeElement.href != null && window.document.activeElement.href.substring(0, 10).toUpperCase() == 'JAVASCRIPT') {return;}
        else{return "您的信息还没有保存！";}
    }
}


//**end method 
};






/*************************************************
//*********************拖动类*********************
*************************************************/
var Drag = {
    obj: null,
    init: function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper) {
        o.onmousedown = Drag.start;

        o.hmode = bSwapHorzRef ? false : true;
        o.vmode = bSwapVertRef ? false : true;

        o.root = oRoot && oRoot != null ? oRoot : o;

        if (o.hmode && isNaN(parseInt(o.root.style.left))) o.root.style.left = "0px";
        if (o.vmode && isNaN(parseInt(o.root.style.top))) o.root.style.top = "0px";
        if (!o.hmode && isNaN(parseInt(o.root.style.right))) o.root.style.right = "0px";
        if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

        o.minX = typeof minX != 'undefined' ? minX : null;
        o.minY = typeof minY != 'undefined' ? minY : null;
        o.maxX = typeof maxX != 'undefined' ? maxX : null;
        o.maxY = typeof maxY != 'undefined' ? maxY : null;

        o.xMapper = fXMapper ? fXMapper : null;
        o.yMapper = fYMapper ? fYMapper : null;

        o.root.onDragStart = new Function();
        o.root.onDragEnd = new Function();
        o.root.onDrag = new Function();
    },

    start: function(e) {
        var o = Drag.obj = this;
        e = Drag.fixE(e);
        var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right);
        o.root.onDragStart(x, y);
        o.style.cursor = "move";
        o.lastMouseX = e.clientX;
        o.lastMouseY = e.clientY;

        if (o.hmode) {
            if (o.minX != null) o.minMouseX = e.clientX - x + o.minX;
            if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
        } else {
            if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
            if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
        }

        if (o.vmode) {
            if (o.minY != null) o.minMouseY = e.clientY - y + o.minY;
            if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY;
        } else {
            if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
            if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
        }

        document.onmousemove = Drag.drag;
        document.onmouseup = Drag.end;

        return false;
    },

    drag: function(e) {
        e = Drag.fixE(e);
        var o = Drag.obj;

        var ey = e.clientY;
        var ex = e.clientX;
        var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right);
        var nx, ny;

        if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
        if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
        if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
        if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

        nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
        ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

        if (o.xMapper) nx = o.xMapper(y)
        else if (o.yMapper) ny = o.yMapper(x)

        Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
        Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
        Drag.obj.lastMouseX = ex;
        Drag.obj.lastMouseY = ey;

        Drag.obj.root.onDrag(nx, ny);
        return false;
    },

    end: function() {
        document.onmousemove = null;
        document.onmouseup = null;
        Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]),
                                    parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
        Drag.obj.style.cursor = "default";
        Drag.obj = null;
    },

    fixE: function(e) {
        if (typeof e == 'undefined') e = window.event;
        if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
        if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
        return e;
    }
};

