<!--
// Copyright (c) 1996 Tomer Shiran. All rights reserved.
// Permission given to use this script provided that the copyright
// notice remains as is. Additional scripts and information are 
// available at http://www.geocities.com/SiliconValley/9000/

// convert decimal value (0 - 255) to hexadecimal
// (use .toString(16) method supported by IE)
var index_waittime, target_waittime, banner_scrolltime
//index_loadtime = 1200;
//target_loadtime = 200;
//banner_scrolltime = 300;
index_loadtime = 1100;
target_loadtime = 100;
banner_scrolltime = 800;

var index_fadein, index_fadeout
//index_fadein = 15;
//index_fadeout = 8;
index_fadein = 5;
index_fadeout = 5;

var target_fadein, target_fadeout
//target_fadein = 15;
//target_fadeout = 8;
target_fadein = 5;
target_fadeout = 5;

var top_frame
top_frame = 1;

//disable back button
if(window.history.forward(1) != null)
	window.history.forward(1);

function preloader_to_content() { 
	document.getElementById('preloader').style.display="none";
	document.getElementById('content').style.display="";
} 
	
function getFilename() {
var iPos
	//alert(location.href);
	if (location.pathname.indexOf("/en/") >= 0 )
		iPos = location.pathname.indexOf("/en/");
	else
		iPos = location.pathname.indexOf("/b5/");

	if (iPos == -1)
		//return "blank.htm";
		return "loading.htm";
	else
		return location.pathname.substring(iPos + 4,location.pathname.length - 4);
}

function printPage() {
	self.print();
}
	
function toHex(dec) {
    // create list of hex characters
    var hexCharacters = "0123456789ABCDEF"
    // if number is out of range return limit
    if (dec < 0)
		return "00"

    if (dec > 255)
		return "FF"
    // decimal equivalent of first hex character in converted number

    var i = Math.floor(dec / 16)
    // decimal equivalent of second hex character in converted number

    var j = dec % 16
    // return hexadecimal equivalent

    return hexCharacters.charAt(i) + hexCharacters.charAt(j)
}

// set background color to specified descriptors
function setbgColor(red, green, blue) {
	document.bgColor = "#" + toHex(red) + toHex(green) + toHex(blue)
}

// fade from start to end descriptors (increase step to increase transition speed)
function fade(sred, sgreen, sblue, ered, egreen, eblue, step) {
    // loop to create fade effect
    for(var i = 0; i <= step; ++i) {
        // set current red descriptor
        var red = Math.floor(sred * ((step - i) / step) + ered * (i / step))
 
        // set current green descriptor
        var green = Math.floor(sgreen * ((step - i) / step) + egreen * (i / step))
 
        // set current green descriptor
        var blue = Math.floor(sblue * ((step - i) / step) + eblue * (i / step))
 
        // set background color according to descriptors
        setbgColor(red, green, blue)
    }
}

function testmovie_DoFSCommand(command, args) { 
	if (command == "call_link") { 
		//alert("Here's the Flash message: " + args);
		//alert("call_link: " + args);
				
		//setTimeout("set_location(args);",1200);
		if (args == "home")
		{
			parent.g_lang_switch = "Y";
			//alert(parent.g_menu_main_item);
			//alert(parent.g_menu_sub_item);
			//alert(parent.g_lang_switch);
			set_location(args);
		}
		else
		{
			switch (args) 
			{ 
			   case "about_us" : 
			      parent.g_menu_main_item = 10;
			      break; 
			   case "contact_us" : 
			      parent.g_menu_main_item = 11;
			      break; 
			   case "sitemap" : 
			      parent.g_menu_main_item = 12;
			      break; 
			   case "disclaimer" : 
			      parent.g_menu_main_item = 13;
			      break; 
			} 
			//alert(parent.g_menu_main_item);
			//alert(parent.g_menu_sub_item);
			//alert(parent.g_lang_switch);
			set_default_main();
			setTimeout("set_location('" + args + "');",banner_scrolltime);
		}
	
		//var s_location;
		//if (args == "home")
		//{
		//	s_location = "../b5/main.htm";
		//	parent.location = s_location;
		//}
		//else
		//{
		//	s_location = args + ".htm";
		//	menu_target.location = s_location;
		//	
		//}
	}
}

function set_location(args) { 
	var old_location, new_location;
	if (args == "home")
	{
		//new_location = "../b5/main.htm";
		new_location = self.location.toString().replace("/en/","/b5/");
		//change for new parent/main.htm
		//parent.location = new_location;
		self.location = new_location;
	}
	else
	{
		old_location = String(menu_target.location);
		if (old_location.indexOf(args) <= 0)
		{
			//set_default_main();
			//if (args == "sitemap")
			//{
			//	new_location = args + ".asp";
			//}
			//else
			//{
			//	new_location = args + ".htm";
			//}
			new_location = args + ".htm";
			menu_target.location = new_location;
		}
	}
}

//member login function
function member_login() { 
	//parent.div_menu_5_login.style.display="none";
	//parent.div_menu_5.style.display="";
	if (parent.g_browser_type == "IE")
	{
		parent.div_menu_5_login.style.display="none";
		parent.div_menu_5.style.display="";	
	}
	else
	{
		parent.document.getElementById('div_menu_5_login').style.display="none";
		parent.document.getElementById('div_menu_5').style.display="";
	}
}

//member logout function
//called by menu target
function member_logout() { 
	if (confirm("Are you sure to logout ?")) 
	{
		//logout function
		//alert(parent.login_id.value);
		//alert(parent.parent.g_login_id);
		
	//parent.login_id.value="";

		top.g_login_id = "";
		top.g_login_name = "";
		top.g_chi_login_name = "";
		top.g_login_type = "";
		
	//parent.login_username.value="";
	//parent.login_type.value="";
		
		//alert(parent.login_id.value);
		parent.menu_main_name=0;
		parent.menu_main_prev_item=5;
		
		if (parent.g_browser_type == "IE")
		{
			parent.div_menu_5_login.style.display="none";
			parent.div_menu_5.style.display="none";	
		}
		else
		{
			parent.document.getElementById('div_menu_5_login').style.display="none";
			parent.document.getElementById('div_menu_5').style.display="none";
		}
		
		parent.menu_main_clicked('member_login.asp',5);
	}
}

//member force logout function
function member_force_logout() { 
	//logout function
	parent.login_id.value="";
	parent.login_username.value="";
	parent.login_type.value="";
	//alert(parent.login_id.value);
	parent.menu_main_name=0;
	parent.menu_main_prev_item=5;
	
	document.getElementById('parent.parent.div_menu_5').style.display="none";
	document.getElementById('parent.parent.div_menu_5_login').style.display="none";
	parent.menu_main_clicked('member_login.asp',5);
}

function setMenuTarget() { 
	//alert(parent.g_menu_main_item);
	//alert(parent.g_menu_sub_item);
	//alert(parent.g_lang_switch);
	if (parent.g_lang_switch=="N")
	{
		menu_target.location = "home.htm";
	}
	else
	{
		//set main_menu
		switch (parent.g_menu_main_item) 
		{ 
		   case 0 : 
		      menu_target.location = "home.htm";
		      break; 
		   case 1 : 
		      switch (parent.g_menu_sub_item) 
			  { 
			    case 1 : 
			       menu_target.location = "council_message.htm";
				   break; 
				case 2 : 
				   menu_target.location = "council_members.htm";
				   break;  
			  }
			  obj = document.getElementById('link_table_1').rows[parent.g_menu_sub_item].cells[0];
			  obj.style.color="yellow";
		      break; 
		   case 2 : 
		      switch (parent.g_menu_sub_item) 
			  { 
			    case 2 : 
			       menu_target.location = "committee_cpd.htm";
				   break; 
				case 3 : 
				   menu_target.location = "committee_education.htm";
				   break;  
				case 4 : 
				   menu_target.location = "committee_function.htm";
				   break;  
				case 5 : 
			       menu_target.location = "committee_affairs.htm";
				   break; 
				case 6 : 
				   menu_target.location = "committee_publication.htm";
				   break;  
				case 7 : 
				   menu_target.location = "committee_registration.htm";
				   break;  
			  }
			  obj = document.getElementById('link_table_2').rows[parent.g_menu_sub_item].cells[0];
			  obj.style.color="yellow";
		      break; 
		   case 3 : 
		      menu_target.location = "registered_practices.htm";
		      break; 
		   case 4 : 
		      menu_target.location = "public_news.htm";
		      break; 
		   case 5 :
		      //alert(parent.g_login_id); 
		      //alert(self.login_id.value);
		      //self.login_id.value = parent.g_login_id;
			  //alert(self.login_id.value);
		      switch (parent.g_menu_sub_item) 
			  { 
			    case 2 : 
			       if (parent.g_login_id != "")
			       {
			       	  menu_target.location = "member_bye_laws.htm";
			       	  obj = document.getElementById('link_table_5').rows[parent.g_menu_sub_item].cells[0];
			  		  obj.style.color="yellow";
			       }
			       else
			       {
			       	  menu_target.location = "member_login.asp";
			       }
				   break; 
				case 3 : 
				   menu_target.location = "member_conduct.htm";
				   obj = document.getElementById('link_table_5').rows[parent.g_menu_sub_item].cells[0];
			  	   obj.style.color="yellow";
				   break; 
				case 4 : 
				   menu_target.location = "member_news.htm";
				   obj = document.getElementById('link_table_5').rows[parent.g_menu_sub_item].cells[0];
			  	   obj.style.color="yellow";
				   break; 
				case 5 : 
				   menu_target.location = "member_info.asp";
				   obj = document.getElementById('link_table_5').rows[parent.g_menu_sub_item].cells[0];
			  	   obj.style.color="yellow";
				   break; 
				case 6 : 
				   menu_target.location = "member_download.htm";
				   obj = document.getElementById('link_table_5').rows[parent.g_menu_sub_item].cells[0];
			  	   obj.style.color="yellow";
				   break; 
				case 7 : 
				   menu_target.location = "member_password.asp";
				   obj = document.getElementById('link_table_5').rows[parent.g_menu_sub_item].cells[0];
			  	   obj.style.color="yellow";
				   break; 
				case 8 : 
				   menu_target.location = "member_logout.asp";
				   obj = document.getElementById('link_table_5').rows[parent.g_menu_sub_item].cells[0];
			  	   obj.style.color="yellow";
				   break;  
			  }
		      break; 
		   case 6 : 
		      menu_target.location = "publication.htm";
		      break; 
		   case 7 : 
		      menu_target.location = "related_links.htm";
		      break; 
		   case 8 : 
		      menu_target.location = "job_vacancy.htm";
		      break; 
		   case 10 : 
		      menu_target.location = "about_us.htm";
		      break; 
		   case 11 : 
		      menu_target.location = "contact_us.htm";
		      break; 
		   case 12 : 
		      menu_target.location = "sitemap.htm";
		      break; 
		   case 13 : 
		      menu_target.location = "disclaimer.htm";
		      break; 
		} 
		
		//set sub_menu
		set_default_other(parent.g_menu_main_item);
		
		//set sub_menu image
		if (parent.g_menu_main_item >= 10)
		{
			//alert("block")
			document.getElementById('div_menu_0').style.display='';
			for (i=1;i<apl_main.length;i++)
			{
				//s = "div_menu_" + i.toString() + ".style.display='none';"
				s = "document.getElementById('div_menu_" + i.toString() + "').style.display='none';"
				eval(s);
			}
			document.getElementById('div_menu_5_login').style.display='none';
		}
		else
		{
			if (parent.g_menu_main_item == 5)
			{
				//s = "div_menu_5_login.style.display='none';"
				s = "document.getElementById('div_menu_5_login').style.display='none';"
				eval(s);
			}	
			for (i=0;i<apl_main.length;i++)
			{
				if (i==parent.g_menu_main_item)
				{
					if (parent.g_menu_main_item != 5)
					{
						//s = "div_menu_" + i.toString() + ".style.display='';"
						s = "document.getElementById('div_menu_" + i.toString() + "').style.display='';"
					}
					else
					{
						//if (self.login_id.value != "")
						if (parent.g_login_id != "")
						{
							//s = "div_menu_" + i.toString() + ".style.display='';"
							s = "document.getElementById('div_menu_" + i.toString() + "').style.display='';"
						}
						else
						{
							//s = "div_menu_" + i.toString() + "_login.style.display='';"
							s = "document.getElementById('div_menu_" + i.toString() + "_login').style.display='';"
						}
					}
				}
				else
				{
					//s = "div_menu_" + i.toString() + ".style.display='none';"
					s = "document.getElementById('div_menu_" + i.toString() + "').style.display='none';"
				}
				eval(s);
			}
		}
		
		//set g_lang_switch
		parent.g_lang_switch = "N";
	}
}

//not right-click function
function stopthief(ie) 
{
	var warning = "Right clicking this page is not allowed.";
	if (navigator.appName == 'Netscape' && ie.which == 3) 
	{
		alert(warning);
		return false;
	}
	else
	if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) 
	{
		alert(warning);
		return false;
	}
	return true;
}
//document.onmousedown = stopthief;
//--> 