﻿//require common.as

var BLOG_TYPE = "blog_type";
var CHAT_TYPE = "chat_type";
var FORUM_TYPE = "forum_type";
var HOME_TYPE = "home_type";

var blogPath = "blog/";
var chatPath = "chat/client/";
var forumPath = "forum_en";
var homePath = "";

var blogWin;
var chatWin;
var forumWin;
var homeWin;

function resetHomePath(path)
{
	if (path != "" && path != null)
	{
		homePath = path;
	}
}

function openApp(appType, lang, para)
{
	if (typeof(lang) == "undefined")
	{
		lang = "en";
	}
	if (typeof(para) == "undefined")
	{
		para = "";
	}

	var w = screen.width;
	var h = screen.height;
	if (appType == BLOG_TYPE)
	{
		blogWin = openAppWindow(blogWin, "http://10.0.0.206/"+blogPath+para, appType, w, h);
	}
	else if (appType == CHAT_TYPE)
	{
		w = 486;
		h = 350;
		chatWin = openAppWindow(chatWin, chatPath+para, appType, w, h, "resizable=1");
	}
	else if (appType == FORUM_TYPE)
	{
		if (lang == "b5")
		{
			forumPath = "forum_b5";
		}
		else if (lang == "gb")
		{
			forumPath = "forum_gb";
		}
		else
		{
			forumPath = "forum_en";
		}
		
		forumWin = openAppWindow(forumWin, "http://10.0.0.206/"+forumPath+para, appType, w, h);
	}
	else if (appType == HOME_TYPE)
	{
		homeWin = openAppWindow(homeWin, homePath, appType, w, h);
	}
}

function openAppWindow(win, path, winName, w, h, property)
{
// don't check win reference as it still reference an "object" though the window is deleted!! 
/*
	if (win != null)
	{
		win.focus();
		return;
	}
*/

	return openWindow(path, winName, w, h, property);
}
