// JavaScript Document
var isPrint = GetQueryValue(location.search.toLowerCase(),'jsprint');
var globalPath = '/tc/';
var globalImgPath = globalPath+'file_manager/images/';

//Global Setting
if (isPrint) {
	document.write('<link href="'+globalPath+'file_manager/stylesheet/chuangs_print.css" rel="stylesheet" type="text/css">')
	window.status = '';
	document.title = 'Print Page';
} else {
	window.status = 'Welcome to Chuang\'s China Investments Limited Website';
	document.title = 'Chuang\'s China Investments Limited Website';
}

//Section Submenu
function SubMenuItem(name,url,urlType,menuHeight){
	this.name = name;
	this.url = url;
	this.urlType = urlType;
	this.menuHeight = menuHeight;
}
var CompanyNav = new Array();
CompanyNav[0] = new SubMenuItem('公司致辭',globalPath+'company/welcome_message.html','',26)
CompanyNav[1] = new SubMenuItem('公司理念',globalPath+'company/mission_statement.html','',26)
CompanyNav[2] = new SubMenuItem('企業架構',globalPath+'company/organization_structure.html','',26)
CompanyNav[3] = new SubMenuItem('榮譽主席',globalPath+'company/honorary_chairman.html','',26)
CompanyNav[4] = new SubMenuItem('管理團隊',globalPath+'company/management_team.html','',26)
CompanyNav[5] = new SubMenuItem('投身莊士',globalPath+'company/job_opportunities.html','',26)
CompanyNav[6] = new SubMenuItem('網站連結',globalPath+'company/links.html','',26)
CompanyNav[7] = new SubMenuItem('聯絡我們',globalPath+'company/contact_us.html','',26)
var InvestorsNav = new Array();
InvestorsNav[0] = new SubMenuItem('年報/中期報告',globalPath+'investors/financial_reports.html','',26)
InvestorsNav[1] = new SubMenuItem('公告及通函',globalPath+'investors/announcements.html','',26)
InvestorsNav[2] = new SubMenuItem('股本變動報表','/tc/investors/share_capital.html','',26)
var PropertiesNav = new Array();
PropertiesNav[0] = new SubMenuItem('莊士新都',globalPath+'properties/chuangs_new_city_1.html','',26)
PropertiesNav[1] = new SubMenuItem('莊士 &bull; 映蝶藍灣',globalPath+'properties/chuangs_le_papillon_1.html','',26)
PropertiesNav[2] = new SubMenuItem('長沙項目',globalPath+'properties/chuangs_changsha_projects_1.html','',26)
PropertiesNav[3] = new SubMenuItem('莊士新城',globalPath+'properties/chuangs_new_town.html','',26)
PropertiesNav[4] = new SubMenuItem('莊士 &bull; 香榭春天',globalPath+'properties/chuangs_le_printempts.html','',26)
PropertiesNav[5] = new SubMenuItem('莊士 &bull; 中心城',globalPath+'properties/chuangs_anshan_cyber_mall.html','',26)
PropertiesNav[6] = new SubMenuItem('莊士廣場',globalPath+'properties/chuangs_plaza_anshan.html','',26)
PropertiesNav[7] = new SubMenuItem('廈門佲家濱海',globalPath+'properties/chuangs_xiamen_mingjia_binhai.html','',26)


//For Flash
//start of flash language control
var lang = 'tc';
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
function FlashHeader_DoFSCommand(command, args) {
	var FlashHeaderObj = isInternetExplorer ? document.all.FlashHeader : document.FlashHeader;
	if (command == 'setlang') {
		//alert('Chinese version is under construction, please visit later.');
		lang = args;
		LangSwitch(lang)
	}
	if (command == 'complink') {
		goLink = args;
		if (goLink=='consortium') {
			location = 'http://www.chuangs-consortium.com:'+location.port+'/'+lang;
		} else if (goLink=='china'){
			location = 'http://www.chuangs-china.com:'+location.port+'/'+lang;
		} else if (goLink=='main'){
			location = 'http://www.chuangs.com.hk:'+location.port;
		};
	}
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub FlashHeader_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call FlashHeader_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
//end of flash language control

//Layout Setting
function PreloadImage(){
	MM_preloadImages(
					globalImgPath+'common/china_on.gif',
					globalImgPath+'menu/home_on.gif',
					globalImgPath+'menu/site_map_on.gif',
					globalImgPath+'menu/contact_us_on.gif',
					globalImgPath+'icon/bookmark_on.gif',
					globalImgPath+'icon/printer_on.gif',
					globalImgPath+'icon/font_plus_on.gif',
					globalImgPath+'icon/font_minus_on.gif',
					globalImgPath+'menu/top_on.gif'
					)
}

function Init(){
	if (isPrint) {
			var pageLink = document.getElementsByTagName("a")
			for(var i=0; i<pageLink.length; i++) {
				pageLink[i].href = 'javascript://';
				pageLink[i].target = '_self';
			}
			window.print();
	} else {
		PreloadImage();
	}
}

function LayoutHeader(){
	var htmlStr = '';
	htmlStr += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	htmlStr += '<tr>';
	htmlStr += '<td width="118">';
	htmlStr += '<div id="FlashHeader" style="top:0px;position:absolute;z-index:2;"></div>';
	htmlStr += '</td>';
	htmlStr += '<td height="70"><table width="642" border="0" cellspacing="0" cellpadding="0">';
	htmlStr += '<tr>';
	htmlStr += '<td height="60" align="right" valign="bottom">';
	htmlStr += '<a href="'+globalPath+'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'home\',\'\',\''+globalImgPath+'menu/home_on.gif\',1)">';
	htmlStr += '<img src="'+globalImgPath+'menu/home.gif" name="home" border="0"></a>';
	htmlStr += '<a href="'+globalPath+'site_map.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'sitemap\',\'\',\''+globalImgPath+'menu/site_map_on.gif\',1)">';
	htmlStr += '<img src="'+globalImgPath+'menu/site_map.gif" name="sitemap" border="0"></a>';
	htmlStr += '<a href="'+globalPath+'company/contact_us.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'contactus\',\'\',\''+globalImgPath+'menu/contact_us_on.gif\',1)">';
	htmlStr += '<img src="'+globalImgPath+'menu/contact_us.gif" name="contactus" border="0"></a>';
	htmlStr += '<img src="'+globalImgPath+'common/shim.gif" width="20" height="10">';
	htmlStr += '</td>';
	htmlStr += '</tr>';
	htmlStr += '<tr>';
	htmlStr += '<td colspan="2"><img src="'+globalImgPath+'common/shim.gif" width="42" height="10"><img src="'+globalImgPath+'common/shim.gif" name="menu" width="10" height="10" id="menu"></td>';
	htmlStr += '</tr>';
	htmlStr += '</table></td>';
	htmlStr += '</tr>';
	htmlStr += '<tr>';
	htmlStr += '<td height="170" colspan="2">';
	htmlStr += '<div id="FlashGraphic" style="top:70px;position:absolute;z-index:1;">';
	htmlStr += '<img src="'+globalImgPath+'common/shim.gif" height="18" width="10">';
	htmlStr += '<table width="755" border="0" cellspacing="0" cellpadding="5">';
	htmlStr += '<tr>';
	htmlStr += '<td align="right"><table border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">';
	htmlStr += '<tr>';
	htmlStr += '<td bgcolor="#333333"><b>You need to upgrade your Flash Player.</b><br/>Chuang\'s Group Website requires Macromedia Flash, version 8 or greater. Please click <a href="http://www.adobe.com/products/flashplayer/">here</a> to download. </td>';
	htmlStr += '</tr>';
	htmlStr += '</table></td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	htmlStr += '</div>';
	htmlStr += '</td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	htmlStr += '<table width="730" border="0" align="center" cellpadding="0" cellspacing="0">';
	htmlStr += '<tr>';
	htmlStr += '<td><img src="'+globalImgPath+'common/shim.gif" width="10" height="2"></td>';
	htmlStr += '</tr>';
	htmlStr += '<tr>';
	htmlStr += '<td bgcolor="#787878"><img src="'+globalImgPath+'common/shim.gif" width="10" height="2"></td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	if (isPrint) {
		return '<table width="620" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="'+globalImgPath+'common/logo.gif"></td></tr></table>';
	}else{
		return htmlStr;
	}
}

function CreateFlashObject(section){
	if (isPrint) {
		return;
	}
	//for logo display
	var FlashHeaderObj = new SWFObject(globalPath+"file_manager/flash/Header.swf?lang="+lang, "FlashHeader", "760", "140", "8", "#FFFFFF");
	FlashHeaderObj.addVariable("ie", "0");
	FlashHeaderObj.addVariable("app", "");
	FlashHeaderObj.addVariable("id", "");
	FlashHeaderObj.addParam("scale", "noscale");
	FlashHeaderObj.addParam("wmode","transparent");
	FlashHeaderObj.write("FlashHeader");
	//for center flash animation display
	var FlashGraphicObj = new SWFObject(globalPath+"file_manager/flash/"+section+".swf", "FlashGraphic", "760", "170", "8", "#FFFFFF");
	FlashGraphicObj.addVariable("ie", "0");
	FlashGraphicObj.addVariable("app", "");
	FlashGraphicObj.addVariable("id", "");
	FlashGraphicObj.addParam("scale", "noscale");
	FlashGraphicObj.addParam("wmode","transparent");
	FlashGraphicObj.write("FlashGraphic");
}

function LayoutFooter(){
	var htmlStr = '';
	htmlStr += '<table width="100%" border="0" cellspacing="0" cellpadding="15">';
	htmlStr += '<tr>';
	htmlStr += '<td><table width="400" border="0" cellpadding="0" cellspacing="0">';
	htmlStr += '<tr>';
	htmlStr += '<td><a href="javascript:BackToTop();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'top\',\'\',\''+globalImgPath+'menu/top_on.gif\',0)"><img src="'+globalImgPath+'menu/top.gif" name="top" border="0"></a></td>';
	htmlStr += '</tr>';
	htmlStr += '<tr>';
	htmlStr += '<td background="'+globalImgPath+'common/sep_line_black.gif"><img src="file_manager/images/common/shim.gif" width="10" height="1"></td>';
	htmlStr += '</tr>';
	htmlStr += '<tr>';
//	htmlStr += '<td><img src="'+globalImgPath+'common/copyright.gif"></td>';
	htmlStr += '<td class="copyright">&copy; 2011 莊士中國投資有限公司。版權所有。</td>';
	htmlStr += '</tr>';
	htmlStr += '<tr>';
	htmlStr += '<td><a href="http://www.netconcept.com.hk" target="_blank"><img src="'+globalImgPath+'common/site_by.gif" border="0"></a></td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	htmlStr += '</td>';
	htmlStr += '<td height="100%">';
	htmlStr += '<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">';
	htmlStr += '<tr>';
	htmlStr += '<td align="right" valign="top">';
	htmlStr += '<table border="0" cellspacing="0" cellpadding="3">';
	htmlStr += '<tr>';
	htmlStr += '<td><a href="javascript:AddFavourite();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'bookmark\',\'\',\''+globalImgPath+'icon/bookmark_on.gif\',0)"><img src="'+globalImgPath+'icon/bookmark.gif" name="bookmark" border="0"></a></td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	htmlStr += '</td>';
	htmlStr += '</tr>';
	htmlStr += '<tr>';
	htmlStr += '<td align="right" valign="bottom" class="Footer"><a href="javascript:LegalStatement();">法律聲明</a></td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	htmlStr += '</td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	if (isPrint) {
		return '<br><br><hr><table width="100%"><tr><td>&copy; 2011 Chuang\'s China Investments Limited. All rights reserved.</td></tr></table>';
	}else{
		return htmlStr;
	}
}

function LayoutIcon(){
	var htmlStr = '';
	htmlStr += '<table border="0" cellspacing="0" cellpadding="3" height="32">';
	htmlStr += '<tr>';
	htmlStr += '<td><a href="javascript:PrinterFriendly();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'printer\',\'\',\''+globalImgPath+'icon/printer_on.gif\',0)"><img src="'+globalImgPath+'icon/printer.gif" name="printer" border="0"></a></td>';
	htmlStr += '<td><img src="'+globalImgPath+'icon/font.gif"><a href="javascript:ChangeFontSize(\'ArticleContent\',1,0);" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'font_plus\',\'\',\''+globalImgPath+'icon/font_large_on.gif\',0)"><img src="'+globalImgPath+'icon/font_large.gif" name="font_plus" border="0"></a><img src="'+globalImgPath+'common/shim.gif" width="2" height="10"><a href="javascript:ChangeFontSize(\'ArticleContent\',-1,0);" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'font_minus\',\'\',\''+globalImgPath+'icon/font_small_on.gif\',0)"><img src="'+globalImgPath+'icon/font_small.gif" name="font_minus" border="0"></a></td>';
	htmlStr += '</tr>';
	htmlStr += '</table>';
	if (isPrint) {
		return '';
	}else{
		return htmlStr;
	}
}

function LayoutSideMenu(menuObj,name){
	var htmlStr = '';
	if (name=='') {
		htmlStr += '<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">';
	} else {
		htmlStr += '<table width="180" border="0" cellspacing="0" cellpadding="0" height="100%">';
	}
	htmlStr += '<tr valign="top">';
	if (name!='') {
		htmlStr += '<td height="100%">';
		htmlStr += '<table width="1" border="0" cellspacing="0" cellpadding="0" height="100%">';
		htmlStr += '<tr>';
		htmlStr += '<td background="'+globalImgPath+'common/sep_menu.gif"><img src="'+globalImgPath+'common/shim.gif" width="1" height="10"></td>';
		htmlStr += '</tr>';
		htmlStr += '</table>';
		htmlStr += '</td>';
		htmlStr += '<td width="10">';
		htmlStr += '</td>';
	}
	htmlStr += '<td>';
	if (typeof(menuObj) != 'undefined'){
		htmlStr += '<table width="100%" border="0" cellspacing="0" cellpadding="2">';
		for (var i=0; i<menuObj.length; i++){
			htmlStr += '<tr';
			if (menuObj[i].name==name) {
				htmlStr += ' bgcolor="#dedede"';
			}
			htmlStr += '>';
			htmlStr += '<td align="right" valign="top" class="SideMenu"><img src="'+globalImgPath+'common/plus_menu.gif"></td>';
			htmlStr += '<td valign="top" width="100%" class="SideMenu"><a href="'+menuObj[i].url+'" class="section_menu_item">'+menuObj[i].name+'</a></td>';
			htmlStr += '</tr>';
		}
		htmlStr += '</td>';
		htmlStr += '</tr>';
		htmlStr += '</table>';
	}
	htmlStr += '</table>';
	if (isPrint) {
		return '';
	}else{
		return htmlStr;
	}
}

function GetQueryValue(queryString,name) {
	var queryItems = queryString.substring(1,location.search.length).split('&');
	var queryValues = new Array();
	for (var i=0; i<queryItems.length; i++){
		queryValues[i] = queryItems[i].substring(queryItems[i].indexOf('=')+1,queryItems[i].length)
		queryItems[i] = queryItems[i].substr(0,queryItems[i].indexOf('='))
	}
	for (var i=0; i<queryItems.length; i++) {
		if (queryItems[i]==name) {
			return queryValues[i];
		}
	}
	return false;
}

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','table','tr','td','strong','a','span','li','ul');
var startSz=null;

var thisDate= new Date();
thisDate.setTime (thisDate.getTime()+(365*24*60*60*1000));
var thisDomain = (location.domain) ? location.domain : null;
var thisPath = "/";
function GetFontSize() {
	if (document.cookie.indexOf("fontSize") < 0) {
		startSz = 0;
	} else {
		var startStr = document.cookie.indexOf("fontSize") + 9;
		var endStr = document.cookie.indexOf(";", startStr);
		if (endStr == -1) {
			endStr = document.cookie.length;
		}
		startSz = unescape(document.cookie.substring(startStr, endStr));

		ChangeFontSize("ArticleContent",0,0);
	}
}

function ChangeFontSize( trgt, inc, type ) {
	var sizeArray = new Array('90%','100%','130%');
	var smallSize = '100%';
	if (!document.getElementById) return;
	var d = document;
	var cEl = null;
	var sz = eval(startSz), i, j, cTags;
	if (type==0) {
		sz += inc;
	}
	if (sz<0) sz = 0;
	if (sz>(sizeArray.length-1)) sz=(sizeArray.length-1);
	startSz = sz;
	
	if (!(cEl=d.getElementById(trgt))) cEl=d.getElementsByTagName(trgt)[0];
	cEl.style.fontSize = sizeArray[sz];
		
	for (i=0 ; i<tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName(tgs[i]);
		for (j=0 ; j<cTags.length ; j++) {
			cTags[j].style.fontSize = smallSize;
		}
	}
	if (type==0) {
		SetCookie("fontSize", sz, thisDate, thisPath, thisDomain);
	}
}

function SetCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function AddFavourite() {
	theURL = location.href;
	theTitle = document.title;
	if (window.external) {
		window.external.AddFavorite(theURL, theTitle);
	} else if( window.sidebar && window.sidebar.addPanel ) { 
		if (navigator.userAgent.lastIndexOf("Netscape") != -1) { 
			window.sidebar.addPanel(theTitle, theURL, '');
		}else{ 
			window.sidebar.addPanel(theTitle, theURL, '');
		} 
	}
}

var position;
function MoveScrollPosition(){
	position = Math.floor(position*0.9);
	if( position > 0.1 ){
		window.scrollTo(0,position)
		setTimeout("BackToTop()",15);
	} else {
		window.scrollTo(0,0)
	}
}

function BackToTop(){
	if(navigator.appName.indexOf("Microsoft Internet Explorer")!=-1){
		position = document.body.scrollTop;
	} else {
		position = window.pageYOffset;
	}
	MoveScrollPosition();
}

function PrinterFriendly(){
	var hash = location.hash
	var url = location.toString();
	url = url.substring(0,url.indexOf(hash))
	if (location.search != '') url = location.search + '&jsprint=1';
	else url = url + '?jsprint=1';
	window.open(url,'','top=10,left=10,width=700px,height=500px,menubar=yes,resizable=no,scrollbars=yes,status=no')
}

function LegalStatement(){
	window.open(globalPath+'legal_statement.html','','top=10,left=10,width=400px,height=300px,menubar=no,resizable=no,scrollbars=yes,status=no')
}

function LangSwitch(lang) {
	var langTypes = new Array('en','tc','sc')
	var locationStr = location.href.toLowerCase();
	if (locationStr.indexOf('#')!=-1) {
		locationStr = locationStr.substr(0,locationStr.indexOf('#'))
	}
	var newLocationStr = '';
	for (var i=0; i<langTypes.length; i++) {
		locationStr=locationStr.replace('/'+langTypes[i]+'/', '/'+lang+'/');
	}
	location = locationStr;
}


//Dreamweaver Code
function MM_swapImgRestore() { //v3.0
  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 MM_preloadImages() { //v3.0
  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 MM_findObj(n, d) { //v4.01
  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 MM_swapImage() { //v3.0
  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];}
}
