// JavaScript Document
	var lastWin = null;
	var lastWinHeight = 0;
	var lastWinWidth = 0;
	var index = 10;
	
	function exeWin(_this,contentDiv,place,aspect,vidUrl){
		index += 1;
		var obj = {'place':place,'aspect':aspect,'url':vidUrl};
		flashWindowClose.closeWin(lastWin,lastWinHeight,lastWinWidth);
		flashWindowOpen.openWin(_this,document.getElementById(contentDiv).innerHTML,obj);
	}
	
	function closeWin(){
		flashWindowClose.closeWin(lastWin,lastWinHeight,lastWinWidth);	
	}

	var flashWindowOpen = function(){
	var timer = 50;
	var newWidth = 420;
	var newHeight = 400;
	var w = 0;
	var h = 0;
	var left = 0;
	var top = 0;
	var intW = 10;
	var intH = 10;
	var alpha = 0;
	var winID = null;
	var winName = null;
	var intervalH = null;
	var intervalW = null;
	var intervalA = null;
	var dataObj = null;
	var contentHTML = "";
	var ie = document.all ? true : false;
	return {
	openWin:function(this_,html,obj){
		var id = this_.id;
		var x = pos(this_,'X');
		var y = pos(this_,'Y');
		var width = this_.offsetWidth;
		var height = this_.offsetHeight;
		var win = document.createElement('div');
		win.setAttribute('id', 'win_'+id);
		lastWin = 'win_'+id;
		winName = 'win_'+id;
		lastWinWidth = width;
		lastWinHeight = height;
		win.style.width = width;
        win.style.height = height;
		w = width;
		h = height;
		left = x;
		top = y;
		win.style.position = "absolute";
		win.style.zIndex = index;
		win.style.left = x;
		win.style.top = y;
		win.className = 'flashWin';
		dataObj = obj;
		document.getElementById('winHolder').appendChild(win);
		winID = document.getElementById('win_'+id);
		var bt = '<div style="width:11px; height:21px; float:left;"><img src="images/window/tl.png" alt=""/></div>'
			   + '<div id="top_win_'+id+'" style="background:url(images/window/tm.png) repeat-x; float:left; height:21px;">'
			   + '<div style="text-align:right; width:100%; height:13px; margin-top:2px;"><a href="javascript:;" onclick="closeWin();" title="Close"><img src="images/window/close_up.png" alt="Close" width="13" height="13" border="0"/></a></div>'
			   + '</div>'
			   + '<div style="width:11px; height:21px; float:left;"><img src="images/window/tr.png" alt=""/></div>'
			   + '<div style="clear:left;"></div>'
			   + '<div id="left_win_'+id+'" style="clear:left; background:url(images/window/lm.png) repeat-y; float:left; width:11px;"></div>'
			   + '<div id="center_win_'+id+'" style="background:#232323; float:left;">'; //height:200px; width:200px;
		
		var bb = '</div>'
			   + '<div id="right_win_'+id+'" style="background:url(images/window/rm.png) repeat-y; float:left; width:11px;"></div>'
			   + '<div style="clear:left;"></div>'
			   + '<div style="width:11px; height:10px; float:left;"><img src="images/window/bl.png" alt=""/></div>'
			   + '<div id="bottom_win_'+id+'" style="background:url(images/window/bm.png) repeat-x; float:left; height:10px;"></div>' //width:200px;
			   + '<div style="width:11px; height:10px; float:left;"><img src="images/window/br.png" alt=""/></div>';
		winID.innerHTML = bt+bb;
		var flash = showMovie(dataObj['aspect'],dataObj['url']);
		var newhtml = html.replace("##"+dataObj['place']+"##",flash);
		contentHTML = '<div class="flashWindowContent">'+newhtml+'</div>';
		intW = ((newWidth-w)/10);
		intH = ((newHeight-h)/10);
		intervalW = setInterval(function(){flashWindowOpen.animateEnlarge('W');},timer);
  		intervalH = setInterval(function(){flashWindowOpen.animateEnlarge('H');},timer);
	},
	animateEnlarge:function(type){
		if(type == 'W'){
			if(winID.offsetWidth < newWidth){
				w += intW;
				left -= intW/2;
				winID.style.width = w+'px';
				winID.style.left = left+'px';
				document.getElementById('top_'+winName).style.width = (w-22)+'px';
				document.getElementById('center_'+winName).style.width = (w-22)+'px';
				document.getElementById('bottom_'+winName).style.width = (w-22)+'px';
			}else{
				clearInterval(intervalW);
				document.getElementById('center_'+winName).innerHTML = contentHTML;
			}
		}else{
			if(winID.offsetHeight < newHeight){
				h += intH;
				top -= intH/2;
				winID.style.height = h+'px';
				winID.style.top = top+'px';
				document.getElementById('left_'+winName).style.height = (h-31)+'px';
				document.getElementById('center_'+winName).style.height = (h-31)+'px';
				document.getElementById('right_'+winName).style.height = (h-31)+'px';
			}else{
				clearInterval(intervalH);
			}
		}
		
	}
	};
	}();
	
	var flashWindowClose = function(){
	var timer = 50;
	var newWidth = 0;
	var newHeight = 0;
	var w = 0;
	var h = 0;
	var left = 0;
	var top = 0;
	var intW = 10;
	var intH = 10;
	var winID = null;
	var winName = null;
	var intervalH = null;
	var intervalW = null;
	var ie = document.all ? true : false;
	return {
	closeWin:function(id,height,width){
		winName = id;
		if(document.getElementById(id) != null){
			winID = document.getElementById(id);
			document.getElementById('center_'+winName).innerHTML = "";
			newWidth = width;
			newHeight = height;
			var x = pos(winID,'X');
			var y = pos(winID,'Y');
			w = winID.offsetWidth;
			h = winID.offsetHeight;
			left = x;
			top = y;
			intW = ((w-newWidth)/2);
			intH = ((h-newHeight)/2);
			intervalW = setInterval(function(){flashWindowClose.animateDecrease('W');},timer);
			intervalH = setInterval(function(){flashWindowClose.animateDecrease('H');},timer);
		}
	},
	animateDecrease:function(type){
		if(type == 'W'){
			if(winID.offsetWidth > newWidth){
				w -= intW;
				left += intW/2;
				winID.style.width = w+'px';
				winID.style.left = left+'px';
				document.getElementById('top_'+winName).style.width = (w-22)+'px';
				document.getElementById('center_'+winName).style.width = (w-22)+'px';
				document.getElementById('bottom_'+winName).style.width = (w-22)+'px';
			}else{
				clearInterval(intervalW);
				flashWindowClose.remove();
			}
		}else{
			if(winID.offsetHeight > newHeight){
				h -= intH;
				top += intH/2;
				winID.style.height = h+'px';
				winID.style.top = top+'px';
				document.getElementById('left_'+winName).style.height = (h-31)+'px';
				document.getElementById('center_'+winName).style.height = (h-31)+'px';
				document.getElementById('right_'+winName).style.height = (h-31)+'px';
			}else{
				clearInterval(intervalH);
			}
		}
	},
	remove:function(){
		document.getElementById('winHolder').removeChild(winID);
	}
	};
	}();
	
	function pos(obj,type){
		if(type == 'X'){
			var curleft = 0;
			if(obj.offsetParent){
				while(1){
					curleft += obj.offsetLeft;
					if(!obj.offsetParent){
						break;
					}
					obj = obj.offsetParent;
				}
			}else if(obj.x){
				curleft += obj.x;
			}
			return curleft;
		}else{
			var curtop = 0;
			if(obj.offsetParent){
				while(1){
					curtop += obj.offsetTop;
					if(!obj.offsetParent){
						break;
					}
					obj = obj.offsetParent;
				}
			}else if(obj.y){
				curtop += obj.y;
			}
			return curtop;
		}
	}
	
	function showMovie(aspect,videourl){
		var swfURL = "flash/video_player.swf";
		var flashEmbed = "<div align=\"center\" style=\"height:225px;\"><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"300px\" height=\"225px\" align=\"top\">";
		flashEmbed += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
		flashEmbed += "<param name=\"movie\" value=\""+swfURL+"\" />";
		flashEmbed += "<param name=\"quality\" value=\"high\" />";
		flashEmbed += "<param name=\"bgcolor\" value=\"#ffffff\" />";
		flashEmbed += "<param name=\"FlashVars\" value=\"aspect="+aspect+"&vidUrl="+videourl+"\"/>";
		flashEmbed += "<embed src=\""+swfURL+"\" flashvars=\"aspect="+aspect+"&vidUrl="+videourl+"\" quality=\"high\" bgcolor=\"#ffffff\" width=\"300px\" height=\"225px\" align=\"middle\" allowScriptAccess=sameDomain type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>";
		flashEmbed += "</object></div>";
		return flashEmbed;
	}