function playWMV(path, x, y, volume, islive, w, h)
{
	//alert("playWmv " + path);
	g_lastPath = path;
	
	var wmp = document.getElementById("wmppane");
	wmp.style.display = "";
	wmp.style.left = "20px";
	if (w) wmp.style.width = w + "px";
	if (h) wmp.style.height = h + "px";
	
	if(g_isIE)
	{	
		wmp.style.top = "70px";
		wmp = getPlayer();
		wmp.url = path;
		wmp.settings.volume = volume;
		if (w) wmp.width = w + "px";
		if (h) wmp.height = h + "px";
	}
	else
	{
		wmp.style.top = "65px";
		h =Number(h) + 45;
		wmp.style.height = h + "px";
		wmp.contentWindow.writeWMP(path,h,null,w,null,null,null,null,false);	
	}
}

function getPlayer()
{
	var wmp = null;
	try{
		if (g_isIE)
			wmp = document.getElementById("wmppane").contentWindow.document.getElementById("wmpMain");
		else
			wmp = document.getElementById("wmppane").contentWindow.document.getElementById("wmpMain-ff");
	}catch(e){}
	return wmp;
}

function wmpProxy(action, value)
{
	var wmp = getPlayer();	
	if (wmp == null) return;
	
	switch(action)
	{
	case "fullscreen":
		if( !g_isIE) wmp.DisplaySize=3;
		wmp.fullScreen = true;
		break;
	case "stop":
		wmp.controls.stop();
		break;
	case "fastReverse":
		wmp.controls.fastReverse();
		break;
	case "fastForward":
		wmp.controls.fastForward();
		break;
	case "pause":
		wmp.controls.pause();
		break;
	case "play":
		wmp.controls.play();
		break;
	case "setvolume":
		wmp.settings.volume = value;
		break;
	case "getvolume":
		return wmp.settings.volume;
		break;
	case "shareshow":
		document.getElementById("wmppane").style.display = "none";
		break;
	case "sharehide":
		document.getElementById("wmppane").style.display = "";
		break;
	case "position":
		//var p = document.getElementById("wmppane");
		//p.style.left = value[0] + "px";
		//p.style.top = value[1] + "px";
		break;
	case "seek":
		value = parseInt(value);
		wmp.controls.currentposition = value;
		break;
	case "getcurtime":
		return "" + Math.floor(wmp.controls.currentPosition);
		break;
	case "gettoltime":
		return (wmp.currentMedia ? "" + Math.floor(wmp.currentMedia.duration) : "0");
		break;
	case "refreshtime":
		return (wmp.currentMedia ? ["" + Math.floor(wmp.controls.currentPosition), "" + Math.floor(wmp.currentMedia.duration)] : ["0", "0"]);
		break;
	case "getDownloadProgress":
		return "" + Math.floor(wmp.network.downloadProgress);
		break;
	case "ecm":
		wmp.enableContextMenu = true;
		break;
	case "changediv":		// change player div size (show, w, h)
		wmpShowHide(value[0], value[1], value[2]);
		break;
	case "hide":
		if(g_isIE)
			wmp.controls.stop();
		else
			(document.getElementById("wmppane").contentWindow ? document.getElementById("wmppane").contentWindow.writeWMP("") : writeWMP(""));
		document.getElementById("wmppane").style.display = "none";
		
	case "switchAudio":    					// home: 1, away: 2
		//alert(value[0]);
        if (wmp.controls && wmp.controls.audioLanguageCount>1)
        {
            var lang1 = wmp.controls.getAudioLanguageID(1);
            var lang2 = wmp.controls.getAudioLanguageID(2);
            var asc = (lang1 < lang2);
            var val = parseInt(value);
            val = (asc ? val : (val % 2) + 1);
			wmp.controls.currentAudioLanguageIndex = val;
        }
        
        //var val = parseInt(value);
        //wmp.settings.balance = (val == 2 ? -100 : 100);	        		
		break;
	}
}

function wmpShowHide(show, w, h)
{
	var wmppane = document.getElementById("wmppane");
	var wmp = getPlayer();
	
	if(show)
	{
		wmppane.style.left = "20px";
		if(g_isIE)
		{
			wmppane.style.top = "70px";
			if (w) 
			{
				wmppane.style.width = w + "px";
				wmp.width = w;
			}
			if (h) 
			{
				wmppane.style.height = h + "px";
				wmp.height = h;
			}
		}
		else
		{
			wmppane.style.top = "65px";
			h = Number(h) + 45;
			wmppane.style.height = h + "px";
			wmppane.contentWindow.writeWMP(g_lastPath,h,null,w,null,null,null,null,false);	
		}
	}
	else
	{
		wmppane.style.width = "1px";
		wmppane.style.height = "1px";
		wmppane.style.left = "-100px";
	}
	
	
}

function wmpCallback(action, value)
{
	var swfConsole = document.getElementById("console");
	if (!value) value = "";
	if (swfConsole && swfConsole.wmpCallback) swfConsole.wmpCallback(action, value);
}
