﻿var siteUrl = "http://www.kxpx.com.cn/";
var siteNam = "科信培训网 - 新疆科信学院";
var isIE = (navigator.userAgent.indexOf("MSIE")>0) ? true : false;
var nName = navigator.appName;
var nVers = "";
var _v = navigator.appVersion;
if(_v.indexOf('MSIE 4')>0){nVers = "IE 4.0";} else if(_v.indexOf('MSIE 5')>0){nVers = "IE 5.0";} else if(_v.indexOf('MSIE 5.5')>0){nVers = "IE 5.5";} else if(_v.indexOf('MSIE 6.0')>0){nVers = "IE 6.0";} else if(_v.indexOf('MSIE 7.0')>0){nVers = "IE 7.0";} else if(_v.indexOf('MSIE 8.0')>0){nVers = "IE 8.0";} else{nVers = _v;}

function AddFavorite(){
    try {
        window.external.addFavorite(siteUrl, siteNam);
    } catch (e1) {
        try {
            window.sidebar.addPanel(siteNam, siteUrl, "");
        } catch (e2) {
            alert("加入收藏失败，请使用 Ctrl+D 进行添加。");
        }
    }
}
function SetHome(obj){
    try {
        obj.style.behavior = "url(#default#homepage)";
        obj.setHomePage(siteUrl);
    } catch(e){
        if(window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("此操作被浏览器拒绝，请手动进行设置。");
                return;
            }
            var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', siteUrl);
        }
    }
}
function CheckSrchTop(f){
    var kw = f.keyword.value;
    if(kw == "" || kw == "请输入搜索关键字"){
        alert("请输入搜索关键字。");
        f.keyword.focus();
        return false;
    }
    return true;
}
function ShowHideTab(id, len, ind){
    for(var i = 1; i <= len; i++){
        document.getElementById("tab" + id + "_" + i).className = "";
        document.getElementById("cnt" + id + "_" + i).className = "undis";
    }
    document.getElementById("tab" + id + "_" + ind).className = "focus";
    document.getElementById("cnt" + id + "_" + ind).className = "";
}
function QuickSearch(val, act)
{
    var url = "/Search.aspx?x=0";
    if(act == "keyword"){
        url += "&keyword=" + encodeURIComponent(val);
    }
    if(act == "date"){
        url += "&date1=" + val;
    }
    window.open(url);
}
function ConsultantPhotoError(im){
    im.onerror = function(){};
    im.src = "/images/nophoto.jpg";
}
var Drag={
    "obj":null,
	"init":function(handle, dragBody, e){
		if (e == null) {
			handle.onmousedown=Drag.start;
		}
		handle.root = dragBody;
		
		if(isNaN(parseInt(handle.root.style.left)))handle.root.style.left="0px";
		if(isNaN(parseInt(handle.root.style.top)))handle.root.style.top="0px";
		handle.root.onDragStart=new Function();
		handle.root.onDragEnd=new Function();
		handle.root.onDrag=new Function();
		if (e !=null) {
			var handle=Drag.obj=handle;
			e=Drag.fixe(e);
			var top=parseInt(handle.root.style.top);
			var left=parseInt(handle.root.style.left);
			handle.root.onDragStart(left,top,e.pageX,e.pageY);
			handle.lastMouseX=e.pageX;
			handle.lastMouseY=e.pageY;
			document.onmousemove=Drag.drag;
			document.onmouseup=Drag.end;
		}
	},
	"start":function(e){
		var handle=Drag.obj=this;
		e=Drag.fixEvent(e);
		var top=parseInt(handle.root.style.top);
		var left=parseInt(handle.root.style.left);
		
		handle.root.onDragStart(left,top,e.pageX,e.pageY);
		handle.lastMouseX=e.pageX;
		handle.lastMouseY=e.pageY;
		document.onmousemove=Drag.drag;
		document.onmouseup=Drag.end;
		return false;
	},	
	"drag":function(e){
		e=Drag.fixEvent(e);
		var handle=Drag.obj;
		var mouseY=e.pageY;
		var mouseX=e.pageX;
		var top=parseInt(handle.root.style.top);
		var left=parseInt(handle.root.style.left);
		
		var currentLeft,currentTop;
		currentLeft=left+mouseX-handle.lastMouseX;
		currentTop=top+(mouseY-handle.lastMouseY);
		
		handle.root.style.left=currentLeft +"px";
		handle.root.style.top=currentTop+"px";
		
		handle.lastMouseX=mouseX;
		handle.lastMouseY=mouseY;
		
		handle.root.onDrag(currentLeft,currentTop,e.pageX,e.pageY);
		return false;
	},
	"end":function(){
		document.onmousemove=null;
		document.onmouseup=null;
		Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style.left),parseInt(Drag.obj.root.style.top));
		Drag.obj=null;
	},
	"fixEvent":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;
		if(typeof e.pageX == "undefined")e.pageX = e.clientX + document.body.scrollLeft - document.body.clientLeft;
		if(typeof e.pageY == "undefined")e.pageY = e.clientY + document.body.scrollTop - document.body.clientTop;
		return e;
	}
};
function Dialog(){
    this.isIE = (navigator.userAgent.indexOf("MSIE")>0) ? true : false;
    this.dlgCss = "position:absolute;top:120px;left:0;width:400px;height:auto;background-color:#FFFFFF;text-align:left;border-left:1px solid #0075C2; border-right:1px solid #0075C2; border-bottom:5px solid #0075C2; z-index:202;";
    this.width = 400;
    this.offsetTop = 120;
    this.offsetMid = 0;
    this.titleHtml = "科信培训网";//对话框默认标题
    this.titleCss = "margin:0;background-color:#0075C2;height:25px;font-size:12px;color:#FFFFFF;padding:0 10px;cursor:move; line-height:25px;";
    this.closeBtnHtml = "[关闭]";
    this.closeBtnCss = "position:absolute;top:5px;right:10px;width:60px;height:20px;cursor:pointer;color:#FFFFFF;text-align:right;";
    this.OnClose = function(){};
    this.isDrag = true;
    this.bodyHtml = "";
    this.bodyCss = "padding:5px 10px 10px 10px;";
    this.footHtml = "";
    this.footCss = "height:1px;overflow:hidden;";
    this.isMask = true;
    this.maskColor = "#000000";
    this.maskAlpha = 40;
    this.dlg = null;
    this.title = null;
    this.closeBtn = null;
    this.body = null;
    this.foot = null;
    this.mask = null;
}
Dialog.prototype.OpenDialog = function(){
    var owner = this;
    var bodyWidth  = Math.max(document.body.clientWidth,document.documentElement.clientWidth);
    var bodyHeight = Math.max(document.body.clientHeight,document.documentElement.clientHeight);
    
    if(this.isMask){
        this.mask = this.CreateElement(document.body,"div","","","");
        this.mask.style.cssText = "position:absolute;left:0px;top:0px;width:"+bodyWidth+"px;height:"+bodyHeight+"px;filter:Alpha(Opacity="+this.maskAlpha+");opacity:0.3;background-color:"+this.maskColor+";z-index:101;";
        var frm = this.CreateElement(this.mask,"iframe","","","");
        frm.setAttribute("src","javascript:void(0);");
        frm.style.cssText = "position:absolute;visibility:inherit;top:0px;left:0px;width:"+bodyWidth+"px;height:"+bodyHeight+"px;z-index:-1;filter:Alpha(Opacity=0);opacity:0;";
    }
    
    this.dlg = this.CreateElement(document.body,"div","","","");
    if(this.dlgCss!="") this.dlg.style.cssText = this.dlgCss;
    this.dlg.style.position = "absolute";
    this.dlg.style.width = this.width + "px";
    this.dlg.style.top  = (document.documentElement.scrollTop + this.offsetTop) + "px";
    this.dlg.style.left = ((bodyWidth - this.width)/2) + this.offsetMid + "px";
    
    this.closeBtn = this.CreateElement(this.dlg,"div","","","");
    if(this.closeBtnCss!="") this.closeBtn.style.cssText = this.closeBtnCss;
    this.closeBtn.innerHTML = this.closeBtnHtml;
    this.closeBtn.onclick = function(){owner.CloseDialog();}
    
    this.title = this.CreateElement(this.dlg,"h1","","","");
    if(this.titleCss!="") this.title.style.cssText = this.titleCss;
    this.title.onselectstart = function(){return false;}
    this.title.innerHTML = "◎" + this.titleHtml;
    
    this.body = this.CreateElement(this.dlg,"div","","","");
    if(this.bodyCss!="") this.body.style.cssText = this.bodyCss;
    this.body.innerHTML = this.bodyHtml;
    
    this.foot = this.CreateElement(this.dlg,"div","","","");
    if(this.footCss!="") this.foot.style.cssText = this.footCss;
    this.foot.innerHTML = this.footHtml;
    
    if(this.isDrag) Drag.init(this.title,this.dlg);
}
Dialog.prototype.CloseDialog = function(){
    try{document.body.removeChild(this.mask);} catch(e){}
    try{document.body.removeChild(this.dlg);} catch(e){}
    this.OnClose();
}
Dialog.prototype.CreateElement = function(target,tag,id,name,css){
    var obj = null;
    if(target==null){alert("Target Element Is Null!");return null;}
    if(tag=="" || tag==null){alert("TagName Is Null!");return null;}
    obj = document.createElement(tag);
    target.appendChild(obj);
    if(id!="" && id!=null) obj.setAttribute("id",id);
    if(name!="" && name!=null) obj.setAttribute("name",name);
    if(css!="" && css!=null) obj.className = css;
    return obj;
}

var qDlg = new Dialog();
qDlg.width = 930;
qDlg.height = 500;
qDlg.titleHtml = "科信培训网 - 我要提问";
function OpenQuestion(courseid, consultantid, topicid){
    qDlg.bodyHtml = "<iframe src=\"Question.aspx?courseid=" + courseid + "&consultantid=" + consultantid + "&topicid=" + topicid + "\" width=\"910\" height=\"454\" frameborder=\"0\" scrolling=\"no\"></iframe>";
    qDlg.OpenDialog();
}
