// JavaScript Document
function pop_mediaplayer()
{


test();
$('#dialog_link').click();
}
function pop_content(httpLink){
  display_content(httpLink);
}
function hide_forum()
{
  var tmp_offset="1000";
  if(parseInt(document.getElementById("main").style.top)>=tmp_offset){
    $('#main').animate({
      top: 0
      
      }, 1000, function() {
      // Animation complete.
      document.getElementById("vxr_forum").innerHTML = "";
    });
  }
}
var mediaplayer_content="";
function test()
{
var tmp_offset="1000";
var tmp_top=(document.getElementById("main").style.top.length==6)?"0px":"-"+tmp_offset+"px";
var tmp_top_value=(tmp_top=="0px")?'-':'+';


  $('#main').animate({
    top: tmp_top_value+"="+tmp_offset
    
    }, 1000, function() {
    // Animation complete.

    mediaplayer_content=(tmp_top_value=="-")?"":"<iframe frameborder=0 id=forum src=http://202.153.110.164/mediaplayer/></iframe>";
    writePOP("dialog",mediaplayer_content);

  });
}
function display_content(httpLink)
{
var tmp_offset="1000";
var tmp_top=(document.getElementById("main").style.top.length==6)?"0px":"-"+tmp_offset+"px";
var tmp_top_value=(tmp_top=="0px")?'-':'+';


  $('#main').animate({
    top: tmp_top_value+"="+tmp_offset
    
    }, 1000, function() {
    // Animation complete.

  });
  $('#vxr').css("z-index", 999);
  $('#vxr_forum').css("z-index", 998);
  $('#main').css("z-index", 997);
  if(tmp_top_value=="-"){
    forum_content="";
  }else{
    display_content_init();
    forum_content="";
    forum_content+="<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td background='images/forum_bg.jpg' height='55'>";
    forum_content+="<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td width='100%'><a id='logo' href='javascript:hide_forum();'><img src='images/forum_logo.jpg' border='0'></a></td><td><a id='home' href='javascript:hide_forum();'><img src='images/forum_home_off.jpg' border='0' onMouseOver='display_content_mouseover(this);' onMouseOut='display_content_mouseout(this);'></a><td></td></tr></table>";
    forum_content+="</td></tr>";
    forum_content+="<tr><td height='100%'>";
    forum_content+="<iframe width='100%' height='100%' frameborder=0 id=forum src="+httpLink+"></iframe>";
    forum_content+="</td></tr></table>";
  }
  document.getElementById("vxr_forum").innerHTML = forum_content;
}
var homeImg_on = new Image();
var homImg_off = new Image();
function display_content_init(){
    homeImg_on.src = "images/forum_home_on.jpg";
    homImg_off.src = "images/forum_home_off.jpg";
}
function display_content_mouseover(img){
    img.src = homeImg_on.src;
}
function display_content_mouseout(img){
    img.src = homImg_off.src;
}
function init_mediaplayer()
{


$.fx.speeds._default = 1000;
			$(function(){

				// Dialog			
				$('#dialog').dialog({
					autoOpen: false,
					draggable:false,
          modal:true,
          width:820,
          height:700,
					resizable: false,
					margin:0,
					position: 'center',
					show:'blind',
			    close: function(event, ui) { test()}

				});
				
				
				// Dialog Link
				$('#dialog_link').click(function(){
          $('#dialog').dialog('open');
					return false;
				});


				
				//hover states on the static widgets
				$('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				
			});
}
function init_swfobject()
{
			var flashvars = {};
			var params = {};
			params.quality = "high";
			params.wmode = "window";
			params.bgcolor = "#c2c2c2";
			params.allowfullscreen = "true";
			params.allowscriptaccess = "always";
			var attributes = {};
			attributes.id = "indexView_flash";
			attributes.align = "middle";
			swfobject.embedSWF(writeSWF('indexView', 'index.swf', fileversion), "vxr", "100%", "100%", "10.1.0", "js/expressInstall.swf", flashvars, params, attributes);
}

function writePOP(container,content)
{

document.getElementById(container).innerHTML =content;
}
function writeSWF(aId, aFile, aVersion) {
	var tParaObj = queryStringToObj(getQueryString());
	if (aVersion != null) {
		tParaObj["v"] = String(aVersion);
	}
	var tAnchor = getAnchor();
	if (tAnchor != "") {
		tParaObj["anch"] = tAnchor;
	}
	
	//document.write(getHTMLString(aId + "_flash", aFile, tParaObj, "100%", "100%"));
	return (getHTMLString(aId + "_flash", aFile, tParaObj));
}
function getQueryString() {
	var tIndex = window.location.href.indexOf("?");
	var tEndIndex = window.location.href.indexOf("#");
	if (tIndex > -1) {
		if (tEndIndex > tIndex) {
			return window.location.href.substring(tIndex + 1, tEndIndex);
		} else {
			return window.location.href.substr(tIndex + 1);
		}
	} else {
		return "";
	}
}
function getAnchor() {
	var tIndex = window.location.href.indexOf("#");
	if (tIndex > -1) {
		return window.location.href.substr(tIndex + 1);
	} else {
		return "";
	}
}
function addPara(aQueryString, aAddParaObj) {
	if (aQueryString == "" || aQueryString == null || aQueryString == undefined) {
		return objToQueryString(aAddParaObj);
	} else {
		return aQueryString + "&" + objToQueryString(aAddParaObj);
	}
}
function objToQueryString(aObj) {
	var t = "";
	for (var i in aObj) {
		if (t == "") {
			t = i + "=" + escape(aObj[i]);
		} else {
			t += "&" + i + "=" + escape(aObj[i]);
		}
	}
	return t;
}
function queryStringToObj(aQueryString) {
	var tObj = new Object();
	var tPairList = String(aQueryString).split("&");
	for (var i = 0; i < tPairList.length; i++) {
		var tS = tPairList[i];
		if (tS.length > 0) {
			var tList = tPairList[i].split("=");
			tObj[tList[0]] = tList[1];
		}
	}
	return tObj;
}

function getHTMLString(aId, aFilePath, aParaObj) {
	var tParaString = objToQueryString(aParaObj);
	var t = "";
	
	/*
    if (navigator.appName.indexOf("Microsoft") != -1) {
		t += "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" align=\"middle\" width=\"";
		t += aWidth;
		t += "\" height=\"";
		t += aHeight;
		t += "\" id=\"";
		t += aId;
		t += "\"><param name=\"allowScriptAccess\" value=\"always\" />";
		t += "<param name=\"allowFullScreen\" value=\"true\" />";
		// firefox doesn't support wmode = "opaque", it will make mousewheel and chinese input not working
		//t += "<param name=\"wmode\" value=\"opaque\" />";	
		t += "<param name=\"wmode\" value=\"opaque\" />";	
		t += "<param name=\"movie\" value=\"";
		t += aFilePath + "?"+tParaString;
		t += "\" /><param name=\"quality\" value=\"high\" />";
		t += "<param name=\"bgcolor\" value=\"#c2c2c2\" />";
		t += "</object>";
    } else {
		t += "<embed src=\"";
		t += aFilePath + "?"+tParaString;
		//t += "\" quality=\"high\" wmode=\"opaque\" bgcolor=\"#ffffff\" align=\"middle\" width=\"";
		t += "\" quality=\"high\" bgcolor=\"#c2c2c2\" align=\"middle\" width=\"";
		t += aWidth;
		t += "\" height=\"";
		t += aHeight;
		t += "\" id=\"";
		t += aId;
		t += "\" wmode=\"opaque\" allowFullScreen=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
    }
  */
  t=aFilePath + "?"+tParaString;
	return t;
}


function gebi(aId) {
	return document.getElementById(aId);
}

function doresize(){

  //window.resizeBy(1,0);window.resizeBy(-1,0);
  //window.resizeTo(window.outerWidth,window.outerHeight);
}

function openWin() {
window.open("facebook.htm","facebook", "width=500,height=600,status=no,toolbar=no,resizable=0,menubar=no,scrollbars=no,location=no,top=0,left=0");
}

var siteName ="VXRWorld";
var titleInterval;
var titleIntervalFlag = false;
function editTitle(str, flag){
	document.title = flag?str:siteName;
	titleInterval = setTimeout("editTitle('"+str+"', "+(flag?"false":"true")+")",1000);
}
function blinkTitle(str)
{
        if(titleInterval!=undefined)
                clearTimeout(titleInterval);
        editTitle(str, true);
}
function freezeTitle()
{
        if(titleInterval!=undefined)
                clearTimeout(titleInterval);
        document.title = siteName;
}
function getID( swfID ){
	 if(navigator.appName.indexOf("Microsoft") != -1){
		  return window[swfID];
	 }else{
		  return document[swfID];
	 }
}
//kilo
function sendId(swfID)
{
	window.parent.me = getID(swfID);
}
//call facebook api
function showStream(message, name, caption, description, hrefTitle, hrefLink, userPrompt, media){
	window.parent.showStream(message, name, caption, description, hrefTitle, hrefLink, userPrompt, media);
}
function share(u, t){
	window.parent.share(u, t);
}
function fqlQuery(fql)
{
	window.parent.fqlQuery(fql);
}
function setStatus(str)
{
	window.parent.setStatus(str);
}

function init()
{


//module init
init_swfobject();
init_mediaplayer();
}

//****************************************************************
//Start

init();

