/*###########################################################
#	JavaScript Document
#	File name : main.js
#	
#	function list
#	MM_swapImgRestore......Restore the swaped image
#	MM_preloadImages......Preload the images that the document needs
#	MM_findObj......Find the object the function will handle
#	MM_swapImage......Swap the link image when mouse  rolls over
# popWin......Pop pages
# isRoot......Check if the page is in the root folder
# chgfSize......Get the font size and pop a window then pass the font size to the url
#
#
###########################################################*/

/*###########################################################
#	
#	function: Restore the swaped image 
#	value: none
#	returne: none
#	
###########################################################*/

function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++){
		x.src=x.oSrc;
	}
}

/*###########################################################
#	
#	function: Preload the images that the document needs 
#	value: none
#	returne: none
#	
###########################################################*/

function MM_preloadImages() { 
  var d=document; if(d.images) { 
	if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
    	if (a[i].indexOf("#")!=0) { 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
		}
}

/*###########################################################
#	
#	function: Find the object the function will handle 
#	value n:a value stores the object id
#	      d:a value points to the object
#	returne x: the id that the function found
#	
###########################################################*/

function MM_findObj(n, d) { 
  var p,i,x;
	if(!d) d=document;
		if((p=n.indexOf("?"))>0&&parent.frames.length) {
			d=parent.frames[n.substring(p+1)].document;
			n=n.substring(0,p);
		}
			if(!(x=d[n])&&d.all) x=d.all[n];
			for (i=0;!x&&i<d.forms.length;i++)
				x=d.forms[i][n];
				for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
					x=MM_findObj(n,d.layers[i].document);
				if(!x && d.getElementById) 
				x=d.getElementById(n); 
				return x;
}

/*###########################################################
#	
#	function: Swap the link image when mouse  rolls over 
#	value: none
#	returne: none
#	
###########################################################*/

function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;
	 if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

/*###########################################################
#	
#	function: Pop pages 
#	value: url page url
#	returne: none
#	by:Neo
#	
###########################################################*/

function popWin(url){
	pWindow=window.open(url,"PopWindow","toolbar=no,directories=no,location=yes,menubar=no,status=no,scrollbars=yes,width=380,height=520");
	pWindow.focus();
}
function popVideo(url){
	open(url,"videoWindow","toolbar=no,directories=no,location=yes,menubar=no,status=no,scrollbars=yes,width=380,height=480");
}
function popNorWin(url){
	pWindow=window.open(url,'NewWindow','titlebar=yes,location=yes, toolbar=no,directories=no,menubar=yes,toolbar=yes,resizable=yes,status=yes,scrollbars=yes');
	pWindow.focus();

}
/*###########################################################
#	
#	function: check if the page is in the root path
#	value: none
#	returne: true or fals
#	by:Neo
#	
###########################################################*/

function isRoot(){
	var oStr=document.location.href;
	//alert(oStr);
	s=oStr.split("/");
	//var oStr="Source/webpage/chinese/index.html";
	path=s[s.length-2];
	//alert(path);
	if(path!="japanese"){
		//alert(oStr);
		return false;
	}else{
		//alert("root");
		return true;
	}	
}
//isRoot();
// ########## Delete Error Message
window.onerror = null;

// ########## Select OS

var mac = (navigator.userAgent.indexOf('Mac') != -1 || navigator.userAgent.indexOf('mac') != -1);
var win = (navigator.userAgent.indexOf('Win') != -1 || navigator.userAgent.indexOf('win') != -1);
var crrntos;
var fsize;

crrntCookie=document.cookie + ";";
var thename='fsize=';
start=crrntCookie.indexOf(thename);

if (start!=-1){
end=crrntCookie.indexOf(';',start);

fsize=unescape(crrntCookie.substring(start+thename.length,end));
}

//
if(fsize==2){
	if(isRoot()){
		str='<link rel="stylesheet" href="cmn_css/extraFont.css" type="text/css">';
	}else{
		str='<link rel="stylesheet" href="../cmn_css/extraFont.css" type="text/css">';
	}
	document.write(str);
	//alert("change");
}else{
	//alert("unchange");
}
/*###########################################################
#	
#	function: change the page font size
#	value: fValue font size value
#	returne: none
#	by:Neo
#	
###########################################################*/

function chgfSize(fValue){
	num = fValue;
	if(isRoot()){
		//alert(crrntUrl);
		crrntUrl = 'change.html\?'+ num;
	}else{
		crrntUrl = '../change.html\?'+ num;
		//alert(crrntUrl);
	}
	//alert(crrntUrl);
	newWin = window.open(crrntUrl,'win1','width=360, height=155');
	newWin.focus();
}
/*###########################################################
#	
#	function: judge the flash player
#	value: none
#	returne: none
#	by:Neo
#	
###########################################################*/

function judgePlayer(){
	<!--
	// -----------------------------------------------------------------------------
	// Globals
	// Major version of Flash required
	var requiredMajorVersion = 8;
	// Minor version of Flash required
	var requiredMinorVersion = 0;
	// Revision of Flash required
	var requiredRevision = 0;
	// -----------------------------------------------------------------------------
	// -->
	if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	}
	else {
		var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		if(hasRightVersion) {  // if we've detected an acceptable version
			// embed the flash movie
			AC_FL_RunContent(
				'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
				'width', '320',
				'height', '284',
				'src', '../media/videoPlayer?videoPath=transcosmosteam.flv',
				'quality', 'high',
				'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'false',
				'scale', 'noscale',
				'wmode', 'window',
				'devicefont', 'false',
				'id', 'compnentVersion',
				'bgcolor', '#000000',
				'name', 'videoPlayer',
				'menu', 'true',
				'allowScriptAccess','sameDomain',
				'allowFullScreen','false',
				'movie', '../media/videoPlayer?videoPath=transcosmosteam.flv',
				'salign', 'lt'
				); //end AC code
		}
		else {  // flash is too old or we can't detect the plugin
			var alternateContent ='<div id="getPlayer">' 
				+ '<p>This content requires the Adobe Flash Player.</p><p>&nbsp;</p>'
				+ '<p><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></p>'
				+'<a href=http://www.macromedia.com/go/getflash/><img src="../cmn_images/getFlashPlayer_bt.gif" width="88" height="31" /></a>'
				+'</div>';
			document.write(alternateContent);  // insert non-flash content
		}
	}
}