﻿var screenMinW = 970;
var screenMinH = 620;
var screenW;
var screenH;
var theSwf;

function getTree()
{
	var loc = String(location);
	loc.replace('\\','/');
	var sitePath = loc.split("//")[1];
	var siteSplit = sitePath.split("/");
	var siteSplitIndex = 1;
	if (loc.indexOf("html_web")!=-1) siteSplitIndex = 2;
	this["lang"] = siteSplit[siteSplitIndex];
	var tree = new Array();
	for (var i=(1+siteSplitIndex); i<siteSplit.length; i++)
		{
			var txt = siteSplit[i].split("#")[0];
			txt = txt.split("_")[0];
			txt = String(txt).replace(".html","");
			txt = String(txt).replace(".htm","");
			tree.push(String(txt));
		}
	return tree;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function winInit() {
	//window.status = document.body.clientWidth+" : "+document.body.offsetWidth;
	
	if (navigator.appName.indexOf("Microsoft") > -1) {
		screenW = document.body.clientWidth;
		screenH = document.body.clientHeight;
	} else {
		screenW = document.body.clientWidth;
		screenH = document.body.clientHeight;
	}
//	alert(document.body.offsetWidth+" : "+document.body.clientWidth);
}

function resizeHomeScreen() {
	winInit();
	theSwf = document.getElementById('home');
	
	if (screenW > screenMinW) {
		theSwf.width = screenW;
	} else {
		theSwf.width = screenMinW;
	}
	if (screenH > screenMinH) {
		theSwf.height = screenH;
	} else {
		theSwf.height = screenMinH;
	}
}



function genFlash(file, width, height, id, vars) {
	vars = "loc=" + location + "&" + vars;
	vars = "currentLoc=" + getTree()[0] + "&" + vars;
	if (typeof(path)!='undefined')
		{
			vars = "path=" + path + "&" + vars;
			vars = "xmlPath=" + path + "xml/" + "&" + vars;
		}

	tempHTML = '	<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'">';
	tempHTML += '	<param name="movie" value="'+file+'">';
	tempHTML += '	<param name="quality" value="high">';
	tempHTML += '	<param name="menu" value="false">';
	tempHTML += '	<param name="wmode" value="opaque">';
	tempHTML += '	<param name="scale" value="noscale">';
	tempHTML += '	<param name="salign" value="">';
	
	if (vars != null) {
		tempHTML += '	<param name="flashVars" value="'+vars+'">';
		tempHTML += '	<embed src="'+file+'" flashVars="'+vars+'" salign="" quality="high" scale="noscale" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	} else {
		tempHTML += '	<embed src="'+file+'" salign="TL" quality="high" scale="noscale" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	}
	
	tempHTML += '	</object>';
	
	document.write(tempHTML);
}

function genFlash_trans(file, width, height, id, vars) {
	vars = "loc=" + location + "&" + vars;
	if (typeof(path)!='undefined')
		{
			vars = "path=" + path + "&" + vars;
			vars = "xmlPath=" + path + "xml/" + "&" + vars;
		}

	tempHTML = '	<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'">';
	tempHTML += '	<param name="movie" value="'+file+'">';
	tempHTML += '	<param name="quality" value="high">';
	tempHTML += '	<param name="menu" value="false">';
	tempHTML += '	<param name="wmode" value="transparent">';
	tempHTML += '	<param name="scale" value="noscale">';
	tempHTML += '	<param name="salign" value="">';
	
	if (vars != null) {
		tempHTML += '	<param name="flashVars" value="'+vars+'">';
		tempHTML += '	<embed src="'+file+'" flashVars="'+vars+'" salign="" quality="high" scale="noscale" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	} else {
		tempHTML += '	<embed src="'+file+'" salign="TL" quality="high" scale="noscale" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	}
	
	tempHTML += '	</object>';
	
	document.write(tempHTML);
}

function menuOpen()
{
	var item = document.getElementById('flashMenuContainer');
	if (!(item)) return;
	item.style.width = "650px";
}

function menuClose()
{
	var item = document.getElementById('flashMenuContainer');
	if (!(item)) return;
	item.style.width = "80px";
}

// function changeLanguage(target, sect) {
	// var nowL = 'eng';
	// var url = location.href.replace((nowL+'/'), (target+'/'));
	// if ((url.indexOf('?')==-1) && (sect))
		// {
			// url += '?section='+sect;
		// }
	// location.href = url;
// }

function changeLanguage(target, sect) {
	var nowL = this["lang"];
	var url = location.href.replace((nowL+'/'), (target+'/'));
	if (sect)
		{
			if (url.indexOf('?section')==-1)
				{
					url += '?section='+sect;
				}
			else
				{
					var urlParam = url.split("?");
					var urlSec = urlParam[1].split("&");
					var params = '';
					for (var i=0; i<urlSec.length; i++)
						{
							if (params!='')
								{
									params += '&';
								}
							params += (urlSec[i].indexOf('section=')!=-1)?('section='+sect):urlSec[i];
						}
					url = urlParam[0] + '?' + params;
				}
		}
	location.href = url;
}