// JavaScript Document
function perfex_replace(src,dis,value){
	return value.replace(src,dis);
}

/*add compatibility to firefox*/
function isNetscape() {
  if (navigator.appName.indexOf("Netscape") >-1)
    return 1;
}

function display_tbl(obj) {
	if (!obj) return;
  if (isNetscape()) {
    obj.style.display="table";
	}
  else {
		obj.style.display="block";
	}
	
}

function sub_nav_selects(num){
	var page=null, btn=null;
	for (i=1;( (page=document.getElementById("sub_con_"+i))!=null );i++){
		/*if (("sub_con"+i)==("sub_con"+num)) {
			display_tbl(document.getElementById("sub_con_"+num));
		}
		else*/ page.style.display="none";
		btn=document.getElementById("sub_nav_"+i);
		if (btn!=null && btn.src.indexOf("_f2.jpg" )<0 )
				btn.src=btn.src.replace(".jpg","_f2.jpg");
	}
	
	/*var test1=null, test2=null;
	for(i=1;((test1 = document.getElementById("sub_nav_"+i))!=null)&&((test2 = document.getElementById("sub_con_"+i))!=null);++i){
		//test1.src = imgs[i-1]+"_f2.jpg";
		if (test1.src.indexOf("_f2.jpg" )<0 )
				test1.src=test1.src.replace(".jpg","_f2.jpg");
		test2.style.display = "none";
	}*/
	//document.getElementById("sub_con_"+num).style.display = "block";
  display_tbl(document.getElementById("sub_con_"+num));
	if (document.getElementById("sub_nav_"+num))
		document.getElementById("sub_nav_"+num).src=document.getElementById("sub_nav_"+num).src.replace("_f2.jpg",".jpg");
	document.getElementsByTagName("body")[0].style.height="100%";
}


function sub_nav_select(num){
	sub_nav_selects(num);
}
//function sub_nav_select_central_cityscape(num){	
//	document.getElementById("sub_nav_1").src = "../images/sub_nav_bg_f2.jpg";
//	document.getElementById("sub_nav_2").src = "../images/sub_nav_media_f2.jpg";
//	
//	for(i=1;i<=2;++i){
//		document.getElementById("sub_con_"+i).style.display = "none";
//	}
//	document.getElementById("sub_con_"+num).style.display = "block";
//	switch(num){
//		case 1:
//	document.getElementById("sub_nav_1").src = "../images/sub_nav_bg.jpg";
//		break;
//		case 2:
//	document.getElementById("sub_nav_2").src = "../images/sub_nav_media.jpg";
//		break;
//	}
//}
function sub_nav_select_central_cityscape(num){	
	var imgs = new Array();
	imgs[0] = "../images/sub_nav_bg";
	imgs[1] = "../images/sub_nav_media";
	sub_nav_selects(num, imgs);
}
//function sub_nav_select_photo_library(num){	
//	document.getElementById("sub_nav_1").src = "../images/photo_library/sub_nav_com_property_f2.jpg";
//	document.getElementById("sub_nav_2").src = "../images/photo_library/photo_res_property_f2.jpg";
//	
//	var test = null;
//	for(i=1;((test = document.getElementById("sub_con_"+i))!=null);++i){
//		test.style.display = "none";
//	}
//	document.getElementById("sub_con_"+num).style.display = "block";
//	switch(num){
//		case 1:
//	document.getElementById("sub_nav_1").src = "../images/photo_library/sub_nav_com_property.jpg";
//		break;
//		case 2:
//	document.getElementById("sub_nav_2").src = "../images/photo_library/photo_res_property.jpg";
//		break;
//	}
//}
function sub_nav_select_photo_library(num){	
	var imgs = new Array();
	imgs[0] = "../images/photo_library/sub_nav_com_property";
	imgs[1] = "../images/photo_library/photo_res_property";
	sub_nav_selects(num);
	//sub_nav_selects(num, imgs);
}

//function sub_nav_select_press_room(num){	
//	document.getElementById("sub_nav_1").src = "../images/press/sub_nav_full_list.jpg";
//	document.getElementById("sub_nav_2").src = "../images/press/sub_nav_corporate.jpg";
//	document.getElementById("sub_nav_3").src = "../images/press/sub_nav_financial.jpg";
//	document.getElementById("sub_nav_4").src = "../images/press/sub_nav_com_property.jpg";
//	document.getElementById("sub_nav_5").src = "../images/press/sub_nav_res_property.jpg";
//	document.getElementById("sub_nav_6").src = "../images/press/sub_nav_infrastructure.jpg";
//	
//	for(i=1;i<=6;++i){
//		document.getElementById("sub_con_"+i).style.display = "none";
//	}
//	document.getElementById("sub_con_"+num).style.display = "block";
//	document.getElementById("changeColor").bgColor = "#D4E1F2";
//	switch(num){
//		case 1:
//	document.getElementById("sub_nav_1").src = "../images/press/sub_nav_full_list_f2.jpg";
//	document.getElementById("changeColor").bgColor = "#E5E5E5";
//		break;
//		case 2:
//	document.getElementById("sub_nav_2").src = "../images/press/sub_nav_corporate_f2.jpg";
//		break;
//		case 3:
//	document.getElementById("sub_nav_3").src = "../images/press/sub_nav_financial_f2.jpg";
//		break;
//		case 4:
//	document.getElementById("sub_nav_4").src = "../images/press/sub_nav_com_property_f2.jpg";
//		break;
//		case 5:
//	document.getElementById("sub_nav_5").src = "../images/press/sub_nav_res_property_f2.jpg";
//		break;
//		case 6:
//	document.getElementById("sub_nav_6").src = "../images/press/sub_nav_infrastructure_f2.jpg";
//		break;
//	}
//}
function sub_nav_select_press_room(num){	
	document.getElementById("sub_nav_1").src = "../images/press/sub_nav_full_list.jpg";
	document.getElementById("sub_nav_2").src = "../images/press/sub_nav_corporate.jpg";
	document.getElementById("sub_nav_3").src = "../images/press/sub_nav_financial.jpg";
	document.getElementById("sub_nav_4").src = "../images/press/sub_nav_com_property.jpg";
	document.getElementById("sub_nav_5").src = "../images/press/sub_nav_res_property.jpg";
	document.getElementById("sub_nav_6").src = "../images/press/sub_nav_infrastructure.jpg";
	
	var testObj = null;
	for(i=1;((testObj = document.getElementById("sub_con_"+i)) != null);++i){
		testObj.style.display = "none";
	}
  display_tbl(document.getElementById("sub_con_"+num));
	//document.getElementById("sub_con_"+num).style.display = "block";
	switch(num){
		case 1:
	document.getElementById("sub_nav_1").src = "../images/press/sub_nav_full_list_f2.jpg";
		break;
		case 2:
	document.getElementById("sub_nav_2").src = "../images/press/sub_nav_corporate_f2.jpg";
		break;
		case 3:
	document.getElementById("sub_nav_3").src = "../images/press/sub_nav_financial_f2.jpg";
		break;
		case 4:
	document.getElementById("sub_nav_4").src = "../images/press/sub_nav_com_property_f2.jpg";
		break;
		case 5:
	document.getElementById("sub_nav_5").src = "../images/press/sub_nav_res_property_f2.jpg";
		break;
		case 6:
	document.getElementById("sub_nav_6").src = "../images/press/sub_nav_infrastructure_f2.jpg";
		break;
	}
}

function gallery_1063_select(num,ext){//1063 King's Road
	gallery_detail_select(num,"1063","/commercial_property/hk_properties/1063",ext);
}
function gallery_ah_select(num,ext){//Alexandra House
	gallery_detail_select(num,"ah","/commercial_property/hk_properties/ah",ext);
}
function gallery_ch_select(num, ext){//Chater House
	gallery_detail_select(num,"ch","/commercial_property/hk_properties/ch",ext);
}
function gallery_es12_select(num,ext){//One & Two Exchange Square
	gallery_detail_select(num,"es12","/commercial_property/hk_properties/es12",ext);
}
function gallery_es3_select(num,ext){//Three Exchange Square
	gallery_detail_select(num,"es3","/commercial_property/hk_properties/es3",ext);
}
function gallery_hkcb_select(num,ext){//The Hong Kong Club Building
	gallery_detail_select(num,"hkcb","/commercial_property/hk_properties/hkcb",ext);
}
function gallery_jh_select(num,ext){//Jardine House
	gallery_detail_select(num,"jh","/commercial_property/hk_properties/jh",ext);
}
function gallery_lm_select(num,ext){//The Landmark
	gallery_detail_select(num,"lm","/commercial_property/hk_properties/lm",ext);
}
function gallery_gt_select(num,ext){//Gloucester Tower
	gallery_detail_select(num,"gt","/commercial_property/hk_properties/gt",ext);
}
function gallery_et_select(num,ext){//Edinburgh Tower
	gallery_detail_select(num,"et","/commercial_property/hk_properties/et",ext);
}
function gallery_pb_select(num,ext){//Prince's Building
	gallery_detail_select(num,"pb","/commercial_property/hk_properties/pb",ext);
}
function gallery_thk_select(num,ext){//Tradeport Hong Kong
	gallery_detail_select(num,"thk","/commercial_property/hk_properties/thk",ext);
}
function gallery_yh_select(num,ext){//York House
	gallery_detail_select(num,"yh","/commercial_property/hk_properties/yh",ext);
}
function gallery_os_63ltt_select(num,ext){//63 Ly Thai To, Vietnam
	gallery_detail_select(num,"63ltt","/commercial_property/overseas_properties/63ltt",ext);
}
function gallery_os_cb_select(num,ext){//Central Building, Vietnam 
	gallery_detail_select(num,"cb","/commercial_property/overseas_properties/cb",ext);
}
function gallery_os_clm_select(num,ext){//CityLink Mall, Singapore 
	gallery_detail_select(num,"clm","/commercial_property/overseas_properties/clm",ext);
}
function gallery_os_g_select(num,ext){//Gaysorn, Thailand
	gallery_detail_select(num,"g","/commercial_property/overseas_properties/g",ext);
}
function gallery_os_jl_select(num,ext){//Jakarta Land, Indonesia 
	gallery_detail_select(num,"jl","/commercial_property/overseas_properties/jl",ext);
}
function gallery_os_bfc_select(num,ext){
	gallery_detail_select(num,"bfc","/commercial_property/overseas_properties/bfc",ext);
}
function gallery_os_orl_select(num,ext){//One Raffles Link, Singapore
	gallery_detail_select(num,"orl","/commercial_property/overseas_properties/orl",ext);
}
function gallery_os_orq_select(num,ext){//One Raffles Quay, Singapore 
	gallery_detail_select(num,"orq","/commercial_property/overseas_properties/orq",ext);
}
function gallery_os_mp_select(num,ext){//commercial - One central
	gallery_detail_select(num,"mp","/commercial_property/overseas_properties/mp",ext);
}	
function gallery_rp_hk_iob_select(num,ext){//Ivy on Belcher's
	gallery_detail_select(num,"iob","/residential_property/hk_properties/iob",ext);
}
function gallery_rp_hk_gl_select(num,ext){//Grosvenor Land
	gallery_detail_select(num,"gl","/residential_property/hk_properties/gl",ext);
}
function gallery_rp_hk_sc_select(num,ext){//Stanley Court
	gallery_detail_select(num,"sc","/residential_property/hk_properties/sc",ext);
}
function gallery_rp_pa_cp_select(num,ext){
	gallery_detail_select(num,"cp","/residential_property/properties_in_asia/cp",ext);	
}
function gallery_rp_pa_rtt_select(num,ext){
	gallery_detail_select(num,"rtt","/residential_property/properties_in_asia/rtt",ext);
}
function gallery_rp_pa_bfc_select(num,ext){
	gallery_detail_select(num,"bfc","/residential_property/properties_in_asia/bfc",ext);
}
function gallery_rp_pa_mpabr_select(num,ext){//Maple Place at Beijing Riviera, Biejing
	gallery_detail_select(num,"mpabr","/residential_property/properties_in_asia/mpabr",ext);
}
function gallery_rp_pa_np_select(num,ext){//NorthPine
	gallery_detail_select(num,"np","/residential_property/properties_in_asia/np",ext);
	}
function gallery_rp_pa_mp_select(num,ext){//One central
	gallery_detail_select(num,"mp","/residential_property/properties_in_asia/mp",ext);
}	

function gallery_rp_pa_mcl_select(num,ext){//MCLLand
	gallery_detail_select(num,"mcl","/residential_property/properties_in_asia/mcl",ext);
}
function gallery_rp_pa_bg_select(num,ext){//MCLLand
	gallery_detail_select(num,"bg","/residential_property/properties_in_asia/bg",ext);
}

function gallery_detail_select(num,sub_name,path,ext){

	//document.getElementById("image_display").src = "../../../images"+path.toString()+"/gallery_"+sub_name+"_b"+num+".jpg";
	var pos=document.getElementById("image_display").src.indexOf("gallery");
	document.getElementById("image_display").src = document.getElementById("image_display").src.substring(0,pos)+"gallery_"+sub_name+"_b"+num+".jpg";

//	for(i=1;i<=num_max;++i){
//		document.getElementById("gallery_"+i).src = "../../images"+path.toString()+"/gallery_"+sub_name+"_s"+i+".jpg";
//	}
	var testObj = null;
	for(i=1;((testObj = document.getElementById("gallery_"+i)) != null);++i){
		//testObj.src = "../../../images"+path.toString()+"/gallery_"+sub_name+"_s"+i+".jpg";
		testObj.src = testObj.src.replace("_active","");
	}
	//document.getElementById("gallery_"+num).src = "../../../images"+path.toString()+"/gallery_"+sub_name+"_s"+num+"_active.jpg";
	document.getElementById("gallery_"+num).src = document.getElementById("gallery_"+num).src.replace(".jpg","_active.jpg");
	if (ext) {
		document.getElementById("download_img").href=document.getElementById("image_display").src.replace(".jpg","."+ext).replace("_"+sub_name+"_b", "_"+sub_name+"_h");
		document.getElementById("download_img").innerHTML="Download High Resolution Image";
	}
	else {
		document.getElementById("download_img").href=document.getElementById("image_display").src;
		document.getElementById("download_img").innerHTML="Download Image";
	}
}

function facts_figures_select_ch(oj,text,src,url){

	for(i=1; i<=6;++i){
		document.getElementById("facts_figures_name_"+i).className = "facts_figures_name";
		document.getElementById("facts_figures_content_"+i).style.display = "none";
	}
	oj.className = "facts_figures_name_sel";
	//document.getElementById("facts_figures_txt").innerHTML = text;
	document.getElementById(perfex_replace("facts_figures_name_","facts_figures_content_",oj.id.toString())).style.display = "block";
}
function floor_plan_select_ch(oj,text,src,url){
	for(i=1; i<=100;++i){
		if (document.getElementById("floor_plan_lay_"+i)==null ) break;
		document.getElementById("floor_plan_lay_"+i).className = "floor_plan_lay";
		document.getElementById("floor_plan_content_"+i).style.display = "none";
	}
	document.getElementById(perfex_replace("floor_plan_lay_","floor_plan_content_",oj.id.toString())).style.display = "block";

	//document.getElementById("floor_plan_txt").innerHTML = text;
	oj.className = "floor_plan_lay_sel";
}
/*for marina bay financial center*/
function facts_figures_ch(oj) {
	 right_list_select(oj,"facts_figures_name","facts_figures_name_","facts_figures_content_");
}


function media_release_ch(oj){
	right_list_select(oj,"press_room_year","media_release_ch_","mr_ch_list_year_");	
}

function right_list_select(oj,nameClass,sClass,sDisplay){
	var test1=null, test2=null;
	for(i=1;((test1=document.getElementById(sClass+i))!=null)&&((test2=document.getElementById(sDisplay+i))!=null);++i){
		test1.className = nameClass;
		test2.style.display = "none";
	}
	oj.className = nameClass + "_sel";
  display_tbl(document.getElementById(perfex_replace(sClass,sDisplay,oj.id.toString())));
	//document.getElementById(perfex_replace(sClass,sDisplay,oj.id.toString())).style.display = "block";
}

function select_offer(num, max_num) {
	select_from_right_list(num, "offer_content_", "offer_name_", max_num) ;
}

function select_from_right_list(num, page_prefix, list_item_prefix, no_right_list_items) {
	for (i=1;i<=no_right_list_items;i++) {	//clear all selection
		document.getElementById(page_prefix+i).style.display="none";
		document.getElementById(list_item_prefix+i).className="right_list";
	}
	//document.getElementById(page_prefix+num).style.display="block";	//highlight selected page
  display_tbl(document.getElementById(page_prefix+num));
	document.getElementById(list_item_prefix+num).className="right_list_sel";
}


















