function ResizeWindow() {

	 var pageWidth, pageHeight;

	 if (newWindow.document.getElementById) 
		 { // Work Both on IE & FF	 	 
			pageWidth = newWindow.document.body.scrollWidth + 30;
			pageHeight = newWindow.document.body.scrollHeight + 60;
	 
				if (pageWidth > screen.availWidth) 
				{ pageWidth = screen.availWidth;  }
		
				if (pageHeight > screen.availHeight)	
				{ pageHeight = screen.availHeight; }
		  }
	   else
	   {  // Setting for default V360 
		 pageWidth = 796;
		 pageHeight = 640;
	   } 
	   
	   newWindow.resizeTo(pageWidth,pageHeight);
	   newWindow.focus();
}

winMediaPlayer = function (src, w, h) {
	this.param = {};
	this.wid = w;
	this.hgh = h;
	this.src = src;
	this.setParam = function (n, v) {
		this.param[n] = v;
	}
	this.getEmbedHTML = function () {
		var str = "<obj" + "ect id=MediaPlayer \r\ncodeBase=http://activex"+
			".microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 "+
			"\r\ntype=application/x-oleobject hei" + "ght=$hei" +
			"ght$ \r\nstandby=\"Loading Microsoft Windows Media Player components...\" wi" +
			"dth=$wid" + "th$ \r\nalign=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95>\r\n";
		str = str.replace(/\$width\$/gi,this.wid).replace(/\$height\$/gi,this.hgh);
		str += "<param name='FileName' value='$value$'>".replace(/\$value\$/gi,this.src);
		for(var item in this.param)
			str += "<param name='$name$' value='$value$'>".replace(/\$name\$/gi,item).replace(/\$value\$/gi,this.param[item]);
		str += "<embed type=\"application/x-mplayer2\" \r\npluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/\" \r\nname=\"MediaPlayer\" align=\"middle\" \r\nsrc=\"$src$\" filename=\"$src$\" \r\nwidth=$width$ height=$height$\r\n"
				.replace(/\$width\$/gi,this.wid).replace(/\$height\$/gi,this.hgh)
				.replace(/\$src\$/gi,this.src);
		for(var item in this.param)
			str += " $name$='$value$'".replace(/\$name\$/gi,item).replace(/\$value\$/gi,this.param[item]);
		str += "></embed>";
		str += "</ob" + "ject>";
		return str;
	}
}
        
function playMedia(id_name,type, content, autoplay,img,rl,art_id,vid) {
	switch (type) {
		case "embed":
			document.getElementById("NMI:mediaBox").innerHTML = content;
			break;
		case "swf":
			// assume loaded swfobject.js
			var so = new SWFObject(content,"swf",320,240,8,"#FFFFFF");
			document.getElementById("NMI:mediaBox").innerHTML = so.getSWFHTML();
			break;
		case "wmv":
			var mp = new winMediaPlayer(content,480,427);
			mp.setParam("AutoStart", "true");
			mp.setParam("ShowControls", "true");
			mp.setParam("ShowStatusBar", "true");
			document.getElementById("NMI:mediaBox").innerHTML = mp.getEmbedHTML();
			break;
		case "flv":
			//var so = new SWFObject("images/vdoplayer.swf","swf",500,440,8,"#FFFFFF");
			//var so = new SWFObject("images/vdoplayer.swf","swf",480,398,8,"#FFFFFF");
			//var so = new SWFObject("images/vdoplayer.swf","vdoplayer",480,312,8,"#FFFFFF");	
			var so = new SWFObject("/swf/vdoplayer.swf","swf",480,402,8,"#FFFFFF");	
			so.addVariable("movie", content);
			so.addVariable("img", img);
			so.addVariable("autoplay", autoplay);
		//	so.addVariable("rl", rl);

			so.addVariable("art_id", art_id);
			so.addVariable("vid", vid);		
			so.addParam("allowFullScreen", true);
			so.addParam("allowScriptAccess", "sameDomain");
			document.getElementById(id_name).innerHTML = so.getSWFHTML();
			break;
		case "mp3":
			var so = new SWFObject("images/sndplayer.swf","swf",364,327,8,"#FFFFFF");
			so.addVariable("job", content);
			so.addVariable("autoplay", autoplay);
			so.addParam("wmode", "transparent");
			document.getElementById("NMI:mediaBox").innerHTML = so.getSWFHTML();
			break;
		case "html":
			<!--- edited by kk 20071122 --->
			newWindow = window.open(content,"html","width=815,height=640,resizable=yes,scrollbars=yes");
			// Internet Explorer
		   if (navigator.appName == "Microsoft Internet Explorer") 
		   {  version=0
			  if (navigator.appVersion.indexOf("MSIE")!=-1){
				  temp =navigator.appVersion.split("MSIE");
				  version=parseFloat(temp[1]);
				  }
			  if (version <= 6 )
				 { //IE6 
					newWindow.document.body.onload = new Function("ResizeWindow();");
				  }
			  else
				 { //IE7
					newWindow.document.onload = ResizeWindow();	 
				 }
			}	 
		  else 
			// Other Browser
		  {         newWindow.onload = ResizeWindow; 	
		  }
			break;
	}
}
											
function videoTracker(a,v){

	var kw = {
		url:"/ajax/model/act_VideoTracker.php?art_id="+a+"&av_id="+ v +"&"+Math.random(),
		handleAs:"json",
		timeout:60000,
		load: function (response, ioArgs) {},
		error: function (response, ioArgs) {}
	}
	dojo.xhrGet(kw);

}

function visiblePlayer() {
   // document.getElementById("videoBox").className = "videobox715";
	document.getElementById("NMI:mediaBox").style.display = "";
   // document.getElementById("NMI:mediaBox").className = "flash-video-visible";
	/*
	if (! document.all)
		document.getElementById("videobox715_content").style.height = "440px";
	*/
}

var flvZoom;
function openFlvZoom(content) {
	flvZoom =window.open("flvZoom.html?job="+escape(content),"zoom",
		"toolbar=no,width=" + screen.availWidth  + ",height=" + screen.availHeight 
		+ ",status=no,resizable=yes,fullscreen=yes,scrollbars=no");
}
                                            
function closeFlvZoom() {
	flvZoom.close();
}
function vdo_notify(type, data) {
	if (type == "aspect") { // change player size to cater for diff aspect ratio of FLV video
/*	var h,w;
	if (data == "4:3") {
		h = 370;
		w = 569;
	} else {
		h = 312;
		w = 480;
	}
	document["vdoplayer"].style.height = h + "px";
	document["vdoplayer"].style.width = w + "px";*/
	} else if (type == "playing") {
		videoTracker(data.art_id, data.vid);
	// call other function to handle video view statistic, may use the optional art_id, video properties inside the "data" parameter (a javascript object)
	}
}
