﻿function StrCode(str){if(encodeURIComponent) return encodeURIComponent(str);if(escape) return escape(str);}
function UnStrCode(str){if(decodeURIComponent ) return decodeURIComponent (str);if(unescape) return unescape(str);}
function Trim(s){var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);return (m == null)?"":m[1];}
function HtmlEncode(text){var re = {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'};for (i in re) text = text.replace(new RegExp(i,'g'), re[i]);return text;}
function HtmlDecode(text){var re = {'&lt;':'<','&gt;':'>','&amp;':'&','&quot;':'"'};for (i in re) text = text.replace(new RegExp(i,'g'), re[i]);return text;}
function gid(id){return document.getElementById?document.getElementById(id):null;}
function gna(id){return document.getElementsByName?document.getElementsByName(id):null;}
function gname(name){return document.getElementsByTagName?document.getElementsByTagName(name):new Array()}
var get_e_src = function(e){if(e) return e.target;if(window.event) return window.event.srcElement;return null;};
function addEvent(obj,evType,fn,useCapture ){if (obj.addEventListener){obj.addEventListener( evType, fn, useCapture );return true;}if (obj.attachEvent) return obj.attachEvent( "on" + evType, fn );alert( "Unable to add event listener for " + evType + " to " + obj.tagName );}
function Browser(){var ua, s, i;this.isIE = false;this.isNS = false;this.isOP = false;this.isSF = false;ua = navigator.userAgent.toLowerCase();s = "opera";if ((i = ua.indexOf(s)) >= 0){this.isOP = true;return;}s = "msie";if ((i = ua.indexOf(s)) >= 0) {this.isIE = true;return;}s = "netscape6/";if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;return;}s = "gecko";if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;return;}s = "safari";if ((i = ua.indexOf(s)) >= 0) {this.isSF = true;return;}}
function ClickButton(event, buttonid){var btnObj = gid(buttonid);if (btnObj){var e = (event||window.event);if (e.keyCode == 13){btnObj.click();return false;}}return true;}
function WarpClass(eID,tID,fID,ev){var eObj = document.getElementById(eID);var tObj = document.getElementById(tID);var fObj = document.getElementById(fID);if (eObj && tObj){if (!tObj.style.display || tObj.style.display == "block"){tObj.style.display = "none";eObj.className = "Warp";if (fObj) fObj.style.display = "none";}else{tObj.style.display = "block";eObj.className = "UnWarp";if (ev) eval(ev);if (fObj) fObj.style.display = "block";}}}

function mcl(show, div, btn, over, padd){var objdiv = gid(div);var objbtn = gid(btn);if (objdiv && objbtn){var browser = new Browser();if (show){objdiv.style.display = "block";if (browser.isIE && over){var allselect = gname("select");for (var i=0; i<allselect.length; i++){allselect[i].style.visibility = "hidden";}}objdiv.style.top = (objbtn.offsetTop + objbtn.offsetHeight - 2) + "px";objdiv.style.left = (objbtn.offsetLeft - (padd?0:50)) + "px";}else{objdiv.style.display = "none";if (browser.isIE && over){var allselect = gname("select");for (var i=0; i<allselect.length; i++){allselect[i].style.visibility = "visible";}}}}}
function Logout(){PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", "do=logout");}
function SelectTagGet(svalue,tvalue){if(svalue!=null){if(tvalue=="10")location.href = "/" + svalue + "/food";else if(tvalue=="20")location.href = "/" + svalue + "/shopping";else if(tvalue=="30")location.href = "/" + svalue + "/life";else if(tvalue=="40")location.href = "/" + svalue + "/service";else location.href = "/" + svalue + "/food";}}
function SearchClass(city, sel1, sel2, sel3){var sel1Obj = gid(sel1);var sel2Obj = gid(sel2);var sel3Obj = gid(sel3);if (sel1Obj && sel2Obj && sel3Obj){var sel1Value = sel1Obj.value;var sel2Value = sel2Obj.value;var sel3Value = sel3Obj.value;if (sel2Value == "0") sel2Value = "";if (sel3Value == "0"){sel3Value = "";}else{sel3Value = "&d=" + sel3Value;}var SearchURL = "/search/m/" + city + "/" + sel1Value + "/" + StrCode(sel2Value + sel3Value);TrackShop(1106);location.href = SearchURL;}}
function SearchKeyword(city, sel1, sel2, sel3){var sel1Obj = gid(sel1);var sel2Obj = gid(sel2);var sel3Obj = gid(sel3);if (sel1Obj && sel2Obj && sel3Obj){var sel1Value = sel1Obj.value;var sel2Value = sel2Obj.value;var sel3Value = sel3Obj.value;if (!sel3Value){alert("请输入搜索关键字!");sel3Obj.focus();return;}sel3Value = Trim(sel3Value);sel3Value = sel3Value.replace("%","");sel3Value = sel3Value.replace("\"","");var SearchURL = "/search/k/" + city + "/" + sel1Value + "/" + sel2Value + "/" + StrCode(sel3Value);TrackShop(1107);location.href = SearchURL;}}

function InitRequest(){var C_req = null;try{C_req = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{C_req = new ActiveXObject("Microsoft.XMLHTTP");}catch(oc){C_req = null;}}if (!C_req && typeof XMLHttpRequest != "undefined"){try{C_req = new XMLHttpRequest();}catch(fa){alert("对不起!您的浏览器不支持该功能,请使用Internet Explorer 6.0或FireFox浏览器!");C_req = null;}}return C_req;}
function PostRequest(url, data){var AjaxRequestObj = InitRequest();if (AjaxRequestObj != null){AjaxRequestObj.onreadystatechange = function (){if (AjaxRequestObj.readyState == 4 && AjaxRequestObj.responseText){ProcessAjaxData(AjaxRequestObj.responseText);}};AjaxRequestObj.open("POST", url, true);AjaxRequestObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");AjaxRequestObj.send(data);}}
function ProcessAjaxData(data){eval(data);}
function ScreenConvert(){var browser = new Browser();var objScreen = gid("ScreenOver");if(!objScreen) var objScreen = document.createElement("div");var oS = objScreen.style;objScreen.id = "ScreenOver";oS.display = "block";oS.top = oS.left = oS.margin = oS.padding = "0px";if (document.body.clientHeight)	{var wh = document.body.clientHeight + "px";}else if (window.innerHeight){var wh = window.innerHeight + "px";}else{var wh = "100%";}oS.width = "100%";oS.height = wh;oS.position = "absolute";oS.zIndex = "3";if ((!browser.isSF) && (!browser.isOP)){oS.background = "#cccccc";}else{oS.background = "#cccccc";}oS.filter = "alpha(opacity=40)";oS.opacity = 40/100;oS.MozOpacity = 40/100;document.body.appendChild(objScreen);var allselect = gname("select");for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "hidden";}
function ScreenClean(){var objScreen = document.getElementById("ScreenOver");if (objScreen) objScreen.style.display = "none";var allselect = gname("select");for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "visible";}
var t_DiglogX,t_DiglogY,t_DiglogW,t_DiglogH;
function DialogLoc(){var dde = document.documentElement;if (window.innerWidth){var ww = window.innerWidth;var wh = window.innerHeight;var bgX = window.pageXOffset;var bgY = window.pageYOffset;}else{var ww = dde.offsetWidth;var wh = dde.offsetHeight;var bgX = dde.scrollLeft;var bgY = dde.scrollTop;}t_DiglogX = (bgX + ((ww - t_DiglogW)/2));t_DiglogY = (bgY + ((wh - t_DiglogH)/2));}
function DialogShow(showdata,ow,oh,w,h){var objDialog = document.getElementById("DialogMove");if (!objDialog) objDialog = document.createElement("div");t_DiglogW = ow;t_DiglogH = oh;DialogLoc();objDialog.id = "DialogMove";var oS = objDialog.style;oS.display = "block";oS.top = t_DiglogY + "px";oS.left = t_DiglogX + "px";oS.margin = "0px";oS.padding = "0px";oS.width = w + "px";oS.height = h + "px";oS.position = "absolute";oS.zIndex = "5";oS.background = "#FFF";oS.border = "solid #000 3px";objDialog.innerHTML = showdata;document.body.appendChild(objDialog);}
function DialogHide(){ScreenClean();var objDialog = document.getElementById("DialogMove");if (objDialog) objDialog.style.display = "none";}

function Wait( id, channelfrom)
{
	ScreenConvert();	
	var Content="<div id=\"DialogTitle\"><div id=\"DialogTitleText\"></div><div id=\"DialogTitleBtn\" onclick=\"return DialogHide();\" onmouseover=\"var objShut = document.getElementById('DialogTitleBtn');objShut.style.border='solid 1px #000000';\" onmouseout=\"var objShut = document.getElementById('DialogTitleBtn');objShut.style.border='solid 1px #EEE';\"></div></div><div id=\"DialogContent\">正在导入中,请稍等......<a href='http://tv.smgbb.cn/PlayerPage.aspx?videoid="+id+"&channel="+channelfrom+"' target='_blank'><font color='red'>点击这里,在IE中浏览效果更好</font></a></div><div id=\"DialogValidator\"></div><div id=\"DialogButtons\"></div>";
	DialogShow(Content,250,60,300,20);	
}

function NoWait()
{
	DialogHide();
	ScreenClean();
}
var pid = 1;
var channel = 'film'

function Call_ModListen( id , channelfrom)
{   
    //var clientinfo = 'null';
	//if(typeof(netobj) != 'object')
	//{
		//try
		//{
			//clientinfo = netobj.GetSystemInfo();
			////alert(clientinfo);		
		//}
		//catch(e)
		//{
			//clientinfo = 'null';
		//}
	//}
	//clientinfo = netobj.GetSystemInfo();
	//try
	//{
	     //var g_oManager = external.DownloadManager;
	     //if( g_oManager == null)
	     //{     	     }  
	     //else
	     //{
	       //Wait(id,channelfrom);	       
	     //}
	//}
	//catch(err)
	//{	    
	//}
    ////Wait();
////	menu = document.all.itemopen
////	menu.style.pixelLeft = Math.floor(window.screen.width/2 - 80)	
////    menu.style.pixelTop = Math.floor(window.screen.height/2 + document.documentElement.scrollTop - 20)
////	menu.style.display = ""           
	//pid = id;  
	//channel = channelfrom;
	//var _s = clientinfo + "|" + id + "|" + channelfrom;
    //CallTheServerBack_ModListen( _s );    
}
        
function Call_ModListenHandler( result, context )
{               
    var clientinfo = 'null';
	if(typeof(netobj) != 'object')
	{
		try
		{
			clientinfo = netobj.GetSystemInfo();
			//alert(clientinfo);		
		}
		catch(e)
		{
			clientinfo = 'null';
		}
	}	
	        try
			{			
				if(result.responseText != "error" || result.responseText != null)
				{
					netobj.StoreLicense(result.responseText);			
				}
			}
			catch(e)
			{
			}
			//window.location.href = "Playlist.aspx?videoid="+pid+"&channel="+channel;
			//window.setTimeout("NoWait()",10000);
//			menu.style.display = "none";	
    //Player.openPlayer("http://tv.smgbb.cn/Playlist.aspx?key=mod&videoid="+pid+"&channel="+channel);
    try
	{
	     var g_oManager = external.DownloadManager;
	     if( g_oManager == null)
	     {
	        //window.location = "http://tv.smgbb.cn/PlayerPage.aspx?videoid="+pid+"&channel="+channel;
	        //var focusid=setTimeout("focus();window.showModelessDialog('http://tv.smgbb.cn/PlayerJump.aspx?videoid="+pid+"&channel="+channel+"','','scroll:1;status:1;help:1;toolbar=1;resizable:1;dialogWidth:0px;dialogHeight:0px')",1000);
	        //window.showModelessDialog("http://tv.smgbb.cn/PlayerPage.aspx?videoid="+pid+"&channel="+channel,"","");
	     }  
	     else
	     {
	        //window.setTimeout("NoWait()",10000);
	        //Player.openPlayer("http://tv.smgbb.cn/Playlist.aspx?key=mod&videoid="+pid+"&channel="+channel);
	        //window.open("http://tv.smgbb.cn/PlayerPage.aspx?videoid="+pid+"&channel="+channel,"newwindow","");
	        //window.location = "http://tv.smgbb.cn/PlayerPage.aspx?videoid="+pid+"&channel="+channel;
	     }
	}
	catch(err)
	{
	    //window.location = "http://tv.smgbb.cn/PlayerPage.aspx?videoid="+pid+"&channel="+channel;
	}
                                 
}


function addPlist(name, id, channelfrom, obj)
{
    obj.style.backgroundImage = 'url(http://tv.smgbb.cn/img/addDone.gif)' ;
    var _s = "AddPlayList|" + id + "|" + channelfrom + "|" + name;
    playlistContent.innerHTML = "<p class=\"playlist_p\" id=\""+id + "_" + channelfrom +"\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td class=\"playlist_p_font\">"+name+"</td><td><img src=\"img/playlist_del.jpg\" width=\"8\" border=\"0\" height=\"8\" onclick=\"delPlist(" + id + "," + channelfrom + ",'" + name + "')\" /></td></tr></table></p>" + playlistContent.innerHTML;
    CallTheServerBack_AddPlistListen( _s );
}

function Call_AddPlistListenHandler( result, context )
{               
    menuOut();
    window.setTimeout("menuIn()",3000);                    
}

function delPlist(id, channelfrom, name)
{
    document.getElementById(id+"_"+channelfrom).innerHTML = "";
    document.getElementById(id+"_"+channelfrom).style.display = "none";
    var _s = "DelPlayList|" + id + "|" + channelfrom + "|" + name;
    CallTheServerBack_DelPlistListen( _s );
}

function Call_DelPlistListenHandler( result, context )
{               
    //alert(result);              
}

function delAllPlist()
{
    var _s = "DelAllPlayList";
    playlistContent.innerHTML = "";
    CallTheServerBack_DelAllPlistListen( _s );
}

function Call_DelAllPlistListenHandler( result, context )
{               
    //alert(result);              
}

function PlayPlaylist()
{
    Player.openPlayer("http://tv.smgbb.cn/Playlist.aspx?key=all");
}