<!--[33,157,996] published at 2006-04-19 19:52:08 from #010 by 814-->
WMPbject = function(file, id, w, h, holder, ver) {
	this.holder = holder;
	this.file = file;
	this.id = id;
	this.width = w;
	this.height = h;
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "请安装windows media player 9以上版本.";
	this.params = new Object();
	this.doDetect = getQueryParamValue('detect');
}
WMPbject.prototype.addParam = function(name, value) {
	this.params[name] = value;
}
WMPbject.prototype.getParams = function() {
    return this.params;
}
WMPbject.prototype.getParam = function(name) {
    return this.params[name];
}
WMPbject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}
WMPbject.prototype.getHTML = function() {
    var wmpObjHTML = "";
    var fullIcoLeft = this.width-30;
    var fullIcoTop = this.height-27;
	if (navigator.plugins && navigator.plugins.length) { // not ie
        wmpObjHTML += '<embed type="application/x-mplayer2"  transparentatstart="true" sendopenstatechangeevents="true" src="' + this.file + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '"';
        for (var param in this.getParams()) {
        	var boolParam
        	if(this.getParam(param).toLowerCase()=="true"){
        		boolParam = 1;
        	}
        	else if(this.getParam(param).toLowerCase()=="false"){
        		boolParam = 0;
        	}
        	else{
        		boolParam = this.getParam(param)
        	}
            wmpObjHTML += ' ' + param + '="' + boolParam + '"';
        }
        wmpObjHTML += '></embed>';
    }
    else { // pc ie
        wmpObjHTML += '<div style="width:0px;height:0px;position:relative;"><div style="position:absolute; z-index:10;left:'+fullIcoLeft+'px;top:'+fullIcoTop+'px;"><img onclick="fullscreen('+this.id+')" id="fullscreenIco" alt="全屏观看" src="http://image2.sina.com.cn/qc/z20060419timg/fullscreen.gif" width="21" height="21" alt="" /></div><object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '">';
        this.addParam("URL", this.file);
        if (this.getParamTags() != null) {
            wmpObjHTML += this.getParamTags();
        }
        wmpObjHTML += '</object></div>';
    }
    return wmpObjHTML;
}
WMPbject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}
WMPbject.prototype.write = function(elementId) {
	if(isWMPInstalled() || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else {
			if (elementId) {
				document.getElementById(elementId).innerHTML = '<a href=“http://www.microsoft.com/downloads/info.aspx?na=22&p=2&SrcDisplayLang=en&SrcCategoryId=4&SrcFamilyId=&u=%2fdownloads%2fdetails.aspx%3fFamilyID%3db446ae53-3759-40cf-80d5-cde4bbe07999%26DisplayLang%3den”><img style="border:1px solid #0E1792;" src="'+this.holder+'" alt="' + this.altTxt + '" width="'+this.width+'" height="'+this.height+'" /></a>';
			} else {
				document.write('<a href=“http://www.microsoft.com/downloads/info.aspx?na=22&p=2&SrcDisplayLang=en&SrcCategoryId=4&SrcFamilyId=&u=%2fdownloads%2fdetails.aspx%3fFamilyID%3db446ae53-3759-40cf-80d5-cde4bbe07999%26DisplayLang%3den”><img style="border:1px solid #0E1792;" src="'+this.holder+'" alt="' + this.altTxt + '" width="'+this.width+'" height="'+this.height+'" /></a>');
			}
		}
	}		
}
function isWMPInstalled() {
	var WMPInstalled = false;
	WMPObj = false;
	if (navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] &&  navigator.mimeTypes["video/x-ms-wm"].enabledPlugin && navigator.mimeTypes["video/x-ms-wmv"] && navigator.mimeTypes["video/x-ms-wmv"].enabledPlugin) {
			WMPInstalled = true;
	} else {
		execScript('on error resume next: WMPObj = IsObject(CreateObject("MediaPlayer.MediaPlayer.1"))','VBScript');
		WMPInstalled = WMPObj;
	}
	return WMPInstalled;
}
function fullscreen(playerid){
	if (playerid.playState == 3) playerid.fullScreen = 'true';
}
/* get value of querystring param */
function getQueryParamValue(param) {
	var q = document.location.search;
	var detectIndex = q.indexOf(param);
	var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length;
	if(q.length > 1 && detectIndex != -1) {
		return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
	} else {
		return "";
	}
}