﻿// 取得窗体中的Flash控件
F$=function(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
//无提示关闭窗口
function CloseWin()
{
    var ua=navigator.userAgent
    var ie=navigator.appName=="Microsoft Internet Explorer" ? true : false
    if(ie){
	     var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))
	     if(IEversion <= 5.5){
		    var str  = "<object id=noTipClose classid=\"clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11\">"
		    str += "<param name=\"Command\" value=\"Close\"></object>";
		    document.body.insertAdjacentHTML("beforeEnd", str);
		    document.all.noTipClose.Click();
	    }else{
		    window.opener =null;
		    window.close();
	    }
    }else{
	    window.close()
    }
}
//获取当前活动元素
GetTarget=function(e)
{
    return window.event != null ? document.activeElement : e.explicitOriginalTarget;
}
//获取当前元素
GetSrcElement = function(e)
{
    return window.event != null ? window.event.srcElement : e.explicitOriginalTarget
}
//获取当前鼠标位置
GetMousePoint = function(e)
{
    var o = new Object();
    o.x = window.event ?event.x:e.clientX;
    o.y = window.event ?event.y:e.clientY;
    return o;
}

// ------------------------------------------------------------------------------事件处理
// 打开窗口：地址，窗体名称，宽，高，是否全屏，是否模式窗体
function OpenWindow(url,name,w,h,allScreen,mode){
    if(w == null || w == "")w = screen.availWidth;
    if(h == null || h == "")h = screen.availHeight;
    var win;
    if(mode){
        win = showModalDialog(url,name,'dialogWidth:'+ w +'px;dialogHeight:'+h+'px;center:yes;help:no;resizable:no;status:no')
    }else{
        if(allScreen){
            win = window.open(url,name,'fullscreen')
        }else{
            if(w == screen.availWidth || h == screen.availHeight)
                win = window.open(url,name,'width=' + w + ',height=' + h + 'toolbar=no,left=0,top=0,channelmode=no,menubar=0,scrollbars=0,status=no');
            else
                win = window.open(url,name,'width=' + w + ',height=' + h + 'toolbar=no,channelmode=no,menubar=0,scrollbars=0,status=no');
        }
    }
    win.focus();
    return win;
}
// ------------------------------------------------------------------------------插入对像
// 插入Flash：地址：宽，高，是否透明
function getFlash(src, w, h,istran,id,isref)
{
    var ret = "";
	ret += ('<object '+(id==null?"":"id="+id+"")+' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'"> ');
    ret += ('<param name="movie" value="' + src + '">');
    ret += ('<param name="quality" value="high"> ');
    if(istran)ret += ('<param name="wmode" value="transparent"> ');
    ret += ('<param name="menu" value="false"> ');
    ret += ('<embed src="' + src + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" swLiveConnect="true" '+(istran? "wmode=transparent":"")+'></embed> ');
    ret += ('</object> ');
    if(isref)
        return ret;
    else
    	document.write(ret);
}
//添加JS文件
function appendScript(url,isFrist){
    if(isFrist)
    {
        document.write("<script type='text/javascript' src='"+url+"'></script>");
    }else{
        var e = document.createElement('script');
        e.src=url;
        e.type='text/javascript';
        document.appendChild(e);
    }
}
//添加CSS文件
function appendCss(CssUrl,id,isCreate)
{
    if(isCreate)
    {
        var e = document.createElement('link');
        if(id != null)e.id=id;
        e.href = CssUrl;
        e.type = 'text/css';
        e.rel = 'stylesheet';
        document.appendChild(e);
    }
    else
    {
        var CssID = "";
        if(id != null)
            CssID = "id='" + id + "'";
        document.write('<link '+ CssID +' href="' + CssUrl + '" rel="stylesheet" type="text/css" />');
    }
}
//只取后缀名
var EXFURLParams = new Object() ;
(function()
{
	var aParams = document.location.search.substr(1).split('&') ;
	for ( var i = 0 ; i < aParams.length ; i++ )
	{
		var aParam = aParams[i].split('=') ;
		var sParamName  = decodeURIComponent( aParam[0] ) ;
		var sParamValue = decodeURIComponent( aParam[1] ) ;

		EXFURLParams[ sParamName ] = sParamValue ;
	}
})();

//设置Cookie的值
function SetCookie(cookiename, cookievalue) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;

  document.cookie = cookiename + "=" + escape(cookievalue) +
    ((expires == null) ? "" 	    : ("; expires=" + expires.toGMTString())) +
    ((path    == null) ? ""	    : ("; path="    + path                 )) +
    ((domain  == null) ? "" 	    : ("; domain="  + domain               )) +
    ((secure  == true) ? "; secure" : "");

  return;
}
//检查图片控件大小，如果大于指定值，则设为指定的值
function CheckImgSize(obj,w,h)
{
    if(typeof obj == "string")
        obj = $("#" + obj);
    if($(obj).width() > w && w != null)
        $(obj).width(w);
    if($(obj).height() > h && h != null)
        $(obj).height(h);
}

