function js_include()
{
}

function domainRedirect()
{
	if( document.domain == "stringbc.com" )
		location.href = document.URL.replace(document.domain,"www.stringbc.com");
}

function onPageLoadFinish()
{
	domainRedirect();
	getFullScreenSize();
	import_enquiry_box();
	
	if( iae_check_show() )	important_alert();

	
	if( document.URL.match(/direct_mail/gi) && document.URL.match(/\?/) )
		document.getElementById('i_mailpage').src = document.getElementById('i_mailpage').src + "?" + document.URL.replace(/^.*?\?/,"");
}

function onPageResize()
{
	if( site_notice_show() )	fullScreenBackground();
	else	getFullScreenSize();
}

//------------------------------------------------------------------------------------------------------------------

function lang_change(nowIS,changeTO)
{
	var str_url=document.URL;

	if( str_url.match("/chinese_index.htm") )
		str_url=str_url.replace("/chinese_index.htm","/index.htm");
	else if( str_url.match("/index.htm") )
		str_url=str_url.replace("/index.htm","/chinese_index.htm");
	else if( str_url == "http://www.stringbc.com/" )
		str_url="http://www.stringbc.com/chinese_index.htm";
	else
	{
		while(str_url.match(nowIS))
			str_url=str_url.replace(nowIS,changeTO);
	}

	if( str_url.charAt(str_url.length-1) == "#" )
		str_url = str_url.replace("#","");
	
	location.href=str_url;
}

//------------------------------------------------------------------------------------------------------------------

var xmlHttp,xmlHttp2;
var msgIAE;
var sorns = "";

function hide_sub_list(doc_obj)
{
	document.getElementById(doc_obj).style.display = 'none';
	document.getElementById(doc_obj).style.position = 'relative';
}

function show_sub_list(doc_obj)
{
	document.getElementById(doc_obj).style.display = 'block';
	document.getElementById(doc_obj).style.position = 'absolute';
}

function site_notice_show()
{
	show_or_not_show();
	if( sorns == "Y" )
	{
		get_notice_content();
		return true;
	}
	else
		return false;
}

function site_notice_message()
{
	document.getElementById('site_notice_content').innerHTML  = msgIAE;
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest) objXMLHttp=new XMLHttpRequest();
	else if (window.ActiveXObject)		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	return objXMLHttp;
}

function show_or_not_show()
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)	{ alert ("Browser does not support HTTP Request");return; }
	var url="http://www.abacushkcpa.com/IAE/check_show.php";
	xmlHttp.onreadystatechange=show_YN;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
}

function show_YN() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		xmlDoc=xmlHttp.responseText;
		sorns = xmlDoc;
	}
}

function get_notice_content()
{ 
	xmlHttp2=GetXmlHttpObject();
	if (xmlHttp2==null)	{ alert ("Browser does not support HTTP Request");return; }
	var url="http://www.abacushkcpa.com/IAE/notification.php";
	xmlHttp2.onreadystatechange=get_notice_content_exe;
	xmlHttp2.open("GET",url,false);
	xmlHttp2.send(null);
}

function get_notice_content_exe() 
{ 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{
		xmlDoc=xmlHttp2.responseText;
		msgIAE = xmlDoc;
	}
}

function re_set_second_bg()
{
	document.getElementById('second_bg').style.height = (Math.abs(document.getElementById('body_div').offsetHeight) + 95+24) + "px";
}

//------------------------------------------------------------------------------------------------------------------

var page_innerHeight;
var page_innerWidth;

function fullScreenBackground()
{
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	page_innerWidth  = x;
	page_innerHeight = y;
	
	if( navigator.userAgent.toLowerCase().indexOf('msie 6') > 0 || navigator.userAgent.toLowerCase().indexOf('msie 5.5') > 0 )
	{
		document.getElementById('site_notice').style.height   = y+"px";
		document.getElementById('site_notice').style.width    = x+"px";
		//document.getElementById('site_notice').style.position = "fixed";
		
		document.getElementById('site_notice_bg').style.height   = y+"px";
		document.getElementById('site_notice_bg').style.width    = x+"px";
		document.getElementById('site_notice_bg').style.backgroungImage = "none";
		document.getElementById('site_notice_bg').style.backgroungColor = "#FFFFFF";
		document.getElementById('site_notice_bg').className = "siteNotice";
		
		site_notice_message();
		
		document.getElementById('site_notice_partition').style.width      = (x/2)+"px";
		document.getElementById('site_notice_partition').style.left       = "50%";
		document.getElementById('site_notice_partition').style.marginLeft = "-"+(x/4)+"px";
		document.getElementById('site_notice_partition').style.top        = "50%";

		document.getElementById('site_notice').style.display  = "";
		document.getElementById('site_notice_partition').style.marginTop  = "-" + Math.abs(document.getElementById('site_notice_partition').offsetHeight)/2 + "px";
	}
	else
	{
		document.getElementById('site_notice').style.height   = y+"px";
		document.getElementById('site_notice').style.width    = x+"px";
		document.getElementById('site_notice').style.position = "fixed";
		
		document.getElementById('site_notice_bg').style.height   = y+"px";
		document.getElementById('site_notice_bg').style.width    = x+"px";
		
		site_notice_message();
		
		document.getElementById('site_notice_partition').style.width      = (x/2)+"px";
		document.getElementById('site_notice_partition').style.left       = "50%";
		document.getElementById('site_notice_partition').style.marginLeft = "-" + (x/4) + "px";
		document.getElementById('site_notice_partition').style.top        = "50%";
		
		document.getElementById('site_notice').style.display  = "";
		document.getElementById('site_notice_partition').style.marginTop  = "-" + Math.abs(document.getElementById('site_notice_partition').offsetHeight)/2 + "px";
	}
}

function getFullScreenSize()
{
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	page_innerWidth  = x;
	page_innerHeight = y;
}

//------------------------------------------------------------------------------------------------------------------

function top_btn_onMouseOver(str,str2,align)
{
	document.getElementById(str).className='top_btn_table_onMouseOver';
	
	switch(true)
	{
		case ( align == "right" ):
			document.getElementById(str).style.marginRight = "-" + ( 880 - Math.abs(document.getElementById(str2).offsetLeft) - Math.abs(document.getElementById(str2).offsetWidth) ) + "px";
			break;
		case ( align == "center" ):
			document.getElementById(str).style.marginRight = "-" + Math.abs(( Math.abs(document.getElementById(str2).offsetWidth) - Math.abs(document.getElementById(str).offsetWidth) )/2) + "px";
			break;
	}
}

function top_btn_onMouseOut(str)
{
	document.getElementById(str).className='top_btn_table';
}
//------------------------------------------------------------------------------------------------------------------

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];}
}
//------------------------------------------------------------------------------------------------------------------

function newWin(str)
{
	window.open(str);
}

function subWin(str1,str2,str3)
{
	window.open(str1,'test','width='+str2+',height='+str3+',scrollbars=no');
}

function show_refer_mail(top,left,mail_to)
{//show_refer_mail(this.offsetParent.offsetTop + this.offsetTop,this.offsetParent.offsetLeft + this.offsetLeft,'Gary@AsiaBS.com')
	//alert(top + "," + left);
	
	var ie4 = document.all?1:0 ;
	
	getFullScreenSize();
	
	//document.getElementById('refer_to').value = mail_to
	if( document.URL.match("chinese") )
		document.getElementById('enquiry_box').getElementsByTagName('iframe')[0].src = "http://www.asiabs.com/direct_mail/stringbc/chinese_import_enquiry_box.htm?_to=" + mail_to;
	else
		document.getElementById('enquiry_box').getElementsByTagName('iframe')[0].src = "http://www.asiabs.com/direct_mail/stringbc/english_import_enquiry_box.htm?_to=" + mail_to;
		
	document.getElementById('enquiry_box').style.display = "";
	
	if( (document.getElementById('enquiry_box').offsetWidth + left ) > page_innerWidth )
		left = page_innerWidth - document.getElementById('enquiry_box').offsetWidth;
	
	if( ie4 )
	{
		document.getElementById('enquiry_box').style.top = (Math.abs(top) + 30);
		document.getElementById('enquiry_box').style.left = (Math.abs(left) + 10);
	}
	else
	{
		document.getElementById('enquiry_box').style.top = (Math.abs(top) + 30)+"px";
		document.getElementById('enquiry_box').style.left = (Math.abs(left) + 10)+"px";
	}
}

function import_enquiry_box()
{
	var temp = "";
	
	temp += "<div id=\"enquiry_box\" style=\"position:absolute;border:4px solid #666666;padding:2px;background-color:#FFFFFF;display:none;z-index:100\">";
	temp += "	<div style=\"border:2px solid #666666;padding:10px\">";
	temp += "		<div style=\"width:332px;height:300px\">";
	temp += "			<span style=\"font-family:font-size:10pt;cursor:pointer;float:right\" onClick=\"document.getElementById('enquiry_box').style.display='none'\"><img alt=\"Close\" src=\"http://www.asiabs.com/english/online_form/close.gif\"></span>";
	temp += "			<iframe src=\"\" width=\"332\" height=\"296\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\"></iframe>";
	temp += "		</div>";
	temp += "	</div>";
	temp += "</div>	";
	
	document.body.innerHTML = document.body.innerHTML + temp;
}
//------------------------------------------------------------------------------------------------------------------
//Holiday and Important Notice

var ia_title = "Important Notice 重要通知";
var ia_content = "We are providing China and Hong Kong Company Formation, Company Secretary, Accounting and Auditing Service for client with interest in Hong Kong and China.";

function important_alert()
{
	if( navigator.userAgent.toLowerCase().match("msie 6.0") )
	{
		getFullScreenSize();
		var ia_msie6 = css_class_selector("#IA_bg");
		
		if( ia_msie6.style.cssText != "" )
		{
			ia_msie6.style.cssText = ia_msie6.style.cssText + ";margin-top:-"+document.body.offsetHeight+"px;";
			ia_msie6.style.cssText = ia_msie6.style.cssText.replace("HEIGHT: 100%","HEIGHT: "+page_innerHeight+"px");
		}
	}
	
	document.body.innerHTML = document.body.innerHTML + "<div id=\"Important_Notice\"></div>";
	document.getElementById('Important_Notice').innerHTML = "<div id=\"IA_bg\"><div id=\"IA_box\"><div id=\"IA_close\" class=\"right\" onClick=\"close_IA()\"><img alt=\"Close\" title=\"Close\" width=\"16\" height=\"16\" src=\"http://www.asiabs.com/images/gif/IA_close.gif\"></div><div id=\"IA_title\">"+ia_title+"</div><div id=\"IA_content\">"+ia_content+"</div></div></div>";

	var ia_box_top = css_class_selector("#IA_box");
	if( ia_box_top && ia_box_top.style.cssText != "" )
	{
		var temp = (page_innerHeight - Math.abs(document.getElementById('IA_box').offsetHeight))/2;
		temp = Math.ceil(temp / page_innerHeight * 100);
		
		ia_box_top.style.cssText = ia_box_top.style.cssText.replace(/top([ ]+)?:([ ]+)?[\d]+%/gi,"TOP:"+temp+"%");
		//alert(ia_box_top.style.cssText);
	}
}

function close_IA()
{
	document.getElementById('IA_bg').style.display='none';
	if( document.getElementById('theme_topic') )
		theme_bg_move();
}

var iae_http;
var iae_http_content;
var iae_show_result = false;

function iae_check_show()
{
	iae_check_now();
	return iae_show_result;
}

function iae_check_now()
{
	iae_http = GetXmlHttpObject();
	if( iae_http == null )
	{
		alert("Browser does not support HTTP Request");
		return;
	} 
	
	if( navigator.userAgent.toLowerCase().match('msie') )
	{
		iae_http.onreadystatechange = iae_check_show_return;
		iae_http.open("GET","http://www.stringbc.com/css/important_notice.asp",false);
		iae_http.send(null);
	}
	else
	{
		iae_http.onload = iae_check_show_return;
		iae_http.open("GET","http://www.stringbc.com/css/important_notice.asp",false);
		iae_http.send(null);
	}
}

function iae_check_show_return()
{
	if( iae_http.readyState==4 || iae_http.readyState=="complete" )
	{
		//document.getElementById("toplinks_inner").innerHTML = document.getElementById("toplinks_inner").innerHTML + "<span style=color:#FFF>" + iae_http.responseText + "</span>";
		if( iae_http.responseText == "Yes")
		{
			iae_show_result = true;
			iae_notice_content();
		}
		else
			iae_show_result = false;
	}
}

function iae_notice_content()
{
	iae_http_content = GetXmlHttpObject();
	if( iae_http_content == null )
	{
		alert("Browser does not support HTTP Request");
		return;
	}
	
	if( navigator.userAgent.toLowerCase().match('msie') )
	{
		iae_http_content.onreadystatechange = get_iae_notice_content;
		iae_http_content.open("GET","http://www.stringbc.com/css/notice_content.asp",false);
		iae_http_content.send(null);
	}
	else
	{
		iae_http_content.onload = get_iae_notice_content;
		iae_http_content.open("GET","http://www.stringbc.com/css/notice_content.asp",false);
		iae_http_content.send(null);
	}
}

function get_iae_notice_content()
{
	if( iae_http_content.readyState==4 || iae_http_content.readyState=="complete" )
	{
		ia_content = iae_http_content.responseText;
	}
}

//--------------------------------------------------------------------------------------------------------------------------------------------

function css_class_selector(target)
{
	if (!document.styleSheets) return;
	var css_style = document.styleSheets;
	
	for( var x=0 ; css_style.length > x ; x++ )
	{
		if( document.styleSheets[x].cssRules )	var css_style_class = document.styleSheets[x].cssRules;
		else	var css_style_class = document.styleSheets[x].rules;
		
		for( var y=0 ; css_style_class.length > y ; y++ )
		{
			if( css_style_class[y].selectorText.toLowerCase() == target.toLowerCase() )
				return css_style_class[y];
		}
	}
	return null;
}

